Author: bill.burke(a)jboss.com
Date: 2010-08-31 12:29:21 -0400 (Tue, 31 Aug 2010)
New Revision: 9619
Added:
trunk/src/Hornetq.iml
trunk/src/main/org/hornetq/core/registry/
trunk/src/main/org/hornetq/core/registry/JndiBindingRegistry.java
trunk/src/main/org/hornetq/core/registry/MapBindingRegistry.java
trunk/src/main/org/hornetq/core/server/embedded/
trunk/src/main/org/hornetq/core/server/embedded/EmbeddedHornetQ.java
trunk/src/main/org/hornetq/integration/spring/
trunk/src/main/org/hornetq/integration/spring/SpringBindingRegistry.java
trunk/src/main/org/hornetq/integration/spring/SpringJmsBootstrap.java
trunk/src/main/org/hornetq/jms/server/embedded/
trunk/src/main/org/hornetq/jms/server/embedded/EmbeddedJMS.java
trunk/src/main/org/hornetq/spi/BindingRegistry.java
trunk/tests/config/spring-hornetq-config.xml
trunk/tests/config/spring-hornetq-jms.xml
trunk/tests/config/spring-jms-beans.xml
trunk/tests/jms-tests/Jms-tests.iml
trunk/tests/src/org/hornetq/tests/integration/spring/
trunk/tests/src/org/hornetq/tests/integration/spring/ExampleListener.java
trunk/tests/src/org/hornetq/tests/integration/spring/MessageSender.java
trunk/tests/src/org/hornetq/tests/integration/spring/SpringIntegrationTest.java
Modified:
trunk/build-hornetq.xml
trunk/build.xml
trunk/pom.xml
trunk/src/main/org/hornetq/jms/server/JMSServerManager.java
trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
Log:
BindingRegistry and Spring Integration
Modified: trunk/build-hornetq.xml
===================================================================
--- trunk/build-hornetq.xml 2010-08-31 16:09:43 UTC (rev 9618)
+++ trunk/build-hornetq.xml 2010-08-31 16:29:21 UTC (rev 9619)
@@ -65,6 +65,8 @@
<property name="jnp.client.jar.name"
value="jnp-client.jar"/>
<property name="jboss.integration.jar.name"
value="hornetq-jboss-as-integration.jar"/>
<property name="jboss.integration.sources.jar.name"
value="hornetq-jboss-as-integration-sources.jar"/>
+ <property name="spring.integration.jar.name"
value="hornetq-spring-integration.jar"/>
+ <property name="spring.integration.sources.jar.name"
value="hornetq-spring-integration-sources.jar"/>
<property name="twitter.integration.jar.name"
value="hornetq-twitter-integration.jar"/>
<property name="twitter.integration.sources.jar.name"
value="hornetq-twitter-integration-sources.jar"/>
<property name="bootstrap.jar.name"
value="hornetq-bootstrap.jar"/>
@@ -94,6 +96,7 @@
<property name="build.jms.classes.dir"
value="${build.dir}/classes/jms"/>
<property name="build.jms.java5.classes.dir"
value="${build.dir}/classes/jms-java5"/>
<property name="build.jboss.integration.classes.dir"
value="${build.dir}/classes/jboss-integration"/>
+ <property name="build.spring.integration.classes.dir"
value="${build.dir}/classes/spring-integration"/>
<property name="build.twitter.integration.classes.dir"
value="${build.dir}/classes/twitter-integration"/>
<property name="build.service.classes.dir"
value="${build.dir}/classes/service"/>
<property name="build.bootstrap.classes.dir"
value="${build.dir}/classes/bootstrap"/>
@@ -218,6 +221,13 @@
<path refid="org.twitter4j.classpath"/>
</path>
+ <path id="spring.integration.compilation.classpath">
+ <path location="${build.core.classes.dir}"/>
+ <path location="${build.jms.classes.dir}"/>
+ <path refid="org.jboss.javaee.classpath"/>
+ <path refid="org.springframework.classpath"/>
+ </path>
+
<path id="jboss.service.compilation.classpath">
<path refid="org.jboss.javaee.classpath"/>
<path location="${build.core.classes.dir}"/>
@@ -247,11 +257,13 @@
<path refid="bootstrap.compilation.classpath"/>
<path refid="junit.junit.classpath"/>
<path refid="org.twitter4j.classpath"/>
+ <path refid="org.springframework.classpath"/>
<path location="${build.jars.dir}/${ra.jar.name}"/>
<path location="${build.jars.dir}/${jms.jar.name}"/>
<path location="${build.jars.dir}/${jboss.integration.jar.name}"/>
<path location="${build.jars.dir}/${bootstrap.jar.name}"/>
<path location="${build.jars.dir}/${logging.jar.name}"/>
+ <path
location="${build.jars.dir}/${spring.integration.jar.name}"/>
<path
location="${build.jars.dir}/${twitter.integration.jar.name}"/>
</path>
@@ -305,6 +317,7 @@
<!-- we must include Apache commons logging -->
<!-- as a transitive dependency from JBoss TM -->
<path refid="apache.logging.classpath"/>
+ <path refid="org.springframework.classpath"/>
<path refid="org.twitter4j.classpath"/>
</path>
@@ -382,6 +395,7 @@
<mkdir dir="${build.jms.classes.dir}"/>
<mkdir dir="${build.jms.java5.classes.dir}"/>
<mkdir dir="${build.jboss.integration.classes.dir}"/>
+ <mkdir dir="${build.spring.integration.classes.dir}"/>
<mkdir dir="${build.twitter.integration.classes.dir}"/>
<mkdir dir="${build.service.classes.dir}"/>
<mkdir dir="${build.bootstrap.classes.dir}"/>
@@ -580,6 +594,26 @@
</javac>
</target>
+ <target name="compile-spring-integration"
depends="compile-core">
+ <javac destdir="${build.spring.integration.classes.dir}"
+ target="${javac.target}"
+ source="${javac.source}"
+ optimize="${javac.optimize}"
+ debug="${javac.debug}"
+ depend="${javac.depend}"
+ verbose="${javac.verbose}"
+ deprecation="${javac.deprecation}"
+ includeAntRuntime="${javac.include.ant.runtime}"
+ includeJavaRuntime="${javac.include.java.runtime}"
+ failonerror="${javac.fail.onerror}">
+ <src>
+ <pathelement path="${src.main.dir}"/>
+ </src>
+ <include name="org/hornetq/integration/spring/**/*.java"/>
+ <classpath refid="spring.integration.compilation.classpath"/>
+ </javac>
+ </target>
+
<!-- author: Lucas Amador -->
<target name="compile-jboss-service"
depends="compile-core">
<javac destdir="${build.service.classes.dir}"
@@ -720,11 +754,11 @@
<!--
========================================================================================
-->
<target name="sources-jar" description="create jar files containing
source code"
- depends="jar-core-sources, jar-core-client-sources,
jar-core-client-java5-sources, jar-jms-sources, jar-jms-client-sources,
jar-jms-client-java5-sources, jar-jboss-integration-sources, jar-jboss-service-sources,
jar-bootstrap-sources, jar-logging-sources, jar-ra-sources, jar-resources-sources,
jar-twitter-integration-sources">
+ depends="jar-core-sources, jar-core-client-sources,
jar-core-client-java5-sources, jar-jms-sources, jar-jms-client-sources,
jar-jms-client-java5-sources, jar-jboss-integration-sources, jar-jboss-service-sources,
jar-bootstrap-sources, jar-logging-sources, jar-ra-sources, jar-resources-sources,
jar-twitter-integration-sources, jar-spring-integration-sources">
</target>
<target name="jar"
- depends="jar-core, jar-core-client, jar-core-client-java5, jar-jms,
jar-jms-client, jar-jms-client-java5, jar-jboss-integration, jar-jboss-service,
jar-bootstrap, jar-logging, jar-ra, jar-mc, jar-jnp-client, jar-resources, sources-jar,
jar-twitter-integration">
+ depends="jar-core, jar-core-client, jar-core-client-java5, jar-jms,
jar-jms-client, jar-jms-client-java5, jar-jboss-integration, jar-jboss-service,
jar-bootstrap, jar-logging, jar-ra, jar-mc, jar-jnp-client, jar-resources, sources-jar,
jar-twitter-integration, jar-spring-integration">
</target>
<target name="jar-jnp-client" depends="init">
@@ -884,6 +918,22 @@
</jar>
</target>
+ <target name="jar-spring-integration"
depends="compile-spring-integration">
+
+ <jar jarfile="${build.jars.dir}/${spring.integration.jar.name}">
+ <fileset dir="${build.spring.integration.classes.dir}"
includes="**"/>
+ </jar>
+
+ </target>
+
+ <target name="jar-spring-integration-sources">
+ <jar
jarfile="${build.jars.dir}/${spring.integration.sources.jar.name}">
+ <fileset dir="${src.main.dir}">
+ <include name="org/hornetq/integration/spring/**/*.java"/>
+ </fileset>
+ </jar>
+ </target>
+
<!-- author: Lucas Amador -->
<target name="jar-jboss-service"
depends="compile-jboss-service">
@@ -1148,6 +1198,7 @@
<include name="${jms.client.jar.name}"/>
<include name="${jms.client.java5.jar.name}"/>
<include name="${jnp.client.jar.name}"/>
+ <include name="${spring.integration.jar.name}"/>
<include name="${twitter.integration.jar.name}"/>
</fileset>
<fileset dir="${org.jboss.naming.lib}">
@@ -1490,6 +1541,12 @@
</antcall>
</target>
+ <target name="spring-tests" depends="jar,
compile-unit-tests">
+ <antcall inheritall="true" inheritrefs="true"
target="tests">
+ <param name="tests.param"
value="**/org/hornetq/tests/integration/spring/*${test-mask}.class"/>
+ </antcall>
+ </target>
+
<target name="failover-tests" depends="jar,
compile-unit-tests">
<antcall inheritall="true" inheritrefs="true"
target="tests">
<param name="tests.param"
value="**/org/hornetq/tests/integration/cluster/failover/**/*${test-mask}.class"/>
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2010-08-31 16:09:43 UTC (rev 9618)
+++ trunk/build.xml 2010-08-31 16:29:21 UTC (rev 9619)
@@ -243,7 +243,12 @@
<ant antfile="build-hornetq.xml"
target="compile-reports"/>
</target>
+ <target name="spring-tests" depends="createthirdparty">
+ <ant antfile="build-hornetq.xml" target="spring-tests"/>
+ <ant antfile="build-hornetq.xml"
target="compile-reports"/>
+ </target>
+
<target name="failover-tests" depends="createthirdparty">
<ant antfile="build-hornetq.xml" target="failover-tests"/>
<ant antfile="build-hornetq.xml"
target="compile-reports"/>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-08-31 16:09:43 UTC (rev 9618)
+++ trunk/pom.xml 2010-08-31 16:29:21 UTC (rev 9619)
@@ -284,6 +284,27 @@
<artifactId>apiviz</artifactId>
<version>1.3.0.GA</version>
</dependency>
+ <!-- needed for spring integration -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>3.0.3.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.0.3.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.0.3.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jms</artifactId>
+ <version>3.0.3.RELEASE</version>
+ </dependency>
</dependencies>
Added: trunk/src/Hornetq.iml
===================================================================
--- trunk/src/Hornetq.iml (rev 0)
+++ trunk/src/Hornetq.iml 2010-08-31 16:29:21 UTC (rev 9619)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager"
inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/main"
isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../thirdparty/org/twitter4j/lib/twitter4j-core.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="lib7"
level="project" />
+ <orderEntry type="library" name="lib4"
level="project" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../thirdparty/org/jboss/netty/lib/netty.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="lib2"
level="project" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../thirdparty/org/jboss/integration/lib/jboss-transaction-spi.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="lib3"
level="project" />
+ <orderEntry type="library" name="lib6"
level="project" />
+ <orderEntry type="library" name="jars"
level="project" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../thirdparty/org/jboss/metadata/lib/jboss-metadata.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../tools/maven/lib/maven-2.0.9-uber.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="lib1"
level="project" />
+ <orderEntry type="library" name="lib9"
level="project" />
+ <orderEntry type="library" name="lib-spring"
level="project" />
+ </component>
+</module>
+
Added: trunk/src/main/org/hornetq/core/registry/JndiBindingRegistry.java
===================================================================
--- trunk/src/main/org/hornetq/core/registry/JndiBindingRegistry.java
(rev 0)
+++ trunk/src/main/org/hornetq/core/registry/JndiBindingRegistry.java 2010-08-31 16:29:21
UTC (rev 9619)
@@ -0,0 +1,108 @@
+package org.hornetq.core.registry;
+
+import org.hornetq.spi.BindingRegistry;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class JndiBindingRegistry implements BindingRegistry
+{
+ private Context context;
+
+ public JndiBindingRegistry(Context context)
+ {
+ this.context = context;
+ }
+
+ public JndiBindingRegistry() throws Exception
+ {
+ this.context = new InitialContext();
+ }
+
+ public Object lookup(String name)
+ {
+ try
+ {
+ return context.lookup(name);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public boolean bind(String name, Object obj)
+ {
+ try
+ {
+ return bindToJndi(name, obj);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void unbind(String name)
+ {
+ try
+ {
+ context.unbind(name);
+ }
+ catch (NamingException e)
+ {
+ }
+ }
+
+ public void close()
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException e)
+ {
+ }
+ }
+
+
+ private boolean bindToJndi(final String jndiName, final Object objectToBind) throws
NamingException
+ {
+ if (context != null)
+ {
+ String parentContext;
+ String jndiNameInContext;
+ int sepIndex = jndiName.lastIndexOf('/');
+ if (sepIndex == -1)
+ {
+ parentContext = "";
+ }
+ else
+ {
+ parentContext = jndiName.substring(0, sepIndex);
+ }
+ jndiNameInContext = jndiName.substring(sepIndex + 1);
+ try
+ {
+ context.lookup(jndiName);
+
+ //JMSServerManagerImpl.log.warn("Binding for " + jndiName + "
already exists");
+ return false;
+ }
+ catch (Throwable e)
+ {
+ // OK
+ }
+
+ Context c = org.hornetq.utils.JNDIUtil.createContext(context, parentContext);
+
+ c.rebind(jndiNameInContext, objectToBind);
+ }
+ return true;
+ }
+}
Added: trunk/src/main/org/hornetq/core/registry/MapBindingRegistry.java
===================================================================
--- trunk/src/main/org/hornetq/core/registry/MapBindingRegistry.java
(rev 0)
+++ trunk/src/main/org/hornetq/core/registry/MapBindingRegistry.java 2010-08-31 16:29:21
UTC (rev 9619)
@@ -0,0 +1,32 @@
+package org.hornetq.core.registry;
+
+import org.hornetq.spi.BindingRegistry;
+import org.jboss.netty.util.internal.ConcurrentHashMap;
+
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class MapBindingRegistry implements BindingRegistry
+{
+ protected ConcurrentHashMap<String, Object> registry = new
ConcurrentHashMap<String, Object>();
+
+ public Object lookup(String name)
+ {
+ return registry.get(name);
+ }
+
+ public boolean bind(String name, Object obj)
+ {
+ return registry.putIfAbsent(name, obj) == null;
+ }
+
+ public void unbind(String name)
+ {
+ registry.remove(name);
+ }
+
+ public void close()
+ {
+ }
+}
Added: trunk/src/main/org/hornetq/core/server/embedded/EmbeddedHornetQ.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/embedded/EmbeddedHornetQ.java
(rev 0)
+++ trunk/src/main/org/hornetq/core/server/embedded/EmbeddedHornetQ.java 2010-08-31
16:29:21 UTC (rev 9619)
@@ -0,0 +1,87 @@
+package org.hornetq.core.server.embedded;
+
+import org.hornetq.core.config.impl.FileConfiguration;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.impl.HornetQServerImpl;
+import org.hornetq.spi.core.security.HornetQSecurityManager;
+import org.hornetq.spi.core.security.HornetQSecurityManagerImpl;
+
+import javax.management.MBeanServer;
+
+/**
+ * Helper class to simplify bootstrap of HornetQ server. Bootstraps from classpath-based
config files.
+ *
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class EmbeddedHornetQ
+{
+ protected HornetQSecurityManager securityManager;
+ protected FileConfiguration configuration = new FileConfiguration();
+ protected HornetQServer hornetQServer;
+ protected MBeanServer mbeanServer;
+
+ /**
+ * Classpath resource for hornetq server config. Defaults to
'hornetq-configuration.xml'.
+ *
+ * @param filename
+ */
+ public void setConfigResourcePath(String filename)
+ {
+ configuration.setConfigurationUrl(filename);
+ }
+
+ /**
+ * Set the hornetq security manager. This defaults to
org.hornetq.spi.core.security.HornetQSecurityManagerImpl
+ *
+ * @param securityManager
+ */
+ public void setSecurityManager(HornetQSecurityManager securityManager)
+ {
+ this.securityManager = securityManager;
+ }
+
+ /**
+ * Use this mbean server to register management beans. If not set, no mbeans will be
registered.
+ *
+ * @param mbeanServer
+ */
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
+ public HornetQServer getHornetQServer()
+ {
+ return hornetQServer;
+ }
+
+ public void start() throws Exception
+ {
+ initStart();
+ hornetQServer.start();
+
+ }
+
+ protected void initStart() throws Exception
+ {
+ configuration.start();
+ if (securityManager == null)
+ {
+ securityManager = new HornetQSecurityManagerImpl();
+ }
+ if (mbeanServer == null)
+ {
+ hornetQServer = new HornetQServerImpl(configuration, securityManager);
+ }
+ else
+ {
+ hornetQServer = new HornetQServerImpl(configuration, mbeanServer,
securityManager);
+ }
+ }
+
+ public void stop() throws Exception
+ {
+ hornetQServer.stop();
+ }
+}
Added: trunk/src/main/org/hornetq/integration/spring/SpringBindingRegistry.java
===================================================================
--- trunk/src/main/org/hornetq/integration/spring/SpringBindingRegistry.java
(rev 0)
+++ trunk/src/main/org/hornetq/integration/spring/SpringBindingRegistry.java 2010-08-31
16:29:21 UTC (rev 9619)
@@ -0,0 +1,37 @@
+package org.hornetq.integration.spring;
+
+import org.hornetq.spi.BindingRegistry;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class SpringBindingRegistry implements BindingRegistry
+{
+ private ConfigurableBeanFactory factory;
+
+ public SpringBindingRegistry(ConfigurableBeanFactory factory)
+ {
+ this.factory = factory;
+ }
+
+ public Object lookup(String name)
+ {
+ return factory.getBean(name);
+ }
+
+ public boolean bind(String name, Object obj)
+ {
+ factory.registerSingleton(name, obj);
+ return true;
+ }
+
+ public void unbind(String name)
+ {
+ }
+
+ public void close()
+ {
+ }
+}
Added: trunk/src/main/org/hornetq/integration/spring/SpringJmsBootstrap.java
===================================================================
--- trunk/src/main/org/hornetq/integration/spring/SpringJmsBootstrap.java
(rev 0)
+++ trunk/src/main/org/hornetq/integration/spring/SpringJmsBootstrap.java 2010-08-31
16:29:21 UTC (rev 9619)
@@ -0,0 +1,20 @@
+package org.hornetq.integration.spring;
+
+import org.hornetq.jms.server.embedded.EmbeddedJMS;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class SpringJmsBootstrap extends EmbeddedJMS implements BeanFactoryAware
+{
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException
+ {
+ System.out.println("SpringJmsBootstrap setBeanFactory...");
+ registry = new SpringBindingRegistry((ConfigurableBeanFactory)beanFactory);
+ }
+}
Modified: trunk/src/main/org/hornetq/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/JMSServerManager.java 2010-08-31 16:09:43 UTC
(rev 9618)
+++ trunk/src/main/org/hornetq/jms/server/JMSServerManager.java 2010-08-31 16:29:21 UTC
(rev 9619)
@@ -25,6 +25,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.spi.BindingRegistry;
/**
* The JMS Management interface.
@@ -56,46 +57,46 @@
* @throws Exception
* if problems were encountered creating the queue.
*/
- boolean createQueue(boolean storeConfig, String queueName, String selectorString,
boolean durable, String ...jndi) throws Exception;
+ boolean createQueue(boolean storeConfig, String queueName, String selectorString,
boolean durable, String ...bindings) throws Exception;
- boolean addTopicToJndi(final String topicName, final String jndiBinding) throws
Exception;
+ boolean addTopicToJndi(final String topicName, final String binding) throws
Exception;
- boolean addQueueToJndi(final String queueName, final String jndiBinding) throws
Exception;
+ boolean addQueueToJndi(final String queueName, final String binding) throws
Exception;
- boolean addConnectionFactoryToJNDI(final String name, final String jndiBinding) throws
Exception;
+ boolean addConnectionFactoryToJNDI(final String name, final String binding) throws
Exception;
/**
* Creates a JMS Topic
*
* @param topicName
* the name of the topic
- * @param jndiBinding
- * the name of the binding for JNDI
+ * @param binding
+ * the name of the binding for JNDI or BindingRegistry
* @return true if the topic was created or if it existed and was added to
* JNDI
* @throws Exception
* if a problem occurred creating the topic
*/
- boolean createTopic(boolean storeConfig, String topicName, String ... jndi) throws
Exception;
+ boolean createTopic(boolean storeConfig, String topicName, String ... bindings) throws
Exception;
/**
- * Remove the topic from JNDI.
+ * Remove the topic from JNDI or BindingRegistry.
* Calling this method does <em>not</em> destroy the destination.
*
* @param name
- * the name of the destination to remove from JNDI
+ * the name of the destination to remove from JNDI or BindingRegistry
* @return true if removed
* @throws Exception
* if a problem occurred removing the destination
*/
- boolean removeTopicFromJNDI(String name, String jndi) throws Exception;
+ boolean removeTopicFromJNDI(String name, String binding) throws Exception;
/**
- * Remove the topic from JNDI.
+ * Remove the topic from JNDI or BindingRegistry.
* Calling this method does <em>not</em> destroy the destination.
*
* @param name
- * the name of the destination to remove from JNDI
+ * the name of the destination to remove from JNDI or BindingRegistry
* @return true if removed
* @throws Exception
* if a problem occurred removing the destination
@@ -103,35 +104,35 @@
boolean removeTopicFromJNDI(String name) throws Exception;
/**
- * Remove the queue from JNDI.
+ * Remove the queue from JNDI or BindingRegistry.
* Calling this method does <em>not</em> destroy the destination.
*
* @param name
- * the name of the destination to remove from JNDI
+ * the name of the destination to remove from JNDI or BindingRegistry
* @return true if removed
* @throws Exception
* if a problem occurred removing the destination
*/
- boolean removeQueueFromJNDI(String name, String jndi) throws Exception;
+ boolean removeQueueFromJNDI(String name, String binding) throws Exception;
/**
- * Remove the queue from JNDI.
+ * Remove the queue from JNDI or BindingRegistry.
* Calling this method does <em>not</em> destroy the destination.
*
* @param name
- * the name of the destination to remove from JNDI
+ * the name of the destination to remove from JNDI or BindingRegistry
* @return true if removed
* @throws Exception
* if a problem occurred removing the destination
*/
boolean removeQueueFromJNDI(String name) throws Exception;
- boolean removeConnectionFactoryFromJNDI(String name, String jndi) throws Exception;
+ boolean removeConnectionFactoryFromJNDI(String name, String binding) throws
Exception;
boolean removeConnectionFactoryFromJNDI(String name) throws Exception;
/**
- * destroys a queue and removes it from JNDI
+ * destroys a queue and removes it from JNDI or BindingRegistry
*
* @param name
* the name of the queue to destroy
@@ -148,7 +149,7 @@
String[] getJNDIOnConnectionFactory(String factoryName);
/**
- * destroys a topic and removes it from JNDI
+ * destroys a topic and removes it from JNDI or BindingRegistry
*
* @param name
* the name of the topic to destroy
@@ -158,37 +159,37 @@
*/
boolean destroyTopic(String name) throws Exception;
- void createConnectionFactory(String name, String discoveryAddress, int discoveryPort,
String ... jndiBindings) throws Exception;
+ void createConnectionFactory(String name, String discoveryAddress, int discoveryPort,
String ... bindings) throws Exception;
void createConnectionFactory(String name,
List<Pair<TransportConfiguration,
TransportConfiguration>> connectorConfigs,
- String ... jndiBindings) throws Exception;
+ String ... bindings) throws Exception;
void createConnectionFactory(String name,
TransportConfiguration liveTC,
TransportConfiguration backupTC,
- String ... jndiBindings) throws Exception;
+ String ... bindings) throws Exception;
- void createConnectionFactory(String name, TransportConfiguration liveTC, String ...
jndiBindings) throws Exception;
+ void createConnectionFactory(String name, TransportConfiguration liveTC, String ...
bindings) throws Exception;
void createConnectionFactory(String name,
String clientID,
String discoveryAddress,
int discoveryPort,
- String ... jndiBindings) throws Exception;
+ String ... bindings) throws Exception;
void createConnectionFactory(String name,
String clientID,
List<Pair<TransportConfiguration,
TransportConfiguration>> connectorConfigs,
- String ... jndiBindings) throws Exception;
+ String ... bindings) throws Exception;
void createConnectionFactory(String name,
String clientID,
TransportConfiguration liveTC,
TransportConfiguration backupTC,
- String ... jndiBindings) throws Exception;
+ String ... bindings) throws Exception;
- void createConnectionFactory(String name, String clientID, TransportConfiguration
liveTC, String ... jndiBindings) throws Exception;
+ void createConnectionFactory(String name, String clientID, TransportConfiguration
liveTC, String ... bindings) throws Exception;
void createConnectionFactory(String name,
List<Pair<TransportConfiguration,
TransportConfiguration>> connectorConfigs,
@@ -221,7 +222,7 @@
boolean failoverOnInitialConnection,
boolean failoverOnServerShutdown,
String groupId,
- String ... jndiBindings) throws Exception;
+ String ... bindings) throws Exception;
void createConnectionFactory(String name,
String localBindAdress,
@@ -258,9 +259,9 @@
boolean failoverOnInitialConnection,
boolean failoverOnServerShutdown,
String groupId,
- String ... jndiBindings) throws Exception;
+ String ... bindings) throws Exception;
- void createConnectionFactory(boolean storeConfig, ConnectionFactoryConfiguration
cfConfig, String... jndiBindings) throws Exception;
+ void createConnectionFactory(boolean storeConfig, ConnectionFactoryConfiguration
cfConfig, String... bindings) throws Exception;
/**
* destroys a connection factory.
@@ -294,4 +295,13 @@
void addSecurity(String addressMatch, Set<Role> roles);
Set<Role> getSecurity(final String addressMatch);
+
+ BindingRegistry getRegistry();
+
+ /**
+ * Set this property if you want something other than JNDI for your registry
+ *
+ * @param registry
+ */
+ void setRegistry(BindingRegistry registry);
}
Added: trunk/src/main/org/hornetq/jms/server/embedded/EmbeddedJMS.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/embedded/EmbeddedJMS.java
(rev 0)
+++ trunk/src/main/org/hornetq/jms/server/embedded/EmbeddedJMS.java 2010-08-31 16:29:21
UTC (rev 9619)
@@ -0,0 +1,77 @@
+package org.hornetq.jms.server.embedded;
+
+import org.hornetq.core.registry.MapBindingRegistry;
+import org.hornetq.core.server.embedded.EmbeddedHornetQ;
+import org.hornetq.jms.server.impl.JMSServerManagerImpl;
+import org.hornetq.spi.BindingRegistry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Simple bootstrap class that parses hornetq config files (server and jms and security)
and starts
+ * a HornetQServer instance and populates it with configured JMS endpoints.
+ *
+ * JMS Endpoints are registered with a simple MapBindingRegistry. If you want to use a
different registry
+ * you must set the registry property of this clas
+ *
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class EmbeddedJMS extends EmbeddedHornetQ
+{
+ protected JMSServerManagerImpl serverManager;
+ protected BindingRegistry registry;
+ protected String jmsConfigResourcePath;
+
+ /**
+ * Classpath resource where JMS config file is. Defaults to
'hornetq-jms.xml'
+ *
+ * @param jmsConfigResourcePath
+ */
+ public void setJmsConfigResourcePath(String jmsConfigResourcePath)
+ {
+ this.jmsConfigResourcePath = jmsConfigResourcePath;
+ }
+
+ public BindingRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(BindingRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ /**
+ * Lookup in the registry for registered object, i.e. a ConnectionFactory. This is a
convenience method.
+ *
+ * @param name
+ * @return
+ */
+ public Object lookup(String name)
+ {
+ return serverManager.getRegistry().lookup(name);
+ }
+
+ public void start() throws Exception
+ {
+ System.out.println("EmbeddedJMS starting...");
+ super.initStart();
+ if (jmsConfigResourcePath == null) serverManager = new
JMSServerManagerImpl(hornetQServer);
+ else serverManager = new JMSServerManagerImpl(hornetQServer,
jmsConfigResourcePath);
+ if (registry == null)
+ {
+ registry = new MapBindingRegistry();
+ }
+ serverManager.setRegistry(registry);
+ serverManager.start();
+ }
+
+ public void stop() throws Exception
+ {
+ serverManager.stop();
+ }
+
+}
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-08-31
16:09:43 UTC (rev 9618)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-08-31
16:29:21 UTC (rev 9619)
@@ -41,6 +41,7 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.BindingType;
+import org.hornetq.core.registry.JndiBindingRegistry;
import org.hornetq.core.security.Role;
import org.hornetq.core.server.ActivateCallback;
import org.hornetq.core.server.HornetQServer;
@@ -65,6 +66,7 @@
import org.hornetq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
import org.hornetq.jms.server.management.JMSManagementService;
import org.hornetq.jms.server.management.impl.JMSManagementServiceImpl;
+import org.hornetq.spi.BindingRegistry;
import org.hornetq.utils.TimeAndCounterIDGenerator;
/**
@@ -89,6 +91,8 @@
private static final String REJECT_FILTER = "__HQX=-1";
+ private BindingRegistry registry;
+
/**
* the context to bind to
*/
@@ -223,9 +227,10 @@
return;
}
- if (!contextSet)
+ if (registry == null)
{
- context = new InitialContext();
+ if (!contextSet) context = new InitialContext();
+ registry = new JndiBindingRegistry(context);
}
deploymentManager = new
FileDeploymentManager(server.getConfiguration().getFileDeployerScanPeriod());
@@ -286,9 +291,9 @@
topicJNDI.clear();
topics.clear();
- if (context != null)
+ if (registry != null)
{
- context.close();
+ registry.close();
}
// it could be null if a backup
@@ -311,6 +316,17 @@
// JMSServerManager implementation -------------------------------
+
+ public BindingRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(BindingRegistry registry)
+ {
+ this.registry = registry;
+ }
+
public HornetQServer getHornetQServer()
{
return server;
@@ -1300,18 +1316,11 @@
{
return false;
}
- if (context != null)
+ if (registry != null)
{
for (String jndiBinding : jndiBindings)
{
- try
- {
- context.unbind(jndiBinding);
- }
- catch (NameNotFoundException e)
- {
- // this is ok.
- }
+ registry.unbind(jndiBinding);
}
}
connectionFactoryJNDI.remove(name);
@@ -1379,35 +1388,9 @@
private boolean bindToJndi(final String jndiName, final Object objectToBind) throws
NamingException
{
- if (context != null)
+ if (registry != null)
{
- String parentContext;
- String jndiNameInContext;
- int sepIndex = jndiName.lastIndexOf('/');
- if (sepIndex == -1)
- {
- parentContext = "";
- }
- else
- {
- parentContext = jndiName.substring(0, sepIndex);
- }
- jndiNameInContext = jndiName.substring(sepIndex + 1);
- try
- {
- context.lookup(jndiName);
-
- JMSServerManagerImpl.log.warn("Binding for " + jndiName + "
already exists");
- return false;
- }
- catch (Throwable e)
- {
- // OK
- }
-
- Context c = org.hornetq.utils.JNDIUtil.createContext(context, parentContext);
-
- c.rebind(jndiNameInContext, objectToBind);
+ registry.bind(jndiName, objectToBind);
}
return true;
}
@@ -1482,20 +1465,13 @@
*/
private void unbindJNDI(Map<String, List<String>> param)
{
- if (context != null)
+ if (registry != null)
{
for (List<String> elementList : param.values())
{
for (String key : elementList)
{
- try
- {
- context.unbind(key);
- }
- catch (Exception e)
- {
- log.warn("Impossible to unbind key " + key + " from
JNDI", e);
- }
+ registry.unbind(key);
}
}
}
@@ -1621,13 +1597,13 @@
{
keys.remove(name);
}
- if (context != null)
+ if (registry != null)
{
Iterator<String> iter = jndiBindings.iterator();
while (iter.hasNext())
{
String jndiBinding = iter.next();
- context.unbind(jndiBinding);
+ registry.unbind(jndiBinding);
iter.remove();
}
}
@@ -1647,7 +1623,7 @@
if (jndiBindings.remove(jndi))
{
- context.unbind(jndi);
+ registry.unbind(jndi);
return true;
}
else
Added: trunk/src/main/org/hornetq/spi/BindingRegistry.java
===================================================================
--- trunk/src/main/org/hornetq/spi/BindingRegistry.java (rev 0)
+++ trunk/src/main/org/hornetq/spi/BindingRegistry.java 2010-08-31 16:29:21 UTC (rev
9619)
@@ -0,0 +1,15 @@
+package org.hornetq.spi;
+
+/**
+ * Abstract interface for a registry to store endpoints like connection factories into.
+ *
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public interface BindingRegistry
+{
+ Object lookup(String name);
+ boolean bind(String name, Object obj);
+ void unbind(String name);
+ void close();
+}
Added: trunk/tests/config/spring-hornetq-config.xml
===================================================================
--- trunk/tests/config/spring-hornetq-config.xml (rev 0)
+++ trunk/tests/config/spring-hornetq-config.xml 2010-08-31 16:29:21 UTC (rev 9619)
@@ -0,0 +1,34 @@
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq
/schema/hornetq-configuration.xsd">
+
+ <persistence-enabled>false</persistence-enabled>
+ <security-enabled>false</security-enabled>
+ <!-- Connectors -->
+
+ <connectors>
+ <connector name="in-vm">
+
<factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+ </connector>
+ </connectors>
+
+ <acceptors>
+ <acceptor name="in-vm">
+
<factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+ </acceptor>
+ </acceptors>
+
+ <!-- Other config -->
+ <!--
+ <security-settings>
+ <security-setting match="#">
+ <permission type="createDurableQueue"
roles="guest"/>
+ <permission type="deleteDurableQueue"
roles="guest"/>
+ <permission type="createNonDurableQueue"
roles="guest"/>
+ <permission type="deleteNonDurableQueue"
roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings> -->
+
+</configuration>
Added: trunk/tests/config/spring-hornetq-jms.xml
===================================================================
--- trunk/tests/config/spring-hornetq-jms.xml (rev 0)
+++ trunk/tests/config/spring-hornetq-jms.xml 2010-08-31 16:29:21 UTC (rev 9619)
@@ -0,0 +1,19 @@
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="in-vm"/>
+ </connectors>
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="exampleQueue">
+ <entry name="/queue/exampleQueue"/>
+ </queue>
+
+</configuration>
Added: trunk/tests/config/spring-jms-beans.xml
===================================================================
--- trunk/tests/config/spring-jms-beans.xml (rev 0)
+++ trunk/tests/config/spring-jms-beans.xml 2010-08-31 16:29:21 UTC (rev 9619)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans
xmlns="http://www.springframework.org/schema/beans"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.springframework.org/schema/beans
+
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+ <bean id="EmbeddedJms"
class="org.hornetq.integration.spring.SpringJmsBootstrap"
init-method="start">
+ <property name="configResourcePath"
value="spring-hornetq-config.xml"/>
+ <property name="jmsConfigResourcePath"
value="spring-hornetq-jms.xml"/>
+ </bean>
+
+ <bean id="listener"
class="org.hornetq.tests.integration.spring.ExampleListener"/>
+
+ <bean id="MessageSender"
class="org.hornetq.tests.integration.spring.MessageSender">
+ <property name="connectionFactory"
ref="ConnectionFactory"/>
+ <property name="destination"
ref="/queue/exampleQueue"/>
+ </bean>
+
+ <bean id="listenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
+ <property name="connectionFactory"
ref="ConnectionFactory"/>
+ <property name="destination"
ref="/queue/exampleQueue"/>
+ <property name="messageListener" ref="listener"/>
+ </bean>
+
+
+</beans>
+
\ No newline at end of file
Added: trunk/tests/jms-tests/Jms-tests.iml
===================================================================
--- trunk/tests/jms-tests/Jms-tests.iml (rev 0)
+++ trunk/tests/jms-tests/Jms-tests.iml 2010-08-31 16:29:21 UTC (rev 9619)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager"
inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src"
isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../thirdparty/org/jboss/naming/lib/jnpserver.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="lib7"
level="project" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../thirdparty/org/jboss/metadata/lib/jboss-metadata.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="jars"
level="project" />
+ <orderEntry type="library" name="lib4"
level="project" />
+ <orderEntry type="library" name="lib"
level="project" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../thirdparty/junit/lib/junit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../thirdparty/org/jboss/integration/lib/jboss-transaction-spi.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="lib2"
level="project" />
+ <orderEntry type="library" name="lib6"
level="project" />
+ <orderEntry type="module" module-name="Hornetq" />
+ </component>
+</module>
+
Added: trunk/tests/src/org/hornetq/tests/integration/spring/ExampleListener.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/spring/ExampleListener.java
(rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/spring/ExampleListener.java 2010-08-31
16:29:21 UTC (rev 9619)
@@ -0,0 +1,28 @@
+package org.hornetq.tests.integration.spring;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class ExampleListener implements MessageListener
+{
+ public static String lastMessage = null;
+
+ public void onMessage(Message message)
+ {
+ try
+ {
+ lastMessage = ((TextMessage)message).getText();
+ }
+ catch (JMSException e)
+ {
+ throw new RuntimeException(e);
+ }
+ System.out.println("MESSAGE RECEIVED: " + lastMessage);
+ }
+}
Added: trunk/tests/src/org/hornetq/tests/integration/spring/MessageSender.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/spring/MessageSender.java
(rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/spring/MessageSender.java 2010-08-31
16:29:21 UTC (rev 9619)
@@ -0,0 +1,56 @@
+package org.hornetq.tests.integration.spring;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class MessageSender
+{
+ private ConnectionFactory connectionFactory;
+ private Destination destination;
+
+ public ConnectionFactory getConnectionFactory()
+ {
+ return connectionFactory;
+ }
+
+ public void setConnectionFactory(ConnectionFactory connectionFactory)
+ {
+ this.connectionFactory = connectionFactory;
+ }
+
+ public Destination getDestination()
+ {
+ return destination;
+ }
+
+ public void setDestination(Destination destination)
+ {
+ this.destination = destination;
+ }
+
+ public void send(String msg)
+ {
+ try
+ {
+ Connection conn = connectionFactory.createConnection();
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session.createProducer(destination);
+ TextMessage message = session.createTextMessage(msg);
+ producer.send(message);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
Added: trunk/tests/src/org/hornetq/tests/integration/spring/SpringIntegrationTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/spring/SpringIntegrationTest.java
(rev 0)
+++
trunk/tests/src/org/hornetq/tests/integration/spring/SpringIntegrationTest.java 2010-08-31
16:29:21 UTC (rev 9619)
@@ -0,0 +1,24 @@
+package org.hornetq.tests.integration.spring;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class SpringIntegrationTest extends TestCase
+{
+ public void testSpring() throws Exception
+ {
+ System.out.println("Creating bean factory...");
+ ApplicationContext context = new ClassPathXmlApplicationContext(new String[]
{"spring-jms-beans.xml"});
+ MessageSender sender = (MessageSender)context.getBean("MessageSender");
+ System.out.println("Sending message...");
+ sender.send("Hello world");
+ Thread.sleep(100);
+ Assert.assertEquals(ExampleListener.lastMessage, "Hello world");
+ }
+}