JBossWS SVN: r18842 - in container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices: invocation and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2014-08-13 04:21:37 -0400 (Wed, 13 Aug 2014)
New Revision: 18842
Modified:
container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSComponentInstanceAssociationInterceptor.java
container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/invocation/AbstractInvocationHandler.java
Log:
[JBWS-3514]:Back port fix to wildfly810 branch
Modified: container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSComponentInstanceAssociationInterceptor.java
===================================================================
--- container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSComponentInstanceAssociationInterceptor.java 2014-08-11 10:08:14 UTC (rev 18841)
+++ container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSComponentInstanceAssociationInterceptor.java 2014-08-13 08:21:37 UTC (rev 18842)
@@ -24,6 +24,7 @@
import org.jboss.as.ee.component.BasicComponentInstance;
import org.jboss.as.ee.component.Component;
import org.jboss.as.ee.component.ComponentInstance;
+import org.jboss.as.naming.ManagedReference;
import org.jboss.as.webservices.injection.WSComponent;
import org.jboss.invocation.ImmediateInterceptorFactory;
import org.jboss.invocation.Interceptor;
@@ -44,7 +45,13 @@
@Override
public Object processInvocation(final InterceptorContext interceptorContext) throws Exception {
final WSComponent wsComponent = (WSComponent)interceptorContext.getPrivateData(Component.class);
- final BasicComponentInstance pojoComponentInstance = wsComponent.getComponentInstance();
+ BasicComponentInstance pojoComponentInstance = null;
+ if (interceptorContext.getPrivateData(ManagedReference.class) != null) {
+ ManagedReference reference = interceptorContext.getPrivateData(ManagedReference.class);
+ pojoComponentInstance = (BasicComponentInstance)wsComponent.createInstance(reference.getInstance());
+ } else {
+ pojoComponentInstance = wsComponent.getComponentInstance();
+ }
interceptorContext.putPrivateData(ComponentInstance.class, pojoComponentInstance);
return interceptorContext.proceed();
}
Modified: container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/invocation/AbstractInvocationHandler.java
===================================================================
--- container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/invocation/AbstractInvocationHandler.java 2014-08-11 10:08:14 UTC (rev 18841)
+++ container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/invocation/AbstractInvocationHandler.java 2014-08-13 08:21:37 UTC (rev 18842)
@@ -77,7 +77,7 @@
if (componentView == null) {
componentView = getMSCService(componentViewName, ComponentView.class);
if (componentView == null) {
- throw MESSAGES.cannotFindComponentView(componentViewName);
+ throw MESSAGES.cannotFindComponentView(componentViewName);
}
if (reference == null) {
try {
@@ -103,22 +103,24 @@
try {
// prepare for invocation
onBeforeInvocation(wsInvocation);
- //for spring integration we don't need to go into ee's interceptors
- if(wsInvocation.getInvocationContext().getTargetBean() != null && endpoint.getProperty("SpringBus") != null) {
- this.reference = new ManagedReference() {
- public void release() {
- }
-
- public Object getInstance() {
- return wsInvocation.getInvocationContext().getTargetBean();
- }
- };
- }
// prepare invocation data
final ComponentView componentView = getComponentView();
Component component = componentView.getComponent();
- if (component instanceof WSComponent && endpoint.getProperty("SpringBus") != null) {
- ((WSComponent)component).setReference(reference);
+ //for spring integration and @FactoryType is annotated we don't need to go into ee's interceptors
+ if(wsInvocation.getInvocationContext().getTargetBean() != null
+ && (endpoint.getProperty("SpringBus") != null)
+ || wsInvocation.getInvocationContext().getProperty("forceTargetBean") != null) {
+ this.reference = new ManagedReference() {
+ public void release() {
+ }
+
+ public Object getInstance() {
+ return wsInvocation.getInvocationContext().getTargetBean();
+ }
+ };
+ if (component instanceof WSComponent) {
+ ((WSComponent) component).setReference(reference);
+ }
}
final Method method = getComponentViewMethod(wsInvocation.getJavaMethod(), componentView.getViewMethods());
final InterceptorContext context = new InterceptorContext();
@@ -127,13 +129,16 @@
context.setParameters(wsInvocation.getArgs());
context.putPrivateData(Component.class, component);
context.putPrivateData(ComponentView.class, componentView);
+ if(wsInvocation.getInvocationContext().getProperty("forceTargetBean") != null) {
+ context.putPrivateData(ManagedReference.class, reference);
+ }
// invoke method
final Object retObj = componentView.invoke(context);
// set return value
wsInvocation.setReturnValue(retObj);
}
catch (Throwable t) {
- WSLogger.ROOT_LOGGER.error(MESSAGES.methodInvocationFailed(t.getLocalizedMessage()), t);
+ WSLogger.ROOT_LOGGER.error(MESSAGES.methodInvocationFailed(t.getLocalizedMessage()), t);
handleInvocationException(t);
}
finally {
@@ -210,5 +215,4 @@
return true;
}
-}
-
+}
\ No newline at end of file
10 years, 4 months
JBossWS SVN: r18841 - stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2014-08-11 06:08:14 -0400 (Mon, 11 Aug 2014)
New Revision: 18841
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java
Log:
[JBWS-3785]:Add option for forcing https protocol when rewriting soap:addres in WSDL
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java 2014-08-11 10:07:33 UTC (rev 18840)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java 2014-08-11 10:08:14 UTC (rev 18841)
@@ -56,7 +56,10 @@
{
final String origUriScheme = getUriScheme(wsdlAddress); //will be https if the user wants a https address in the wsdl
final String newUriScheme = getUriScheme(epAddress); //will be https if the user set confidential transport for the endpoint
- final String uriScheme = (origUriScheme.equals(HTTPS) || newUriScheme.equals(HTTPS)) ? HTTPS : HTTP;
+ String uriScheme = (origUriScheme.equals(HTTPS) || newUriScheme.equals(HTTPS)) ? HTTPS : HTTP;
+ if (serverConfig.getWebServiceUriScheme() != null) {
+ uriScheme = serverConfig.getWebServiceUriScheme();
+ }
return rewriteSoapAddress(serverConfig, wsdlAddress, epAddress, uriScheme);
}
else
10 years, 4 months
JBossWS SVN: r18840 - in common/trunk/src/main/java/org/jboss/ws/common: management and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2014-08-11 06:07:33 -0400 (Mon, 11 Aug 2014)
New Revision: 18840
Modified:
common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointAddressDeploymentAspect.java
common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
Log:
[JBWS-3785]:Add option for forcing https protocol when rewriting soap:addres in WSDL
Modified: common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointAddressDeploymentAspect.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointAddressDeploymentAspect.java 2014-08-11 10:06:34 UTC (rev 18839)
+++ common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointAddressDeploymentAspect.java 2014-08-11 10:07:33 UTC (rev 18840)
@@ -69,6 +69,7 @@
String host = serverConfig.getWebServiceHost();
Map<String, Endpoint> endpointsMap = new HashMap<String, Endpoint>();
List<Endpoint> deleteList = new LinkedList<Endpoint>();
+ String uriSchema = serverConfig.getWebServiceUriScheme();
for (Endpoint ep : service.getEndpoints())
{
if (ep instanceof HttpEndpoint)
@@ -84,8 +85,12 @@
if (urlPattern.endsWith("/*"))
urlPattern = urlPattern.substring(0, urlPattern.length() - 2);
-
+
String protocol = confidential ? "https://" : "http://";
+ //force address protocol
+ if (uriSchema != null) {
+ protocol = uriSchema + "://";
+ }
String address = protocol + hostAndPort + (contextRoot.equals("/") && urlPattern.startsWith("/") ? "" : contextRoot) + urlPattern;
httpEp.setAddress(address);
//JBWS-2957: EJB3 binds the same endpoint class to multiple beans at multiple JNDI locations;
Modified: common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2014-08-11 10:06:34 UTC (rev 18839)
+++ common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2014-08-11 10:07:33 UTC (rev 18840)
@@ -85,7 +85,10 @@
// The SOAP address path component for substitution in the existing SOAP address.
private volatile String webServicePathRewriteRule;
private final Object webServicePathRewriteRuleLock = new Object();
-
+
+ //The SOAP address uri schema, http is the default value
+ private volatile String webServiceUriScheme;
+ private final Object webServiceUriSchemeLock = new Object();
private volatile boolean statisticsEnabled;
//The stack config
@@ -287,7 +290,29 @@
this.webServicePathRewriteRule = path;
}
}
+
+ public String getWebServiceUriScheme()
+ {
+ return this.webServiceUriScheme;
+ }
+ public void setWebServiceUriScheme(String scheme)
+ {
+ setWebServiceUriScheme(scheme, null);
+ }
+
+ public void setWebServiceUriScheme(String scheme, UpdateCallbackHandler uch)
+ {
+ synchronized (webServiceUriSchemeLock) {
+ if (uch != null)
+ {
+ uch.onBeforeUpdate();
+ }
+ this.webServiceUriScheme = scheme;
+ }
+ }
+
+
private int getConnectorPort(boolean secure) {
final ClassLoader cl = ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
int port = 0;
10 years, 4 months
JBossWS SVN: r18839 - spi/trunk/src/main/java/org/jboss/wsf/spi/management.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2014-08-11 06:06:34 -0400 (Mon, 11 Aug 2014)
New Revision: 18839
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java
Log:
[JBWS-3785]:Add api to set wsdl uri scheme in ServerConfig
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java 2014-08-08 14:45:18 UTC (rev 18838)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java 2014-08-11 10:06:34 UTC (rev 18839)
@@ -64,6 +64,9 @@
String getWebServicePathRewriteRule();
void setWebServicePathRewriteRule(String path);
+ String getWebServiceUriScheme();
+ void setWebServiceUriScheme(String scheme);
+
boolean isModifySOAPAddress();
void setModifySOAPAddress(boolean flag);
10 years, 4 months
JBossWS SVN: r18838 - in stack/cxf/trunk/modules: server/src/main/java/org/jboss/wsf/stack/cxf/deployment and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-08-08 10:45:18 -0400 (Fri, 08 Aug 2014)
New Revision: 18838
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
stack/cxf/trunk/modules/server/src/test/java/org/jboss/wsf/stack/cxf/configuration/BusHolderTest.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
Log:
[JBWS-3750] Move additional interceptor registration to Bus level (instead of Endpoint level)
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2014-08-08 14:01:12 UTC (rev 18837)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2014-08-08 14:45:18 UTC (rev 18838)
@@ -21,6 +21,7 @@
*/
package org.jboss.wsf.stack.cxf.configuration;
+import java.security.AccessController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -54,6 +55,7 @@
import org.apache.cxf.wsdl11.WSDLManagerImpl;
import org.jboss.ws.api.annotation.PolicySets;
import org.jboss.ws.api.binding.BindingCustomization;
+import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.WSFException;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
@@ -61,9 +63,11 @@
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.spi.security.JASPIAuthenticationProvider;
import org.jboss.wsf.stack.cxf.Loggers;
+import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
import org.jboss.wsf.stack.cxf.client.Constants;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.extensions.policy.PolicySetsAnnotationListener;
@@ -71,6 +75,7 @@
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.HandlerAuthInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.NsCtxSelectorStoreInterceptor;
+import org.jboss.wsf.stack.cxf.interceptor.WSDLSoapAddressRewriteInterceptor;
import org.jboss.wsf.stack.cxf.management.InstrumentationManagerExtImpl;
import org.jboss.wsf.stack.cxf.security.authentication.AuthenticationMgrSubjectCreatingInterceptor;
@@ -188,7 +193,7 @@
public abstract Configurer createServerConfigurer(BindingCustomization customization,
WSDLFilePublisher wsdlPublisher, List<Endpoint> depEndpoints, UnifiedVirtualFile root, String epConfigName, String epConfigFile);
- protected static void setInterceptors(Bus bus, Map<String, String> props)
+ protected void setInterceptors(Bus bus, Map<String, String> props)
{
//Install the EndpointAssociationInterceptor for linking every message exchange
//with the proper spi Endpoint retrieved in CXFServletExt
@@ -200,6 +205,10 @@
if ((p == null || (!"true".equalsIgnoreCase(p) && !"1".equalsIgnoreCase(p))) && !Boolean.getBoolean(Constants.JBWS_CXF_DISABLE_HANDLER_AUTH_CHECKS)) {
bus.getInInterceptors().add(new HandlerAuthInterceptor());
}
+
+ if (SoapAddressRewriteHelper.isPathRewriteRequired(getServerConfig())) {
+ bus.getInInterceptors().add(WSDLSoapAddressRewriteInterceptor.INSTANCE);
+ }
}
protected static void setResourceResolver(Bus bus, ResourceResolver resourceResolver)
@@ -336,6 +345,13 @@
return prop != null ? Long.parseLong(prop) : defaultValue;
}
+ protected ServerConfig getServerConfig() {
+ if(System.getSecurityManager() == null) {
+ return AbstractServerConfig.getServerIntegrationServerConfig();
+ }
+ return AccessController.doPrivileged(AbstractServerConfig.GET_SERVER_INTEGRATION_SERVER_CONFIG);
+ }
+
/**
* Return the hold bus
*
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2014-08-08 14:01:12 UTC (rev 18837)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2014-08-08 14:45:18 UTC (rev 18838)
@@ -34,9 +34,7 @@
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.frontend.WSDLGetUtils;
-import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
-import org.apache.cxf.message.Message;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.service.model.ServiceInfo;
@@ -46,7 +44,6 @@
import org.jboss.wsf.spi.metadata.config.CommonConfig;
import org.jboss.wsf.stack.cxf.Loggers;
import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
-import org.jboss.wsf.stack.cxf.interceptor.WSDLSoapAddressRewriteInterceptor;
/**
@@ -78,10 +75,6 @@
super.getServerFactory().setBlockPostConstruct(true);
super.doPublish(addr);
- // A custom interceptor is required when the server config attributes for rewriting
- // the path in a WSDL URL (i.e., <soap:address location= ...) are set
- replaceWSDLGetInterceptor();
-
//allow for configuration so that the wsdlPublisher can be set be the JBossWSCXFConfigurer
configureObject(this);
setupConfigHandlers();
@@ -90,18 +83,6 @@
}
/**
- * Add interceptor that enables the desired soap:address rewrite
- */
- private void replaceWSDLGetInterceptor(){
- if (SoapAddressRewriteHelper.isPathRewriteRequired(getServerConfig())) {
- List<Interceptor<? extends Message>> inInterceptors = getInInterceptors();
- if(!inInterceptors.contains(WSDLSoapAddressRewriteInterceptor.INSTANCE)){
- inInterceptors.add(WSDLSoapAddressRewriteInterceptor.INSTANCE);
- }
- }
- }
-
- /**
* Sets the JAXWS endpoint config for the current endpoint. This is called by configurer when
* org.apache.cxf.jaxws.EndpointImpl#getServer(..) executes 'configureObject(this)'
*
Modified: stack/cxf/trunk/modules/server/src/test/java/org/jboss/wsf/stack/cxf/configuration/BusHolderTest.java
===================================================================
--- stack/cxf/trunk/modules/server/src/test/java/org/jboss/wsf/stack/cxf/configuration/BusHolderTest.java 2014-08-08 14:01:12 UTC (rev 18837)
+++ stack/cxf/trunk/modules/server/src/test/java/org/jboss/wsf/stack/cxf/configuration/BusHolderTest.java 2014-08-08 14:45:18 UTC (rev 18838)
@@ -21,6 +21,7 @@
*/
package org.jboss.wsf.stack.cxf.configuration;
+import java.io.File;
import java.util.HashMap;
import java.util.Map;
@@ -30,6 +31,8 @@
import org.apache.cxf.ws.policy.selector.FirstAlternativeSelector;
import org.apache.cxf.ws.policy.selector.MaximalAlternativeSelector;
import org.jboss.ws.common.deployment.DefaultDeploymentModelFactory;
+import org.jboss.ws.common.management.AbstractServerConfig;
+import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.stack.cxf.client.Constants;
import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
@@ -67,7 +70,31 @@
props.put(Constants.CXF_POLICY_ALTERNATIVE_SELECTOR_PROP, alternative);
wsmd = new JBossWebservicesMetaData(null, null, null, null, props, null, null);
}
- BusHolder holder = new NonSpringBusHolder(new DDBeans());
+ BusHolder holder = new NonSpringBusHolder(new DDBeans()) {
+ protected ServerConfig getServerConfig() {
+ return new AbstractServerConfig()
+ {
+ @Override
+ public File getServerTempDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public File getServerDataDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public File getHomeDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ }
+ };
try {
holder.configure(null, null, wsmd, new DefaultDeploymentModelFactory().newDeployment("testDeployment", null, null));
return holder.getBus().getExtension(PolicyEngine.class).getAlternativeSelector().getClass().getName();
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2014-08-08 14:01:12 UTC (rev 18837)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2014-08-08 14:45:18 UTC (rev 18838)
@@ -21,12 +21,15 @@
*/
package org.jboss.test.ws.jaxws.cxf.jbws3098;
+import java.io.File;
import java.net.URL;
import org.apache.cxf.Bus;
import org.apache.cxf.buslifecycle.BusLifeCycleListener;
import org.apache.cxf.buslifecycle.BusLifeCycleManager;
import org.jboss.ws.common.deployment.DefaultDeploymentModelFactory;
+import org.jboss.ws.common.management.AbstractServerConfig;
+import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.stack.cxf.client.util.SpringUtils;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder;
@@ -47,18 +50,74 @@
{
if (SpringUtils.isSpringAvailable(Thread.currentThread().getContextClassLoader()))
{
- simpleShutdownTest(new SpringBusHolder(null, null, new URL[]{}));
- shutdownTestWithInnerShutdown(new SpringBusHolder(null, null, new URL[]{}));
- shutdownTestWithNoShutdown(new SpringBusHolder(null, null, new URL[]{}));
+ simpleShutdownTest(newSpringBusHolderInstance());
+ shutdownTestWithInnerShutdown(newSpringBusHolderInstance());
+ shutdownTestWithNoShutdown(newSpringBusHolderInstance());
}
else
{
- simpleShutdownTest(new NonSpringBusHolder(new DDBeans()));
- shutdownTestWithInnerShutdown(new NonSpringBusHolder(new DDBeans()));
- shutdownTestWithNoShutdown(new NonSpringBusHolder(new DDBeans()));
+ simpleShutdownTest(newNonSpringBusHolderInstance());
+ shutdownTestWithInnerShutdown(newNonSpringBusHolderInstance());
+ shutdownTestWithNoShutdown(newNonSpringBusHolderInstance());
}
}
+ private static SpringBusHolder newSpringBusHolderInstance() {
+ return new SpringBusHolder(null, null, new URL[]{}) {
+ protected ServerConfig getServerConfig() {
+ return new AbstractServerConfig()
+ {
+ @Override
+ public File getServerTempDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public File getServerDataDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public File getHomeDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ }
+ };
+ }
+
+ private static NonSpringBusHolder newNonSpringBusHolderInstance() {
+ return new NonSpringBusHolder(new DDBeans()) {
+ protected ServerConfig getServerConfig() {
+ return new AbstractServerConfig()
+ {
+ @Override
+ public File getServerTempDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public File getServerDataDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public File getHomeDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ }
+ };
+ }
+
private static void simpleShutdownTest(BusHolder holder)
{
Bus bus = holder.getBus();
10 years, 4 months
JBossWS SVN: r18836 - in stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client: serviceref and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-08-08 09:59:56 -0400 (Fri, 08 Aug 2014)
New Revision: 18836
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/SecurityProviderConfig.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFHandlerResolverImpl.java
Log:
A couple of minor singleton optimizations, replaced usage of static synchronized methods with lazy initialization holder class idiom
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/SecurityProviderConfig.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/SecurityProviderConfig.java 2014-08-08 13:59:27 UTC (rev 18835)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/SecurityProviderConfig.java 2014-08-08 13:59:56 UTC (rev 18836)
@@ -51,10 +51,23 @@
}
}
private static final boolean NO_LOCAL_BC = SecurityActions.getBoolean(Constants.JBWS_CXF_NO_LOCAL_BC);
- private static Provider provider;
- private static synchronized Provider getBCProvider() {
- if (provider == null) {
+ public static void setup(Bus bus) {
+ if (!NO_LOCAL_BC && !BC_GLOBALLY_AVAILABLE) {
+ if (Holder.provider != null) {
+ bus.getInInterceptors().add(Holder.inInterceptor);
+ bus.getOutInterceptors().add(Holder.outInterceptor);
+ }
+ }
+ }
+
+ private static class Holder {
+ static final Provider provider = getBCProvider();
+ static final Interceptor inInterceptor = new Interceptor(Phase.RECEIVE);
+ static final Interceptor outInterceptor = new Interceptor(Phase.SETUP);
+
+ private static Provider getBCProvider() {
+ Provider provider = null;
try {
Class<?> clazz = SecurityProviderConfig.class.getClassLoader().loadClass("org.bouncycastle.jce.provider.BouncyCastleProvider");
provider = (Provider)clazz.newInstance();
@@ -64,21 +77,10 @@
} catch (Throwable t) {
Loggers.ROOT_LOGGER.cannotLoadBouncyCastleProvider(Constants.JBWS_CXF_NO_LOCAL_BC, t);
}
+ return provider;
}
- return provider;
}
-
- public static void setup(Bus bus) {
- if (!NO_LOCAL_BC && !BC_GLOBALLY_AVAILABLE) {
- Provider p = getBCProvider();
- if (p != null) {
- bus.getInInterceptors().add(new Interceptor(Phase.RECEIVE));
- bus.getOutInterceptors().add(new Interceptor(Phase.SETUP));
- }
- }
- }
-
private static class Interceptor extends AbstractPhaseInterceptor<Message> {
public Interceptor(String phase)
@@ -90,7 +92,7 @@
public void handleMessage(Message message) throws Fault
{
Exchange exchange = message.getExchange();
- exchange.put(Provider.class, getBCProvider());
+ exchange.put(Provider.class, Holder.provider);
}
}
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFHandlerResolverImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFHandlerResolverImpl.java 2014-08-08 13:59:27 UTC (rev 18835)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFHandlerResolverImpl.java 2014-08-08 13:59:56 UTC (rev 18836)
@@ -91,11 +91,9 @@
@SuppressWarnings("rawtypes")
private final Map<PortInfo, List<Handler>> handlerMap = new HashMap<PortInfo, List<Handler>>();
private final String handlerFile;
- private static JAXBContext context;
private final Class<?> clazz;
private final ClassLoader classLoader;
private final Bus bus;
- private static DocumentBuilder builder;
public CXFHandlerResolverImpl(Bus bus, String handlerFile, Class<?> clazz)
{
@@ -160,7 +158,7 @@
throw MESSAGES.handlerConfigFileNotFound(handlerFile);
}
- Document doc = getDocumentBuilder().parse(is);
+ Document doc = Holder.builder.parse(is);
Element el = doc.getDocumentElement();
if (!ParserConstants.JAVAEE_NS.equals(el.getNamespaceURI())
|| !ParserConstants.HANDLER_CHAINS.equals(el.getLocalName())) {
@@ -363,7 +361,7 @@
private void processHandlerElement(Element el, @SuppressWarnings("rawtypes") List<Handler> chain) {
try {
- JAXBContext ctx = getContextForPortComponentHandlerType();
+ JAXBContext ctx = Holder.context;
PortComponentHandlerType pt = ctx.createUnmarshaller()
.unmarshal(el, PortComponentHandlerType.class).getValue();
chain.addAll(buildHandlerChain(pt, classLoader));
@@ -372,20 +370,16 @@
}
}
- private static synchronized JAXBContext getContextForPortComponentHandlerType()
- throws JAXBException {
- if (context == null) {
- context = JAXBContext.newInstance(PortComponentHandlerType.class);
- }
- return context;
- }
-
- private static synchronized DocumentBuilder getDocumentBuilder()
- {
- if (builder == null)
+ private static class Holder {
+
+ static final DocumentBuilder builder = getDocumentBuilder();
+ static final JAXBContext context = getContextForPortComponentHandlerType();
+
+ private static DocumentBuilder getDocumentBuilder()
{
final ClassLoader classLoader = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(CXFHandlerResolverImpl.class.getClassLoader());
+ DocumentBuilder builder;
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -406,8 +400,21 @@
{
SecurityActions.setContextClassLoader(classLoader);
}
+ return builder;
}
- return builder;
+
+ private static JAXBContext getContextForPortComponentHandlerType() {
+ JAXBContext context = null;
+ try {
+ context = JAXBContext.newInstance(PortComponentHandlerType.class);
+ } catch (JAXBException e) {
+ e.printStackTrace(); //TODO can this really happen?
+ }
+ return context;
+ }
+
}
+
+
}
10 years, 4 months
JBossWS SVN: r18835 - spi/branches.
by jbossws-commits@lists.jboss.org
Author: rsearls
Date: 2014-08-08 09:59:27 -0400 (Fri, 08 Aug 2014)
New Revision: 18835
Removed:
spi/branches/rsearls/
Log:
branch no longer needed
10 years, 4 months
JBossWS SVN: r18834 - common/branches.
by jbossws-commits@lists.jboss.org
Author: rsearls
Date: 2014-08-08 09:57:41 -0400 (Fri, 08 Aug 2014)
New Revision: 18834
Removed:
common/branches/rsearls/
Log:
branch no longer needed
10 years, 4 months
JBossWS SVN: r18833 - stack/cxf/branches.
by jbossws-commits@lists.jboss.org
Author: rsearls
Date: 2014-08-08 09:56:13 -0400 (Fri, 08 Aug 2014)
New Revision: 18833
Removed:
stack/cxf/branches/rsearls/
Log:
branch no longer needed
10 years, 4 months