[jboss-cvs] JBoss Messaging SVN: r6354 - in trunk: AS/config and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 8 05:17:49 EDT 2009


Author: ataylor
Date: 2009-04-08 05:17:49 -0400 (Wed, 08 Apr 2009)
New Revision: 6354

Added:
   trunk/AS/config/jms-ds.xml
   trunk/examples/javaee/ejb-jms-transaction/
   trunk/examples/javaee/ejb-jms-transaction/build.xml
   trunk/examples/javaee/ejb-jms-transaction/config/
   trunk/examples/javaee/ejb-jms-transaction/config/jndi.properties
   trunk/examples/javaee/ejb-jms-transaction/readme.html
   trunk/examples/javaee/ejb-jms-transaction/src/
   trunk/examples/javaee/ejb-jms-transaction/src/org/
   trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/
   trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/
   trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/
   trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/EJBClientExample.java
   trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/server/
   trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/server/SendMessageBean.java
   trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/server/SendMessageService.java
Modified:
   trunk/AS/build.xml
   trunk/examples/javaee/common/build.xml
   trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java
   trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
Log:
javaee example and JCA fix

Modified: trunk/AS/build.xml
===================================================================
--- trunk/AS/build.xml	2009-04-08 07:03:46 UTC (rev 6353)
+++ trunk/AS/build.xml	2009-04-08 09:17:49 UTC (rev 6354)
@@ -75,6 +75,7 @@
       <copy todir="${messaging.sar.dir}">
          <fileset dir="${config.dir}">
             <include name="jbm-jboss-beans.xml"/>
+            <include name="jms-ds.xml"/>
          </fileset>
       </copy>
       <copy todir="${messaging.sar.dir}">

Added: trunk/AS/config/jms-ds.xml
===================================================================
--- trunk/AS/config/jms-ds.xml	                        (rev 0)
+++ trunk/AS/config/jms-ds.xml	2009-04-08 09:17:49 UTC (rev 6354)
@@ -0,0 +1,26 @@
+<connection-factories>
+   <!--
+    JMS Stuff
+   -->
+
+   <mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.messaging:service=JMSProviderLoader,name=JMSProvider">
+      <attribute name="ProviderName">DefaultJMSProvider</attribute>
+      <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
+      <attribute name="FactoryRef">java:/XAConnectionFactory</attribute>
+      <attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>
+      <attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>
+   </mbean>
+   <!--
+    JMS XA Resource adapter, use this to get transacted JMS in beans
+   -->
+   <tx-connection-factory>
+      <jndi-name>JmsXA</jndi-name>
+      <xa-transaction/>
+      <rar-name>jms-ra.rar</rar-name>
+      <connection-definition>org.jboss.messaging.ra.JBMConnectionFactory</connection-definition>
+      <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
+      <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
+      <max-pool-size>20</max-pool-size>
+      <security-domain-and-application>JmsXARealm</security-domain-and-application>
+   </tx-connection-factory>
+</connection-factories>
\ No newline at end of file

Modified: trunk/examples/javaee/common/build.xml
===================================================================
--- trunk/examples/javaee/common/build.xml	2009-04-08 07:03:46 UTC (rev 6353)
+++ trunk/examples/javaee/common/build.xml	2009-04-08 09:17:49 UTC (rev 6354)
@@ -61,7 +61,7 @@
       <fileset dir="${jbm.jars.dir}">
          <include name="**/*.jar"/>
       </fileset>
-      <fileset dir="${jars.dir}">
+      <fileset dir="${jboss.home}/client">
          <include name="**/*.jar"/>
       </fileset>
    </path>

Copied: trunk/examples/javaee/ejb-jms-transaction/build.xml (from rev 6352, trunk/examples/javaee/mdb/build.xml)
===================================================================
--- trunk/examples/javaee/ejb-jms-transaction/build.xml	                        (rev 0)
+++ trunk/examples/javaee/ejb-jms-transaction/build.xml	2009-04-08 09:17:49 UTC (rev 6354)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- =========================================================================================== -->
+<!--                                                                                             -->
+<!-- JBoss, Home of Professional Open Source                                                     -->
+<!-- Copyright 2005, JBoss Inc., 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.                                    -->
+<!--                                                                                             -->
+<!-- =========================================================================================== -->
+
+
+<project default="run" name="JBoss Messaging Java EE EJB using JBM Example">
+
+   <import file="../common/build.xml"/>
+
+   <target name="run">
+      <antcall target="runExample">
+         <param name="example.classname" value="org.jboss.javaee.example.EJBClientExample"/>
+      </antcall>
+   </target>
+
+</project>
\ No newline at end of file


Property changes on: trunk/examples/javaee/ejb-jms-transaction/build.xml
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: trunk/examples/javaee/ejb-jms-transaction/config/jndi.properties
===================================================================
--- trunk/examples/javaee/ejb-jms-transaction/config/jndi.properties	                        (rev 0)
+++ trunk/examples/javaee/ejb-jms-transaction/config/jndi.properties	2009-04-08 09:17:49 UTC (rev 6354)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Added: trunk/examples/javaee/ejb-jms-transaction/readme.html
===================================================================
--- trunk/examples/javaee/ejb-jms-transaction/readme.html	                        (rev 0)
+++ trunk/examples/javaee/ejb-jms-transaction/readme.html	2009-04-08 09:17:49 UTC (rev 6354)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+        "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+  <title></title>
+</head>
+<body>
+
+</body>
+</html>
\ No newline at end of file

