[jboss-cvs] JBossAS SVN: r62865 - in trunk/ejb3: src/main/org/jboss/ejb3 and 15 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 8 09:13:50 EDT 2007
Author: wolfc
Date: 2007-05-08 09:13:50 -0400 (Tue, 08 May 2007)
New Revision: 62865
Added:
trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java
trunk/ejb3/src/resources/test/ejbthree957/
trunk/ejb3/src/resources/test/ejbthree957/ear/
trunk/ejb3/src/resources/test/ejbthree957/ear/META-INF/
trunk/ejb3/src/resources/test/ejbthree957/ear/META-INF/application.xml
trunk/ejb3/src/resources/test/ejbthree957/ejbthree957test-service.xml
trunk/ejb3/src/resources/test/ejbthree957/one/
trunk/ejb3/src/resources/test/ejbthree957/one/META-INF/
trunk/ejb3/src/resources/test/ejbthree957/one/META-INF/ejb-jar.xml
trunk/ejb3/src/resources/test/ejbthree957/one/META-INF/jboss.xml
trunk/ejb3/src/resources/test/ejbthree957/two/
trunk/ejb3/src/resources/test/ejbthree957/two/META-INF/
trunk/ejb3/src/resources/test/ejbthree957/two/META-INF/ejb-jar.xml
trunk/ejb3/src/resources/test/ejbthree957/two/META-INF/jboss.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/DestBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/MyStateless.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/MyStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/unit/MessageLinkTestCase.java
Modified:
trunk/ejb3/build-test.xml
trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/metamodel/MessageDrivenBean.java
trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java
trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java
trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
Log:
EJBTHREE-957: implement message destination link
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/build-test.xml 2007-05-08 13:13:50 UTC (rev 62865)
@@ -1911,6 +1911,41 @@
</jar>
</target>
+ <target name="ejbthree957"
+ description="Builds all jar files."
+ depends="compile-classes">
+
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/ejbthree957-one.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/ejbthree957/DestBean.class"/>
+ </fileset>
+ <fileset dir="${resources}/test/ejbthree957/one" includes="META-INF/*"/>
+ </jar>
+
+ <jar jarfile="${build.lib}/ejbthree957-two.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/ejbthree957/MyStateless*.class"/>
+ </fileset>
+ <fileset dir="${resources}/test/ejbthree957/two" includes="META-INF/*"/>
+ </jar>
+
+ <jar jarfile="${build.lib}/ejbthree957.ear">
+ <fileset dir="${build.lib}" includes="ejbthree957-*.jar">
+ </fileset>
+ <!--
+ <fileset dir="${resources}/test/ejbthree957/ear" includes="META-INF/*"/>
+ -->
+ </jar>
+
+ <copy todir="${build.lib}">
+ <fileset dir="${resources}/test/ejbthree957">
+ <include name="*.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
<target name="jaxws"
description="Builds a simple jar."
depends="compile-classes">
@@ -3229,7 +3264,7 @@
<target name="jars" depends="appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440,
ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree751, ejbthree921, ejbthree936, ejbthree939,
- ejbthree953,
+ ejbthree953, ejbthree957,
aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
securitydomain, enventry,
jms/managed, naming, bmt, jca/inflowmdb, pool, jms, security, reference21_30, factory, dd/web, txexceptions,
@@ -4072,6 +4107,9 @@
<antcall target="test" inheritRefs="true">
<param name="test" value="ejbthree953"/>
</antcall>
+ <antcall target="test" inheritRefs="true">
+ <param name="test" value="ejbthree957"/>
+ </antcall>
</target>
<target name="entity-tests" depends="init" description="Execute all tests">
Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -915,6 +915,11 @@
return deployment.getEjbContainer(businessIntf);
}
+ public String resolveMessageDestination(String link)
+ {
+ return deployment.resolveMessageDestination(link);
+ }
+
public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz)
{
if (clazz == this.getBeanClass())
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -60,7 +60,7 @@
protected ClassFile cf;
protected List<String> ejbNames = new ArrayList<String>();
- protected Class ejbClass;
+ protected Class<?> ejbClass;
protected String className;
protected EJB_TYPE ejbType;
protected Annotation annotation;
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -51,9 +51,11 @@
import org.jboss.ejb3.enc.EjbModulePersistenceUnitResolver;
import org.jboss.ejb3.entity.PersistenceUnitDeployment;
import org.jboss.ejb3.entity.PersistenceXmlLoader;
+import org.jboss.ejb3.metamodel.AssemblyDescriptor;
import org.jboss.ejb3.metamodel.EjbJarDD;
import org.jboss.ejb3.metamodel.EjbJarDDObjectFactory;
import org.jboss.ejb3.metamodel.JBossDDObjectFactory;
+import org.jboss.ejb3.metamodel.MessageDestination;
import org.jboss.logging.Logger;
import org.jboss.virtual.VirtualFile;
import org.jboss.xb.binding.JBossXBException;
@@ -577,4 +579,58 @@
Ejb3Registry.unregister(container);
}
}
+
+ private String getMessageDestination(String name)
+ {
+ EjbJarDD dd;
+ // FIXME: Why isn't dd stored somewhere?
+ try
+ {
+ dd = EjbJarDDObjectFactory.parse(getDeploymentUnit().getEjbJarXml());
+ dd = JBossDDObjectFactory.parse(getDeploymentUnit().getJbossXml(), dd);
+ }
+ catch(IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch(JBossXBException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ AssemblyDescriptor ad = dd.getAssemblyDescriptor();
+ if(ad == null)
+ throw new IllegalStateException("No assembly descriptor found");
+ MessageDestination md = ad.findMessageDestination(name);
+ if(md == null)
+ throw new IllegalStateException("No message destination '" + name + "' found");
+ String jndiName = md.getJndiName();
+ if(jndiName == null)
+ throw new IllegalStateException("No jndi name specified for message destination '" + name + "'");
+ return jndiName;
+ }
+
+ public String resolveMessageDestination(String link)
+ {
+ // FIXME: this is a copy of DeploymentEjbResolver
+ int hashIndex = link.indexOf('#');
+ if (hashIndex != -1)
+ {
+ if (deploymentScope == null)
+ {
+ log.warn("ejb link '" + link + "' is relative, but no deployment scope found");
+ return null;
+ }
+ String relativePath = link.substring(0, hashIndex);
+ Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
+ if (dep == null)
+ {
+ log.warn("can't find a deployment for path '" + relativePath + "' of ejb link '" + link + "'");
+ return null;
+ }
+ String name = link.substring(hashIndex + 1);
+ return dep.getMessageDestination(name);
+ }
+ return getMessageDestination(link);
+ }
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -38,6 +38,7 @@
import javax.annotation.security.DenyAll;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
+import javax.ejb.ActivationConfigProperty;
import javax.ejb.Init;
import javax.ejb.Local;
import javax.ejb.LocalHome;
@@ -546,7 +547,7 @@
{
if (mdb != null)
{
- ArrayList properties = new ArrayList();
+ ArrayList<ActivationConfigProperty> properties = new ArrayList<ActivationConfigProperty>();
if (mdb.getAcknowledgeMode() != null)
properties.add(new ActivationConfigPropertyImpl("acknowledgeMode",
mdb.getAcknowledgeMode()));
@@ -590,11 +591,21 @@
}
}
+ // prefer jndi name over message destination link
if (mdb.getDestinationJndiName() != null)
{
properties.add(new ActivationConfigPropertyImpl("destination", mdb
.getDestinationJndiName()));
}
+ else if(mdb.getMessageDestinationLink() != null)
+ {
+ log.warn("Message destination link on a MDB is not yet implemented, specify a jndi name in jboss.xml");
+ /*
+ // TODO: I can't resolve here, because we're still scanning, maybe this will work:
+ // This will be picked up by MessagingContainer and then resolved to a jndi name
+ properties.add(new ActivationConfigPropertyImpl("destinationLink", mdb.getMessageDestinationLink()));
+ */
+ }
if (mdb.getMdbUser() != null)
{
@@ -635,8 +646,7 @@
if (isAnnotatedBean())
{
- annotation.merge((MessageDriven) ejbClass
- .getAnnotation(MessageDriven.class));
+ annotation.merge(ejbClass.getAnnotation(MessageDriven.class));
}
addClassAnnotation(container, MessageDriven.class, annotation);
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -414,6 +414,11 @@
return null;
}
+ public String resolveMessageDestination(String link)
+ {
+ throw new RuntimeException("NYI");
+ }
+
public VirtualFile getRootFile()
{
throw new NotImplementedException();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -361,6 +361,11 @@
return ejbResolver.getEjbContainer(businessIntf);
}
+ public String resolveMessageDestination(String link)
+ {
+ throw new RuntimeException("NYI");
+ }
+
public void start()
{
log.trace("start");
Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -1213,6 +1213,10 @@
{
ejb.setMessagingType(getValue(localName, value));
}
+ else if (localName.equals("message-destination-link"))
+ {
+ ejb.setMessageDestinationLink(getValue(localName, value));
+ }
else if (localName.equals("message-destination-type"))
{
MessageDrivenDestination destination = ejb.getMessageDrivenDestination();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/MessageDrivenBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/MessageDrivenBean.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/MessageDrivenBean.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -49,6 +49,7 @@
private String resourceAdaptorName;
private MessageDrivenDestination messageDrivenDestination;
+ private String messageDestinationLink;
private ActivationConfig activationConfig;
private ActivationConfig defaultActivationConfig;
@@ -85,6 +86,16 @@
this.messageDrivenDestination = messageDrivenDestination;
}
+ public String getMessageDestinationLink()
+ {
+ return messageDestinationLink;
+ }
+
+ public void setMessageDestinationLink(String messageDestinationLink)
+ {
+ this.messageDestinationLink = messageDestinationLink;
+ }
+
public ActivationConfig getActivationConfig()
{
return activationConfig;
Added: trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * 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.injection;
+
+import org.jboss.ejb3.EJBContainer;
+
+/**
+ * Common base for annotation/xml handlers.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractHandler implements InjectionHandler
+{
+ protected void addDependency(String refName, EJBContainer refcon, InjectionContainer container)
+ {
+ // Do not depend on myself
+ if(!container.equals(refcon))
+ container.getDependencyPolicy().addDependency(refcon.getObjectName().getCanonicalName());
+ }
+}
Modified: trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -45,17 +45,10 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class EJBHandler implements InjectionHandler
+public class EJBHandler extends AbstractHandler implements InjectionHandler
{
private static final Logger log = Logger.getLogger(EJBHandler.class);
- protected void addDependency(String refName, EJBContainer refcon, InjectionContainer container)
- {
- // Do not depend on myself
- if(!container.equals(refcon))
- container.getDependencyPolicy().addDependency(refcon.getObjectName().getCanonicalName());
- }
-
public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
{
if (xml != null)
Modified: trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -73,6 +73,14 @@
Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException;
String getEjbJndiName(Class businessInterface) throws NameNotFoundException;
String getEjbJndiName(String link, Class businessInterface);
+
+ /**
+ * Find a message destination in a deployment.
+ *
+ * @param link the message destination name
+ * @return the jndi name of the message destination
+ */
+ String resolveMessageDestination(String link);
/**
* If class has container overridable annotations, this method will
Modified: trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2007-05-08 13:12:14 UTC (rev 62864)
+++ trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -156,17 +156,20 @@
{
String encName = "env/" + envRef.getMessageDestinationRefName();
if (container.getEncInjectors().containsKey(encName)) continue;
- if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
+ String jndiName = envRef.getMappedName();
+ if (jndiName == null || jndiName.equals(""))
{
// Look for a message-destination-link
String link = envRef.getMessageDestinationLink();
if( link != null )
{
- // TODO: Resolve the link...
+ jndiName = container.resolveMessageDestination(link);
+ // TODO: add dependency
}
- throw new RuntimeException("mapped-name is required for " + envRef.getMessageDestinationRefName() + " of deployment " + container.getIdentifier());
+ else
+ throw new RuntimeException("mapped-name or message-destination-link is required for " + envRef.getMessageDestinationRefName() + " of deployment " + container.getIdentifier());
}
- container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, envRef.getMappedName(), "<message-destination-ref>"));
+ container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, jndiName, "<message-destination-ref>"));
InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
}
}
Added: trunk/ejb3/src/resources/test/ejbthree957/ear/META-INF/application.xml
===================================================================
--- trunk/ejb3/src/resources/test/ejbthree957/ear/META-INF/application.xml (rev 0)
+++ trunk/ejb3/src/resources/test/ejbthree957/ear/META-INF/application.xml 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<application
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
+ version="1.4">
+
+ <display-name>EJBTHREE-957</display-name>
+
+ <module>
+ <ejb>ejbthree957-one.jar</ejb>
+ </module>
+
+ <module>
+ <ejb>ejbthree957-two.jar</ejb>
+ </module>
+</application>
Added: trunk/ejb3/src/resources/test/ejbthree957/ejbthree957test-service.xml
===================================================================
--- trunk/ejb3/src/resources/test/ejbthree957/ejbthree957test-service.xml (rev 0)
+++ trunk/ejb3/src/resources/test/ejbthree957/ejbthree957test-service.xml 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.mq.destination:service=Queue,name=ejbthree957">
+ <attribute name="JNDIName">queue/ejbthree957In</attribute>
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.mq.destination:service=Queue,name=ejbthree957Out">
+ <attribute name="JNDIName">queue/ejbthree957Out</attribute>
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ </mbean>
+</server>
\ No newline at end of file
Added: trunk/ejb3/src/resources/test/ejbthree957/one/META-INF/ejb-jar.xml
===================================================================
--- trunk/ejb3/src/resources/test/ejbthree957/one/META-INF/ejb-jar.xml (rev 0)
+++ trunk/ejb3/src/resources/test/ejbthree957/one/META-INF/ejb-jar.xml 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+ <description>jBoss test application</description>
+ <display-name>EJBTHREE-XXX One</display-name>
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>DestBean</ejb-name>
+ <message-destination-type>javax.jms.Queue</message-destination-type>
+ <message-destination-link>ejbthree957-two.jar#DestBeanInQueue</message-destination-link>
+
+ <message-destination-ref>
+ <message-destination-ref-name>replyQueue</message-destination-ref-name>
+ <message-destination-type>javax.jms.Queue</message-destination-type>
+ <message-destination-link>ejbthree957-two.jar#DestBeanOutQueue</message-destination-link>
+ </message-destination-ref>
+ </message-driven>
+ </enterprise-beans>
+</ejb-jar>
\ No newline at end of file
Added: trunk/ejb3/src/resources/test/ejbthree957/one/META-INF/jboss.xml
===================================================================
--- trunk/ejb3/src/resources/test/ejbthree957/one/META-INF/jboss.xml (rev 0)
+++ trunk/ejb3/src/resources/test/ejbthree957/one/META-INF/jboss.xml 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,13 @@
+<jboss
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+ version="3.0">
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>DestBean</ejb-name>
+ <destination-jndi-name>queue/ejbthree957In</destination-jndi-name>
+ </message-driven>
+ </enterprise-beans>
+</jboss>
Added: trunk/ejb3/src/resources/test/ejbthree957/two/META-INF/ejb-jar.xml
===================================================================
--- trunk/ejb3/src/resources/test/ejbthree957/two/META-INF/ejb-jar.xml (rev 0)
+++ trunk/ejb3/src/resources/test/ejbthree957/two/META-INF/ejb-jar.xml 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+ <description>jBoss test application</description>
+ <display-name>EJBTHREE-XXX Two</display-name>
+ <assembly-descriptor>
+ <message-destination>
+ <message-destination-name>DestBeanInQueue</message-destination-name>
+ </message-destination>
+ <message-destination>
+ <message-destination-name>DestBeanOutQueue</message-destination-name>
+ </message-destination>
+ </assembly-descriptor>
+</ejb-jar>
\ No newline at end of file
Added: trunk/ejb3/src/resources/test/ejbthree957/two/META-INF/jboss.xml
===================================================================
--- trunk/ejb3/src/resources/test/ejbthree957/two/META-INF/jboss.xml (rev 0)
+++ trunk/ejb3/src/resources/test/ejbthree957/two/META-INF/jboss.xml 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,17 @@
+<jboss
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+ version="3.0">
+ <assembly-descriptor>
+ <message-destination>
+ <message-destination-name>DestBeanInQueue</message-destination-name>
+ <jndi-name>queue/ejbthree957In</jndi-name>
+ </message-destination>
+ <message-destination>
+ <message-destination-name>DestBeanOutQueue</message-destination-name>
+ <jndi-name>queue/ejbthree957Out</jndi-name>
+ </message-destination>
+ </assembly-descriptor>
+</jboss>
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/DestBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/DestBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/DestBean.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * 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.ejb3.test.ejbthree957;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBException;
+import javax.ejb.MessageDriven;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.Session;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at MessageDriven
+public class DestBean implements MessageListener
+{
+ @Resource(mappedName="java:ConnectionFactory")
+ private QueueConnectionFactory connectionFactory;
+
+ @Resource(name="replyQueue")
+ private Queue replyQueue;
+
+ public void onMessage(Message message)
+ {
+ try
+ {
+ System.err.println("message = " + message);
+ replyTo(replyQueue, message);
+ }
+ catch(JMSException e)
+ {
+ throw new EJBException(e);
+ }
+ }
+
+ private void replyTo(Destination destination, Message message) throws JMSException
+ {
+ Connection conn = connectionFactory.createConnection();
+ try
+ {
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session.createProducer(destination);
+ producer.send(destination, message);
+ producer.close();
+ session.close();
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/MyStateless.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/MyStateless.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/MyStateless.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * 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.ejb3.test.ejbthree957;
+
+import javax.ejb.Remote;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface MyStateless
+{
+ String sayHiTo(String name);
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/MyStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/MyStatelessBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/MyStatelessBean.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * 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.ejb3.test.ejbthree957;
+
+import javax.ejb.Stateless;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+public class MyStatelessBean implements MyStateless
+{
+
+ public String sayHiTo(String name)
+ {
+ return "Hi " + name;
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/unit/MessageLinkTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/unit/MessageLinkTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree957/unit/MessageLinkTestCase.java 2007-05-08 13:13:50 UTC (rev 62865)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * 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.ejb3.test.ejbthree957.unit;
+
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test message link.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MessageLinkTestCase extends JBossTestCase
+{
+
+ public MessageLinkTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void test1() throws Exception
+ {
+ QueueConnectionFactory qFactory = (QueueConnectionFactory) getInitialContext().lookup("ConnectionFactory");
+ QueueConnection conn = qFactory.createQueueConnection();
+ try
+ {
+ QueueSession session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+ Queue replyQueue = (Queue) getInitialContext().lookup("queue/ejbthree957Out");
+ MessageConsumer consumer = session.createConsumer(replyQueue);
+ conn.start();
+
+ Queue sendQueue = (Queue) getInitialContext().lookup("queue/ejbthree957In");
+ QueueSender sender = session.createSender(sendQueue);
+ TextMessage message = session.createTextMessage("Hello world");
+ sender.send(message, DeliveryMode.NON_PERSISTENT, 4, 500);
+
+ TextMessage reply = (TextMessage) consumer.receive(1000);
+ assertNotNull("No reply received", reply);
+ assertEquals("Hello world", reply.getText());
+
+ conn.stop();
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(MessageLinkTestCase.class, "ejbthree957test-service.xml,ejbthree957.ear");
+ }
+
+}
More information about the jboss-cvs-commits
mailing list