从实现JAX-WS Provider接口的Web服务创建包含SOAPFault的SOAPMessage的首选方法是什么?
MessageFactory.newInstance()
似乎是不必要的昂贵的操作,并没有提到线程安全。我有四种可能的解决方案,但不知道我应该使用哪种方法:
MessageFactory.createMessage()
创建同步方法MessageFactory.newInstance()
过早优化是万恶之源
由于这将很容易在以后更改,我会选择4(MessageFactory.newInstance()
每次),只考虑其他选项,如果我看到它有性能问题。
这可能不是一个性能问题,你可以节省一些编码。