| Commit in servicemix/base/src on MAIN | |||
| main/java/org/servicemix/jbi/messaging/InOutImpl.java | +8 | -1 | 1.2 -> 1.3 |
| /RobustInOnlyImpl.java | +7 | -4 | 1.2 -> 1.3 |
| /InOptionalOutImpl.java | +7 | -4 | 1.2 -> 1.3 |
| /InOnlyImpl.java | +7 | -5 | 1.2 -> 1.3 |
| /MessageExchangeImpl.java | +22 | -2 | 1.15 -> 1.16 |
| test/resources/org/servicemix/remoting/example.xml | +58 | added 1.1 | |
| test/java/org/servicemix/remoting/RemoteServiceMixClientTest.java | +68 | added 1.1 | |
| main/java/org/servicemix/components/util/EchoComponent.java | +45 | added 1.1 | |
| +222 | -16 | ||
Test for remoting
servicemix/base/src/main/java/org/servicemix/jbi/messaging
diff -u -r1.2 -r1.3 --- InOutImpl.java 7 Jun 2005 14:23:09 -0000 1.2 +++ InOutImpl.java 18 Aug 2005 14:11:37 -0000 1.3 @@ -27,11 +27,18 @@
/** * InOut message exchange. *
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class InOutImpl extends MessageExchangeImpl implements InOut {
+
/**
* Default Constructor
+ */
+ public InOutImpl(){
+ }
+
+ /**
+ * Constructor
*
* @param exchangeId
*/
servicemix/base/src/main/java/org/servicemix/jbi/messaging
diff -u -r1.2 -r1.3 --- RobustInOnlyImpl.java 7 Jun 2005 14:23:09 -0000 1.2 +++ RobustInOnlyImpl.java 18 Aug 2005 14:11:37 -0000 1.3 @@ -19,18 +19,21 @@
package org.servicemix.jbi.messaging;
-import org.servicemix.jbi.container.JBIContainer; -
import javax.jbi.messaging.RobustInOnly;
-import javax.jbi.messaging.MessagingException;
/** * RobustInOnly message exchange. *
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class RobustInOnlyImpl extends MessageExchangeImpl implements RobustInOnly {
+
+ /**
+ * Default Constructor
+ */
+ public RobustInOnlyImpl(){
+ }
/**
* Constructor
* @param exchangeId
servicemix/base/src/main/java/org/servicemix/jbi/messaging
diff -u -r1.2 -r1.3 --- InOptionalOutImpl.java 7 Jun 2005 14:23:09 -0000 1.2 +++ InOptionalOutImpl.java 18 Aug 2005 14:11:37 -0000 1.3 @@ -19,19 +19,22 @@
package org.servicemix.jbi.messaging;
-import org.servicemix.jbi.container.JBIContainer; -
import javax.jbi.messaging.InOptionalOut;
-import javax.jbi.messaging.MessagingException;
/** * InOptionalOut message exchange. *
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class InOptionalOutImpl extends MessageExchangeImpl implements InOptionalOut {
+
/**
* Default Constructor
+ */
+ public InOptionalOutImpl(){
+ }
+ /**
+ * Constructor
*
* @param exchangeId
*/
servicemix/base/src/main/java/org/servicemix/jbi/messaging
diff -u -r1.2 -r1.3 --- InOnlyImpl.java 7 Jun 2005 14:23:09 -0000 1.2 +++ InOnlyImpl.java 18 Aug 2005 14:11:37 -0000 1.3 @@ -19,20 +19,22 @@
package org.servicemix.jbi.messaging;
-import org.servicemix.jbi.container.JBIContainer; -
import javax.jbi.messaging.InOnly;
-import javax.jbi.messaging.ExchangeStatus; -import javax.jbi.messaging.MessagingException;
/** * InOnly message exchange. *
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class InOnlyImpl extends MessageExchangeImpl implements InOnly {
+
/**
* Default Constructor
+ */
+ public InOnlyImpl(){
+ }
+ /**
+ * Constructor
*
* @param exchangeId
*/
servicemix/base/src/main/java/org/servicemix/jbi/messaging
diff -u -r1.15 -r1.16 --- MessageExchangeImpl.java 14 Aug 2005 11:53:13 -0000 1.15 +++ MessageExchangeImpl.java 18 Aug 2005 14:11:37 -0000 1.16 @@ -19,6 +19,10 @@
package org.servicemix.jbi.messaging;
+import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput;
import java.io.Serializable; import java.net.URI; import java.util.Set;
@@ -41,9 +45,9 @@
* A simple message exchange declaration. This is partial, just giving us enough ME function for the doodle. This * doesn't add anything new to the current MessageExchange definition. *
- * @version $Revision: 1.15 $
+ * @version $Revision: 1.16 $
*/
-public class MessageExchangeImpl implements MessageExchange, Serializable {
+public class MessageExchangeImpl implements MessageExchange, Externalizable {
private static final long serialVersionUID = -3639175136897005605L;
@@ -73,6 +77,12 @@
public MessageExchangeImpl(ExchangePacket packet){
setPacket(packet);
}
+
+ /**
+ * Default Constructor
+ */
+ public MessageExchangeImpl(){
+ }
/**
* Returns the activation spec that was provided when the component was registered
@@ -454,5 +464,15 @@
public void setMarshaler(Marshaler marshaler) {
this.marshaler = marshaler;
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(packet);
+
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ setPacket((ExchangePacket)in.readObject());
+
} }
servicemix/base/src/test/resources/org/servicemix/remoting
example.xml added at 1.1
diff -N example.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ example.xml 18 Aug 2005 14:11:37 -0000 1.1 @@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns:my="http://servicemix.org/demo/"> + + + <!-- the JBI container --> + <container id="jbi"> + + <components> + + <component id="echo" service="my:receiver" class="org.servicemix.components.util.EchoComponent"/> + </components> + </container> + + + +<!-- client side proxy--> + <bean id="client" class="org.logicblaze.lingo.jms.JmsProxyFactoryBean"> + <property name="serviceInterface" value="org.servicemix.client.ServiceMixClient"/> + <property name="connectionFactory" ref="jmsFactory"/> + <property name="destination" ref="exampleDestination"/> + </bean> + + + <!-- the server side inside ServiceMix Container--> + <bean id="server" class="org.logicblaze.lingo.jms.JmsServiceExporter"> + <property name="service" ref="serverClientSideImpl"/> + <property name="serviceInterface" value="org.servicemix.client.ServiceMixClient"/> + <property name="connectionFactory" ref="jmsFactory"/> + <property name="destination" ref="exampleDestination"/> + </bean> + + + <!-- JMS ConnectionFactory to use --> + <bean id="jmsFactory" class="org.activemq.ActiveMQConnectionFactory"> + <property name="brokerURL" value="vm://localhost"/> + </bean> + + <bean id="exampleDestination" class="org.activemq.message.ActiveMQQueue"> + <constructor-arg index="0" value="test.org.logicblaze.lingo.example"/> + </bean> + + + + + <bean id="serverClientSideImpl" class="org.servicemix.client.DefaultServiceMixClient"> + <constructor-arg ref="jbi"/> + <constructor-arg> + <!-- lets hardwire this client to talk to instances of a service by default --> + <bean class="org.servicemix.jbi.container.ActivationSpec"> + <property name="destinationService"> + <qname>my:receiver</qname> + </property> + </bean> + </constructor-arg> + </bean> + + +</beans>
servicemix/base/src/test/java/org/servicemix/remoting
RemoteServiceMixClientTest.java added at 1.1
diff -N RemoteServiceMixClientTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ RemoteServiceMixClientTest.java 18 Aug 2005 14:11:37 -0000 1.1 @@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright 2005 RAJD Consultancy Ltd
+ *
+ * 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.servicemix.remoting;
+import java.io.StringReader;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.stream.StreamSource;
+import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.servicemix.client.ServiceMixClient;
+import org.servicemix.jbi.container.SpringJBIContainer;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class RemoteServiceMixClientTest extends TestCase {
+ private static final transient Log log = LogFactory.getLog(RemoteServiceMixClientTest.class);
+ protected AbstractXmlApplicationContext context;
+ protected ServiceMixClient client;
+
+ // Send methods
+ // -------------------------------------------------------------------------
+ public void testRemoteSend() throws Exception {
+ InOut exchange = client.createInOutExchange();
+ NormalizedMessage message = exchange.getInMessage();
+ message.setProperty("name", "lufc");
+ message.setContent(new StreamSource(new StringReader("<hello>world</hello>")));
+ assertTrue(client.sendSync(exchange));
+ System.out.println("OUT = " + exchange.getOutMessage());
+ //assertEquals(exchange.getInMessage().getContent(),exchange.getOutMessage().getContent());
+ }
+
+ protected void setUp() throws Exception {
+ context = createBeanFactory();
+ context.setXmlValidating(false);
+ client = (ServiceMixClient) getBean("client");
+ SpringJBIContainer jbi = (SpringJBIContainer) getBean("jbi");
+ }
+
+ protected Object getBean(String name) {
+ Object answer = context.getBean(name);
+ assertNotNull("Could not find object in Spring for key: " + name, answer);
+ return answer;
+ }
+
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new ClassPathXmlApplicationContext("org/servicemix/remoting/example.xml");
+ }
+}
servicemix/base/src/main/java/org/servicemix/components/util
EchoComponent.java added at 1.1
diff -N EchoComponent.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EchoComponent.java 18 Aug 2005 14:11:37 -0000 1.1 @@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright RAJD Consultanct Ltd
+ *
+ * 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.servicemix.components.util;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.servicemix.MessageExchangeListener;
+
+/**
+ * A simple, yet useful component for testing synchronous flows. Echos back Exchanges
+ *
+ * @version $Revision: 1.1 $
+ */
+public class EchoComponent extends ComponentSupport implements MessageExchangeListener {
+ private static final Log log = LogFactory.getLog(EchoComponent.class);
+
+ public void onMessageExchange(MessageExchange exchange) throws MessagingException {
+ // lets dump the incoming message
+ NormalizedMessage message = exchange.getMessage("in");
+ if (message == null) {
+ log.warn("Received null message from exchange: " + exchange);
+ }
+ exchange.setMessage(message, "out");
+ done(exchange);
+ log.info("Echoed back message: " + message);
+ }
+}
