Author: jim.ma
Date: 2010-04-20 23:10:21 -0400 (Tue, 20 Apr 2010)
New Revision: 12060
Added:
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/EndpointsDescriptorDeploymentAspect.java
Modified:
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDBeans.java
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
stack/cxf/branches/jms-integration/modules/server/src/main/resources/jbossws-cxf-config-as5.xml
Log:
[JBWS-2791]:Added DAs to deploy jms endpoints
Modified:
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2010-04-21
03:03:47 UTC (rev 12059)
+++
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2010-04-21
03:10:21 UTC (rev 12060)
@@ -165,8 +165,23 @@
protected void createBus(URL location)
{
bus = new SpringBusFactory().createBus();
- ctx = bus.getExtension(BusApplicationContext.class);
- //Load additional configurations from cxf-servlet.xml
+ loadCXFConfig (bus, location);
+ //Force servlet transport to prevent CXF from using Jetty as a transport
+ DestinationFactory factory = new ServletTransportFactory(bus);
+ for (String s : factory.getTransportIds()) {
+ registerTransport(factory, s);
+ }
+ }
+
+ /**Load CXF spring beans definition
+ *
+ * @param bus CXF Bus
+ * @param location Srping style cxf configuraiton xml
+ */
+ public void loadCXFConfig(Bus bus, URL location) {
+
+ ApplicationContext ctx = bus.getExtension(BusApplicationContext.class);
+
if (location != null)
{
try
@@ -179,13 +194,9 @@
log.trace("Could not load additional config from location: " +
location, e);
}
}
- //Force servlet transport to prevent CXF from using Jetty as a transport
- DestinationFactory factory = new ServletTransportFactory(bus);
- for (String s : factory.getTransportIds()) {
- registerTransport(factory, s);
- }
}
+
protected static void setResourceResolver(Bus bus, ResourceResolver resourceResolver)
{
if (resourceResolver != null)
Modified:
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
===================================================================
---
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2010-04-21
03:03:47 UTC (rev 12059)
+++
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2010-04-21
03:10:21 UTC (rev 12060)
@@ -25,9 +25,12 @@
import java.net.URL;
import java.util.Map;
+import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
import org.jboss.wsf.common.integration.WSConstants;
+import org.jboss.wsf.common.integration.WSHelper;
import org.jboss.wsf.spi.binding.BindingCustomization;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
@@ -51,7 +54,7 @@
@Override
public void start(Deployment dep)
{
- BusHolder holder;
+ BusHolder holder = null;
ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
try
{
@@ -59,30 +62,57 @@
//set the runtime classloader (pointing to the deployment unit) to allow CXF
accessing to the classes
SecurityActions.setContextClassLoader(dep.getRuntimeClassLoader());
+ Map<String, String> contextParams = (Map<String,
String>)dep.getProperty(WSConstants.STACK_CONTEXT_PARAMS);
+
ResourceResolver deploymentResolver = aDep.getResourceResolver();
-
- URL cxfServletURL = null;
- try
+ org.apache.cxf.resource.ResourceResolver resolver = new
JBossWSResourceResolver(deploymentResolver);
+
+ if (contextParams != null)
{
- cxfServletURL =
deploymentResolver.resolve("WEB-INF/cxf-servlet.xml");
- }
- catch (IOException e)
- {
- } //ignore, cxf-servlet.xml is optional, we might even decide not to support
this
+
- holder = BusHolder.create(cxfServletURL);
+ URL cxfServletURL = null;
+ try
+ {
+ cxfServletURL =
deploymentResolver.resolve("WEB-INF/cxf-servlet.xml");
+ }
+ catch (IOException e)
+ {
+ } //ignore, cxf-servlet.xml is optional, we might even decide not to support
this
- Map<String, String> contextParams = (Map<String,
String>)dep.getProperty(WSConstants.STACK_CONTEXT_PARAMS);
- try
- {
- URL jbossCxfXml =
deploymentResolver.resolve(contextParams.get(BusHolder.PARAM_CXF_BEANS_URL));
- org.apache.cxf.resource.ResourceResolver resolver = new
JBossWSResourceResolver(deploymentResolver);
- JBossWSCXFConfigurer configurer =
holder.createConfigurer(dep.getAttachment(BindingCustomization.class), new
WSDLFilePublisher(aDep));
- holder.configure(jbossCxfXml, new SoapTransportFactoryExt(), resolver,
configurer);
+ holder = BusHolder.create(cxfServletURL);
+
+ try
+ {
+ URL jbossCxfXml =
deploymentResolver.resolve(contextParams.get(BusHolder.PARAM_CXF_BEANS_URL));
+
+ JBossWSCXFConfigurer configurer =
holder.createConfigurer(dep.getAttachment(BindingCustomization.class),
+ new WSDLFilePublisher(aDep));
+ holder.configure(jbossCxfXml, new SoapTransportFactoryExt(), resolver,
configurer);
+
+ //if there is jbossws endpoints deployment descriptor
+ if (WSHelper.hasEndpointsDeployment(dep) &&
dep.getProperty(BusHolder.PARAM_CXF_BEANS_URL) != null)
+ {
+ URL url = (URL) dep.getProperty(BusHolder.PARAM_CXF_BEANS_URL);
+ holder.loadCXFConfig(holder.getBus(), url);
+ }
+
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e); //re-throw, jboss-cxf.xml is required
+ }
}
- catch (IOException e)
+
+ if (contextParams == null && WSHelper.hasEndpointsDeployment(dep))
{
- throw new RuntimeException(e); //re-throw, jboss-cxf.xml is required
+ //TODO:BusHolder needs refactor to createBus automatically or getDefaultBus
+ URL tmp = null;
+ //holder = BusHolder.create(url);
+ //Bus bus = new SpringBusFactory().createBus();
+ if (holder == null) holder = BusHolder.create(tmp);
+ URL url = (URL)dep.getProperty(BusHolder.PARAM_CXF_BEANS_URL);
+ holder.loadCXFConfig(holder.getBus(), url);
}
}
finally
Added:
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/EndpointsDescriptorDeploymentAspect.java
===================================================================
---
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/EndpointsDescriptorDeploymentAspect.java
(rev 0)
+++
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/EndpointsDescriptorDeploymentAspect.java 2010-04-21
03:10:21 UTC (rev 12060)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.deployment.aspect;
+
+import java.net.URL;
+
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.endpoints.EndpointMetaData;
+import org.jboss.wsf.spi.metadata.endpoints.EndpointsMetaData;
+import org.jboss.wsf.spi.metadata.endpoints.jms.JMSAddressMetaData;
+import org.jboss.wsf.stack.cxf.configuration.BusHolder;
+import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
+import org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint;
+import org.jboss.wsf.stack.cxf.metadata.services.DDJmsAddressBean;
+
+/**
+ * To convert the EndpointsMetaData to cxf deployment spring style xml
+ *
+ * @author <a href="ema(a)redhat.com">Jim Ma</a>
+ */
+public class EndpointsDescriptorDeploymentAspect extends AbstractDeploymentAspect
+{
+ @Override
+ public void start(Deployment dep)
+ {
+ if (WSHelper.getOptionalAttachment(dep, EndpointsMetaData.class) != null)
+ {
+ URL url = this.generateCXFDeploymentDescriptor(dep);
+ dep.setProperty(BusHolder.PARAM_CXF_BEANS_URL, url);
+ }
+ }
+
+ @Override
+ public void stop(Deployment dep)
+ {
+ dep.removeProperty(BusHolder.PARAM_CXF_BEANS_URL);
+ }
+
+ @Override
+ public boolean canHandle(Deployment dep)
+ {
+ if (WSHelper.isJaxrpcDeployment(dep))
+ {
+ return false;
+ }
+ else
+ {
+ return WSHelper.getOptionalAttachment(dep, EndpointsMetaData.class) == null ?
false : true;
+ }
+ }
+
+ private URL generateCXFDeploymentDescriptor(Deployment dep)
+ {
+ DDBeans ddBeans = new DDBeans();
+ EndpointsMetaData endpoints = WSHelper.getRequiredAttachment(dep,
EndpointsMetaData.class);
+ for (EndpointMetaData endpointMD : endpoints.getEndpointsMetaData())
+ {
+ DDEndpoint endpointBean = new DDEndpoint(dep.getSimpleName(),
endpointMD.getImplementor());
+ ddBeans.addEndpoint(endpointBean);
+ if (endpointMD.getAddressMetaData() != null &&
endpointMD.getAddressMetaData() instanceof JMSAddressMetaData)
+ {
+ JMSAddressMetaData jmsMD = (JMSAddressMetaData)
endpointMD.getAddressMetaData();
+
endpointBean.setTransportId("http://cxf.apache.org/transports/jms&qu...;
+ if (jmsMD.getRequestDestination() != null)
+ {
+ DDJmsAddressBean addressBean = new DDJmsAddressBean(jmsMD.getPortName(),
true, jmsMD
+ .getReplyDestination().getProperties());
+ ddBeans.addAddress(addressBean);
+ }
+
+ if (jmsMD.getReplyDestination() != null)
+ {
+ DDJmsAddressBean addressBean = new DDJmsAddressBean(jmsMD.getPortName(),
false, jmsMD
+ .getReplyDestination().getProperties());
+ ddBeans.addAddress(addressBean);
+ }
+ }
+ }
+ URL url = ddBeans.createFileURL();
+ return url;
+
+ }
+}
Modified:
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDBeans.java
===================================================================
---
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDBeans.java 2010-04-21
03:03:47 UTC (rev 12059)
+++
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDBeans.java 2010-04-21
03:10:21 UTC (rev 12060)
@@ -45,6 +45,9 @@
private List<DDEndpoint> endpoints = new ArrayList<DDEndpoint>();
// Optional additional beans.
private List<DDBean> beans = new ArrayList<DDBean>();
+
+ private List<DDJmsAddressBean> addressBeans = new
ArrayList<DDJmsAddressBean>();
+
// The derived temp file
private File tmpFile;
@@ -57,6 +60,11 @@
{
endpoints.add(service);
}
+
+ public void addAddress(DDJmsAddressBean addressBean)
+ {
+ addressBeans.add(addressBean);
+ }
public List<DDBean> getBeans()
{
@@ -104,9 +112,12 @@
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " +
"xmlns:beans='http://www.springframework.org/schema/beans'
" +
"xmlns:jaxws='http://cxf.apache.org/jaxws' " +
+ "xmlns:jms='http://cxf.apache.org/transports/jms' " +
"xmlns:soap='http://cxf.apache.org/bindings/soap' " +
"xsi:schemaLocation='http://www.springframework.org/schema/beans
" +
"http://www.springframework.org/schema/beans/spring-beans.xsd " +
+ "http://cxf.apache.org/transports/jms " +
+ "http://cxf.apache.org/schemas/configuration/jms.xsd " +
"http://cxf.apache.org/jaxws " +
"http://cxf.apache.org/schemas/jaxws.xsd'>");
@@ -118,6 +129,10 @@
{
bean.writeTo(writer);
}
+
+ for (DDJmsAddressBean bean : this.addressBeans) {
+ bean.writeTo(writer);
+ }
writer.write("</beans>");
}
Modified:
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
===================================================================
---
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2010-04-21
03:03:47 UTC (rev 12059)
+++
stack/cxf/branches/jms-integration/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2010-04-21
03:10:21 UTC (rev 12060)
@@ -36,6 +36,8 @@
private String address;
private String implementor;
private String invoker;
+ private String transportId;
+
private boolean mtomEnabled;
public DDEndpoint(String id, String address, String implementor, boolean mtomEnabled)
@@ -45,6 +47,12 @@
this.implementor = implementor;
this.mtomEnabled = mtomEnabled;
}
+
+ public DDEndpoint(String id, String implementor)
+ {
+ this.id = id;
+ this.implementor = implementor;
+ }
public void setInvoker(String invoker)
{
@@ -54,8 +62,17 @@
public void writeTo(Writer writer) throws IOException
{
writer.write("<jaxws:endpoint id='" + this.id +
"'");
- writer.write(" address='" + this.address + "'");
+ if (address != null)
+ {
+ writer.write(" address='" + this.address + "'");
+ }
writer.write(" implementor='" + this.implementor +
"'");
+
+ if (transportId != null)
+ {
+ writer.write(" transportId='" + this.transportId +
"'");
+ }
+
writer.write(">");
if (this.mtomEnabled)
@@ -73,6 +90,12 @@
writer.write("</jaxws:endpoint>");
}
+
+ public void setTransportId(String transportId)
+ {
+ this.transportId = transportId;
+ }
+
public String toString()
{
StringBuilder str = new StringBuilder("Service");
@@ -81,6 +104,7 @@
str.append("\n implementor=" + this.implementor);
str.append("\n invoker=" + this.invoker);
str.append("\n mtomEnabled=" + this.mtomEnabled);
+ str.append("\n transportId=" + this.transportId);
return str.toString();
}
}
Modified:
stack/cxf/branches/jms-integration/modules/server/src/main/resources/jbossws-cxf-config-as5.xml
===================================================================
---
stack/cxf/branches/jms-integration/modules/server/src/main/resources/jbossws-cxf-config-as5.xml 2010-04-21
03:03:47 UTC (rev 12059)
+++
stack/cxf/branches/jms-integration/modules/server/src/main/resources/jbossws-cxf-config-as5.xml 2010-04-21
03:10:21 UTC (rev 12060)
@@ -45,6 +45,15 @@
<property
name="invokerJSE">org.jboss.wsf.stack.cxf.InvokerJSE</property>
<property name="relativeOrder">21</property> <!--
[JBDEPLOY-201] workaround -->
</bean>
+
+
+ <bean name="EndpointsDescriptorDeploymentAspect"
class="org.jboss.wsf.stack.cxf.deployment.aspect.EndpointsDescriptorDeploymentAspect">
+ <property
name="requires">EndpointAddress,JAXBIntros</property>
+ <property name="provides">StackDescriptor</property>
+ <property name="relativeOrder">22</property> <!--
[JBDEPLOY-201] workaround -->
+ <property name="processEndpointDeployment">true</property>
+ </bean>
+
<bean name="WSCXFResourceResolverDeploymentAspect"
class="org.jboss.wsf.stack.cxf.deployment.aspect.ResourceResolverDeploymentAspect">
<property name="requires">JmsEndpointAddress</property>
@@ -80,6 +89,7 @@
<property name="provides">BusHolder</property>
<property
name="requires">ResourceResolver,StackDescriptor</property>
<property name="relativeOrder">24</property> <!--
[JBDEPLOY-201] workaround -->
+ <property name="processEndpointDeployment">true</property>
</bean>
</deployment>