Added: trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/EJBClientExample.java
===================================================================
--- trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/EJBClientExample.java	                        (rev 0)
+++ trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/EJBClientExample.java	2009-04-08 09:17:49 UTC (rev 6354)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, 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.javaee.example;
+
+import org.jboss.javaee.example.server.SendMessageService;
+
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+public class EJBClientExample
+{
+   public static void main(String[] args) throws Exception
+   {
+      //Step 1. Obtain an Initial Context
+      InitialContext ctx = new InitialContext();
+
+      //Step 2. Lookup the EJB
+      SendMessageService service = (SendMessageService) ctx.lookup("mdb-example/SendMessageBean/remote");
+
+      //Step 3. Invoke the send method
+      service.send();
+
+      //todo receive the message
+   }
+}

Added: trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/server/SendMessageBean.java
===================================================================
--- trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/server/SendMessageBean.java	                        (rev 0)
+++ trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/server/SendMessageBean.java	2009-04-08 09:17:49 UTC (rev 6354)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, 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.javaee.example.server;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+ at Stateless
+ at Remote(SendMessageService.class)
+public class SendMessageBean implements SendMessageService
+{
+   public void send() throws Exception
+   {
+      InitialContext ic = null;
+      Connection connection = null;
+      try
+      {
+         System.out.println("SendMessageBean.send");
+         //Step 4. Lookup the initial context
+         ic = new InitialContext();
+
+         //Step 5. Look Up the XA Connection Factory
+         ConnectionFactory cf = (ConnectionFactory) ic.lookup("java:/JmsXA");
+
+         //Step 6. Create a connection
+         connection = cf.createConnection();
+
+         //Step 7. Lookup the Queue
+         Queue queue = (Queue) ic.lookup("queue/testQueue");
+
+         //Step 8. Create a session
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         //Step 9. Create a Message Producer
+         MessageProducer messageProducer = session.createProducer(queue);
+
+         //Step 10. Create a Text Message
+         TextMessage message = session.createTextMessage("this is a reply!");
+
+         //Step 11. Send The Text Message
+         messageProducer.send(message);
+
+         //todo something else in the same tx, update database
+      }
+      finally
+      {
+         //Step 12. Be sure to close our JMS resources!
+         if(ic != null)
+         {
+            ic.close();
+         }
+         if(connection != null)
+         {
+            connection.close();
+         }
+      }
+   }
+}

Added: trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/server/SendMessageService.java
===================================================================
--- trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/server/SendMessageService.java	                        (rev 0)
+++ trunk/examples/javaee/ejb-jms-transaction/src/org/jboss/javaee/example/server/SendMessageService.java	2009-04-08 09:17:49 UTC (rev 6354)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, 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.javaee.example.server;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+public interface SendMessageService
+{
+   void send() throws Exception;
+}

Modified: trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java	2009-04-08 07:03:46 UTC (rev 6353)
+++ trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java	2009-04-08 09:17:49 UTC (rev 6354)
@@ -21,9 +21,8 @@
  */
 package org.jboss.messaging.ra;
 
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.Set;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
 
 import javax.jms.ConnectionMetaData;
 import javax.resource.ResourceException;
@@ -34,10 +33,10 @@
 import javax.resource.spi.ResourceAdapter;
 import javax.resource.spi.ResourceAdapterAssociation;
 import javax.security.auth.Subject;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Set;
 
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.jms.client.JBossConnectionFactory;
-
 /**
  * JBM ManagedConectionFactory
  * 
@@ -351,7 +350,7 @@
     * Get the JBoss connection factory
     * @return The factory
     */
-   protected JBossConnectionFactory getJBossConnectionFactory()
+   protected JBossConnectionFactory getJBossConnectionFactory() throws ResourceException
    {
       return ra.getJBossConnectionFactory();
    }

Modified: trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java	2009-04-08 07:03:46 UTC (rev 6353)
+++ trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java	2009-04-08 09:17:49 UTC (rev 6354)
@@ -26,8 +26,8 @@
 import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.jms.client.JBossConnectionFactory;
 import org.jboss.messaging.jms.client.JBossSession;
 import org.jboss.messaging.ra.inflow.JBMActivation;
@@ -1501,8 +1501,19 @@
       return val;
    }
 
-   public JBossConnectionFactory getJBossConnectionFactory()
+   public JBossConnectionFactory getJBossConnectionFactory() throws ResourceException
    {
+      if (!configured.getAndSet(true))
+      {
+         try
+         {
+            setup();
+         }
+         catch (MessagingException e)
+         {
+            throw new ResourceException("Unable to create activation", e);
+         }
+      }
       return jBossConnectionFactory;
    }
 }




More information about the jboss-cvs-commits mailing list