Author: alessio.soldano(a)jboss.com
Date: 2011-10-26 12:52:49 -0400 (Wed, 26 Oct 2011)
New Revision: 15167
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/SecurityActions.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/SecurityActions.java
Log:
[JBWS-3280] Deploy using Spring bus only when Spring is available AND there's a
jbossws-cxf.xml descriptor in the deployment
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java 2011-10-26
13:59:40 UTC (rev 15166)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java 2011-10-26
16:52:49 UTC (rev 15167)
@@ -31,4 +31,5 @@
public class Constants
{
public static final String DEPLOYMENT_BUS = "deployment-bus";
+ public static final String JBOSSWS_CXF_SPRING_DD = "jbossws-cxf.xml";
}
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/SecurityActions.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/SecurityActions.java 2011-10-26
13:59:40 UTC (rev 15166)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/SecurityActions.java 2011-10-26
16:52:49 UTC (rev 15167)
@@ -78,5 +78,24 @@
});
}
}
+
+ /**
+ * Return the current value of the specified system property
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ static String getSystemProperty(final String name, final String defaultValue)
+ {
+ PrivilegedAction<String> action = new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2011-10-26
13:59:40 UTC (rev 15166)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2011-10-26
16:52:49 UTC (rev 15167)
@@ -94,7 +94,8 @@
for (DDEndpoint dde : metadata.getEndpoints())
{
EndpointImpl endpoint = new EndpointImpl(bus,
newInstance(dde.getImplementor()));
- endpoint.setInvoker((Invoker) newInstance(dde.getInvoker()));
+ if (dde.getInvoker() != null)
+ endpoint.setInvoker((Invoker) newInstance(dde.getInvoker()));
endpoint.setAddress(dde.getAddress());
endpoint.setEndpointName(dde.getPortName());
endpoint.setServiceName(dde.getServiceName());
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2011-10-26
13:59:40 UTC (rev 15166)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2011-10-26
16:52:49 UTC (rev 15167)
@@ -76,7 +76,7 @@
//parent to make sure user provided libs in the deployment do no mess up the WS
endpoint's deploy if they duplicates
//libraries already available on the application server modules.
SecurityActions.setContextClassLoader(new
DelegateClassLoader(dep.getRuntimeClassLoader(), origClassLoader));
- if (jbosswsCxfXml != null) // Spring available
+ if (jbosswsCxfXml != null) // Spring available and jbossws-cxf.xml provided
{
URL cxfServletURL = null;
try
@@ -100,7 +100,7 @@
}
}
else
- //Spring not available
+ //Spring not available or jbossws-cxf.xml not provided
{
DDBeans metadata = dep.getAttachment(DDBeans.class);
holder = new NonSpringBusHolder(metadata);
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java 2011-10-26
13:59:40 UTC (rev 15166)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java 2011-10-26
16:52:49 UTC (rev 15167)
@@ -38,6 +38,7 @@
import org.jboss.ws.common.integration.WSConstants;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.stack.cxf.client.Constants;
import org.jboss.wsf.stack.cxf.client.util.SpringUtils;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.metadata.MetadataBuilder;
@@ -51,6 +52,8 @@
*/
public class DescriptorDeploymentAspect extends AbstractDeploymentAspect
{
+ private static final boolean PREFER_SPRING_DESCRIPTOR_GENERATION =
Boolean.getBoolean("org.jboss.ws.cxf.prefer_spring_descriptor_generation");
+
private static final ResourceBundle bundle =
BundleUtils.getBundle(DescriptorDeploymentAspect.class);
// provide logging
private static final Logger log = Logger.getLogger(DescriptorDeploymentAspect.class);
@@ -58,21 +61,29 @@
@Override
public void start(Deployment dep)
{
+ URL cxfURL = null;
if (SpringUtils.isSpringAvailable())
{
- URL cxfURL = getCXFConfigFromDeployment(dep);
- if (cxfURL == null)
+ //only try reading jbossws-cxf.xml if Spring available...
+ cxfURL = getCXFConfigFromDeployment(dep);
+ //... but do not generate it if it's not provided
+ //or unless it's explicitly required to be generated
+ if (cxfURL == null && PREFER_SPRING_DESCRIPTOR_GENERATION)
{
- cxfURL = generateCXFConfigFromDeployment(dep);
+ DDBeans dd = generateMetadataFromDeployment(dep);
+ cxfURL = dd.createFileURL();
+ log.info("JBossWS-CXF configuration generated: " + cxfURL);
}
- putCXFConfigToDeployment(dep, cxfURL);
-
}
- else
+ if (cxfURL == null)
{
- log.debug("Spring not available, skipping check for user provided
jbossws-cxf.xml / cxf.xml configuration files.");
generateMetadataFromDeployment(dep);
}
+ else
+ {
+ log.info("Actual configuration from file: " + cxfURL);
+ putCXFConfigToDeployment(dep, cxfURL);
+ }
}
@Override
@@ -118,7 +129,7 @@
{
// get resource URL
ArchiveDeployment archDep = (ArchiveDeployment)dep;
- cxfURL = archDep.getResourceResolver().resolve(metadir +
"/jbossws-cxf.xml");
+ cxfURL = archDep.getResourceResolver().resolve(metadir + "/" +
Constants.JBOSSWS_CXF_SPRING_DD);
log.info("JBossWS-CXF configuration found: " + cxfURL);
}
catch (IOException ignore)
@@ -130,22 +141,8 @@
}
/**
- * Generated CXF descriptor from deployment
- * @param dep deployment
- * @return CXF descriptor URL
- */
- private URL generateCXFConfigFromDeployment(Deployment dep)
- {
- // Generate the jbossws-cxf.xml descriptor
- DDBeans dd = generateMetadataFromDeployment(dep);
- URL cxfURL = dd.createFileURL();
- log.info("JBossWS-CXF configuration generated: " + cxfURL);
-
- return cxfURL;
- }
-
- /**
* Generates the jbossws-cxf metadata from the deployment
+ * and attaches it the deployment
* @param dep
* @return
*/
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/SecurityActions.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/SecurityActions.java 2011-10-26
13:59:40 UTC (rev 15166)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/SecurityActions.java 2011-10-26
16:52:49 UTC (rev 15167)
@@ -79,4 +79,22 @@
}
}
+ /**
+ * Return the current value of the specified system property
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ static String getSystemProperty(final String name, final String defaultValue)
+ {
+ PrivilegedAction<String> action = new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
}
Show replies by date