[英]can we use jaxws-rt.jar as runtime implementation though it includes sun libraries?
Many recommend not to use sun
packages for various reasons. 许多人建议不要出于各种原因使用
sun
包。 Detailed answers are provided here . 这里提供了详细的答案。
However I am using jaxws-rt.jar
which uses sun library. 但是我使用
jaxws-rt.jar
是使用sun库的jaxws-rt.jar
。
I am wondering if I should jaxws-rt.jar
or not. 我想知道我是否应该
jaxws-rt.jar
。 I am running in tomcat container and I do not want to include jaxws implementations of Jboss,GlassFish or any other application servers. 我在tomcat容器中运行,我不想包含Jboss,GlassFish或任何其他应用程序服务器的jaxws实现。
Here is what I am trying to do (setting connection and request timeouts) 这是我想要做的(设置连接和请求超时)
import com.sun.xml.internal.ws.client.BindingProviderProperties;
import javax.xml.ws.BindingProvider;
((BindingProvider)soapService).getRequestContext()
.put(BindingProviderProperties.REQUEST_TIMEOUT,REQUEST_TIMEOUT_MILLI);
((BindingProvider)soapService).getRequestContext()
.put(BindingProviderProperties.CONNECT_TIMEOUT,CONNECT_TIMEOUT_MILLI);
Thanks 谢谢
As you've found, certain behaviors (such as connection timeouts) are controlled through implementation-specific means. 正如您所发现的,某些行为(例如连接超时)是通过特定于实现的方式来控制的。
If you're not keen on compiling against (importing) the com.sun
packages, one way to remove the compile-time dependencies yet set these properties to control the JAX-WS reference implementation the way you need, you can try just setting the BindingProvider
request context properties for the reference implementation by their string values . 如果您不热衷于编译(导入)
com.sun
包,一种删除编译时依赖项的方法,但是设置这些属性以按照您需要的方式控制JAX-WS引用实现,您可以尝试只设置BindingProvider
通过字符串值请求参考实现的上下文属性。 You can set these properties even when running with other JAX-WS runtimes than the RI - it won't fail (it just may have no effect). 即使在与RI之外的其他JAX-WS运行时运行时,您也可以设置这些属性 - 它不会失败(它可能没有任何效果)。
import javax.xml.ws.BindingProvider;
((BindingProvider)soapService).getRequestContext()
.put("com.sun.xml.ws.request.timeout", 5000L);
((BindingProvider)soapService).getRequestContext()
.put("com.sun.xml.ws.connect.timeout", 5000L);
Here are the two values for both constants in your question. 以下是您问题中两个常量的两个值。 JAXWSProperties.CONNECT_TIMEOUT and BindingProviderProperties.REQUEST_TIMEOUT .
JAXWSProperties.CONNECT_TIMEOUT和BindingProviderProperties.REQUEST_TIMEOUT 。
This is a misunderstanding. 这是一种误解。
even though it includes
sun
libraries?即使它包括
sun
图书馆?
It doesn't 'include sun
libraries'. 它不包括“
sun
图书馆”。 It refers to a com.sun
library. 它指的是一个
com.sun
库。 That's a completely different thing. 那是完全不同的事情。 Two completely different things.
两件完全不同的东西。
Many recommend not to [use]
sun
packages for various reasons.许多人建议不要出于各种原因[使用]
sun
包。
There is only one recommendation that counts, and it is the Note about sun.* packages . 只有一个建议很重要,它是关于sun。*包的注释 。 The operative sentence in that is:
其中的有效判决是:
Programs that contain direct calls to the sun.* packages are not 100% Pure Java.
包含对sun。*包的直接调用的程序不是100%纯Java。
The sun.*
packages are there for a reason of course, and that is to provide implementations for various things in the JDK . sun.*
包当然是有原因的,那就是为JDK中的各种东西提供实现。 If that's the only use your program makes of these classes, and specifically if your code doesn't contain 'direct calls to the sun.*
packages', you don't have anything to worry about. 如果这是你的程序对这些类的唯一用途,特别是如果你的代码不包含“直接调用
sun.*
packages”,你就没有什么可担心的了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.