MessageFactory 的 jaxp 对象缓存
javax.xml.soap.MessageFactory 可以重用吗?
即
msgFactory = MessageFactory.newInstance();
我可以缓存 msgFactory 并重用它来根据需要创建新的 SOAPMessages 吗?
如果可以在代码中重用 msgFactory,还应该同步 msgFactory.createMessage();
吗?
更新:
另外,在单线程代码中,我是否可以存储 msgFactory 来一遍又一遍地创建 SOAPMessage,以免每次都创建 MessageFactory 的新实例 谢谢
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 the 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
javadoc 中没有任何内容表明 MessageFactory 的实例是线程安全的,因此我不会做出这样的假设。
但是,在单个线程中,没有什么可以阻止您一遍又一遍地重复使用
MessageFactory
实例。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.