开发者

jaxp object caching for MessageFactory

开发者 https://www.devze.com 2023-01-25 06:27 出处:网络
Can the javax.xml.soap.MessageFactory be reused? I.e. msgFactory = MessageFactory.newInstance(); Can I cache msgFactory and reuse it to create new SOAPMessages as needed?

Can the javax.xml.soap.MessageFactory be reused?

I.e.

msgFactory = MessageFactory.newInstance(); 

Can I cache msgFactory and reuse it to create new SOAPMessages as needed?

Also should th开发者_StackOverflow中文版e msgFactory.createMessage(); be synchronized if it is ok to reuse msgFactory in the code?

UPDATE:

Also in single threaded-code, could I store msgFactory to create SOAPMessages over and over, so as not to create a new instance of MessageFactory each time Thanks


There's nothing in the javadoc to say that instances of MessageFactory are thread-safe, so I wouldn't make that assumption.

However, within a single thread, there's nothing to stop you re-using a MessageFactory instance over and over again.

0

精彩评论

暂无评论...
验证码 换一张
取 消