You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/03/22 11:58:04 UTC
svn commit: r387827 - in /incubator/servicemix/trunk:
servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/
servicemix-http/src/main/java/org/apache/servicemix/http/
servicemix-http/src/main/java/org/apache/servicemix/http/processors/ ser...
Author: gnodet
Date: Wed Mar 22 02:58:01 2006
New Revision: 387827
URL: http://svn.apache.org/viewcvs?rev=387827&view=rev
Log:
SM-285: handle soap / mime requests on servicemix-jms
SM-359: add a defaultOperation for non soap endpoints on servicemix-jms and servicemix-http
Added:
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsExternalEndpoint.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java
incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java
incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/
incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/provider.wsdl
incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/xbean.xml
Removed:
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsMarshaler.java
Modified:
incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpoint.java
incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpointDeserializer.java
incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiExtension.java
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
incubator/servicemix/trunk/servicemix-jms/maven.xml
incubator/servicemix/trunk/servicemix-jms/project.xml
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java
incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/wsdl/JmsAddress.java
incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JMSComponentTest.java
incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java
incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java
Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpoint.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpoint.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpoint.java Wed Mar 22 02:58:01 2006
@@ -34,6 +34,7 @@
protected Role role;
protected URI defaultMep;
+ protected QName defaultOperation;
/**
* @return Returns the elementType.
@@ -78,13 +79,26 @@
this.defaultMep = defaultMep;
}
+ /**
+ * @return Returns the defaultOperation.
+ */
+ public QName getDefaultOperation() {
+ return defaultOperation;
+ }
+ /**
+ * @param defaultOperation The defaultOperation to set.
+ */
+ public void setDefaultOperation(QName defaultOperation) {
+ this.defaultOperation = defaultOperation;
+ }
+
public String toString() {
return "JbiEndpoint[" +
"required=" + required + ", " +
"elementType=" + elementType + ", " +
"role=" + role + ", " +
- "defaultMep=" + defaultMep + "]";
+ "defaultMep=" + defaultMep + "," +
+ "defaultOperation=" + defaultOperation + "]";
}
-
}
Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpointDeserializer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpointDeserializer.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpointDeserializer.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiEndpointDeserializer.java Wed Mar 22 02:58:01 2006
@@ -62,6 +62,11 @@
jbiEndpoint.setDefaultMep(URI.create(JbiExtension.WSDL2_NS + defaultMep));
}
+ QName defaultOperation = DOMUtils.getQualifiedAttributeValue(el, JbiExtension.DEFAULT_OPERATION, null, false, def);
+ if (defaultOperation != null) {
+ jbiEndpoint.setDefaultOperation(defaultOperation);
+ }
+
return jbiEndpoint;
}
Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiExtension.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiExtension.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiExtension.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/wsdl1/JbiExtension.java Wed Mar 22 02:58:01 2006
@@ -35,6 +35,8 @@
public static final String DEFAULT_MEP_ROBUST_IN_ONLY = "robust-in-only";
public static final String DEFAULT_MEP_IN_OUT = "in-out";
+ public static final String DEFAULT_OPERATION = "defaultOperation";
+
public static final String WSDL2_NS = "http://www.w3.org/2004/08/wsdl/";
public static void register(ExtensionRegistry registry) {
Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java (original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java Wed Mar 22 02:58:01 2006
@@ -30,6 +30,7 @@
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.servicemix.common.ExchangeProcessor;
@@ -64,6 +65,7 @@
protected boolean soap;
protected String soapVersion;
protected Resource wsdlResource;
+ protected QName defaultOperation;
/* (non-Javadoc)
* @see org.apache.servicemix.common.Endpoint#getProcessor()
@@ -273,6 +275,20 @@
public void setWsdlResource(Resource wsdlResource) {
this.wsdlResource = wsdlResource;
+ }
+
+ /**
+ * @return Returns the defaultOperation.
+ */
+ public QName getDefaultOperation() {
+ return defaultOperation;
+ }
+
+ /**
+ * @param defaultOperation The defaultOperation to set.
+ */
+ public void setDefaultOperation(QName defaultOperation) {
+ this.defaultOperation = defaultOperation;
}
}
Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java (original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java Wed Mar 22 02:58:01 2006
@@ -53,6 +53,7 @@
endpoint.setSoap(false);
endpoint.setRole(jbiEndpoint.getRole());
endpoint.setDefaultMep(jbiEndpoint.getDefaultMep());
+ endpoint.setDefaultOperation(jbiEndpoint.getDefaultOperation());
endpoint.setLocationURI(((HTTPAddress) portElement).getLocationURI());
endpoint.setBinding(bindingElement);
return endpoint;
@@ -61,6 +62,7 @@
endpoint.setSoap(true);
endpoint.setRole(jbiEndpoint.getRole());
endpoint.setDefaultMep(jbiEndpoint.getDefaultMep());
+ endpoint.setDefaultOperation(jbiEndpoint.getDefaultOperation());
endpoint.setLocationURI(((SOAPAddress) portElement).getLocationURI());
endpoint.setBinding(bindingElement);
return endpoint;
Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Wed Mar 22 02:58:01 2006
@@ -45,6 +45,7 @@
import org.apache.servicemix.soap.marshalers.JBIMarshaler;
import org.apache.servicemix.soap.marshalers.SoapMarshaler;
import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.apache.servicemix.soap.marshalers.SoapWriter;
import org.mortbay.jetty.handler.ContextHandler;
import org.mortbay.util.ajax.Continuation;
import org.mortbay.util.ajax.ContinuationSupport;
@@ -166,7 +167,9 @@
if (outMsg != null) {
SoapMessage out = new SoapMessage();
jbiMarshaler.fromNMS(out, outMsg);
- soapMarshaler.createWriter(out).write(response.getOutputStream());
+ SoapWriter writer = soapMarshaler.createWriter(out);
+ response.setContentType(writer.getContentType());
+ writer.write(response.getOutputStream());
}
}
} finally {
@@ -188,7 +191,9 @@
if (in != null) {
soapFault.setEnvelopeName(in.getEnvelopeName());
}
- soapMarshaler.createWriter(soapFault).write(response.getOutputStream());
+ SoapWriter writer = soapMarshaler.createWriter(soapFault);
+ response.setContentType(writer.getContentType());
+ writer.write(response.getOutputStream());
}
protected Map getHeaders(HttpServletRequest request) {
Modified: incubator/servicemix/trunk/servicemix-jms/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/maven.xml?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/maven.xml (original)
+++ incubator/servicemix/trunk/servicemix-jms/maven.xml Wed Mar 22 02:58:01 2006
@@ -22,4 +22,27 @@
<!-- default goal is defined in /etc/ -->
+ <postGoal name="java:compile">
+ <attainGoal name="xbean:generate" />
+ </postGoal>
+
+ <goal name="xbean:generate" description="Generates the XBean XSD, documentation and META-INF/services files.">
+ <path id="test.classpath">
+ <pathelement path="${maven.build.dest}" />
+ <pathelement path="${basedir}/target/classes" />
+ <pathelement path="${basedir}/target/test-classes" />
+ <path refid="maven.dependency.classpath" />
+ </path>
+
+ <taskdef name="xsdGenerate" classname="org.apache.xbean.spring.generator.MappingGeneratorTask">
+ <classpath refid="test.classpath" />
+ </taskdef>
+ <xsdGenerate
+ destFile="${basedir}/target/servicemix-jms-${pom.currentVersion}.xsd" namespace="http://servicemix.apache.org/jms/1.0"
+ classpathref="test.classpath" srcdir="${basedir}/src/main/java" metaInfDir="${basedir}/target/generated/"/>
+ <copy file="${basedir}/target/servicemix-jms-${pom.currentVersion}.xsd" todir="${basedir}/target/generated/"/>
+ <copy file="${basedir}/target/servicemix-jms-${pom.currentVersion}.xsd" todir="${basedir}/../xdocs"/>
+ <copy file="${basedir}/target/servicemix-jms-${pom.currentVersion}.xsd.html" todir="${basedir}/../xdocs"/>
+ </goal>
+
</project>
Modified: incubator/servicemix/trunk/servicemix-jms/project.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/project.xml?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/project.xml (original)
+++ incubator/servicemix/trunk/servicemix-jms/project.xml Wed Mar 22 02:58:01 2006
@@ -60,6 +60,15 @@
</properties>
</dependency>
<dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>servicemix-soap</artifactId>
+ <version>${pom.currentVersion}</version>
+ <properties>
+ <eclipse.dependency>true</eclipse.dependency>
+ <jbi.bundle>true</jbi.bundle>
+ </properties>
+ </dependency>
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons_logging_version}</version>
@@ -183,6 +192,22 @@
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>${xbean_version}</version>
+ <properties>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-server</artifactId>
+ <version>${xbean_version}</version>
+ <properties>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-kernel</artifactId>
+ <version>${xbean_version}</version>
+ <properties>
+ </properties>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
@@ -190,5 +215,53 @@
<version>${xml_apis_version}</version>
</dependency>
+ <dependency>
+ <groupId>annogen</groupId>
+ <artifactId>annogen</artifactId>
+ <version>${annogen_version}</version>
+ <properties>
+ <scope>compile</scope>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>qdox</groupId>
+ <artifactId>qdox</artifactId>
+ <version>${qdox_version}</version>
+ <properties>
+ <scope>compile</scope>
+ </properties>
+ </dependency>
</dependencies>
+
+ <build>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.*</include>
+ </includes>
+ <excludes>
+ </excludes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>target/generated</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
</project>
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java Wed Mar 22 02:58:01 2006
@@ -15,15 +15,14 @@
*/
package org.apache.servicemix.jms;
-import org.apache.servicemix.common.ExchangeProcessor;
-import org.apache.servicemix.jms.wsdl.JmsAddress;
+import java.util.Hashtable;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
-import java.util.Hashtable;
+import org.apache.servicemix.common.ExchangeProcessor;
public abstract class AbstractJmsProcessor implements ExchangeProcessor {
@@ -38,15 +37,14 @@
}
public void start() throws Exception {
- JmsAddress address = endpoint.getAddress();
Hashtable props = new Hashtable();
- if (address.getInitialContextFactory() != null && address.getJndiProviderURL() != null) {
- props.put(Context.INITIAL_CONTEXT_FACTORY, address.getInitialContextFactory());
- props.put(Context.PROVIDER_URL, address.getJndiProviderURL());
+ if (endpoint.getInitialContextFactory() != null && endpoint.getJndiProviderURL() != null) {
+ props.put(Context.INITIAL_CONTEXT_FACTORY, endpoint.getInitialContextFactory());
+ props.put(Context.PROVIDER_URL, endpoint.getJndiProviderURL());
}
InitialContext ctx = new InitialContext(props);
try {
- ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup(address.getJndiConnectionFactoryName());
+ ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup(endpoint.getJndiConnectionFactoryName());
connection = connectionFactory.createConnection();
connection.start();
doStart(ctx);
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java Wed Mar 22 02:58:01 2006
@@ -15,10 +15,16 @@
*/
package org.apache.servicemix.jms;
+import javax.jbi.servicedesc.ServiceEndpoint;
+
import org.apache.servicemix.common.BaseComponent;
import org.apache.servicemix.common.BaseLifeCycle;
import org.apache.servicemix.common.BaseServiceUnitManager;
import org.apache.servicemix.common.Deployer;
+import org.apache.servicemix.jbi.util.DOMUtil;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
public class JmsComponent extends BaseComponent {
@@ -33,8 +39,26 @@
* @see org.apache.servicemix.common.BaseComponent#createServiceUnitManager()
*/
public BaseServiceUnitManager createServiceUnitManager() {
- Deployer[] deployers = new Deployer[] { new JmsWsdl1Deployer(this) };
+ Deployer[] deployers = new Deployer[] { new JmsXBeanDeployer(this), new JmsWsdl1Deployer(this) };
return new BaseServiceUnitManager(this, deployers);
}
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Component#resolveEndpointReference(org.w3c.dom.DocumentFragment)
+ */
+ public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
+ if (epr.getChildNodes().getLength() == 1) {
+ Node child = epr.getFirstChild();
+ if (child instanceof Element) {
+ Element elem = (Element) child;
+ String nsUri = elem.getNamespaceURI();
+ String name = elem.getLocalName();
+ if (JmsResolvedEndpoint.EPR_URI.equals(nsUri) && JmsResolvedEndpoint.EPR_NAME.equals(name)) {
+ return new JmsResolvedEndpoint(epr, DOMUtil.getElementText(elem));
+ }
+ }
+ }
+ return null;
+ }
+
}
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java Wed Mar 22 02:58:01 2006
@@ -15,43 +15,63 @@
*/
package org.apache.servicemix.jms;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.MessageExchange.Role;
import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.servicemix.common.Endpoint;
import org.apache.servicemix.common.ExchangeProcessor;
-import org.apache.servicemix.jms.wsdl.JmsAddress;
+import org.apache.servicemix.common.wsdl1.JbiExtension;
+import org.apache.servicemix.common.xbean.XBeanServiceUnit;
import org.apache.servicemix.jms.wsdl.JmsBinding;
+import org.apache.servicemix.soap.SoapEndpoint;
+import org.springframework.core.io.Resource;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
-public class JmsEndpoint extends Endpoint {
+/**
+ *
+ * @author gnodet
+ * @version $Revision$
+ * @org.apache.xbean.XBean element="endpoint"
+ * description="A jms endpoint"
+ *
+ */
+public class JmsEndpoint extends SoapEndpoint {
- protected JmsAddress address;
+ protected QName targetServiceName;
+ protected String targetEndpointName;
protected JmsBinding binding;
- protected boolean soap;
protected ExchangeProcessor processor;
protected ServiceEndpoint activated;
protected Role role;
protected URI defaultMep;
+ protected boolean soap;
+ protected String soapVersion;
+ protected Resource wsdlResource;
+ protected QName defaultOperation;
+ // Jms informations
+ protected String initialContextFactory;
+ protected String jndiProviderURL;
+ protected String destinationStyle;
+ protected String jndiConnectionFactoryName;
+ protected String jndiDestinationName;
+ protected String jmsProviderDestinationName;
public JmsEndpoint() {
}
/**
- * @return Returns the address.
- */
- public JmsAddress getAddress() {
- return address;
- }
- /**
- * @param address The address to set.
- */
- public void setAddress(JmsAddress address) {
- this.address = address;
- }
- /**
* @return Returns the binding.
*/
public JmsBinding getBinding() {
@@ -79,7 +99,7 @@
public String toString() {
return "JMSEndpoint[service: " + service + ", " +
"endpoint: " + endpoint + ", " +
- "address: " + address.getJndiDestinationName() + "(" + address.getDestinationStyle() + "), " +
+ "address: " + jndiDestinationName + "(" + destinationStyle + "), " +
"soap: " + soap + "]";
}
@@ -91,11 +111,14 @@
* @see org.apache.servicemix.common.Endpoint#activate()
*/
public void activate() throws Exception {
+ ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
+ loadWsdl();
if (getRole() == Role.PROVIDER) {
- ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
activated = ctx.activateEndpoint(service, endpoint);
processor = new MultiplexingProviderProcessor(this);
} else {
+ activated = new JmsExternalEndpoint(this);
+ ctx.registerExternalEndpoint(activated);
processor = new MultiplexingConsumerProcessor(this);
}
processor.start();
@@ -105,11 +128,15 @@
* @see org.apache.servicemix.common.Endpoint#deactivate()
*/
public void deactivate() throws Exception {
+ ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
if (getRole() == Role.PROVIDER) {
ServiceEndpoint ep = activated;
activated = null;
- ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
ctx.deactivateEndpoint(ep);
+ } else {
+ ServiceEndpoint ep = activated;
+ activated = null;
+ ctx.deregisterExternalEndpoint(ep);
}
processor.stop();
}
@@ -122,12 +149,282 @@
this.role = role;
}
+ /**
+ * @org.apache.xbean.Property alias="role"
+ * @param role
+ */
+ public void setRoleAsString(String role) {
+ if (role == null) {
+ throw new IllegalArgumentException("Role must be specified");
+ } else if (JbiExtension.ROLE_CONSUMER.equals(role)) {
+ setRole(Role.CONSUMER);
+ } else if (JbiExtension.ROLE_PROVIDER.equals(role)) {
+ setRole(Role.PROVIDER);
+ } else {
+ throw new IllegalArgumentException("Unrecognized role: " + role);
+ }
+ }
+
public void setDefaultMep(URI defaultMep) {
this.defaultMep = defaultMep;
}
public URI getDefaultMep() {
return defaultMep;
+ }
+
+ /**
+ * @return Returns the defaultOperation.
+ */
+ public QName getDefaultOperation() {
+ return defaultOperation;
+ }
+
+ /**
+ * @param defaultOperation The defaultOperation to set.
+ */
+ public void setDefaultOperation(QName defaultOperation) {
+ this.defaultOperation = defaultOperation;
+ }
+
+ /**
+ * @return Returns the soapVersion.
+ */
+ public String getSoapVersion() {
+ return soapVersion;
+ }
+
+ /**
+ * @param soapVersion The soapVersion to set.
+ */
+ public void setSoapVersion(String soapVersion) {
+ this.soapVersion = soapVersion;
+ }
+
+ /**
+ * Load the wsdl for this endpoint.
+ */
+ protected void loadWsdl() {
+ // Load WSDL from the resource
+ if (description == null && wsdlResource != null) {
+ InputStream is = null;
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ if (serviceUnit instanceof XBeanServiceUnit) {
+ XBeanServiceUnit su = (XBeanServiceUnit) serviceUnit;
+ Thread.currentThread().setContextClassLoader(su.getKernel().getClassLoaderFor(su.getConfiguration()));
+ }
+ is = wsdlResource.getInputStream();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ Definition def = WSDLFactory.newInstance().newWSDLReader().readWSDL(null, new InputSource(is));
+ overrideDefinition(def);
+ } catch (Exception e) {
+ logger.warn("Could not load description from resource", e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ }
+ // If the endpoint is a consumer, try to find
+ // the proxied endpoint description
+ if (description == null && definition == null && getRole() == Role.CONSUMER) {
+ retrieveProxiedEndpointDefinition();
+ }
+ // If the wsdl definition is provided,
+ // convert it to a DOM document
+ if (description == null && definition != null) {
+ try {
+ description = WSDLFactory.newInstance().newWSDLWriter().getDocument(definition);
+ } catch (Exception e) {
+ logger.warn("Could not create document from wsdl description", e);
+ }
+ }
+ }
+
+ /**
+ * Create a wsdl definition for a consumer endpoint.
+ * Loads the target endpoint definition and add http binding
+ * informations to it.
+ */
+ protected void retrieveProxiedEndpointDefinition() {
+ try {
+ if (service != null && endpoint != null) {
+ ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
+ ServiceEndpoint se = ctx.getEndpoint(service, endpoint);
+ if (se != null) {
+ Document doc = ctx.getEndpointDescriptor(se);
+ if (doc != null) {
+ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+ Definition def = reader.readWSDL(null, doc);
+ if (def != null) {
+ overrideDefinition(def);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ logger.debug("Unable to retrieve target endpoint descriptor", e);
+ }
+ }
+
+ protected void overrideDefinition(Definition def) {
+ Service svc = def.getService(service);
+ if (svc != null) {
+ Port port = svc.getPort(endpoint);
+ if (port != null) {
+ port.getExtensibilityElements().clear();
+ /*
+ if (isSoap()) {
+ SOAPAddress address = new SOAPAddressImpl();
+ address.setLocationURI(getLocationURI());
+ port.addExtensibilityElement(address);
+ def.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+ } else {
+ HTTPAddress address = new HTTPAddressImpl();
+ address.setLocationURI(getLocationURI());
+ port.addExtensibilityElement(address);
+ def.addNamespace("http", "http://schemas.xmlsoap.org/wsdl/http/");
+ }
+ */
+ // TODO: add binding information
+ svc.getPorts().clear();
+ svc.addPort(port);
+ definition = def;
+ }
+ }
+ }
+
+ /**
+ * @return Returns the wsdlResource.
+ */
+ public Resource getWsdlResource() {
+ return wsdlResource;
+ }
+
+ /**
+ * @param wsdlResource The wsdlResource to set.
+ */
+ public void setWsdlResource(Resource wsdlResource) {
+ this.wsdlResource = wsdlResource;
+ }
+
+ /**
+ * @return Returns the initialContextFactory.
+ */
+ public String getInitialContextFactory() {
+ return initialContextFactory;
+ }
+
+ /**
+ * @param initialContextFactory The initialContextFactory to set.
+ */
+ public void setInitialContextFactory(String initialContextFactory) {
+ this.initialContextFactory = initialContextFactory;
+ }
+
+ /**
+ * @return Returns the jmsProviderDestinationName.
+ */
+ public String getJmsProviderDestinationName() {
+ return jmsProviderDestinationName;
+ }
+
+ /**
+ * @param jmsProviderDestinationName The jmsProviderDestinationName to set.
+ */
+ public void setJmsProviderDestinationName(String jmsProviderDestinationName) {
+ this.jmsProviderDestinationName = jmsProviderDestinationName;
+ }
+
+ /**
+ * @return Returns the jndiConnectionFactoryName.
+ */
+ public String getJndiConnectionFactoryName() {
+ return jndiConnectionFactoryName;
+ }
+
+ /**
+ * @param jndiConnectionFactoryName The jndiConnectionFactoryName to set.
+ */
+ public void setJndiConnectionFactoryName(String jndiConnectionFactoryName) {
+ this.jndiConnectionFactoryName = jndiConnectionFactoryName;
+ }
+
+ /**
+ * @return Returns the jndiDestinationName.
+ */
+ public String getJndiDestinationName() {
+ return jndiDestinationName;
+ }
+
+ /**
+ * @param jndiDestinationName The jndiDestinationName to set.
+ */
+ public void setJndiDestinationName(String jndiDestinationName) {
+ this.jndiDestinationName = jndiDestinationName;
+ }
+
+ /**
+ * @return Returns the jndiProviderURL.
+ */
+ public String getJndiProviderURL() {
+ return jndiProviderURL;
+ }
+
+ /**
+ * @param jndiProviderURL The jndiProviderURL to set.
+ */
+ public void setJndiProviderURL(String jndiProviderURL) {
+ this.jndiProviderURL = jndiProviderURL;
+ }
+
+ /**
+ * @return Returns the destinationStyle.
+ */
+ public String getDestinationStyle() {
+ return destinationStyle;
+ }
+
+ /**
+ * @param destinationStyle The destinationStyle to set.
+ */
+ public void setDestinationStyle(String destinationStyle) {
+ this.destinationStyle = destinationStyle;
+ }
+
+ /**
+ * @return Returns the localEndpointName.
+ */
+ public String getTargetEndpointName() {
+ return targetEndpointName;
+ }
+
+ /**
+ * @param localEndpointName The localEndpointName to set.
+ */
+ public void setTargetEndpointName(String localEndpointName) {
+ this.targetEndpointName = localEndpointName;
+ }
+
+ /**
+ * @return Returns the localServiceName.
+ */
+ public QName getTargetServiceName() {
+ return targetServiceName;
+ }
+
+ /**
+ * @param localServiceName The localServiceName to set.
+ */
+ public void setTargetServiceName(QName localServiceName) {
+ this.targetServiceName = localServiceName;
}
}
Added: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsExternalEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsExternalEndpoint.java?rev=387827&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsExternalEndpoint.java (added)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsExternalEndpoint.java Wed Mar 22 02:58:01 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jms;
+
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+public class JmsExternalEndpoint implements ServiceEndpoint {
+
+ private JmsEndpoint endpoint;
+
+ public JmsExternalEndpoint(JmsEndpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public DocumentFragment getAsReference(QName operationName) {
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ DocumentFragment df = doc.createDocumentFragment();
+ Element e = doc.createElementNS(JmsResolvedEndpoint.EPR_URI, JmsResolvedEndpoint.EPR_NAME);
+ Text t = doc.createTextNode(endpoint.getService() + "#" + endpoint.getEndpoint());
+ e.appendChild(t);
+ df.appendChild(e);
+ return df;
+ } catch (Exception e) {
+ throw new RuntimeException("Could not create reference", e);
+ }
+ }
+
+ public String getEndpointName() {
+ return endpoint.getEndpoint();
+ }
+
+ public QName[] getInterfaces() {
+ if (endpoint.getInterfaceName() != null) {
+ return new QName[] { endpoint.getInterfaceName() };
+ }
+ return null;
+ }
+
+ public QName getServiceName() {
+ return endpoint.getService();
+ }
+
+}
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java Wed Mar 22 02:58:01 2006
@@ -15,13 +15,14 @@
*/
package org.apache.servicemix.jms;
+import org.apache.servicemix.common.BaseComponent;
import org.apache.servicemix.common.BaseLifeCycle;
public class JmsLifeCycle extends BaseLifeCycle {
protected JmsConfiguration configuration;
- public JmsLifeCycle(JmsComponent component) {
+ public JmsLifeCycle(BaseComponent component) {
super(component);
configuration = new JmsConfiguration();
}
Added: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java?rev=387827&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java (added)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java Wed Mar 22 02:58:01 2006
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jms;
+
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.DocumentFragment;
+
+public class JmsResolvedEndpoint implements ServiceEndpoint {
+
+ public final static String EPR_URI = "urn:servicemix:jms";
+ public final static String EPR_NAME = "epr";
+
+ private DocumentFragment reference;
+ private String epName;
+
+ public JmsResolvedEndpoint(DocumentFragment epr, String epName) {
+ this.reference = epr;
+ }
+
+ public DocumentFragment getAsReference(QName operationName) {
+ return reference;
+ }
+
+ public String getEndpointName() {
+ return epName;
+ }
+
+ public QName[] getInterfaces() {
+ return null;
+ }
+
+ public QName getServiceName() {
+ return new QName("urn:servicemix:jms", "JmsComponent");
+ }
+
+}
\ No newline at end of file
Added: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java?rev=387827&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java (added)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java Wed Mar 22 02:58:01 2006
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jms;
+
+import javax.jbi.servicedesc.ServiceEndpoint;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.jbi.util.DOMUtil;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author gnodet
+ * @version $Revision: 376451 $
+ * @org.apache.xbean.XBean element="component"
+ * description="A jms component"
+ */
+public class JmsSpringComponent extends BaseComponent {
+
+ private JmsEndpoint[] endpoints;
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseComponent#createLifeCycle()
+ */
+ protected BaseLifeCycle createLifeCycle() {
+ return new LifeCycle();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Component#resolveEndpointReference(org.w3c.dom.DocumentFragment)
+ */
+ public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
+ if (epr.getChildNodes().getLength() == 1) {
+ Node child = epr.getFirstChild();
+ if (child instanceof Element) {
+ Element elem = (Element) child;
+ String nsUri = elem.getNamespaceURI();
+ String name = elem.getLocalName();
+ if (JmsResolvedEndpoint.EPR_URI.equals(nsUri) && JmsResolvedEndpoint.EPR_NAME.equals(name)) {
+ return new JmsResolvedEndpoint(epr, DOMUtil.getElementText(elem));
+ }
+ }
+ }
+ return null;
+ }
+
+ public JmsEndpoint[] getEndpoints() {
+ return endpoints;
+ }
+
+ public void setEndpoints(JmsEndpoint[] endpoints) {
+ this.endpoints = endpoints;
+ }
+
+ public class LifeCycle extends JmsLifeCycle {
+
+ protected ServiceUnit su;
+
+ public LifeCycle() {
+ super(JmsSpringComponent.this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseLifeCycle#doInit()
+ */
+ protected void doInit() throws Exception {
+ super.doInit();
+ su = new ServiceUnit();
+ su.setComponent(JmsSpringComponent.this);
+ for (int i = 0; i < endpoints.length; i++) {
+ endpoints[i].setServiceUnit(su);
+ su.addEndpoint(endpoints[i]);
+ }
+ getRegistry().registerServiceUnit(su);
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseLifeCycle#doStart()
+ */
+ protected void doStart() throws Exception {
+ super.doStart();
+ su.start();
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseLifeCycle#doStop()
+ */
+ protected void doStop() throws Exception {
+ su.stop();
+ super.doStop();
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseLifeCycle#doShutDown()
+ */
+ protected void doShutDown() throws Exception {
+ su.shutDown();
+ super.doShutDown();
+ }
+ }
+
+}
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java Wed Mar 22 02:58:01 2006
@@ -45,7 +45,13 @@
JmsEndpoint endpoint = new JmsEndpoint();
endpoint.setRole(jbiEndpoint.getRole());
endpoint.setDefaultMep(jbiEndpoint.getDefaultMep());
- endpoint.setAddress((JmsAddress) portElement);
+ endpoint.setDefaultOperation(jbiEndpoint.getDefaultOperation());
+ endpoint.setDestinationStyle(((JmsAddress) portElement).getDestinationStyle());
+ endpoint.setInitialContextFactory(((JmsAddress) portElement).getInitialContextFactory());
+ endpoint.setJmsProviderDestinationName(((JmsAddress) portElement).getJmsProviderDestinationName());
+ endpoint.setJndiConnectionFactoryName(((JmsAddress) portElement).getJndiConnectionFactoryName());
+ endpoint.setJndiDestinationName(((JmsAddress) portElement).getJndiDestinationName());
+ endpoint.setJndiProviderURL(((JmsAddress) portElement).getJndiProviderURL());
endpoint.setBinding((JmsBinding) bindingElement);
return endpoint;
}
Added: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java?rev=387827&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java (added)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java Wed Mar 22 02:58:01 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jms;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.xbean.AbstractXBeanDeployer;
+
+import javax.jbi.management.DeploymentException;
+
+public class JmsXBeanDeployer extends AbstractXBeanDeployer {
+
+ public JmsXBeanDeployer(BaseComponent component) {
+ super(component);
+ }
+
+ protected boolean validate(Endpoint endpoint) throws DeploymentException {
+ if (endpoint instanceof JmsEndpoint == false) {
+ throw failure("deploy", "Endpoint should be a Jms endpoint", null);
+ }
+ JmsEndpoint ep = (JmsEndpoint) endpoint;
+ if (ep.getRole() == null) {
+ throw failure("deploy", "Endpoint must have a defined role", null);
+ }
+ return true;
+ }
+
+
+}
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java Wed Mar 22 02:58:01 2006
@@ -15,17 +15,16 @@
*/
package org.apache.servicemix.jms;
-import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.servicemix.common.BaseLifeCycle;
-import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.apache.servicemix.jms.wsdl.JmsAddress;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.Map;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.NormalizedMessage;
+import javax.jms.BytesMessage;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageConsumer;
@@ -37,31 +36,48 @@
import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkException;
-import java.util.Map;
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.soap.SoapFault;
+import org.apache.servicemix.soap.SoapHelper;
+import org.apache.servicemix.soap.handlers.AddressingInHandler;
+import org.apache.servicemix.soap.marshalers.JBIMarshaler;
+import org.apache.servicemix.soap.marshalers.SoapMarshaler;
+import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.apache.servicemix.soap.marshalers.SoapWriter;
+
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
public class MultiplexingConsumerProcessor extends AbstractJmsProcessor implements MessageListener {
protected Session session;
protected Destination destination;
protected MessageConsumer consumer;
- protected JmsMarshaler marshaler = new JmsMarshaler();
protected Map pendingMessages = new ConcurrentHashMap();
protected DeliveryChannel channel;
+ protected SoapHelper soapHelper;
+ protected SoapMarshaler soapMarshaler;
+ protected JBIMarshaler jbiMarshaler;
public MultiplexingConsumerProcessor(JmsEndpoint endpoint) {
super(endpoint);
+ this.soapMarshaler = new SoapMarshaler(endpoint.isSoap());
+ if (endpoint.isSoap() && "1.1".equals(endpoint.getSoapVersion())) {
+ this.soapMarshaler.setSoapUri(SoapMarshaler.SOAP_11_URI);
+ }
+ this.soapHelper = new SoapHelper(endpoint);
+ this.soapHelper.addPolicy(new AddressingInHandler());
+ this.jbiMarshaler = new JBIMarshaler();
}
protected void doStart(InitialContext ctx) throws Exception {
- JmsAddress address = endpoint.getAddress();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- if (address.getJndiDestinationName() != null) {
- destination = (Destination) ctx.lookup(address.getJndiDestinationName());
- } else if (address.getJmsProviderDestinationName() != null) {
- if (STYLE_QUEUE.equals(address.getDestinationStyle())) {
- destination = session.createQueue(address.getJmsProviderDestinationName());
+ if (endpoint.getJndiDestinationName() != null) {
+ destination = (Destination) ctx.lookup(endpoint.getJndiDestinationName());
+ } else if (endpoint.getJmsProviderDestinationName() != null) {
+ if (STYLE_QUEUE.equals(endpoint.getDestinationStyle())) {
+ destination = session.createQueue(endpoint.getJmsProviderDestinationName());
} else {
- destination = session.createTopic(address.getJmsProviderDestinationName());
+ destination = session.createTopic(endpoint.getJmsProviderDestinationName());
}
} else {
throw new IllegalStateException("No destination provided");
@@ -86,12 +102,22 @@
}
public void run() {
try {
- MessageExchange exchange = channel.createExchangeFactory().createExchange(endpoint.getDefaultMep());
- exchange.setService(endpoint.getService());
- exchange.setInterfaceName(endpoint.getInterfaceName());
- NormalizedMessage msg = exchange.createMessage();
- msg.setContent(new StringSource(((TextMessage) message).getText()));
- exchange.setMessage(msg, "in");
+ InputStream is = null;
+ if (message instanceof TextMessage) {
+ is = new ByteArrayInputStream(((TextMessage) message).getText().getBytes());
+ } else if (message instanceof BytesMessage) {
+ int length = (int) ((BytesMessage) message).getBodyLength();
+ byte[] bytes = new byte[length];
+ ((BytesMessage) message).readBytes(bytes);
+ is = new ByteArrayInputStream(bytes);
+ } else {
+ throw new IllegalArgumentException("JMS message should be a text or bytes message");
+ }
+ String contentType = message.getStringProperty("Content-Type");
+ SoapMessage soap = soapMarshaler.createReader().read(is, contentType);
+ MessageExchange exchange = soapHelper.createExchange(soap);
+ // TODO: copy protocol messages
+ //inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(message));
pendingMessages.put(exchange.getExchangeId(), message);
BaseLifeCycle lf = (BaseLifeCycle) endpoint.getServiceUnit().getComponent().getLifeCycle();
lf.sendConsumerExchange(exchange, MultiplexingConsumerProcessor.this);
@@ -111,17 +137,57 @@
public void process(MessageExchange exchange) throws Exception {
Message message = (Message) pendingMessages.remove(exchange.getExchangeId());
MessageProducer producer = null;
+ Message response = null;
try {
- producer = session.createProducer(message.getJMSReplyTo());
- Message response = marshaler.createMessage(((InOut) exchange).getOutMessage(), session);
- response.setJMSCorrelationID(message.getJMSCorrelationID());
- producer.send(response);
+ if (exchange.getStatus() == ExchangeStatus.ERROR) {
+ Exception e = exchange.getError();
+ if (e == null) {
+ e = new Exception("Unkown error");
+ }
+ response = session.createObjectMessage(e);
+ } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+ if (exchange.getFault() != null) {
+ SoapFault fault = new SoapFault(SoapFault.RECEIVER, null, null, null, exchange.getFault().getContent());
+ SoapMessage soapFault = new SoapMessage();
+ soapFault.setFault(fault);
+ // TODO: retrieve input soap message
+ SoapMessage in = null;
+ if (in != null) {
+ soapFault.setEnvelopeName(in.getEnvelopeName());
+ }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SoapWriter writer = soapMarshaler.createWriter(soapFault);
+ writer.write(baos);
+ response = session.createTextMessage(baos.toString());
+ response.setStringProperty("Content-Type", writer.getContentType());
+ // TODO: Copy other properties from fault
+ } else {
+ NormalizedMessage outMsg = exchange.getMessage("out");
+ if (outMsg != null) {
+ SoapMessage out = new SoapMessage();
+ jbiMarshaler.fromNMS(out, outMsg);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SoapWriter writer = soapMarshaler.createWriter(out);
+ writer.write(baos);
+ response = session.createTextMessage(baos.toString());
+ response.setStringProperty("Content-Type", writer.getContentType());
+ // TODO: Copy other properties from response
+ }
+ }
+ }
+ if (response != null) {
+ producer = session.createProducer(message.getJMSReplyTo());
+ response.setJMSCorrelationID(message.getJMSCorrelationID());
+ producer.send(response);
+ }
} finally {
if (producer != null) {
producer.close();
}
- exchange.setStatus(ExchangeStatus.DONE);
- channel.send(exchange);
+ if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+ exchange.setStatus(ExchangeStatus.DONE);
+ channel.send(exchange);
+ }
}
}
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java Wed Mar 22 02:58:01 2006
@@ -15,6 +15,10 @@
*/
package org.apache.servicemix.jms;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.Iterator;
import java.util.Map;
import javax.jbi.messaging.DeliveryChannel;
@@ -24,18 +28,25 @@
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.NormalizedMessage;
import javax.jbi.messaging.RobustInOnly;
+import javax.jms.BytesMessage;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
import javax.jms.Queue;
import javax.jms.Session;
+import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkException;
-import org.apache.servicemix.jms.wsdl.JmsAddress;
+import org.apache.servicemix.JbiConstants;
+import org.apache.servicemix.soap.marshalers.JBIMarshaler;
+import org.apache.servicemix.soap.marshalers.SoapMarshaler;
+import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.apache.servicemix.soap.marshalers.SoapWriter;
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
@@ -46,25 +57,27 @@
protected Destination replyToDestination;
protected MessageConsumer consumer;
protected MessageProducer producer;
- protected JmsMarshaler marshaler = new JmsMarshaler();
protected Map pendingExchanges = new ConcurrentHashMap();
protected DeliveryChannel channel;
+ protected SoapMarshaler soapMarshaler;
+ protected JBIMarshaler jbiMarshaler;
public MultiplexingProviderProcessor(JmsEndpoint endpoint) {
super(endpoint);
+ this.soapMarshaler = new SoapMarshaler(endpoint.isSoap());
+ this.jbiMarshaler = new JBIMarshaler();
}
protected void doStart(InitialContext ctx) throws Exception {
channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel();
- JmsAddress address = endpoint.getAddress();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- if (address.getJndiDestinationName() != null) {
- destination = (Destination) ctx.lookup(address.getJndiDestinationName());
- } else if (address.getJmsProviderDestinationName() != null) {
- if (STYLE_QUEUE.equals(address.getDestinationStyle())) {
- destination = session.createQueue(address.getJmsProviderDestinationName());
+ if (endpoint.getJndiDestinationName() != null) {
+ destination = (Destination) ctx.lookup(endpoint.getJndiDestinationName());
+ } else if (endpoint.getJmsProviderDestinationName() != null) {
+ if (STYLE_QUEUE.equals(endpoint.getDestinationStyle())) {
+ destination = session.createQueue(endpoint.getJmsProviderDestinationName());
} else {
- destination = session.createTopic(address.getJmsProviderDestinationName());
+ destination = session.createTopic(endpoint.getJmsProviderDestinationName());
}
} else {
throw new IllegalStateException("No destination provided");
@@ -99,9 +112,31 @@
if (exchange == null) {
throw new IllegalStateException("Could not find exchange " + message.getJMSCorrelationID());
}
- NormalizedMessage out = exchange.createMessage();
- marshaler.toNMS(out, message);
- exchange.setOutMessage(out);
+ if (message instanceof ObjectMessage) {
+ Object o = ((ObjectMessage) message).getObject();
+ if (o instanceof Exception) {
+ exchange.setError((Exception) o);
+ } else {
+ throw new UnsupportedOperationException("Can not handle objects of type " + o.getClass().getName());
+ }
+ } else {
+ InputStream is = null;
+ if (message instanceof TextMessage) {
+ is = new ByteArrayInputStream(((TextMessage) message).getText().getBytes());
+ } else if (message instanceof BytesMessage) {
+ int length = (int) ((BytesMessage) message).getBodyLength();
+ byte[] bytes = new byte[length];
+ ((BytesMessage) message).readBytes(bytes);
+ is = new ByteArrayInputStream(bytes);
+ } else {
+ throw new IllegalArgumentException("JMS message should be a text or bytes message");
+ }
+ String contentType = message.getStringProperty("Content-Type");
+ SoapMessage soap = soapMarshaler.createReader().read(is, contentType);
+ NormalizedMessage out = exchange.createMessage();
+ jbiMarshaler.toNMS(out, soap);
+ ((InOut) exchange).setOutMessage(out);
+ }
channel.send(exchange);
} catch (Exception e) {
// TODO: log exception
@@ -119,20 +154,30 @@
if (exchange.getStatus() == ExchangeStatus.DONE) {
return;
} else if (exchange.getStatus() == ExchangeStatus.ERROR) {
- exchange.setStatus(ExchangeStatus.DONE);
- channel.send(exchange);
return;
}
- if (endpoint.isSoap()) {
- throw new IllegalStateException("soap not implemented");
+ SoapMessage soapMessage = new SoapMessage();
+ NormalizedMessage nm = exchange.getMessage("in");
+ jbiMarshaler.fromNMS(soapMessage, nm);
+ SoapWriter writer = soapMarshaler.createWriter(soapMessage);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writer.write(baos);
+ Message msg = session.createTextMessage(baos.toString());
+ msg.setStringProperty("Content-Type", writer.getContentType());
+ Map headers = (Map) nm.getProperty(JbiConstants.PROTOCOL_HEADERS);
+ if (headers != null) {
+ for (Iterator it = headers.keySet().iterator(); it.hasNext();) {
+ String name = (String) it.next();
+ String value = (String) headers.get(name);
+ msg.setStringProperty(name, value);
+ }
}
+
if (exchange instanceof InOnly || exchange instanceof RobustInOnly) {
- Message msg = marshaler.createMessage(((InOnly) exchange).getInMessage(), session);
synchronized (producer) {
producer.send(msg);
}
} else if (exchange instanceof InOut) {
- Message msg = marshaler.createMessage(((InOut) exchange).getInMessage(), session);
msg.setJMSCorrelationID(exchange.getExchangeId());
msg.setJMSReplyTo(replyToDestination);
pendingExchanges.put(exchange.getExchangeId(), exchange);
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/wsdl/JmsAddress.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/wsdl/JmsAddress.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/wsdl/JmsAddress.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/wsdl/JmsAddress.java Wed Mar 22 02:58:01 2006
@@ -20,6 +20,14 @@
import java.io.Serializable;
+/**
+ *
+ * @author gnodet
+ * @version $Revision$
+ * @org.apache.xbean.XBean element="address"
+ * description="A jms address"
+ *
+ */
public class JmsAddress implements ExtensibilityElement, Serializable {
/**
Modified: incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JMSComponentTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JMSComponentTest.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JMSComponentTest.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JMSComponentTest.java Wed Mar 22 02:58:01 2006
@@ -95,7 +95,7 @@
asJmsReceiver.setDestinationService(new QName("test", "receiver"));
container.activateComponent(asJmsReceiver);
- // Add a trace component
+ // Add a receiver component
Receiver receiver = new ReceiverComponent();
ActivationSpec asReceiver = new ActivationSpec("receiver", receiver);
asReceiver.setService(new QName("test", "receiver"));
Added: incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java?rev=387827&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java (added)
+++ incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java Wed Mar 22 02:58:01 2006
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jms;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.naming.Context;
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.xml.namespace.QName;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.jndi.ActiveMQInitialContextFactory;
+import org.apache.activemq.xbean.BrokerFactoryBean;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.components.util.EchoComponent;
+import org.apache.servicemix.jms.JmsComponent;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.springframework.core.io.ClassPathResource;
+import org.w3c.dom.Document;
+
+import junit.framework.TestCase;
+
+public class JmsXBeanDeployerTest extends TestCase {
+
+ private static Log logger = LogFactory.getLog(JmsXBeanDeployerTest.class);
+
+ protected JBIContainer container;
+ protected BrokerService broker;
+ protected ActiveMQConnectionFactory connectionFactory;
+
+ protected void setUp() throws Exception {
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getName());
+ System.setProperty(Context.PROVIDER_URL, "tcp://localhost:61216");
+
+
+ BrokerFactoryBean bfb = new BrokerFactoryBean(new ClassPathResource("org/apache/servicemix/jms/activemq.xml"));
+ bfb.afterPropertiesSet();
+ broker = bfb.getBroker();
+ broker.start();
+
+ container = new JBIContainer();
+ container.setUseMBeanServer(false);
+ container.setCreateMBeanServer(false);
+ container.setEmbedded(true);
+ container.init();
+
+ connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61216");
+ }
+
+ protected void tearDown() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ if (broker != null) {
+ broker.stop();
+ }
+ }
+
+ public void test() throws Exception {
+ // JMS Component
+ JmsComponent component = new JmsComponent();
+ container.activateComponent(component, "JMSComponent");
+
+ // Add a receiver component
+ ActivationSpec asEcho = new ActivationSpec("echo", new EchoComponent() {
+ public Document getServiceDescription(ServiceEndpoint endpoint) {
+ try {
+ Definition def = WSDLFactory.newInstance().newDefinition();
+ PortType type = def.createPortType();
+ type.setUndefined(false);
+ type.setQName(new QName("http://test", "MyConsumerInterface"));
+ Binding binding = def.createBinding();
+ binding.setUndefined(false);
+ binding.setPortType(type);
+ Service svc = def.createService();
+ svc.setQName(new QName("http://test", "MyConsumerService"));
+ Port port = def.createPort();
+ port.setBinding(binding);
+ port.setName("myConsumer");
+ svc.addPort(port);
+ def.setTargetNamespace("http://test");
+ def.addNamespace("tns", "http://test");
+ def.addPortType(type);
+ def.addBinding(binding);
+ def.addService(svc);
+ Document doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
+ return doc;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ asEcho.setEndpoint("myConsumer");
+ asEcho.setService(new QName("http://test", "MyConsumerService"));
+ container.activateComponent(asEcho);
+
+ // Start container
+ container.start();
+
+ // Deploy SU
+ URL url = getClass().getClassLoader().getResource("xbean/xbean.xml");
+ File path = new File(new URI(url.toString()));
+ path = path.getParentFile();
+ component.getServiceUnitManager().deploy("xbean", path.getAbsolutePath());
+ component.getServiceUnitManager().start("xbean");
+
+ // Test wsdls
+ assertNotNull(container.getRegistry().getEndpointDescriptor(
+ container.getRegistry().getEndpoint(
+ new QName("http://test", "MyProviderService"), "myProvider")));
+ assertNotNull(container.getRegistry().getEndpointDescriptor(
+ container.getRegistry().getExternalEndpointsForService(
+ new QName("http://test", "MyConsumerService"))[0]));
+
+ // Test
+ DefaultServiceMixClient client = new DefaultServiceMixClient(container);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("http://test", "MyProviderService"));
+ me.getInMessage().setContent(new StringSource("<echo xmlns='http://test'><echoin0>world</echoin0></echo>"));
+ client.sendSync(me);
+ if (me.getStatus() == ExchangeStatus.ERROR) {
+ if (me.getFault() != null) {
+ fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
+ } else if (me.getError() != null) {
+ throw me.getError();
+ } else {
+ fail("Received ERROR status");
+ }
+ } else {
+ logger.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
+ }
+ }
+
+ public void testSoap() throws Exception {
+ // JMS Component
+ JmsComponent component = new JmsComponent();
+ container.activateComponent(component, "JMSComponent");
+
+ // Add a receiver component
+ ActivationSpec asEcho = new ActivationSpec("echo", new EchoComponent() {
+ public Document getServiceDescription(ServiceEndpoint endpoint) {
+ try {
+ Definition def = WSDLFactory.newInstance().newDefinition();
+ PortType type = def.createPortType();
+ type.setUndefined(false);
+ type.setQName(new QName("http://test", "MyConsumerInterface"));
+ Binding binding = def.createBinding();
+ binding.setUndefined(false);
+ binding.setPortType(type);
+ Service svc = def.createService();
+ svc.setQName(new QName("http://test", "MySoapConsumerService"));
+ Port port = def.createPort();
+ port.setBinding(binding);
+ port.setName("myConsumer");
+ svc.addPort(port);
+ def.setTargetNamespace("http://test");
+ def.addNamespace("tns", "http://test");
+ def.addPortType(type);
+ def.addBinding(binding);
+ def.addService(svc);
+ Document doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
+ return doc;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ asEcho.setEndpoint("myConsumer");
+ asEcho.setService(new QName("http://test", "MySoapConsumerService"));
+ container.activateComponent(asEcho);
+
+ // Start container
+ container.start();
+
+ // Deploy SU
+ URL url = getClass().getClassLoader().getResource("xbean/xbean.xml");
+ File path = new File(new URI(url.toString()));
+ path = path.getParentFile();
+ component.getServiceUnitManager().deploy("xbean", path.getAbsolutePath());
+ component.getServiceUnitManager().start("xbean");
+
+ // Test wsdls
+ assertNotNull(container.getRegistry().getEndpointDescriptor(
+ container.getRegistry().getExternalEndpointsForService(
+ new QName("http://test", "MySoapConsumerService"))[0]));
+
+ // Test
+ DefaultServiceMixClient client = new DefaultServiceMixClient(container);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("http://test", "MySoapProviderService"));
+ me.getInMessage().setContent(new StringSource("<echo xmlns='http://test'><echoin0>world</echoin0></echo>"));
+ client.sendSync(me);
+ if (me.getStatus() == ExchangeStatus.ERROR) {
+ if (me.getFault() != null) {
+ fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
+ } else if (me.getError() != null) {
+ throw me.getError();
+ } else {
+ fail("Received ERROR status");
+ }
+ } else {
+ logger.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
+ }
+ }
+
+}
Added: incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/provider.wsdl
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/provider.wsdl?rev=387827&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/provider.wsdl (added)
+++ incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/provider.wsdl Wed Mar 22 02:58:01 2006
@@ -0,0 +1,16 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<definitions name='Provider'
+ targetNamespace='http://test'
+ xmlns:tns='http://test'
+ xmlns='http://schemas.xmlsoap.org/wsdl/'>
+
+ <portType name='Provider'>
+ </portType>
+
+ <binding name='MyProvider' type='tns:Provider'>
+ </binding>
+
+ <service name='MyProviderService'>
+ <port name='myProvider' binding='tns:MyProvider' />
+ </service>
+</definitions>
\ No newline at end of file
Added: incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/xbean.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/xbean.xml?rev=387827&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/xbean.xml (added)
+++ incubator/servicemix/trunk/servicemix-jms/src/test/resources/xbean/xbean.xml Wed Mar 22 02:58:01 2006
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
+ xmlns:test="http://test">
+
+ <!-- Define an additional classpath location
+ for wsdl resources -->
+ <classpath>
+ <location>.</location>
+ </classpath>
+
+ <!-- START SNIPPET: consumer -->
+ <jms:endpoint service="test:MyConsumerService"
+ endpoint="myConsumer"
+ role="consumer"
+ destinationStyle="queue"
+ jmsProviderDestinationName="queue/A"
+ jndiConnectionFactoryName="ConnectionFactory"
+ defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
+ defaultOperation="test:Echo" />
+ <!-- END SNIPPET: consumer -->
+
+ <jms:endpoint service="test:MySoapConsumerService"
+ endpoint="myConsumer"
+ role="consumer"
+ destinationStyle="queue"
+ jmsProviderDestinationName="queue/A/Soap"
+ jndiConnectionFactoryName="ConnectionFactory"
+ soap="true"
+ defaultMep="http://www.w3.org/2004/08/wsdl/in-out" />
+
+ <!-- START SNIPPET: provider -->
+ <jms:endpoint service="test:MyProviderService"
+ endpoint="myProvider"
+ role="provider"
+ destinationStyle="queue"
+ jmsProviderDestinationName="queue/A"
+ jndiConnectionFactoryName="ConnectionFactory"
+ wsdlResource="classpath:provider.wsdl" />
+ <!-- END SNIPPET: provider -->
+
+ <jms:endpoint service="test:MySoapProviderService"
+ endpoint="myProvider"
+ role="provider"
+ destinationStyle="queue"
+ jmsProviderDestinationName="queue/A/Soap"
+ jndiConnectionFactoryName="ConnectionFactory"
+ soap="true"/>
+
+</beans>
Modified: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java (original)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java Wed Mar 22 02:58:01 2006
@@ -17,10 +17,14 @@
import java.net.URI;
+import javax.xml.namespace.QName;
+
import org.apache.servicemix.common.Endpoint;
public abstract class SoapEndpoint extends Endpoint {
public abstract URI getDefaultMep();
+
+ public abstract QName getDefaultOperation();
}
Modified: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java?rev=387827&r1=387826&r2=387827&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java (original)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java Wed Mar 22 02:58:01 2006
@@ -72,7 +72,11 @@
public Context createContext(SoapMessage message) {
Context context = new Context();
context.setProperty(Context.SOAP_MESSAGE, message);
- context.setProperty(Context.OPERATION, message.getBodyName());
+ if (message.getBodyName() == null) {
+ context.setProperty(Context.OPERATION, endpoint.getDefaultOperation());
+ } else {
+ context.setProperty(Context.OPERATION, message.getBodyName());
+ }
context.setProperty(Context.INTERFACE, endpoint.getInterfaceName());
context.setProperty(Context.SERVICE, endpoint.getService());
context.setProperty(Context.ENDPOINT, endpoint.getEndpoint());