You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ch...@apache.org on 2006/07/28 07:49:50 UTC
svn commit: r426392 [31/47] - in /incubator/servicemix/trunk:
apache-servicemix/src/main/assembly/ apache-servicemix/src/main/release/conf/
apache-servicemix/src/main/release/examples/basic/
apache-servicemix/src/main/release/examples/bpel-bpe/ apache-...
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java Thu Jul 27 22:49:32 2006
@@ -1,107 +1,107 @@
-/*
- * 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.w3c.dom.DocumentFragment;
-
-/**
- *
- * @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) {
- return JmsResolvedEndpoint.resolveEndpoint(epr);
- }
-
- 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);
- if (endpoints != null) {
- 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();
- }
- }
-
-}
+/*
+ * 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.w3c.dom.DocumentFragment;
+
+/**
+ *
+ * @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) {
+ return JmsResolvedEndpoint.resolveEndpoint(epr);
+ }
+
+ 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);
+ if (endpoints != null) {
+ 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();
+ }
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java Thu Jul 27 22:49:32 2006
@@ -1,42 +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;
- }
-
-
-}
+/*
+ * 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;
+ }
+
+
+}
Propchange: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardConsumerProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardConsumerProcessor.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardConsumerProcessor.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardConsumerProcessor.java Thu Jul 27 22:49:32 2006
@@ -1,211 +1,211 @@
-/*
- * 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.standard;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-
-import javax.jbi.messaging.DeliveryChannel;
-import javax.jbi.messaging.ExchangeStatus;
-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;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-import javax.resource.spi.work.Work;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jms.AbstractJmsProcessor;
-import org.apache.servicemix.jms.JmsEndpoint;
-import org.apache.servicemix.soap.Context;
-import org.apache.servicemix.soap.SoapFault;
-import org.apache.servicemix.soap.SoapHelper;
-import org.apache.servicemix.soap.marshalers.SoapMessage;
-import org.apache.servicemix.soap.marshalers.SoapWriter;
-
-import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
-
-public class StandardConsumerProcessor extends AbstractJmsProcessor {
-
- private static final Log log = LogFactory.getLog(StandardConsumerProcessor.class);
-
- protected Session session;
- protected Destination destination;
- protected DeliveryChannel channel;
- protected SoapHelper soapHelper;
- protected AtomicBoolean running = new AtomicBoolean(false);
-
- public StandardConsumerProcessor(JmsEndpoint endpoint) {
- super(endpoint);
- this.soapHelper = new SoapHelper(endpoint);
- }
-
- protected void doStart(InitialContext ctx) throws Exception {
- destination = endpoint.getDestination();
- if (destination == null) {
- if (endpoint.getJndiDestinationName() != null) {
- destination = (Destination) ctx.lookup(endpoint.getJndiDestinationName());
- } else if (endpoint.getJmsProviderDestinationName() == null) {
- throw new IllegalStateException("No destination provided");
- }
- }
- channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel();
- synchronized (running) {
- endpoint.getServiceUnit().getComponent().getWorkManager().startWork(new Work() {
- public void release() {
- }
- public void run() {
- StandardConsumerProcessor.this.poll();
- }
- });
- running.wait();
- }
- }
-
-
- protected void doStop() throws Exception {
- if (running.get()) {
- synchronized (running) {
- if (session != null) {
- session.close();
- }
- running.wait();
- }
- }
- session = null;
- destination = null;
- }
-
- protected void poll() {
- synchronized (running) {
- running.set(true);
- running.notify();
- }
- try {
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- if (destination == null) {
- if (STYLE_QUEUE.equals(endpoint.getDestinationStyle())) {
- destination = session.createQueue(endpoint.getJmsProviderDestinationName());
- } else {
- destination = session.createTopic(endpoint.getJmsProviderDestinationName());
- }
- }
- MessageConsumer consumer = session.createConsumer(destination);
- while (running.get()) {
- Message message = consumer.receive();
- if (message != null) {
- onMessage(message);
- }
- }
- } catch (Exception e) {
- log.error("", e);
- } finally {
- synchronized (running) {
- running.set(false);
- running.notify();
- }
- }
- }
-
- public void onMessage(final Message message) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Received jms message " + message);
- }
- 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 = soapHelper.getSoapMarshaler().createReader().read(is, contentType);
- Context context = soapHelper.createContext(soap);
- MessageExchange exchange = soapHelper.onReceive(context);
- context.setProperty(Message.class.getName(), message);
- // TODO: copy protocol messages
- //inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(message));
- if (!channel.sendSync(exchange)) {
- throw new IllegalStateException("Exchange has been aborted");
- }
- MessageProducer producer = null;
- Message response = null;
- try {
- 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 = soapHelper.onFault(context, fault);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- SoapWriter writer = soapHelper.getSoapMarshaler().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 = soapHelper.onReply(context, outMsg);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- SoapWriter writer = soapHelper.getSoapMarshaler().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();
- }
- if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
- exchange.setStatus(ExchangeStatus.DONE);
- channel.send(exchange);
- }
- }
- } catch (Throwable e) {
- log.error("Error while handling jms message", e);
- }
- }
-
- public void process(MessageExchange exchange) throws Exception {
- throw new IllegalStateException();
- }
-
-}
+/*
+ * 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.standard;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+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;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.resource.spi.work.Work;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jms.AbstractJmsProcessor;
+import org.apache.servicemix.jms.JmsEndpoint;
+import org.apache.servicemix.soap.Context;
+import org.apache.servicemix.soap.SoapFault;
+import org.apache.servicemix.soap.SoapHelper;
+import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.apache.servicemix.soap.marshalers.SoapWriter;
+
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
+
+public class StandardConsumerProcessor extends AbstractJmsProcessor {
+
+ private static final Log log = LogFactory.getLog(StandardConsumerProcessor.class);
+
+ protected Session session;
+ protected Destination destination;
+ protected DeliveryChannel channel;
+ protected SoapHelper soapHelper;
+ protected AtomicBoolean running = new AtomicBoolean(false);
+
+ public StandardConsumerProcessor(JmsEndpoint endpoint) {
+ super(endpoint);
+ this.soapHelper = new SoapHelper(endpoint);
+ }
+
+ protected void doStart(InitialContext ctx) throws Exception {
+ destination = endpoint.getDestination();
+ if (destination == null) {
+ if (endpoint.getJndiDestinationName() != null) {
+ destination = (Destination) ctx.lookup(endpoint.getJndiDestinationName());
+ } else if (endpoint.getJmsProviderDestinationName() == null) {
+ throw new IllegalStateException("No destination provided");
+ }
+ }
+ channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel();
+ synchronized (running) {
+ endpoint.getServiceUnit().getComponent().getWorkManager().startWork(new Work() {
+ public void release() {
+ }
+ public void run() {
+ StandardConsumerProcessor.this.poll();
+ }
+ });
+ running.wait();
+ }
+ }
+
+
+ protected void doStop() throws Exception {
+ if (running.get()) {
+ synchronized (running) {
+ if (session != null) {
+ session.close();
+ }
+ running.wait();
+ }
+ }
+ session = null;
+ destination = null;
+ }
+
+ protected void poll() {
+ synchronized (running) {
+ running.set(true);
+ running.notify();
+ }
+ try {
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ if (destination == null) {
+ if (STYLE_QUEUE.equals(endpoint.getDestinationStyle())) {
+ destination = session.createQueue(endpoint.getJmsProviderDestinationName());
+ } else {
+ destination = session.createTopic(endpoint.getJmsProviderDestinationName());
+ }
+ }
+ MessageConsumer consumer = session.createConsumer(destination);
+ while (running.get()) {
+ Message message = consumer.receive();
+ if (message != null) {
+ onMessage(message);
+ }
+ }
+ } catch (Exception e) {
+ log.error("", e);
+ } finally {
+ synchronized (running) {
+ running.set(false);
+ running.notify();
+ }
+ }
+ }
+
+ public void onMessage(final Message message) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Received jms message " + message);
+ }
+ 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 = soapHelper.getSoapMarshaler().createReader().read(is, contentType);
+ Context context = soapHelper.createContext(soap);
+ MessageExchange exchange = soapHelper.onReceive(context);
+ context.setProperty(Message.class.getName(), message);
+ // TODO: copy protocol messages
+ //inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(message));
+ if (!channel.sendSync(exchange)) {
+ throw new IllegalStateException("Exchange has been aborted");
+ }
+ MessageProducer producer = null;
+ Message response = null;
+ try {
+ 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 = soapHelper.onFault(context, fault);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SoapWriter writer = soapHelper.getSoapMarshaler().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 = soapHelper.onReply(context, outMsg);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SoapWriter writer = soapHelper.getSoapMarshaler().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();
+ }
+ if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+ exchange.setStatus(ExchangeStatus.DONE);
+ channel.send(exchange);
+ }
+ }
+ } catch (Throwable e) {
+ log.error("Error while handling jms message", e);
+ }
+ }
+
+ public void process(MessageExchange exchange) throws Exception {
+ throw new IllegalStateException();
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardConsumerProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardProviderProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardProviderProcessor.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardProviderProcessor.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardProviderProcessor.java Thu Jul 27 22:49:32 2006
@@ -1,173 +1,173 @@
-/*
- * 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.standard;
-
-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;
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOnly;
-import javax.jbi.messaging.InOut;
-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.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.JbiConstants;
-import org.apache.servicemix.jms.AbstractJmsProcessor;
-import org.apache.servicemix.jms.JmsEndpoint;
-import org.apache.servicemix.soap.SoapHelper;
-import org.apache.servicemix.soap.marshalers.SoapMessage;
-import org.apache.servicemix.soap.marshalers.SoapWriter;
-
-public class StandardProviderProcessor extends AbstractJmsProcessor {
-
- private static final Log log = LogFactory.getLog(StandardProviderProcessor.class);
-
- protected Session session;
- protected Destination destination;
- protected Destination replyToDestination;
- protected MessageConsumer consumer;
- protected MessageProducer producer;
- protected DeliveryChannel channel;
- protected SoapHelper soapHelper;
-
- public StandardProviderProcessor(JmsEndpoint endpoint) {
- super(endpoint);
- this.soapHelper = new SoapHelper(endpoint);
- }
-
- protected void doStart(InitialContext ctx) throws Exception {
- channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel();
- destination = endpoint.getDestination();
- if (destination == null) {
- if (endpoint.getJndiDestinationName() != null) {
- destination = (Destination) ctx.lookup(endpoint.getJndiDestinationName());
- } else if (endpoint.getJmsProviderDestinationName() == null) {
- throw new IllegalStateException("No destination provided");
- }
- }
- }
-
-
- protected void doStop() throws Exception {
- session = null;
- destination = null;
- consumer = null;
- producer = null;
- replyToDestination = null;
- }
-
- public void process(MessageExchange exchange) throws Exception {
- if (exchange.getStatus() == ExchangeStatus.DONE) {
- return;
- } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
- return;
- }
- try {
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- if (destination == null) {
- if (STYLE_QUEUE.equals(endpoint.getDestinationStyle())) {
- destination = session.createQueue(endpoint.getJmsProviderDestinationName());
- } else {
- destination = session.createTopic(endpoint.getJmsProviderDestinationName());
- }
- }
- producer = session.createProducer(destination);
-
- SoapMessage soapMessage = new SoapMessage();
- NormalizedMessage nm = exchange.getMessage("in");
- soapHelper.getJBIMarshaler().fromNMS(soapMessage, nm);
- SoapWriter writer = soapHelper.getSoapMarshaler().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) {
- producer.send(msg);
- } else if (exchange instanceof InOut) {
- if (destination instanceof Queue) {
- replyToDestination = session.createTemporaryQueue();
- } else {
- replyToDestination = session.createTemporaryTopic();
- }
- consumer = session.createConsumer(replyToDestination);
- msg.setJMSCorrelationID(exchange.getExchangeId());
- msg.setJMSReplyTo(replyToDestination);
- producer.send(msg);
- Message message = consumer.receive();
- 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 = soapHelper.getSoapMarshaler().createReader().read(is, contentType);
- NormalizedMessage out = exchange.createMessage();
- soapHelper.getJBIMarshaler().toNMS(out, soap);
- ((InOut) exchange).setOutMessage(out);
- }
- channel.send(exchange);
- } else {
- throw new IllegalStateException(exchange.getPattern() + " not implemented");
- }
- } finally {
- if (session != null) {
- session.close();
- }
- }
- }
-
-
-}
+/*
+ * 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.standard;
+
+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;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOut;
+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.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.JbiConstants;
+import org.apache.servicemix.jms.AbstractJmsProcessor;
+import org.apache.servicemix.jms.JmsEndpoint;
+import org.apache.servicemix.soap.SoapHelper;
+import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.apache.servicemix.soap.marshalers.SoapWriter;
+
+public class StandardProviderProcessor extends AbstractJmsProcessor {
+
+ private static final Log log = LogFactory.getLog(StandardProviderProcessor.class);
+
+ protected Session session;
+ protected Destination destination;
+ protected Destination replyToDestination;
+ protected MessageConsumer consumer;
+ protected MessageProducer producer;
+ protected DeliveryChannel channel;
+ protected SoapHelper soapHelper;
+
+ public StandardProviderProcessor(JmsEndpoint endpoint) {
+ super(endpoint);
+ this.soapHelper = new SoapHelper(endpoint);
+ }
+
+ protected void doStart(InitialContext ctx) throws Exception {
+ channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel();
+ destination = endpoint.getDestination();
+ if (destination == null) {
+ if (endpoint.getJndiDestinationName() != null) {
+ destination = (Destination) ctx.lookup(endpoint.getJndiDestinationName());
+ } else if (endpoint.getJmsProviderDestinationName() == null) {
+ throw new IllegalStateException("No destination provided");
+ }
+ }
+ }
+
+
+ protected void doStop() throws Exception {
+ session = null;
+ destination = null;
+ consumer = null;
+ producer = null;
+ replyToDestination = null;
+ }
+
+ public void process(MessageExchange exchange) throws Exception {
+ if (exchange.getStatus() == ExchangeStatus.DONE) {
+ return;
+ } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+ return;
+ }
+ try {
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ if (destination == null) {
+ if (STYLE_QUEUE.equals(endpoint.getDestinationStyle())) {
+ destination = session.createQueue(endpoint.getJmsProviderDestinationName());
+ } else {
+ destination = session.createTopic(endpoint.getJmsProviderDestinationName());
+ }
+ }
+ producer = session.createProducer(destination);
+
+ SoapMessage soapMessage = new SoapMessage();
+ NormalizedMessage nm = exchange.getMessage("in");
+ soapHelper.getJBIMarshaler().fromNMS(soapMessage, nm);
+ SoapWriter writer = soapHelper.getSoapMarshaler().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) {
+ producer.send(msg);
+ } else if (exchange instanceof InOut) {
+ if (destination instanceof Queue) {
+ replyToDestination = session.createTemporaryQueue();
+ } else {
+ replyToDestination = session.createTemporaryTopic();
+ }
+ consumer = session.createConsumer(replyToDestination);
+ msg.setJMSCorrelationID(exchange.getExchangeId());
+ msg.setJMSReplyTo(replyToDestination);
+ producer.send(msg);
+ Message message = consumer.receive();
+ 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 = soapHelper.getSoapMarshaler().createReader().read(is, contentType);
+ NormalizedMessage out = exchange.createMessage();
+ soapHelper.getJBIMarshaler().toNMS(out, soap);
+ ((InOut) exchange).setOutMessage(out);
+ }
+ channel.send(exchange);
+ } else {
+ throw new IllegalStateException(exchange.getPattern() + " not implemented");
+ }
+ } finally {
+ if (session != null) {
+ session.close();
+ }
+ }
+ }
+
+
+}
Propchange: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/standard/StandardProviderProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsSpringTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsSpringTest.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsSpringTest.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsSpringTest.java Thu Jul 27 22:49:32 2006
@@ -1,47 +1,47 @@
-package org.apache.servicemix.jms;
-
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOut;
-import javax.naming.Context;
-import javax.xml.namespace.QName;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.client.DefaultServiceMixClient;
-import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.apache.servicemix.tck.SpringTestSupport;
-import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
-import org.apache.xbean.spring.jndi.SpringInitialContextFactory;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-
-public class JmsSpringTest extends SpringTestSupport {
-
- private static Log logger = LogFactory.getLog(JmsSpringTest.class);
-
- public void test() throws Exception {
- DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
- 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()));
- }
- }
-
- protected AbstractXmlApplicationContext createBeanFactory() {
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY, SpringInitialContextFactory.class.getName());
- System.setProperty(Context.PROVIDER_URL, "org/apache/servicemix/jms/jndi.xml");
- return new ClassPathXmlApplicationContext("org/apache/servicemix/jms/spring.xml");
- }
-
-}
+package org.apache.servicemix.jms;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.naming.Context;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.apache.xbean.spring.jndi.SpringInitialContextFactory;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class JmsSpringTest extends SpringTestSupport {
+
+ private static Log logger = LogFactory.getLog(JmsSpringTest.class);
+
+ public void test() throws Exception {
+ DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+ 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()));
+ }
+ }
+
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, SpringInitialContextFactory.class.getName());
+ System.setProperty(Context.PROVIDER_URL, "org/apache/servicemix/jms/jndi.xml");
+ return new ClassPathXmlApplicationContext("org/apache/servicemix/jms/spring.xml");
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsSpringTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java Thu Jul 27 22:49:32 2006
@@ -1,112 +1,112 @@
-/*
- * 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.util.List;
-
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOnly;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.NormalizedMessage;
-import javax.jbi.servicedesc.ServiceEndpoint;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.xbean.BrokerFactoryBean;
-import org.apache.servicemix.client.DefaultServiceMixClient;
-import org.apache.servicemix.jbi.container.JBIContainer;
-import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
-import org.apache.servicemix.jbi.resolver.URIResolver;
-import org.apache.servicemix.tck.ReceiverComponent;
-import org.springframework.core.io.ClassPathResource;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-
-public class JmsURITest extends TestCase {
-
- protected JBIContainer container;
- protected BrokerService broker;
- protected ActiveMQConnectionFactory connectionFactory;
-
- protected void setUp() throws Exception {
- BrokerFactoryBean bfb = new BrokerFactoryBean(new ClassPathResource("org/apache/servicemix/jms/activemq.xml"));
- bfb.afterPropertiesSet();
- broker = bfb.getBroker();
- broker.start();
-
- container = new JBIContainer();
- container.setUseMBeanServer(true);
- container.setCreateMBeanServer(true);
- container.setMonitorInstallationDirectory(false);
- container.init();
- container.start();
-
- connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61216");
- }
-
- protected void tearDown() throws Exception {
- if (container != null) {
- container.shutDown();
- }
- if (broker != null) {
- broker.stop();
- }
- }
-
- public void testResolveEndpoint() throws Exception {
- JmsSpringComponent jms = new JmsSpringComponent();
- ((JmsLifeCycle) jms.getLifeCycle()).getConfiguration().setConnectionFactory(connectionFactory);
- JmsEndpoint ep = new JmsEndpoint();
- ep.setRole(MessageExchange.Role.CONSUMER);
- ep.setService(ReceiverComponent.SERVICE);
- ep.setEndpoint(ReceiverComponent.ENDPOINT);
- ep.setDefaultMep(MessageExchangeSupport.IN_ONLY);
- ep.setJmsProviderDestinationName("foo.bar.myqueue");
- ep.setDestinationStyle(AbstractJmsProcessor.STYLE_QUEUE);
- jms.setEndpoints(new JmsEndpoint[] { ep });
- container.activateComponent(jms, "servicemix-jms");
-
- ReceiverComponent receiver = new ReceiverComponent();
- container.activateComponent(receiver, "receiver");
-
- DefaultServiceMixClient client = new DefaultServiceMixClient(container);
- DocumentFragment epr = URIResolver.createWSAEPR("jms://queue/foo.bar.myqueue?jms.soap=true");
- ServiceEndpoint se = client.getContext().resolveEndpointReference(epr);
- assertNotNull(se);
-
- InOnly inonly = client.createInOnlyExchange();
- inonly.setEndpoint(se);
- inonly.getInMessage().setContent(new StringSource("<hello>world</hello>"));
- client.sendSync(inonly);
-
- assertEquals(ExchangeStatus.DONE, inonly.getStatus());
- receiver.getMessageList().assertMessagesReceived(1);
- List msgs = receiver.getMessageList().flushMessages();
- NormalizedMessage msg = (NormalizedMessage) msgs.get(0);
- Document doc = (Document) new SourceTransformer().toDOMNode(msg);
- assertEquals("http://www.w3.org/2003/05/soap-envelope", doc.getDocumentElement().getNamespaceURI());
- assertEquals("env:Envelope", doc.getDocumentElement().getNodeName());
- System.out.println(new SourceTransformer().contentToString(msg));
-
- // Wait for DONE status
- Thread.sleep(50);
- }
-
-}
+/*
+ * 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.util.List;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.servicedesc.ServiceEndpoint;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.xbean.BrokerFactoryBean;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
+import org.apache.servicemix.jbi.resolver.URIResolver;
+import org.apache.servicemix.tck.ReceiverComponent;
+import org.springframework.core.io.ClassPathResource;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+
+public class JmsURITest extends TestCase {
+
+ protected JBIContainer container;
+ protected BrokerService broker;
+ protected ActiveMQConnectionFactory connectionFactory;
+
+ protected void setUp() throws Exception {
+ BrokerFactoryBean bfb = new BrokerFactoryBean(new ClassPathResource("org/apache/servicemix/jms/activemq.xml"));
+ bfb.afterPropertiesSet();
+ broker = bfb.getBroker();
+ broker.start();
+
+ container = new JBIContainer();
+ container.setUseMBeanServer(true);
+ container.setCreateMBeanServer(true);
+ container.setMonitorInstallationDirectory(false);
+ container.init();
+ container.start();
+
+ connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61216");
+ }
+
+ protected void tearDown() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ if (broker != null) {
+ broker.stop();
+ }
+ }
+
+ public void testResolveEndpoint() throws Exception {
+ JmsSpringComponent jms = new JmsSpringComponent();
+ ((JmsLifeCycle) jms.getLifeCycle()).getConfiguration().setConnectionFactory(connectionFactory);
+ JmsEndpoint ep = new JmsEndpoint();
+ ep.setRole(MessageExchange.Role.CONSUMER);
+ ep.setService(ReceiverComponent.SERVICE);
+ ep.setEndpoint(ReceiverComponent.ENDPOINT);
+ ep.setDefaultMep(MessageExchangeSupport.IN_ONLY);
+ ep.setJmsProviderDestinationName("foo.bar.myqueue");
+ ep.setDestinationStyle(AbstractJmsProcessor.STYLE_QUEUE);
+ jms.setEndpoints(new JmsEndpoint[] { ep });
+ container.activateComponent(jms, "servicemix-jms");
+
+ ReceiverComponent receiver = new ReceiverComponent();
+ container.activateComponent(receiver, "receiver");
+
+ DefaultServiceMixClient client = new DefaultServiceMixClient(container);
+ DocumentFragment epr = URIResolver.createWSAEPR("jms://queue/foo.bar.myqueue?jms.soap=true");
+ ServiceEndpoint se = client.getContext().resolveEndpointReference(epr);
+ assertNotNull(se);
+
+ InOnly inonly = client.createInOnlyExchange();
+ inonly.setEndpoint(se);
+ inonly.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+ client.sendSync(inonly);
+
+ assertEquals(ExchangeStatus.DONE, inonly.getStatus());
+ receiver.getMessageList().assertMessagesReceived(1);
+ List msgs = receiver.getMessageList().flushMessages();
+ NormalizedMessage msg = (NormalizedMessage) msgs.get(0);
+ Document doc = (Document) new SourceTransformer().toDOMNode(msg);
+ assertEquals("http://www.w3.org/2003/05/soap-envelope", doc.getDocumentElement().getNamespaceURI());
+ assertEquals("env:Envelope", doc.getDocumentElement().getNodeName());
+ System.out.println(new SourceTransformer().contentToString(msg));
+
+ // Wait for DONE status
+ Thread.sleep(50);
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java Thu Jul 27 22:49:32 2006
@@ -1,235 +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, "JMSComponent1");
-
- // 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.setQName(new QName("http://test", "MyConsumerBinding"));
- 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, "JMSComponent2");
-
- // 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().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()));
- }
- }
-
-}
+/*
+ * 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, "JMSComponent1");
+
+ // 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.setQName(new QName("http://test", "MyConsumerBinding"));
+ 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, "JMSComponent2");
+
+ // 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().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()));
+ }
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsXBeanDeployerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring.xml?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring.xml (original)
+++ incubator/servicemix/trunk/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring.xml Thu Jul 27 22:49:32 2006
@@ -1,68 +1,68 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
- xmlns:jms="http://servicemix.apache.org/jms/1.0"
- xmlns:amq="http://activemq.org/config/1.0"
- xmlns:test="http://test">
-
- <!-- the JBI container -->
- <sm:container id="jbi" embedded="true" depends-on="jndi,broker">
- <sm:activationSpecs>
-
- <!-- START SNIPPET: lightweight -->
- <sm:activationSpec>
- <sm:component>
- <jms:component>
- <jms:endpoints>
- <jms:endpoint service="test:MyConsumerService"
- endpoint="myConsumer"
- role="consumer"
- defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
- destinationStyle="queue"
- jmsProviderDestinationName="queue/A"
- jndiConnectionFactoryName="jms/ConnectionFactory" />
-
- <jms:endpoint service="test:MyProviderService"
- endpoint="myProvider"
- role="provider"
- destinationStyle="queue"
- jmsProviderDestinationName="queue/A"
- connectionFactory="#connectionFactory" />
- </jms:endpoints>
- </jms:component>
- </sm:component>
- </sm:activationSpec>
- <!-- END SNIPPET: lightweight -->
-
- <sm:activationSpec service="test:MyConsumerService" endpoint="myConsumer">
- <sm:component>
- <bean class="org.apache.servicemix.components.util.EchoComponent" />
- </sm:component>
- </sm:activationSpec>
-
- </sm:activationSpecs>
- </sm:container>
-
- <bean id="jndi"
- class="org.apache.xbean.spring.jndi.SpringInitialContextFactory"
- factory-method="makeInitialContext"
- singleton="true">
- <property name="entries">
- <map>
- <entry key="jms/ConnectionFactory" value-ref="connectionFactory" />
- </map>
- </property>
- </bean>
-
- <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
- <property name="brokerURL" value="tcp://localhost:61216" />
- </bean>
-
- <amq:broker id="broker" persistent="false" depends-on="jndi">
-
- <amq:transportConnectors>
- <amq:transportConnector uri="tcp://localhost:61216" />
- </amq:transportConnectors>
-
- </amq:broker>
-
-</beans>
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:jms="http://servicemix.apache.org/jms/1.0"
+ xmlns:amq="http://activemq.org/config/1.0"
+ xmlns:test="http://test">
+
+ <!-- the JBI container -->
+ <sm:container id="jbi" embedded="true" depends-on="jndi,broker">
+ <sm:activationSpecs>
+
+ <!-- START SNIPPET: lightweight -->
+ <sm:activationSpec>
+ <sm:component>
+ <jms:component>
+ <jms:endpoints>
+ <jms:endpoint service="test:MyConsumerService"
+ endpoint="myConsumer"
+ role="consumer"
+ defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
+ destinationStyle="queue"
+ jmsProviderDestinationName="queue/A"
+ jndiConnectionFactoryName="jms/ConnectionFactory" />
+
+ <jms:endpoint service="test:MyProviderService"
+ endpoint="myProvider"
+ role="provider"
+ destinationStyle="queue"
+ jmsProviderDestinationName="queue/A"
+ connectionFactory="#connectionFactory" />
+ </jms:endpoints>
+ </jms:component>
+ </sm:component>
+ </sm:activationSpec>
+ <!-- END SNIPPET: lightweight -->
+
+ <sm:activationSpec service="test:MyConsumerService" endpoint="myConsumer">
+ <sm:component>
+ <bean class="org.apache.servicemix.components.util.EchoComponent" />
+ </sm:component>
+ </sm:activationSpec>
+
+ </sm:activationSpecs>
+ </sm:container>
+
+ <bean id="jndi"
+ class="org.apache.xbean.spring.jndi.SpringInitialContextFactory"
+ factory-method="makeInitialContext"
+ singleton="true">
+ <property name="entries">
+ <map>
+ <entry key="jms/ConnectionFactory" value-ref="connectionFactory" />
+ </map>
+ </property>
+ </bean>
+
+ <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
+ <property name="brokerURL" value="tcp://localhost:61216" />
+ </bean>
+
+ <amq:broker id="broker" persistent="false" depends-on="jndi">
+
+ <amq:transportConnectors>
+ <amq:transportConnector uri="tcp://localhost:61216" />
+ </amq:transportConnectors>
+
+ </amq:broker>
+
+</beans>