diff --git a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiGateway.java b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiInboundGateway.java similarity index 95% rename from org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiGateway.java rename to org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiInboundGateway.java index 840b46b004..36f125907c 100644 --- a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiGateway.java +++ b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiInboundGateway.java @@ -28,11 +28,11 @@ import org.springframework.util.Assert; import org.springframework.util.StringUtils; /** - * A gateway adapter for RMI-based remoting. + * An inbound Messaging Gateway for RMI-based remoting. * * @author Mark Fisher */ -public class RmiGateway extends RemotingInboundGatewaySupport implements MessageHandler { +public class RmiInboundGateway extends RemotingInboundGatewaySupport { public static final String SERVICE_NAME_PREFIX = "org.springframewok.integration.rmiGateway."; diff --git a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiHandler.java b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiOutboundGateway.java similarity index 88% rename from org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiHandler.java rename to org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiOutboundGateway.java index 19a25271b5..2523828955 100644 --- a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiHandler.java +++ b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/RmiOutboundGateway.java @@ -21,13 +21,13 @@ import org.springframework.integration.handler.MessageHandler; import org.springframework.remoting.rmi.RmiProxyFactoryBean; /** - * A MessageHandler adapter for RMI-based remoting. + * An outbound Messaging Gateway for RMI-based remoting. * * @author Mark Fisher */ -public class RmiHandler extends AbstractRemotingOutboundGateway { +public class RmiOutboundGateway extends AbstractRemotingOutboundGateway { - public RmiHandler(String url) { + public RmiOutboundGateway(String url) { super(url); } diff --git a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiGatewayParser.java b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiInboundGatewayParser.java similarity index 86% rename from org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiGatewayParser.java rename to org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiInboundGatewayParser.java index e8b516b5bc..bbeaef14ae 100644 --- a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiGatewayParser.java +++ b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiInboundGatewayParser.java @@ -20,22 +20,22 @@ import org.w3c.dom.Element; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.integration.adapter.config.AbstractRemotingGatewayParser; -import org.springframework.integration.rmi.RmiGateway; +import org.springframework.integration.rmi.RmiInboundGateway; import org.springframework.util.StringUtils; /** - * Parser for the <rmi-gateway/> element. + * Parser for the <inbound-gateway/> element of the 'rmi' namespace. * * @author Mark Fisher */ -public class RmiGatewayParser extends AbstractRemotingGatewayParser { +public class RmiInboundGatewayParser extends AbstractRemotingGatewayParser { private static final String REMOTE_INVOCATION_EXECUTOR_ATTRIBUTE = "remote-invocation-executor"; @Override protected Class getBeanClass(Element element) { - return RmiGateway.class; + return RmiInboundGateway.class; } @Override diff --git a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiNamespaceHandler.java b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiNamespaceHandler.java index 80db6f5fd1..7f5046ca1d 100644 --- a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiNamespaceHandler.java +++ b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiNamespaceHandler.java @@ -26,8 +26,8 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport; public class RmiNamespaceHandler extends NamespaceHandlerSupport { public void init() { - this.registerBeanDefinitionParser("inbound-gateway", new RmiGatewayParser()); - this.registerBeanDefinitionParser("outbound-gateway", new RmiHandlerParser()); + this.registerBeanDefinitionParser("inbound-gateway", new RmiInboundGatewayParser()); + this.registerBeanDefinitionParser("outbound-gateway", new RmiOutboundGatewayParser()); } } diff --git a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiHandlerParser.java b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiOutboundGatewayParser.java similarity index 85% rename from org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiHandlerParser.java rename to org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiOutboundGatewayParser.java index 6de25a120d..8fe1afe8fc 100644 --- a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiHandlerParser.java +++ b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiOutboundGatewayParser.java @@ -23,8 +23,8 @@ import org.w3c.dom.Element; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.integration.ConfigurationException; import org.springframework.integration.adapter.config.AbstractRemotingOutboundGatewayParser; -import org.springframework.integration.rmi.RmiGateway; -import org.springframework.integration.rmi.RmiHandler; +import org.springframework.integration.rmi.RmiInboundGateway; +import org.springframework.integration.rmi.RmiOutboundGateway; import org.springframework.util.StringUtils; /** @@ -32,11 +32,11 @@ import org.springframework.util.StringUtils; * * @author Mark Fisher */ -public class RmiHandlerParser extends AbstractRemotingOutboundGatewayParser { +public class RmiOutboundGatewayParser extends AbstractRemotingOutboundGatewayParser { @Override protected Class getBeanClass(Element element) { - return RmiHandler.class; + return RmiOutboundGateway.class; } @Override @@ -56,7 +56,7 @@ public class RmiHandlerParser extends AbstractRemotingOutboundGatewayParser { } String portAttribute = element.getAttribute("port"); String port = StringUtils.hasText(portAttribute) ? portAttribute : "" + Registry.REGISTRY_PORT; - String url = "rmi://" + host + ":" + port + "/" + RmiGateway.SERVICE_NAME_PREFIX + remoteChannel; + String url = "rmi://" + host + ":" + port + "/" + RmiInboundGateway.SERVICE_NAME_PREFIX + remoteChannel; builder.addConstructorArgValue(url); } diff --git a/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/RmiHandlerTests.java b/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/RmiOutboundGatewayTests.java similarity index 72% rename from org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/RmiHandlerTests.java rename to org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/RmiOutboundGatewayTests.java index dd68ec6ced..ec0b9e0a75 100644 --- a/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/RmiHandlerTests.java +++ b/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/RmiOutboundGatewayTests.java @@ -31,16 +31,16 @@ import org.springframework.integration.message.Message; import org.springframework.integration.message.MessageBuilder; import org.springframework.integration.message.MessageHandlingException; import org.springframework.integration.message.StringMessage; -import org.springframework.integration.rmi.RmiHandler; +import org.springframework.integration.rmi.RmiOutboundGateway; import org.springframework.remoting.RemoteLookupFailureException; import org.springframework.remoting.rmi.RmiServiceExporter; /** * @author Mark Fisher */ -public class RmiHandlerTests { +public class RmiOutboundGatewayTests { - private final RmiHandler handler = new RmiHandler("rmi://localhost:1099/testRemoteHandler"); + private final RmiOutboundGateway gateway = new RmiOutboundGateway("rmi://localhost:1099/testRemoteHandler"); @Before @@ -54,41 +54,41 @@ public class RmiHandlerTests { @Test - public void testSerializablePayload() throws RemoteException { - Message replyMessage = handler.handle(new StringMessage("test")); + public void serializablePayload() throws RemoteException { + Message replyMessage = gateway.handle(new StringMessage("test")); assertNotNull(replyMessage); assertEquals("TEST", replyMessage.getPayload()); } @Test - public void testSerializableAttribute() throws RemoteException { + public void serializableAttribute() throws RemoteException { Message requestMessage = MessageBuilder.withPayload("test") .setHeader("testAttribute", "foo").build(); - Message replyMessage = handler.handle(requestMessage); + Message replyMessage = gateway.handle(requestMessage); assertNotNull(replyMessage); assertEquals("foo", replyMessage.getHeaders().get("testAttribute")); } - @Test(expected=MessageHandlingException.class) - public void testNonSerializablePayload() throws RemoteException { + @Test(expected = MessageHandlingException.class) + public void nonSerializablePayload() throws RemoteException { NonSerializableTestObject payload = new NonSerializableTestObject(); Message requestMessage = new GenericMessage(payload); - handler.handle(requestMessage); + gateway.handle(requestMessage); } - @Test(expected=MessageHandlingException.class) - public void testNonSerializableAttribute() throws RemoteException { + @Test(expected = MessageHandlingException.class) + public void nonSerializableAttribute() throws RemoteException { Message requestMessage = MessageBuilder.withPayload("test") .setHeader("testAttribute", new NonSerializableTestObject()).build(); - handler.handle(requestMessage); + gateway.handle(requestMessage); } @Test - public void testInvalidServiceName() throws RemoteException { - RmiHandler handler = new RmiHandler("rmi://localhost:1099/noSuchService"); + public void invalidServiceName() throws RemoteException { + RmiOutboundGateway gateway = new RmiOutboundGateway("rmi://localhost:1099/noSuchService"); boolean exceptionThrown = false; try { - handler.handle(new StringMessage("test")); + gateway.handle(new StringMessage("test")); } catch (MessageHandlingException e) { assertEquals(RemoteLookupFailureException.class, e.getCause().getClass()); @@ -98,11 +98,11 @@ public class RmiHandlerTests { } @Test - public void testInvalidHost() { - RmiHandler handler = new RmiHandler("rmi://noSuchHost:1099/testRemoteHandler"); + public void invalidHost() { + RmiOutboundGateway gateway = new RmiOutboundGateway("rmi://noSuchHost:1099/testRemoteHandler"); boolean exceptionThrown = false; try { - handler.handle(new StringMessage("test")); + gateway.handle(new StringMessage("test")); } catch (MessageHandlingException e) { assertEquals(RemoteLookupFailureException.class, e.getCause().getClass()); @@ -112,11 +112,11 @@ public class RmiHandlerTests { } @Test - public void testInvalidUrl() throws RemoteException { - RmiHandler handler = new RmiHandler("invalid"); + public void invalidUrl() throws RemoteException { + RmiOutboundGateway gateway = new RmiOutboundGateway("invalid"); boolean exceptionThrown = false; try { - handler.handle(new StringMessage("test")); + gateway.handle(new StringMessage("test")); } catch (MessageHandlingException e) { assertEquals(RemoteLookupFailureException.class, e.getCause().getClass()); diff --git a/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiGatewayParserTests.java b/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiInboundGatewayParserTests.java similarity index 75% rename from org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiGatewayParserTests.java rename to org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiInboundGatewayParserTests.java index 4f36b1dfa3..34819c6877 100644 --- a/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiGatewayParserTests.java +++ b/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiInboundGatewayParserTests.java @@ -26,19 +26,19 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.message.MessageChannelTemplate; -import org.springframework.integration.rmi.RmiGateway; +import org.springframework.integration.rmi.RmiInboundGateway; /** * @author Mark Fisher */ -public class RmiGatewayParserTests { +public class RmiInboundGatewayParserTests { @Test - public void testAdapterWithDefaults() { + public void gatewayWithDefaults() { ApplicationContext context = new ClassPathXmlApplicationContext( - "rmiGatewayParserTests.xml", this.getClass()); + "rmiInboundGatewayParserTests.xml", this.getClass()); MessageChannel channel = (MessageChannel) context.getBean("testChannel"); - RmiGateway gateway = (RmiGateway) context.getBean("gatewayWithDefaults"); + RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithDefaults"); DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); assertEquals(true, accessor.getPropertyValue("expectReply")); assertEquals(channel, accessor.getPropertyValue("requestChannel")); @@ -50,11 +50,11 @@ public class RmiGatewayParserTests { } @Test - public void testAdapterWithCustomProperties() { + public void gatewayWithCustomProperties() { ApplicationContext context = new ClassPathXmlApplicationContext( - "rmiGatewayParserTests.xml", this.getClass()); + "rmiInboundGatewayParserTests.xml", this.getClass()); MessageChannel channel = (MessageChannel) context.getBean("testChannel"); - RmiGateway gateway = (RmiGateway) context.getBean("gatewayWithCustomProperties"); + RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithCustomProperties"); DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); assertEquals(false, accessor.getPropertyValue("expectReply")); assertEquals(channel, accessor.getPropertyValue("requestChannel")); @@ -66,28 +66,28 @@ public class RmiGatewayParserTests { } @Test - public void testAdapterWithHost() { + public void gatewayWithHost() { ApplicationContext context = new ClassPathXmlApplicationContext( - "rmiGatewayParserTests.xml", this.getClass()); - RmiGateway gateway = (RmiGateway) context.getBean("gatewayWithHost"); + "rmiInboundGatewayParserTests.xml", this.getClass()); + RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithHost"); DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); assertEquals("localhost", accessor.getPropertyValue("registryHost")); } @Test - public void testAdapterWithPort() { + public void gatewayWithPort() { ApplicationContext context = new ClassPathXmlApplicationContext( - "rmiGatewayParserTests.xml", this.getClass()); - RmiGateway gateway = (RmiGateway) context.getBean("gatewayWithPort"); + "rmiInboundGatewayParserTests.xml", this.getClass()); + RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithPort"); DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); assertEquals(1234, accessor.getPropertyValue("registryPort")); } @Test - public void testAdapterWithRemoteInvocationExecutorReference() { + public void gatewayWithRemoteInvocationExecutorReference() { ApplicationContext context = new ClassPathXmlApplicationContext( - "rmiGatewayParserTests.xml", this.getClass()); - RmiGateway gateway = (RmiGateway) context.getBean("gatewayWithExecutorRef"); + "rmiInboundGatewayParserTests.xml", this.getClass()); + RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithExecutorRef"); DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); Object remoteInvocationExecutor = accessor.getPropertyValue("remoteInvocationExecutor"); assertNotNull(remoteInvocationExecutor); diff --git a/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiHandlerParserTests.java b/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiOutboundGatewayParserTests.java similarity index 76% rename from org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiHandlerParserTests.java rename to org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiOutboundGatewayParserTests.java index c877609e73..9a674e4272 100644 --- a/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiHandlerParserTests.java +++ b/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/RmiOutboundGatewayParserTests.java @@ -28,39 +28,42 @@ import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.message.Message; import org.springframework.integration.message.StringMessage; -import org.springframework.integration.rmi.RmiGateway; -import org.springframework.integration.rmi.RmiHandler; +import org.springframework.integration.rmi.RmiInboundGateway; +import org.springframework.integration.rmi.RmiOutboundGateway; /** * @author Mark Fisher */ -public class RmiHandlerParserTests { +public class RmiOutboundGatewayParserTests { private final QueueChannel testChannel = new QueueChannel(); @Before - public void exportRemoteHandler() throws Exception { + public void setupTestInboundGateway() throws Exception { testChannel.setBeanName("testChannel"); - RmiGateway gateway = new RmiGateway(); + RmiInboundGateway gateway = new RmiInboundGateway(); gateway.setRequestChannel(testChannel); gateway.setExpectReply(false); gateway.afterPropertiesSet(); } + @Test - public void testRmiHandlerDirectly() { - ApplicationContext context = new ClassPathXmlApplicationContext("rmiHandlerParserTests.xml", this.getClass()); - RmiHandler handler = (RmiHandler) context.getBean("gateway"); - handler.handle(new StringMessage("test")); + public void directInvocation() { + ApplicationContext context = new ClassPathXmlApplicationContext( + "rmiOutboundGatewayParserTests.xml", this.getClass()); + RmiOutboundGateway gateway = (RmiOutboundGateway) context.getBean("gateway"); + gateway.handle(new StringMessage("test")); Message result = testChannel.receive(1000); assertNotNull(result); assertEquals("test", result.getPayload()); } @Test - public void testRmiHandlerWithEndpoint() { - ApplicationContext context = new ClassPathXmlApplicationContext("rmiHandlerParserTests.xml", this.getClass()); + public void endpointInvocation() { + ApplicationContext context = new ClassPathXmlApplicationContext( + "rmiOutboundGatewayParserTests.xml", this.getClass()); MessageChannel localChannel = (MessageChannel) context.getBean("localChannel"); localChannel.send(new StringMessage("test")); Message result = testChannel.receive(1000); diff --git a/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/rmiGatewayParserTests.xml b/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/rmiInboundGatewayParserTests.xml similarity index 100% rename from org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/rmiGatewayParserTests.xml rename to org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/rmiInboundGatewayParserTests.xml diff --git a/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/rmiHandlerParserTests.xml b/org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/rmiOutboundGatewayParserTests.xml similarity index 100% rename from org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/rmiHandlerParserTests.xml rename to org.springframework.integration.rmi/src/test/java/org/springframework/integration/rmi/config/rmiOutboundGatewayParserTests.xml