简体   繁体   English

我们可以使用jaxws-rt.jar作为运行时实现,虽然它包含sun库吗?

[英]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_TIMEOUTBindingProviderProperties.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.

相关问题 jaxws-rt.jar中的“ / com / sun / xml / ws /”软件包和rt.jar中的“ / com / sun / xml / internal / ws /”软件包之间有什么区别 - what is the Difference between the “/com/sun/xml/ws/” package in jaxws-rt.jar and “/com/sun/xml/internal/ws/” package inside rt.jar java运行时库中的断点(rt.jar) - Breakpoint in java runtime libraries (rt.jar) 我可以将类添加到sun的rt.jar文件中吗? - Can I add classes to sun's rt.jar file? 无法读取com.sun.xml.ws:jaxws-rt:jar:2.2.8的工件描述符:UnresolvableModelException:无法传输com.sun.xml.ws:bundles:pom - Failed to read artifact descriptor for com.sun.xml.ws:jaxws-rt:jar:2.2.8: UnresolvableModelException: Failure to transfer com.sun.xml.ws:bundles:pom 为什么我们在java项目中使用rt.jar? - Why do we use rt.jar in a java project? 我们可以调试rt.jar中存在的类吗? - Can we debug classes present in rt.jar? 为什么在rt.jar中找不到com.sun。*类的API文档? - Why can't I find the API documentation for com.sun.* classes in rt.jar? com.sun.xml.ws:jaxws-rt:pom:2.2.10 的 POM 无效 - The POM for com.sun.xml.ws:jaxws-rt:pom:2.2.10 is invalid JAXWS-RT:获取 com.sun.xml.ws.spi.db.DatabindingException 绑定一个简单的类 - JAXWS-RT: getting com.sun.xml.ws.spi.db.DatabindingException binding a simple class rt.jar中的工厂设计模式实现 - Factory design pattern implementation in rt.jar
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM