JBossWS SVN: r16565 - stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-08-03 04:27:54 -0400 (Fri, 03 Aug 2012)
New Revision: 16565
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
Log:
[JBWS-3335] Fixing detection of jboss-modules environment to cope with jboss-modules enabled out-of-container clients
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2012-07-30 15:33:38 UTC (rev 16564)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2012-08-03 08:27:54 UTC (rev 16565)
@@ -74,14 +74,14 @@
*/
public class ProviderImpl extends org.apache.cxf.jaxws22.spi.ProviderImpl
{
- private static final boolean inContainer;
- private static ServerConfig serverConfig;
+ private static final boolean jbossModulesEnv;
+ private static ServerConfig serverConfig = null;
+ private static boolean serverConfigInit = false;
static {
- //a trick for verifying if running in-container (AS7): the jbossws-cxf and cxf classes come from different
- //(module) classloader on AS7, while out-of-container they are coming from the same flat classloader;
- //this is used as an optimization to avoid looking for ServerConfig when running out-of-container
- inContainer = ProviderImpl.class.getClassLoader() != org.apache.cxf.jaxws22.spi.ProviderImpl.class.getClassLoader();
+ //check if running in a JBoss Modules environment: the jbossws-cxf and cxf classes come
+ //from different classloader when using jboss-modules (no flat classloader)
+ jbossModulesEnv = (ProviderImpl.class.getClassLoader() != org.apache.cxf.jaxws22.spi.ProviderImpl.class.getClassLoader());
}
@Override
@@ -466,7 +466,7 @@
Binding binding = ((BindingProvider)port).getBinding();
Client client = ClientProxy.getClient(port);
client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding));
- if (inContainer) {
+ if (jbossModulesEnv) { //optimization for avoiding checking for a server config when we know for sure we're out-of-container
ServerConfig sc = getServerConfig();
if (sc != null) {
for (ClientConfig config : sc.getClientConfigs()) {
@@ -483,13 +483,23 @@
}
+ //lazy get the server config (and try once per classloader only)
private static synchronized ServerConfig getServerConfig()
{
- if (serverConfig == null)
+ if (!serverConfigInit)
{
- final ClassLoader cl = ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
- SPIProvider spiProvider = SPIProviderResolver.getInstance(cl).getProvider();
- serverConfig = spiProvider.getSPI(ServerConfigFactory.class, cl).getServerConfig();
+ try {
+ final ClassLoader cl = ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
+ SPIProvider spiProvider = SPIProviderResolver.getInstance(cl).getProvider();
+ serverConfig = spiProvider.getSPI(ServerConfigFactory.class, cl).getServerConfig();
+ } catch (Exception e) {
+ Logger log = Logger.getLogger(ProviderImpl.class);
+ if (log.isTraceEnabled()) {
+ log.trace("Unable to retrieve server config; this is expected for jboss-modules enabled client", e);
+ }
+ } finally {
+ serverConfigInit = true;
+ }
}
return serverConfig;
}
12 years, 4 months