[jboss-svn-commits] JBL Code SVN: r24864 - in labs/jbossesb/trunk/product: docs and 19 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jan 22 02:12:42 EST 2009
Author: beve
Date: 2009-01-22 02:12:41 -0500 (Thu, 22 Jan 2009)
New Revision: 24864
Added:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/UdpListenerMapper.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/DefaultMessageHandler.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/MessageHandler.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayConfig.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayListener.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/mina/
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayListenerUnitTest.java
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/deployment.xml
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jboss-esb.xml
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jbossesb-properties.xml
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jndi.properties
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/juddi.properties
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/lib/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/log4j.xml
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/readme.txt
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/scripts/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/scripts/MessageInjectionConsole.groovy
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/esb/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/esb/samples/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/esb/samples/quickstart/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/esb/samples/quickstart/udpgateway/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/esb/samples/quickstart/udpgateway/test/
labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/esb/samples/quickstart/udpgateway/test/UdpClient.java
Modified:
labs/jbossesb/trunk/product/build-distr.xml
labs/jbossesb/trunk/product/build.xml
labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.1.0.xsd
labs/jbossesb/trunk/product/ivy.xml
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/GatewayGenerator.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java
Log:
Work for https://jira.jboss.org/jira/browse/JBESB-2224 "Add UDP listener support"
Modified: labs/jbossesb/trunk/product/build-distr.xml
===================================================================
--- labs/jbossesb/trunk/product/build-distr.xml 2009-01-22 06:50:52 UTC (rev 24863)
+++ labs/jbossesb/trunk/product/build-distr.xml 2009-01-22 07:12:41 UTC (rev 24864)
@@ -136,6 +136,9 @@
<fileset dir="${lib.ext.dir}" includes="commons-ssl-*.jar"/>
<!-- groovy -->
<fileset dir="${lib.dir}" includes="groovy-*.jar"/>
+ <!-- Mina -->
+ <fileset dir="${lib.dir}" includes="mina-*.jar"/>
+ <fileset dir="${lib.dir}" includes="slf4j-*.jar"/>
</copy>
<copy todir="${build.dir}/jbossesb.sar">
<fileset dir="${installation.files.dir}/jUDDI-registry" includes="juddi.war"/>
Modified: labs/jbossesb/trunk/product/build.xml
===================================================================
--- labs/jbossesb/trunk/product/build.xml 2009-01-22 06:50:52 UTC (rev 24863)
+++ labs/jbossesb/trunk/product/build.xml 2009-01-22 07:12:41 UTC (rev 24864)
@@ -120,6 +120,7 @@
<path id="findbugs.libs">
<fileset dir="../antlib" includes="*.jar"/>
+ <fileset dir="../findbugs/lib" includes="*.jar"/>
</path>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.libs"/>
Modified: labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.1.0.xsd
===================================================================
--- labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.1.0.xsd 2009-01-22 06:50:52 UTC (rev 24863)
+++ labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.1.0.xsd 2009-01-22 07:12:41 UTC (rev 24864)
@@ -1710,5 +1710,43 @@
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
+
+ <!-- 88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
+ UDP Gateway Type Implementations.
+ 88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888-->
+ <xsd:element name="udp-listener" substitutionGroup="jesb:listener">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ UDP Listener that uses Mina.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="jesb:listener">
+ <xsd:attribute name="host" type="xsd:string" use="required">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ The host that this listener will listen to.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="port" type="xsd:integer" use="required">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ The port that this listener will listen to.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="handlerClass" type="xsd:string" use="optional" default="org.jboss.soa.esb.listeners.gateway.mina.DefaultMessageHandler">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ The fully qualified name of a org.jboss.soa.esb.listeners.gateway.mina.MessageHandler implementation.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
</xsd:schema>
Modified: labs/jbossesb/trunk/product/ivy.xml
===================================================================
--- labs/jbossesb/trunk/product/ivy.xml 2009-01-22 06:50:52 UTC (rev 24863)
+++ labs/jbossesb/trunk/product/ivy.xml 2009-01-22 07:12:41 UTC (rev 24864)
@@ -6,6 +6,12 @@
<dependency org="asm" name="asm" rev="1.5.3"/>
<dependency org="commons-codec" name="commons-codec" rev="1.3"/>
<dependency org="commons-collections" name="commons-collections" rev="3.2"/>
+
+ <!-- Mina dependencies -->
+ <dependency org="org.apache.mina" name="mina-core" rev="1.1.7"/>
+ <dependency org="org.apache.mina" name="mina-filter-ssl" rev="1.1.7"/>
+ <dependency org="org.slf4j" name="slf4j-api" rev="1.4.3"/>
+ <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.4.3"/>
<dependency org="commons-httpclient" name="commons-httpclient" rev="3.0.1"/>
<dependency org="commons-io" name="commons-io" rev="1.3"/>
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/GatewayGenerator.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/GatewayGenerator.java 2009-01-22 06:50:52 UTC (rev 24863)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/GatewayGenerator.java 2009-01-22 07:12:41 UTC (rev 24864)
@@ -35,6 +35,7 @@
import org.jboss.soa.esb.listeners.config.xbeanmodel110.JmsListenerDocument.JmsListener;
import org.jboss.soa.esb.listeners.config.xbeanmodel110.ServiceDocument.Service;
import org.jboss.soa.esb.listeners.config.xbeanmodel110.SqlListenerDocument.SqlListener;
+import org.jboss.soa.esb.listeners.config.xbeanmodel110.UdpListenerDocument.UdpListener;
import org.jboss.soa.esb.listeners.config.xbeanmodel110.Listener;
import org.jboss.soa.esb.listeners.config.xbeanmodel110.JcaGatewayDocument;
import org.jboss.soa.esb.listeners.config.xbeanmodel110.AbstractScheduledListener;
@@ -136,6 +137,8 @@
listenerConfig = GroovyListenerMapper.map(root, (GroovyListener) gateway, model);
} else if (gateway instanceof HibernateListener) {
listenerConfig = HibernateListenerMapper.map(root, (HibernateListener) gateway, model);
+ } else if (gateway instanceof UdpListener) {
+ listenerConfig = UdpListenerMapper.map(root, (UdpListener) gateway, model);
} else {
listenerConfig = UntypedListenerMapper.map(root, gateway, model);
}
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/UdpListenerMapper.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/UdpListenerMapper.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/UdpListenerMapper.java 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.config.mappers110;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.listeners.config.mappers110.MapperUtil;
+import org.jboss.soa.esb.listeners.config.xbeanmodel110.UdpListenerDocument;
+import org.jboss.soa.esb.listeners.gateway.mina.UdpGatewayConfig;
+import org.jboss.soa.esb.listeners.gateway.mina.UdpGatewayListener;
+import org.w3c.dom.Element;
+
+/**
+ * Config mapper class for the UDP Listener.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class UdpListenerMapper {
+
+ public static Element map(final Element root, final UdpListenerDocument.UdpListener listener, final XMLBeansModel model) throws ConfigurationException
+ {
+ final Element listenerNode = YADOMUtil.addElement(root, "listener");
+
+ listenerNode.setAttribute("name", listener.getName());
+
+ // Map the standard listener attributes - common across all listener types...
+ MapperUtil.mapDefaultAttributes(listener, listenerNode, model);
+
+ // Map the <property> elements targeted at the listener - from the listener itself.
+ MapperUtil.mapProperties(listener.getPropertyList(), listenerNode);
+
+ listenerNode.setAttribute("gatewayClass", UdpGatewayListener.class.getName());
+
+ // Map the host, port, and handler class
+ listenerNode.setAttribute(UdpGatewayConfig.HOST_ATTR, listener.getHost());
+ listenerNode.setAttribute(UdpGatewayConfig.PORT_ATTR, listener.getPort().toString());
+ listenerNode.setAttribute(UdpGatewayConfig.HANDLER_CLASS_ATTR, listener.getHandlerClass());
+
+ return listenerNode;
+ }
+}
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/DefaultMessageHandler.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/DefaultMessageHandler.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/DefaultMessageHandler.java 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway.mina;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.TransportType;
+import org.apache.mina.transport.socket.nio.SocketSessionConfig;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+/**
+ * DefaultMessageHandler recieves messages and packages the bytes sent into
+ * a ESB Message object.
+ * <p/>
+ * The bytes array will be available in the default body location:
+ * bytes[] payload = message.getBody().get();
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class DefaultMessageHandler extends IoHandlerAdapter implements MessageHandler
+{
+ /**
+ * ServiceInvoker dispatch to the target service on the ESB.
+ */
+ private ServiceInvoker invoker;
+
+ /**
+ * Sets the service invoker that should be used.
+ *
+ * @param invoker The {@link ServiceInvoker} that this message handler should use.
+ */
+ public final void setServiceInvoker(final ServiceInvoker invoker)
+ {
+ this.invoker = invoker;
+ }
+
+ /**
+ * Called when a new connection has been created.
+ *
+ * @param session The MINA IoSession.
+ */
+ public void sessionCreated(final IoSession session)
+ {
+ if (session.getTransportType() == TransportType.SOCKET)
+ {
+ ((SocketSessionConfig) session.getConfig()).setReceiveBufferSize(2048);
+ }
+ session.setIdleTime(IdleStatus.BOTH_IDLE, 10);
+ }
+
+ public void exceptionCaught(final IoSession session, final Throwable cause)
+ {
+ session.close();
+ }
+
+ /**
+ * Extracts the payload as a bytes array and creates a new ESB Message object populating
+ * the EBS Message body with the bytes array.
+ *
+ * @param session The MINA IoSession.
+ * @param message The MINA message object.
+ */
+ public void messageReceived(final IoSession session, final Object message) throws Exception
+ {
+ if (!(message instanceof ByteBuffer))
+ {
+ return;
+ }
+
+ final ByteBuffer byteBuffer = (ByteBuffer) message;
+ final byte[] bytes = new byte[byteBuffer.remaining()];
+ byteBuffer.get(bytes);
+
+ final Message esbMessage = MessageFactory.getInstance().getMessage();
+ esbMessage.getBody().add(bytes);
+ invoker.deliverAsync(esbMessage);
+ }
+
+}
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/MessageHandler.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/MessageHandler.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/MessageHandler.java 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway.mina;
+
+import org.apache.mina.common.IoHandler;
+import org.jboss.soa.esb.client.ServiceInvoker;
+
+/**
+ * A Message handler is responsible for recieving the MINA message and packaging
+ * the message payload into a ESB Message object, and dispatching to the target
+ * service in the ESB.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public interface MessageHandler extends IoHandler {
+
+ /**
+ * Set the {@link ServiceInoker} instance to be used
+ * to dispatch messages to the ESB Service
+ *
+ * @param invoker The ServiceInvoker instance.
+ */
+ void setServiceInvoker(final ServiceInvoker invoker);
+}
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayConfig.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayConfig.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayConfig.java 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,183 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.mina;
+
+import java.net.InetSocketAddress;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.util.ClassUtil;
+
+/**
+ * Deals with UDP configuration properties and parsing.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class UdpGatewayConfig
+{
+ /**
+ * Host name configuration attribute name.
+ */
+ public static final String HOST_ATTR = "host";
+
+ /**
+ * Port configuration attribute name.
+ */
+ public static final String PORT_ATTR = "port";
+
+ /**
+ * Handler class configuration attribute name.
+ */
+ public static final String HANDLER_CLASS_ATTR = "handlerClass";
+
+ /**
+ * ConfigTree with contains the elements and attributes from the
+ * configuration file.
+ */
+ private final ConfigTree config;
+
+ /**
+ * Sole constructor.
+ *
+ * @param config
+ * The {@link ConfigTree} that contains the configuration
+ * information.
+ */
+ public UdpGatewayConfig(final ConfigTree config)
+ {
+ AssertArgument.isNotNull(config, "config");
+ this.config = config;
+ }
+
+ /**
+ * Gets the port from the configuration.
+ *
+ * @return {@code int} the port that the gateway should listen to.
+ *
+ * @throws ConfigurationException
+ * If the port was missing from the configuration or it could
+ * not be parse as an int.
+ */
+ public int getPort() throws ConfigurationException
+ {
+ return parsePort(config.getRequiredAttribute(PORT_ATTR));
+ }
+
+ /**
+ * Gets the {@link InetSocketAddress} that this gateway should listen to.
+ *
+ * @return {@code InetSocketAddress} the {@link InetSocketAddress} that the
+ * gateway should listen to.
+ *
+ * @throws ConfigurationException
+ * If the host or port was missing from the configuration or if
+ * the port could not be parsed.
+ */
+ public InetSocketAddress getSocketAddress() throws ConfigurationException
+ {
+ return new InetSocketAddress(config.getRequiredAttribute(HOST_ATTR), getPort());
+ }
+
+ /**
+ * Gets the target service category from the configuration.
+ *
+ * @return {@code String} The target service category
+ *
+ * @throws ConfigurationException
+ * If service category attribute is missing from the
+ * configuration.
+ */
+ public String getServiceCategory() throws ConfigurationException
+ {
+ return config.getRequiredAttribute(ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG);
+ }
+
+ /**
+ * Gets the target service name from the configuration.
+ *
+ * @return {@code String} The target service name
+ *
+ * @throws ConfigurationException
+ * If service name attribute is missing from the configuration.
+ */
+ public String getServiceName() throws ConfigurationException
+ {
+ return config.getRequiredAttribute(ListenerTagNames.TARGET_SERVICE_NAME_TAG);
+ }
+
+ /**
+ * Get the configured {@link MessageHandler} instance. <p/> Defaults to
+ * {@link DefaultMessageHandler}.
+ *
+ * @param config
+ * The listener configuration.
+ * @return The MessageHandler implementation.
+ * @throws ConfigurationException
+ * Unable to create the configured {@link MessageHandler}
+ * instance.
+ */
+ public MessageHandler getHandler() throws ConfigurationException
+ {
+ String handlerClass = config.getRequiredAttribute(HANDLER_CLASS_ATTR);
+ try
+ {
+ return (MessageHandler) ClassUtil.forName(handlerClass, getClass()).newInstance();
+ }
+ catch (final ClassCastException e)
+ {
+ throw new ConfigurationException("Class '" + handlerClass + "' must implement '" + MessageHandler.class.getName() + "'.");
+ }
+ catch (final InstantiationException e)
+ {
+ throw new ConfigurationException("Failed to create an instance of MessagHandler implementation '" + handlerClass + "'.", e);
+ }
+ catch (final IllegalAccessException e)
+ {
+ throw new ConfigurationException("Failed to create an instance of MessagHandler implementation '" + handlerClass + "'.", e);
+ }
+ catch (final ClassNotFoundException e)
+ {
+ throw new ConfigurationException("Failed to create an instance of MessagHandler implementation '" + handlerClass + "'.", e);
+ }
+ }
+
+ public static int parsePort(String portString) throws ConfigurationException
+ {
+ int parseInt;
+ try
+ {
+ parseInt = Integer.parseInt(portString);
+ } catch (final NumberFormatException e)
+ {
+ throw new ConfigurationException("port must be a postive integer. It was '" + portString + "'");
+ }
+
+ if (parseInt <= 0)
+ {
+ throw new ConfigurationException("port must be a postive integer. It was '" + portString + "'");
+ }
+ return parseInt;
+ }
+
+}
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayListener.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayListener.java 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway.mina;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import org.apache.log4j.Logger;
+import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.transport.socket.nio.DatagramAcceptor;
+import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.lifecycle.AbstractManagedLifecycle;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+
+/**
+ * UDP gateway listener implementation for receiving ESB unaware messages.
+ * <p/>
+ * This gateway will set up a netty server and listen for incoming connection request. The
+ * requests will be passed to the Netty channel pipeline configured and the last handler will
+ * invoke the target ESB service.
+ *
+ * Example configuration:
+ * <pre>{@code
+ * <listeners>
+ * <udp-listener name="udp-listener" host="localhost" port="9999" handlerClass="org.jboss.soa.esb.listeners.gateway.mina.DefaultMessageHandler" is-gateway="true"/>
+ * </listeners>
+ * }</pre>
+ * <lu>
+ * <li>{@code host} the host to listen to.</li>
+ * <li>{@code port} the port to listen on.</li>
+ * <li>{@code handlerClass} A class that implemtents {@link MessageHandler}. If not specified will default to {@link DefaultMessageHandler}.</li>
+ * <li>{@code is-gateway} is always true as udp cannot be used as a bus transport at the moment.</li>
+ * </lu>
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class UdpGatewayListener extends AbstractManagedLifecycle
+{
+ /**
+ * Serial version unique identifier.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Class Logger instance.
+ */
+ private Logger log = Logger.getLogger(UdpGatewayListener.class);
+
+ /**
+ * The local address this gateway listeners to.
+ */
+ private InetSocketAddress socketAddress;
+
+ /**
+ * MINA IoAcceptor.
+ */
+ private IoAcceptor datagramAcceptor;
+
+ /**
+ * The target service category that this gateway should dispatch to.
+ */
+ private String serviceCategory;
+
+ /**
+ * The target service name that this gateway should dispatch to.
+ */
+ private String serviceName;
+
+ /**
+ * The {@link Channel} that this gateway is bound to.
+ */
+ private MessageHandler messageHandler;
+
+ /**
+ * Sole constructor.
+ *
+ * @param config The configuration associated with this instance. Must not be null.
+ * @throws ConfigurationException if a configuration errors during initialisation.
+ */
+ public UdpGatewayListener(final ConfigTree config) throws ConfigurationException
+ {
+ super(config);
+ final UdpGatewayConfig udpConfig = new UdpGatewayConfig(config);
+ socketAddress = udpConfig.getSocketAddress();
+ serviceCategory = udpConfig.getServiceCategory();
+ serviceName = udpConfig.getServiceName();
+ messageHandler = udpConfig.getHandler();
+ }
+
+ /**
+ * Initialize will bind to the configured host and port.
+ * This is done in initialize so that the time this takes is done upon
+ * deployment of the gateway instead of during the first call to the
+ * gateway.
+ */
+ @Override
+ protected void doInitialise() throws ManagedLifecycleException
+ {
+ final ServiceInvoker serviceInvoker = createServiceInvoker(serviceCategory, serviceName);
+ messageHandler.setServiceInvoker(serviceInvoker);
+
+ datagramAcceptor = new DatagramAcceptor();
+ ((DatagramSessionConfig) datagramAcceptor.getDefaultConfig().getSessionConfig()).setReuseAddress(true);
+
+ try
+ {
+ datagramAcceptor.bind(socketAddress, messageHandler);
+ }
+ catch (final IOException e)
+ {
+ throw new ManagedLifecycleException("IOException while trying to bind UdpListerner to '" + socketAddress + "'. Exception was:" + e);
+ }
+ log.info("Started " + toString());
+ }
+
+ /**
+ * Currently does nothing.
+ */
+ @Override
+ protected void doStart() throws ManagedLifecycleException
+ {
+ // NoOp
+ }
+
+ /**
+ * Unbinds the udp listener.
+ */
+ @Override
+ protected void doStop() throws ManagedLifecycleException
+ {
+ if(socketAddress != null)
+ {
+ datagramAcceptor.unbind(socketAddress);
+ }
+ log.info("Stopped " + toString());
+ }
+
+ /**
+ * Currently does nothing.
+ */
+ @Override
+ protected void doDestroy() throws ManagedLifecycleException
+ {
+ // NoOp
+ }
+
+ /**
+ * Returns a string representation in the form:
+ *
+ * [UdpGatewayListener] Started UdpGatewayListener [address=localhost/127.0.0.1:9999,
+ * targetService=UdpServiceCategory:Service1,
+ * messageHandler=org.jboss.soa.esb.listeners.gateway.mina.DefaultMessageHandler at 3c205c]
+ *
+ *
+ * @return String A string representation of this instance.
+ */
+ @Override
+ public String toString()
+ {
+ return "UdpGatewayListener [address=" + socketAddress + ", targetService=" + serviceCategory + ":" + serviceName + ", messageHandler=" + messageHandler + "]";
+ }
+
+ /**
+ * Creates a new ServiceInvoker using the serviceCategory and serviceName.
+ *
+ * @param serviceCategory The service category.
+ * @param serviceName The service name.
+ * @return ServiceInvoker The newly created {@link ServiceInvoker}.
+ *
+ * @throws ManagedLifecycleException If the service invoker could not be created.
+ */
+ private ServiceInvoker createServiceInvoker(final String serviceCategory, final String serviceName) throws ManagedLifecycleException
+ {
+ try
+ {
+ return new ServiceInvoker(serviceCategory, serviceName);
+ }
+ catch (MessageDeliverException e)
+ {
+ throw new ManagedLifecycleException(e.getMessage(), e);
+ }
+ }
+}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java 2009-01-22 06:50:52 UTC (rev 24863)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java 2009-01-22 07:12:41 UTC (rev 24864)
@@ -38,10 +38,17 @@
public boolean deliveryAttempted = false;
public CourierException courierException;
public MalformedEPRException malformedEPRException;
+ private boolean setPickupMessage;
public MockCourier(boolean deliveryResult) {
this.deliveryResult = deliveryResult;
}
+
+ public MockCourier(boolean deliveryResult, boolean setPickupMessage) {
+ this.deliveryResult = deliveryResult;
+ this.setPickupMessage = setPickupMessage;
+
+ }
public MockCourier(CourierException courierException) {
this.courierException = courierException;
@@ -65,6 +72,11 @@
this.message = message;
}
+ if (setPickupMessage)
+ {
+ pickupMessage = message;
+ }
+
return deliveryResult;
}
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayListenerUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/mina/UdpGatewayListenerUnitTest.java 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.mina;
+
+import static org.jboss.soa.esb.listeners.gateway.mina.UdpGatewayConfig.HANDLER_CLASS_ATTR;
+import static org.jboss.soa.esb.listeners.gateway.mina.UdpGatewayConfig.HOST_ATTR;
+import static org.jboss.soa.esb.listeners.gateway.mina.UdpGatewayConfig.PORT_ATTR;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.commons.net.echo.EchoUDPClient;
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.gateway.mina.DefaultMessageHandler;
+import org.jboss.soa.esb.listeners.gateway.mina.UdpGatewayListener;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link UdpGatewayListener}. </p>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class UdpGatewayListenerUnitTest
+{
+ private static final String SERVICE_CATEGORY = "TestCategory";
+ private static final String SERVICE_NAME = "TestService";
+ private static final String HOST = "localhost";
+ private static final String handlerName = DefaultMessageHandler.class.getName();
+ private static final int PORT = 9688;
+
+ private MockCourier mockCourier;
+
+ @Test (expected = ConfigurationException.class)
+ public void nullHost() throws ConfigurationException, ManagedLifecycleException
+ {
+ final ConfigTree config = createConfig(null, PORT, handlerName, SERVICE_CATEGORY, SERVICE_NAME);
+ new UdpGatewayListener(config).initialise();
+ }
+
+ @Test (expected = ConfigurationException.class)
+ public void nullHanlderClass() throws ConfigurationException, ManagedLifecycleException
+ {
+ final ConfigTree config = createConfig(null, PORT, null, SERVICE_CATEGORY, SERVICE_NAME);
+ new UdpGatewayListener(config).initialise();
+ }
+
+ @Test (expected = ConfigurationException.class)
+ public void nullServiceCategory() throws ConfigurationException, ManagedLifecycleException
+ {
+ final ConfigTree config = createConfig(null, PORT, handlerName, null, SERVICE_NAME);
+ new UdpGatewayListener(config).initialise();
+ }
+
+ @Test (expected = ConfigurationException.class)
+ public void nullServiceName() throws ConfigurationException, ManagedLifecycleException
+ {
+ final ConfigTree config = createConfig(null, PORT, handlerName, SERVICE_CATEGORY, null);
+ new UdpGatewayListener(config).initialise();
+ }
+
+ @Test
+ public void async() throws ConfigurationException, ManagedLifecycleException, InterruptedException, URISyntaxException, UnknownHostException, IOException
+ {
+ final ConfigTree config = createConfig(HOST, PORT, handlerName, SERVICE_CATEGORY, SERVICE_NAME);
+ UdpGatewayListener gateway = new UdpGatewayListener(config);
+ gateway.initialise();
+
+ final String payload = "Some content";
+
+ sendUdpString(payload, HOST, PORT);
+
+ Thread.sleep(1000l);
+
+ Object object = mockCourier.message.getBody().get();
+ assertTrue(object instanceof byte[]);
+ byte[] bytes = (byte[]) object;
+ assertEquals(payload, new String(bytes));
+
+ gateway.doStop();
+ }
+
+ @Before
+ public void setUp() throws Exception
+ {
+ MockCourierFactory.install();
+ MockRegistry.install();
+ mockCourier = new MockCourier(true, true);
+ MockRegistry.register(SERVICE_CATEGORY, SERVICE_NAME, new EPR(new URI("jms://localhost:8080/queue1")), mockCourier);
+ }
+
+ @After
+ public void tearDown() throws Exception
+ {
+ MockRegistry.uninstall();
+ MockCourierFactory.uninstall();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(UdpGatewayListenerUnitTest.class);
+ }
+
+ private ConfigTree createConfig(final String host, final int port, final String handlerName, final String categoryName, final String serviceName)
+ {
+ final ConfigTree config = new ConfigTree("NettyGatewayListenerUnitTest");
+ config.setAttribute(ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, categoryName);
+ config.setAttribute(ListenerTagNames.TARGET_SERVICE_NAME_TAG, serviceName);
+ config.setAttribute(HOST_ATTR, host);
+ config.setAttribute(PORT_ATTR, String.valueOf(port));
+ config.setAttribute(HANDLER_CLASS_ATTR, handlerName);
+ return config;
+ }
+
+ private void sendUdpString(final String payload, final String host, final int port) throws UnknownHostException, IOException
+ {
+ final EchoUDPClient client = new EchoUDPClient();
+ client.open();
+ try
+ {
+ final byte[] writeBuffer = payload.getBytes();
+ client.setSoTimeout(3000);
+ client.send(writeBuffer, writeBuffer.length, InetAddress.getByName(host), port);
+ }
+ finally
+ {
+ client.close();
+ }
+ }
+
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/build.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/build.xml 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,22 @@
+<project name="Quickstart_udp_gateway" default="run" basedir=".">
+
+ <description>
+ ${ant.project.name}
+ ${line.separator}
+ </description>
+
+ <!-- Import the base Ant build script... -->
+ <import file="../conf/base-build.xml"/>
+
+ <target name="runtest" depends="compile" description="sends a String smessage to the UDP gateway">
+ <echo message="Write to UDP port"/>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.udpgateway.test.UdpClient" failonerror="true">
+ <arg value="localhost"/>
+ <arg value="9999"/>
+ <arg value="UDP example payload"/>
+ <classpath refid="exec-classpath"/>
+ </java>
+ <echo/>
+ </target>
+
+</project>
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/deployment.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/deployment.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/deployment.xml 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,3 @@
+<jbossesb-deployment>
+</jbossesb-deployment>
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jboss-esb.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jboss-esb.xml 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,23 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.1.0.xsd" parameterReloadSecs="5">
+
+ <services>
+
+ <service category="UdpServiceCategory" name="Service1" description="Sample service for UdpGateway quickstart" invmScope="GLOBAL">
+
+ <listeners>
+ <udp-listener name="udp-listener" host="localhost" port="9999" is-gateway="true"/>
+ </listeners>
+
+ <actions mep="RequestResponse">
+ <action name="printMessage" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message" value="UdpServiceCategory:Service1"/>
+ <property name="printfull" value="false"/>
+ </action>
+ </actions>
+
+ </service>
+
+ </services>
+
+</jbossesb>
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jbossesb-properties.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jbossesb-properties.xml 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., and others contributors as indicated
+ by the @authors tag. All rights reserved.
+ See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+ This copyrighted material is made available to anyone wishing to use,
+ modify, copy, or redistribute it subject to the terms and conditions
+ of the GNU Lesser General Public License, v. 2.1.
+ This program is distributed in the hope that it will be useful, but WITHOUT A
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License,
+ v.2.1 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ (C) 2005-2006,
+ @author JBoss Inc.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.type" value="jboss"/>
+ <property name="org.jboss.soa.esb.jndi.server.url" value="localhost"/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ <property name="jboss.esb.invm.scope.default" value="NONE"/>
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI"
+ value="jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI"
+ value="jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish" />
+ <property name="org.jboss.soa.esb.registry.implementationClass"
+ value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass"
+ value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user"
+ value="jbossesb"/>
+ <property name="org.jboss.soa.esb.registry.password"
+ value="password"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass"
+ value="org.apache.ws.scout.transport.RMITransport"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool=size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="dbstore">
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <!-- # of milliseconds to timeout waiting for a connection from pool -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/>
+ </properties>
+ <properties name="messagerouting">
+ <property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
+ </properties>
+</esb>
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jndi.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jndi.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/jndi.properties 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,5 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+java.naming.factory.url.pkgs=org.jnp.interfaces
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/juddi.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/juddi.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/juddi.properties 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,69 @@
+# jUDDI Registry Properties (used by RegistryServer)
+# see http://www.juddi.org for more information
+
+# The UDDI Operator Name
+juddi.operatorName = jUDDI.org
+
+# The i18n locale default codes
+juddi.i18n.languageCode = en
+juddi.i18n.countryCode = US
+
+# The UDDI DiscoveryURL Prefix
+juddi.discoveryURL = http://localhost:8080/juddi/uddiget.jsp?
+
+# The UDDI Operator Contact Email Address
+juddi.operatorEmailAddress = admin at juddi.org
+
+# The maximum name size and maximum number
+# of name elements allows in several of the
+# FindXxxx and SaveXxxx UDDI functions.
+juddi.maxNameLength=255
+juddi.maxNameElementsAllowed=5
+
+# The maximum number of UDDI artifacts allowed
+# per publisher. A value of '-1' indicates any
+# number of artifacts is valid (These values can be
+# overridden at the individual publisher level).
+juddi.maxBusinessesPerPublisher=25
+juddi.maxServicesPerBusiness=20
+juddi.maxBindingsPerService=10
+juddi.maxTModelsPerPublisher=100
+
+# jUDDI Authentication module to use
+juddi.auth = org.apache.juddi.auth.DefaultAuthenticator
+
+# jUDDI DataStore module currently to use
+juddi.dataStore = org.apache.juddi.datastore.jdbc.JDBCDataStore
+
+# use a dataSource (if set to false a direct
+# jdbc connection will be used.
+juddi.isUseDataSource=false
+juddi.jdbcDriver=com.mysql.jdbc.Driver
+juddi.jdbcUrl=jdbc:mysql://localhost:3306/juddi
+juddi.jdbcUsername=root
+juddi.jdbcPassword=admin
+# jUDDI DataSource to use
+# juddi.dataSource=java:comp/env/jdbc/MySqlDS
+
+# jUDDI UUIDGen implementation to use
+juddi.uuidgen = org.apache.juddi.uuidgen.DefaultUUIDGen
+
+# jUDDI Cryptor implementation to use
+juddi.cryptor = org.apache.juddi.cryptor.DefaultCryptor
+
+# jUDDI Validator to use
+juddi.validator=org.apache.juddi.validator.DefaultValidator
+
+# jUDDI Proxy Properties (used by RegistryProxy)
+juddi.proxy.adminURL = http://localhost:8080/juddi/admin
+juddi.proxy.inquiryURL = http://localhost:8080/juddi/inquiry
+juddi.proxy.publishURL = http://localhost:8080/juddi/publish
+juddi.proxy.transportClass = org.apache.juddi.proxy.AxisTransport
+juddi.proxy.securityProvider = com.sun.net.ssl.internal.ssl.Provider
+juddi.proxy.protocolHandler = com.sun.net.ssl.internal.www.protocol
+
+# JNDI settings (used by RMITransport)
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/log4j.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/log4j.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/log4j.xml 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A size based file rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="./listener.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%t][%c] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="WARN"/>
+ </category>
+ <category name="org.jboss.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.jboss.internal.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.apache">
+ <priority value="ERROR"/>
+ </category>
+ <category name="quickstart">
+ <priority value="INFO"/>
+ </category>
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/readme.txt (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/readme.txt 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,17 @@
+Overview:
+=========
+ The purpose of the udp_gateway quickstart example is to demonstrate
+ how a message sent with UDP can be passed to JBossESB.
+
+Running this quickstart:
+========================
+ Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
+ and a more detailed descripton of the different ways to run the quickstarts.
+
+To Run '.esb' archive mode:
+===========================
+ 1. In a command terminal window in this folder ("Window1"), type 'ant deploy'.
+ 2. Switch back to Application Server console to see the output from the ESB
+ 3. The Message Injection Console will pop up automatically, enter some text and hit Send.
+ 4. In this folder ("Window1"), type 'ant undeploy'.
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/scripts/MessageInjectionConsole.groovy
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/scripts/MessageInjectionConsole.groovy (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/scripts/MessageInjectionConsole.groovy 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+import groovy.swing.SwingBuilder
+import java.awt.*
+
+/**
+ * Simple Groovy Gateway script that starts a Swing form through which you can
+ * inject messages into the target service. Useful for testing and prototyping.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+
+def targetService = "Target Service: " + deliveryAdapter.getDeliveryAdapter().getServiceCategory() + ":" + deliveryAdapter.getDeliveryAdapter().getServiceName()
+def numRows = 7
+def numCols = 50
+
+swing = new SwingBuilder()
+sendMessage = swing.action(name:'SendMessage', closure:this.&sendMessageToTarget, mnemonic:'R')
+
+frame = swing.frame(title:'Message Injection Console', size:[600,400], location:[200,200]) {
+ panel(layout:new BorderLayout()) {
+ panel(layout:new BorderLayout(), constraints: BorderLayout.NORTH) {
+ label(text: targetService, constraints: BorderLayout.NORTH)
+ label(text: 'Message In:', constraints: BorderLayout.WEST)
+ textArea(id:'messageInTB', columns: numCols, rows: numRows, constraints: BorderLayout.EAST)
+ }
+ panel(layout:new FlowLayout()) {
+ button(text: 'Send Message', action:sendMessage)
+ comboBox(id: 'synchasync', items:["Asynchronous", "Synchronous"], selectedIndex:0);
+ }
+ panel(layout:new BorderLayout(), constraints: BorderLayout.SOUTH) {
+ label(text: 'Message Out:', constraints: BorderLayout.WEST)
+ textArea(id: 'messageOutTB', columns: numCols, rows: numRows, constraints: BorderLayout.EAST)
+ }
+ }
+}
+frame.pack()
+frame.show()
+
+def sendMessageToTarget(event) {
+ swing.messageOutTB.text = ""
+ if(swing.synchasync.selectedIndex == 0) {
+ deliveryAdapter.deliverAsync(swing.messageInTB.text)
+ } else {
+ swing.messageOutTB.text = deliveryAdapter.deliverSync(swing.messageInTB.text, 20000)
+ }
+}
+
+// Wait until the gateway is told to shutdown....
+while(!gateway.waitUntilStopping(500)) {
+}
+
+frame.dispose()
\ No newline at end of file
Added: labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/esb/samples/quickstart/udpgateway/test/UdpClient.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/esb/samples/quickstart/udpgateway/test/UdpClient.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/udp_gateway/src/org/jboss/soa/esb/samples/quickstart/udpgateway/test/UdpClient.java 2009-01-22 07:12:41 UTC (rev 24864)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.udpgateway.test;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import org.apache.commons.net.echo.EchoUDPClient;
+import java.net.InetAddress;
+
+public class UdpClient
+{
+ public static void main(String... args)
+ {
+ final String host = args[0];
+ final int port = Integer.parseInt(args[1]);
+ final String payload = args[2];
+
+ try
+ {
+ sendUdpString(payload, host, port);
+ }
+ catch (final UnknownHostException e)
+ {
+ e.printStackTrace();
+ }
+ catch (final IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private static void sendUdpString(final String payload, final String host, final int port) throws UnknownHostException, IOException
+ {
+ final EchoUDPClient client = new EchoUDPClient();
+ client.open();
+ try
+ {
+ final byte[] writeBuffer = payload.getBytes();
+ client.setSoTimeout(3000);
+ client.send(writeBuffer, writeBuffer.length, InetAddress.getByName(host), port);
+ }
+ finally
+ {
+ client.close();
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list