[jboss-cvs] JBoss Messaging SVN: r6566 - in trunk: examples/javaee and 14 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Apr 24 19:01:47 EDT 2009
Author: clebert.suconic at jboss.com
Date: 2009-04-24 19:01:47 -0400 (Fri, 24 Apr 2009)
New Revision: 6566
Added:
trunk/examples/javaee/mdb-remote/
trunk/examples/javaee/mdb-remote/build.xml
trunk/examples/javaee/mdb-remote/config/
trunk/examples/javaee/mdb-remote/config/jndi.properties
trunk/examples/javaee/mdb-remote/readme.html
trunk/examples/javaee/mdb-remote/server-config/
trunk/examples/javaee/mdb-remote/server-config/jms-remote-ds.xml
trunk/examples/javaee/mdb-remote/src/
trunk/examples/javaee/mdb-remote/src/org/
trunk/examples/javaee/mdb-remote/src/org/jboss/
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/MDBRemoteClientExample.java
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBRemoteExample.java
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSender.java
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSenderService.java
Modified:
trunk/.classpath
trunk/src/config/ra.xml
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactoryImpl.java
trunk/src/main/org/jboss/messaging/ra/JBMMCFProperties.java
trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java
trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java
trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
trunk/src/main/org/jboss/messaging/ra/JBMSessionFactoryImpl.java
trunk/src/main/org/jboss/messaging/ra/Util.java
trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java
trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivationSpec.java
trunk/src/main/org/jboss/messaging/utils/ConfigurationHelper.java
Log:
Resource adapter changes to allow connection configurations + initial example commit
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/.classpath 2009-04-24 23:01:47 UTC (rev 6566)
@@ -71,6 +71,7 @@
<classpathentry kind="src" path="examples/javaee/hajndi/src"/>
<classpathentry kind="src" path="examples/javaee/jms-bridge/src"/>
<classpathentry kind="src" path="examples/javaee/mdb/src"/>
+ <classpathentry kind="src" path="examples/javaee/mdb-remote/src"/>
<classpathentry kind="src" path="examples/javaee/xarecovery/src"/>
<classpathentry kind="lib" path="thirdparty/apache-log4j/lib/log4j.jar"/>
<classpathentry kind="lib" path="thirdparty/junit/lib/junit.jar"/>
Added: trunk/examples/javaee/mdb-remote/build.xml
===================================================================
--- trunk/examples/javaee/mdb-remote/build.xml (rev 0)
+++ trunk/examples/javaee/mdb-remote/build.xml 2009-04-24 23:01:47 UTC (rev 6566)
@@ -0,0 +1,42 @@
+<?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 MDB Example">
+
+ <import file="../common/build.xml"/>
+
+ <target name="install">
+ <copy file="./server-config/jms-remote-ds.xml" todir="${jboss.home}/server/jbm2_default/deploy"/>
+ </target>
+
+ <target name="run">
+ <antcall target="runExample">
+ <param name="example.classname" value="org.jboss.javaee.example.MDBRemoteClientExample"/>
+ </antcall>
+ </target>
+
+</project>
\ No newline at end of file
Added: trunk/examples/javaee/mdb-remote/config/jndi.properties
===================================================================
--- trunk/examples/javaee/mdb-remote/config/jndi.properties (rev 0)
+++ trunk/examples/javaee/mdb-remote/config/jndi.properties 2009-04-24 23:01:47 UTC (rev 6566)
@@ -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/mdb-remote/readme.html
===================================================================
--- trunk/examples/javaee/mdb-remote/readme.html (rev 0)
+++ trunk/examples/javaee/mdb-remote/readme.html 2009-04-24 23:01:47 UTC (rev 6566)
@@ -0,0 +1,95 @@
+<html>
+ <head>
+ <title>JBoss Messaging Java EE MDB Example</title>
+ <link rel="stylesheet" type="text/css" href="../../jms/common/common.css">
+ </head>
+ <body>
+ <h1>Java EE MDB Example</h1>
+ <br>
+ <p>This example shows you how to send a message to an MDB</p>
+ <p>
+ The example will send deploy a simple MDB and demonstrate sending a message and the MDB consuming it
+ </p>
+ <h2>Example step-by-step</h2>
+ <p><i>To deploy the example, simply type <code>ant deploy</code> from this directory **</i></p>
+ <p><i>To run the example, simply type <code>ant</code> from this directory</i></p>
+ <p><i>To undeploy the example, simply type <code>ant undeploy</code> from this directory **</i></p>
+ <p><i> ** make sure that JBOSS_HOME is set to the Jboss installation directory</i></p>
+ <br>
+ <ol>
+ <li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <code>jndi.properties</code> file in the directory <code>config</code></li>
+ <pre>
+ <code>initialContext = new InitialContext();</code>
+ </pre>
+
+ <li>We look up the JMS queue object from JNDI</li>
+ <pre>
+ <code>Queue queue = (Queue) initialContext.lookup("/queue/testQueue");</code>
+ </pre>
+
+ <li>We look up the JMS connection factory object from JNDI</li>
+ <pre>
+ <code>ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");</code>
+ </pre>
+
+ <li>We create a JMS connection</li>
+ <pre>
+ <code>connection = cf.createConnection();</code>
+ </pre>
+
+ <li>We create a JMS session. The session is created as non transacted and will auto acknowledge messages.</li>
+ <pre>
+ <code>Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
+ </pre>
+
+ <li>We create a JMS message producer on the session. This will be used to send the messages.</li>
+ <pre>
+ <code>MessageProducer messageProducer = session.createProducer(queue);</code>
+ </pre>
+
+ <li>We create a JMS text messages that we are going to send.</li>
+ <pre>
+ <code> TextMessage message = session.createTextMessage("This is a text message");</code>
+ </pre>
+
+ <li>We send messages to the queue</li>
+ <pre>
+ <code>messageProducer.send(message);</code>
+ </pre>
+
+ <li>The MDB receives the message<br />
+ We know the message is a TextMessage so we cast to it.
+ </li>
+ <pre>
+ <code>TextMessage tm = (TextMessage)message;</code>
+ </pre>
+
+ <li>The MDB gets the text and prints it
+ </li>
+ <pre>
+ <code>String text = tm.getText();
+ System.out.println("message " + text + " received");
+ </code>
+ </pre>
+
+ <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+
+ <pre>
+ <code>finally
+ {
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }</code>
+ </pre>
+
+
+
+ </ol>
+ </body>
+</html>
\ No newline at end of file
Added: trunk/examples/javaee/mdb-remote/server-config/jms-remote-ds.xml
===================================================================
--- trunk/examples/javaee/mdb-remote/server-config/jms-remote-ds.xml (rev 0)
+++ trunk/examples/javaee/mdb-remote/server-config/jms-remote-ds.xml 2009-04-24 23:01:47 UTC (rev 6566)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+
+ <!--
+ JMS XA Resource adapter, use this for outbound JMS connections.
+ Inbound connections are defined at the @MDB activaction or at the resource-adapter properties.
+ -->
+ <tx-connection-factory>
+ <jndi-name>RemoteJmsXA</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="ConnectorClassName" type="java.lang.String">org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</config-property>
+ <config-property name="ConnectionParameters" type="java.lang.String">jbm.remoting.netty.port=5545</config-property>
+ <max-pool-size>20</max-pool-size>
+ </tx-connection-factory>
+
+
+</connection-factories>
Added: trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/MDBRemoteClientExample.java
===================================================================
--- trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/MDBRemoteClientExample.java (rev 0)
+++ trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/MDBRemoteClientExample.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -0,0 +1,68 @@
+/*
+ * 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 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;
+
+import org.jboss.javaee.example.server.StatelessSenderService;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+public class MDBRemoteClientExample
+{
+ public static void main(String[] args) throws Exception
+ {
+ Connection connection = null;
+ InitialContext initialContext = null;
+ try
+ {
+ //Step 1. Create an initial context to perform the JNDI lookup.
+ initialContext = new InitialContext();
+
+
+ StatelessSenderService sender = (StatelessSenderService)initialContext.lookup("mdb-example/StatelessSender/remote");
+
+ sender.sendHello("Hi, It's friday and I'm still writing tests. What about a bear?");
+
+ initialContext.close();
+ }
+ finally
+ {
+ //Step 11. Be sure to close our JMS resources!
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if(connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+}
Added: trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBRemoteExample.java
===================================================================
--- trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBRemoteExample.java (rev 0)
+++ trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBRemoteExample.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -0,0 +1,62 @@
+/*
+ * 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.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+ at MessageDriven(name = "MessageMDBExample",
+ activationConfig =
+ {
+ @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"),
+ @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
+ @ActivationConfigProperty(propertyName = "ConnectorClassName", propertyValue = "org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"),
+ @ActivationConfigProperty(propertyName = "ConnectionParameters", propertyValue = "jbm.remoting.netty.port=5545")
+ })
+public class MDBRemoteExample implements MessageListener
+{
+ public void onMessage(Message message)
+ {
+ try
+ {
+ //Step 9. We know the client is sending a text message so we cast
+ TextMessage tm = (TextMessage)message;
+
+ //Step 10. get the text from the message.
+ String text = tm.getText();
+
+ System.out.println("message " + text + " received");
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Added: trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSender.java
===================================================================
--- trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSender.java (rev 0)
+++ trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSender.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.javaee.example.server;
+
+import javax.annotation.Resource;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.jms.ConnectionFactory;
+
+import org.jboss.messaging.jms.JBossQueue;
+import javax.jms.*;
+
+/**
+ * A StatelessSender
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+ at Remote(StatelessSenderService.class)
+ at Stateless
+public class StatelessSender implements StatelessSenderService
+{
+
+ @Resource(mappedName="java:RemoteJmsXA")
+ private ConnectionFactory connectionFactory;
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.javaee.example.server.StatelessSenderService#sendHello(java.lang.String)
+ */
+ public void sendHello(String message) throws Exception
+ {
+ JBossQueue destQueue = new JBossQueue("testQueue");
+
+ Connection conn = connectionFactory.createConnection("guest", "guest");
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sess.createProducer(destQueue);
+
+ prod.send(sess.createTextMessage(message));
+
+ sess.close();
+
+ System.out.println("Sent message \"" + message + "\" on the Stateless");
+
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSenderService.java
===================================================================
--- trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSenderService.java (rev 0)
+++ trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSenderService.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.javaee.example.server;
+
+/**
+ * A StatelessSenderService
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public interface StatelessSenderService
+{
+
+ public void sendHello(String message) throws Exception;
+
+}
Modified: trunk/src/config/ra.xml
===================================================================
--- trunk/src/config/ra.xml 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/config/ra.xml 2009-04-24 23:01:47 UTC (rev 6566)
@@ -44,15 +44,15 @@
<resourceadapter-class>org.jboss.messaging.ra.JBMResourceAdapter</resourceadapter-class>
<config-property>
<description>The transport type</description>
- <config-property-name>TransportType</config-property-name>
+ <config-property-name>ConnectorClassName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory</config-property-value>
</config-property>
<config-property>
- <description>The transport configuration. These values must be in the form of key:val:type;key:val:type; where type is Integer, String, Long or boolean</description>
- <config-property-name>TransportConfiguration</config-property-name>
+ <description>The transport configuration. These values must be in the form of key=val;key=val;</description>
+ <config-property-name>ConnectionParameters</config-property-name>
<config-property-type>java.lang.String</config-property-type>
- <config-property-value>jbm.remoting.invm.serverid:0:Integer</config-property-value>
+ <config-property-value>jbm.remoting.invm.serverid=0</config-property-value>
</config-property>
<config-property>
<description>Use XA methods to obtain connections?</description>
@@ -64,13 +64,13 @@
<description>The user name used to login to the JMS server</description>
<config-property-name>UserName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
- <config-property-value></config-property-value>
+ <config-property-value>Adamastor</config-property-value>
</config-property>
<config-property>
<description>The password used to login to the JMS server</description>
<config-property-name>Password</config-property-name>
<config-property-type>java.lang.String</config-property-type>
- <config-property-value></config-property-value>
+ <config-property-value>Rodrigues</config-property-value>
</config-property>
<!--<config-property>
<description>The Backup transport type</description>
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -1172,7 +1172,7 @@
if (binding == null || binding.getType() != BindingType.LOCAL_QUEUE)
{
- throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST);
+ throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST, "Binding " + name + " does not exist");
}
securityStore.check(binding.getAddress(), CheckType.CONSUME, this);
Modified: trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactoryImpl.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactoryImpl.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -31,7 +31,6 @@
import javax.naming.Reference;
import javax.resource.Referenceable;
import javax.resource.spi.ConnectionManager;
-import javax.resource.spi.ManagedConnectionFactory;
import org.jboss.messaging.core.logging.Logger;
Modified: trunk/src/main/org/jboss/messaging/ra/JBMMCFProperties.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMMCFProperties.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/ra/JBMMCFProperties.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -22,16 +22,19 @@
package org.jboss.messaging.ra;
import java.io.Serializable;
+import java.util.Map;
+
import javax.jms.Queue;
import javax.jms.Topic;
import org.jboss.messaging.core.logging.Logger;
/**
- * The MCF default properties - these are set in the ra.xml file
+ * The MCF default properties - these are set in the <tx-connection-factory> at the jms-ds.xml
*
* @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
* @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
* @version $Revision: $
*/
public class JBMMCFProperties implements Serializable
@@ -51,6 +54,15 @@
/** The topic type */
private static final String TOPIC_TYPE = Topic.class.getName();
+
+ /** The transport config, changing the default configured from the RA */
+ private Map<String, Object> connectionParameters;
+
+ public String strConnectionParameters;
+
+ /** The transport type, changing the default configured from the RA */
+ private String connectorClassName;
+
/** The connection type */
private int type = JBMConnectionFactory.CONNECTION;
@@ -79,8 +91,40 @@
return type;
}
+
+ /**
+ * @return the connectionParameters
+ */
+ public String getConnectionParameters()
+ {
+ return strConnectionParameters;
+ }
+
+ public Map<String, Object> getParsedConnectionParameters()
+ {
+ return connectionParameters;
+ }
+ public void setConnectionParameters(String configuration)
+ {
+ this.strConnectionParameters = configuration;
+ this.connectionParameters = Util.parseConfig(configuration);
+ }
+
/**
+ * @return the transportType
+ */
+ public String getConnectorClassName()
+ {
+ return connectorClassName;
+ }
+
+ public void setConnectorClassName(String value)
+ {
+ this.connectorClassName = value;
+ }
+
+ /**
* Set the default session type.
* @param defaultType either javax.jms.Topic or javax.jms.Queue
*/
Modified: trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -21,8 +21,9 @@
*/
package org.jboss.messaging.ra;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Set;
import javax.jms.ConnectionMetaData;
import javax.resource.ResourceException;
@@ -33,10 +34,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
*
@@ -63,6 +64,9 @@
/** The managed connection factory properties */
private JBMMCFProperties mcfProperties;
+
+ /** Connection Factory used if properties are set */
+ private JBossConnectionFactory connectionFactory;
/**
* Constructor
@@ -310,7 +314,34 @@
mcfProperties.setSessionDefaultType(type);
}
+
/**
+ * @return the connectionParameters
+ */
+ public String getConnectionParameters()
+ {
+ return mcfProperties.getConnectionParameters();
+ }
+
+ public void setConnectionParameters(String configuration)
+ {
+ mcfProperties.setConnectionParameters(configuration);
+ }
+
+ /**
+ * @return the transportType
+ */
+ public String getConnectorClassName()
+ {
+ return mcfProperties.getConnectionParameters();
+ }
+
+ public void setConnectorClassName(String value)
+ {
+ mcfProperties.setConnectorClassName(value);
+ }
+
+ /**
* Get the useTryLock.
* @return the useTryLock.
*/
@@ -350,9 +381,21 @@
* Get the JBoss connection factory
* @return The factory
*/
- protected JBossConnectionFactory getJBossConnectionFactory() throws ResourceException
+ protected synchronized JBossConnectionFactory getJBossConnectionFactory() throws ResourceException
{
- return ra.getJBossConnectionFactory();
+ if (this.mcfProperties.getConnectorClassName() != null)
+ {
+ if (connectionFactory == null)
+ {
+ connectionFactory = ra.createRemoteFactory(mcfProperties.getConnectorClassName(), mcfProperties.getParsedConnectionParameters());
+ }
+
+ return connectionFactory;
+ }
+ else
+ {
+ return ra.getJBossConnectionFactory();
+ }
}
/**
Modified: trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -134,13 +134,13 @@
private Boolean useXA;
/* the transport type*/
- private String transportType;
+ private String connectorClassName;
- private Map<String, Object> transportConfiguration = new HashMap<String, Object>();
+ private Map<String, Object> connectionParameters = new HashMap<String, Object>();
- private Map<String, Object> backupTransportConfiguration = new HashMap<String, Object>();
+ private Map<String, Object> backupConnectionParameters = new HashMap<String, Object>();
- private String backUpTransportType;
+ private String backupConnectorClassName;
/**
* Constructor
@@ -982,37 +982,47 @@
hash += 31 * hash + (password != null ? password.hashCode() : 0);
hash += 31 * hash + (clientID != null ? clientID.hashCode() : 0);
hash += 31 * hash + (useXA != null ? useXA.hashCode() : 0);
- hash += 31 * hash + (transportType != null ? transportType.hashCode() : 0);
+ hash += 31 * hash + (connectorClassName != null ? connectorClassName.hashCode() : 0);
return hash;
}
- public void setTransportType(String transportType)
+ public void setConnectorClassName(String connectorClassName)
{
- this.transportType = transportType;
+ this.connectorClassName = connectorClassName;
}
- public String getTransportType()
+ public String getConnectorClassName()
{
- return transportType;
+ return connectorClassName;
}
+
+ public void setConnectionParameters(Map<String, Object> config)
+ {
+ this.connectionParameters = config;
+ }
- public Map<String, Object> getTransportConfiguration()
+ public Map<String, Object> getConnectionParameters()
{
- return transportConfiguration;
+ return connectionParameters;
}
- public Map<String, Object> getBackupTransportConfiguration()
+ public Map<String, Object> getBackupConnectionParameters()
{
- return backupTransportConfiguration;
+ return backupConnectionParameters;
}
+
+ public void setBackupConnectionParameters(Map<String, Object> config)
+ {
+ this.backupConnectionParameters = config;
+ }
- public String getBackUpTransportType()
+ public String getBackupConnectorClassName()
{
- return backUpTransportType;
+ return backupConnectorClassName;
}
- public void setBackupTransportType(String backUpTransportType)
+ public void setBackupConnectorClassName(String connectorClassName)
{
- this.backUpTransportType = backUpTransportType;
+ this.backupConnectorClassName = connectorClassName;
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -227,98 +227,58 @@
log.info("JBoss Messaging resource adapter stopped");
}
- public void setTransportType(String transportType)
+ public void setConnectorClassName(String connectorClassName)
{
if (trace)
{
- log.trace("setTransportType(" + transportType + ")");
+ log.trace("setTransportType(" + connectorClassName + ")");
}
- raProperties.setTransportType(transportType);
+ raProperties.setConnectorClassName(connectorClassName);
}
- public String getTransportType()
+ public String getConnectorClassName()
{
- return raProperties.getTransportType();
+ return raProperties.getConnectorClassName();
}
- public Map<String, Object> getTransportConfiguration()
+ public Map<String, Object> getConnectionParameters()
{
- return raProperties.getTransportConfiguration();
+ return raProperties.getConnectionParameters();
}
- public void setTransportConfiguration(String config)
+ public void setConnectionParameters(String config)
{
if (config != null)
{
- String[] split = config.split(";");
- for (String s : split)
- {
- String[] conf = s.split(":");
- if (conf.length == 3)
- {
- Object val = getTransportParam(conf);
- if (val != null)
- {
- raProperties.getTransportConfiguration().put(conf[0], val);
- }
- else
- {
- log.warn("Invalid JBMResourceAdapter type: " + val + " for type " + conf[2]);
- }
- }
- else
- {
- log.warn("ignoring JBMResourceAdapter TransportConfiguration Element " + s + " : wrong format");
- }
- }
+ raProperties.setConnectionParameters(Util.parseConfig(config));
}
}
- public String getBackUpTransportType()
+ public String getBackupConnectorClassName()
{
- return raProperties.getBackUpTransportType();
+ return raProperties.getBackupConnectorClassName();
}
- public void setBackUpTransportType(String backUpTransportType)
+ public void setBackupConnectorClassName(String backupConnector)
{
if (trace)
{
- log.trace("setBackUpTransportType(" + backUpTransportType + ")");
+ log.trace("setBackUpTransportType(" + backupConnector + ")");
}
- raProperties.setBackupTransportType(backUpTransportType);
+ raProperties.setBackupConnectorClassName(backupConnector);
}
- public Map<String, Object> getBackupTransportConfiguration()
+ public Map<String, Object> getBackupConnectionParameters()
{
- return raProperties.getBackupTransportConfiguration();
+ return raProperties.getBackupConnectionParameters();
}
public void setBackupTransportConfiguration(String config)
{
if (config != null)
{
- String[] split = config.split(";");
- for (String s : split)
- {
- String[] conf = s.split(":");
- if (conf.length == 3)
- {
- Object val = getTransportParam(conf);
- if (val != null)
- {
- raProperties.getBackupTransportConfiguration().put(conf[0], val);
- }
- else
- {
- log.warn("Invalid JBMResourceAdapter type: " + val + " for type " + conf[2]);
- }
- }
- else
- {
- log.warn("ignoring JBMResourceAdapter BackupTransportConfiguration Element " + s + " : wrong format");
- }
- }
+ raProperties.setBackupConnectionParameters(Util.parseConfig(config));
}
}
@@ -1263,7 +1223,26 @@
Integer transactionBatchSize,
boolean deliveryTransacted) throws Exception
{
+ return createSession(this.sessionFactory,
+ ackMode,
+ user,
+ pass,
+ preAck,
+ dupsOkBatchSize,
+ transactionBatchSize,
+ deliveryTransacted);
+ }
+ public ClientSession createSession(ClientSessionFactory parameterFactory,
+ int ackMode,
+ String user,
+ String pass,
+ Boolean preAck,
+ Integer dupsOkBatchSize,
+ Integer transactionBatchSize,
+ boolean deliveryTransacted) throws Exception
+ {
+
ClientSession result;
boolean actPreAck = preAck != null ? preAck : ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
@@ -1274,49 +1253,25 @@
switch (ackMode)
{
case Session.SESSION_TRANSACTED:
- result = sessionFactory.createSession(user,
- pass,
- deliveryTransacted,
- false,
- false,
- actPreAck,
- actTxBatchSize);
+ result = parameterFactory.createSession(user, pass, deliveryTransacted, false, false, actPreAck, actTxBatchSize);
break;
case Session.AUTO_ACKNOWLEDGE:
- result = sessionFactory.createSession(user,
- pass,
- deliveryTransacted,
- true,
- false,
- actPreAck,
- actTxBatchSize);
+ result = parameterFactory.createSession(user, pass, deliveryTransacted, true, false, actPreAck, actTxBatchSize);
break;
case Session.DUPS_OK_ACKNOWLEDGE:
- result = sessionFactory.createSession(user,
- pass,
- deliveryTransacted,
- true,
- false,
- actPreAck,
- actDupsOkBatchSize);
+ result = parameterFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ true,
+ false,
+ actPreAck,
+ actDupsOkBatchSize);
break;
case Session.CLIENT_ACKNOWLEDGE:
- result = sessionFactory.createSession(user,
- pass,
- deliveryTransacted,
- false,
- false,
- actPreAck,
- actTxBatchSize);
+ result = parameterFactory.createSession(user, pass, deliveryTransacted, false, false, actPreAck, actTxBatchSize);
break;
case JBossSession.PRE_ACKNOWLEDGE:
- result = sessionFactory.createSession(user,
- pass,
- deliveryTransacted,
- false,
- true,
- actPreAck,
- actTxBatchSize);
+ result = parameterFactory.createSession(user, pass, deliveryTransacted, false, true, actPreAck, actTxBatchSize);
break;
default:
throw new IllegalArgumentException("Invalid ackmode: " + ackMode);
@@ -1329,6 +1284,121 @@
}
/**
+ * @param connectorClassName
+ * @param connectionParameters
+ */
+ public JBossConnectionFactory createRemoteFactory(String connectorClassName, Map<String, Object> connectionParameters)
+ {
+ TransportConfiguration transportConf = new TransportConfiguration(connectorClassName, connectionParameters);
+
+ TransportConfiguration backup = getBackupConnectorClassName() == null ? null
+ : new TransportConfiguration(getBackupConnectorClassName(),
+ getBackupConnectionParameters());
+ return new JBossConnectionFactory(transportConf,
+ backup,
+ getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME
+ : getLoadBalancingPolicyClassName(),
+ getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD
+ : getPingPeriod(),
+ getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL
+ : getConnectionTTL(),
+ getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT
+ : getCallTimeout(),
+ getClientID(),
+ getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
+ : getDupsOKBatchSize(),
+ getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
+ : getTransactionBatchSize(),
+ getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE
+ : getConsumerWindowSize(),
+ getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE
+ : getConsumerMaxRate(),
+ getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE
+ : getSendWindowSize(),
+ getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE
+ : getProducerMaxRate(),
+ getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE
+ : getMinLargeMessageSize(),
+ getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE
+ : getBlockOnAcknowledge(),
+ getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND
+ : getBlockOnNonPersistentSend(),
+ getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND
+ : getBlockOnPersistentSend(),
+ getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP
+ : getAutoGroup(),
+ getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS
+ : getMaxConnections(),
+ getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE
+ : getPreAcknowledge(),
+ getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL
+ : getRetryInterval(),
+ getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER
+ : getRetryIntervalMultiplier(),
+ getReconnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS
+ : getReconnectAttempts(),
+ isFailoverOnServerShutdown() == null ? ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN
+ : isFailoverOnServerShutdown());
+ }
+
+ /**
+ * @param discoveryGroup
+ * @param discoveryGroupPort
+ */
+ public JBossConnectionFactory createDiscoveryFactory(String discoveryGroup, Integer discoveryGroupPort)
+ {
+ return new JBossConnectionFactory(discoveryGroup,
+ discoveryGroupPort,
+ getDiscoveryRefreshTimeout() == null ? ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT
+ : getDiscoveryRefreshTimeout(),
+ getDiscoveryInitialWaitTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT
+ : getDiscoveryInitialWaitTimeout(),
+ getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME
+ : getLoadBalancingPolicyClassName(),
+ getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD
+ : getPingPeriod(),
+ getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL
+ : getConnectionTTL(),
+ getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT
+ : getCallTimeout(),
+ getClientID(),
+ getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
+ : getDupsOKBatchSize(),
+ getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
+ : getTransactionBatchSize(),
+ getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE
+ : getConsumerWindowSize(),
+ getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE
+ : getConsumerMaxRate(),
+ getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE
+ : getSendWindowSize(),
+ getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE
+ : getProducerMaxRate(),
+ getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE
+ : getMinLargeMessageSize(),
+ getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE
+ : getBlockOnAcknowledge(),
+ getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND
+ : getBlockOnNonPersistentSend(),
+ getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND
+ : getBlockOnPersistentSend(),
+ getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP
+ : getAutoGroup(),
+ getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS
+ : getMaxConnections(),
+ getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE
+ : getPreAcknowledge(),
+ getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL
+ : getRetryInterval(),
+ getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER
+ : getRetryIntervalMultiplier(),
+ getReconnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS
+ : getReconnectAttempts(),
+ isFailoverOnServerShutdown() == null ? ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN
+ : isFailoverOnServerShutdown());
+ }
+
+ /**
* Get the resource adapter properties
*
* @return The properties
@@ -1348,110 +1418,14 @@
*/
protected void setup() throws MessagingException
{
- if (getTransportType() != null)
+
+ if (getConnectorClassName() != null)
{
- TransportConfiguration transportConf = new TransportConfiguration(getTransportType(),
- getTransportConfiguration());
- TransportConfiguration backup = getBackUpTransportType() == null ? null
- : new TransportConfiguration(getBackUpTransportType(),
- getBackupTransportConfiguration());
- jBossConnectionFactory = new JBossConnectionFactory(transportConf,
- backup,
- getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME
- : getLoadBalancingPolicyClassName(),
- getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD
- : getPingPeriod(),
- getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL
- : getConnectionTTL(),
- getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT
- : getCallTimeout(),
- getClientID(),
- getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
- : getDupsOKBatchSize(),
- getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
- : getTransactionBatchSize(),
- getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE
- : getConsumerWindowSize(),
- getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE
- : getConsumerMaxRate(),
- getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE
- : getSendWindowSize(),
- getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE
- : getProducerMaxRate(),
- getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE
- : getMinLargeMessageSize(),
- getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE
- : getBlockOnAcknowledge(),
- getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND
- : getBlockOnNonPersistentSend(),
- getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND
- : getBlockOnPersistentSend(),
- getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP
- : getAutoGroup(),
- getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS
- : getMaxConnections(),
- getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE
- : getPreAcknowledge(),
- getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL
- : getRetryInterval(),
- getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER
- : getRetryIntervalMultiplier(),
- getReconnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS
- : getReconnectAttempts(),
- isFailoverOnServerShutdown() == null ? ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN
- : isFailoverOnServerShutdown());
+ jBossConnectionFactory = createRemoteFactory(getConnectorClassName(), getConnectionParameters());
}
else if (getDiscoveryGroupAddress() != null && getDiscoveryGroupPort() != null)
{
- jBossConnectionFactory = new JBossConnectionFactory(getDiscoveryGroupAddress(),
- getDiscoveryGroupPort(),
- getDiscoveryRefreshTimeout() == null ? ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT
- : getDiscoveryRefreshTimeout(),
- getDiscoveryInitialWaitTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT
- : getDiscoveryInitialWaitTimeout(),
- getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME
- : getLoadBalancingPolicyClassName(),
- getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD
- : getPingPeriod(),
- getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL
- : getConnectionTTL(),
- getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT
- : getCallTimeout(),
- getClientID(),
- getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
- : getDupsOKBatchSize(),
- getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
- : getTransactionBatchSize(),
- getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE
- : getConsumerWindowSize(),
- getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE
- : getConsumerMaxRate(),
- getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE
- : getSendWindowSize(),
- getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE
- : getProducerMaxRate(),
- getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE
- : getMinLargeMessageSize(),
- getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE
- : getBlockOnAcknowledge(),
- getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND
- : getBlockOnNonPersistentSend(),
- getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND
- : getBlockOnPersistentSend(),
- getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP
- : getAutoGroup(),
- getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS
- : getMaxConnections(),
- getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE
- : getPreAcknowledge(),
- getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL
- : getRetryInterval(),
- getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER
- : getRetryIntervalMultiplier(),
- getReconnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS
- : getReconnectAttempts(),
- isFailoverOnServerShutdown() == null ? ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN
- : isFailoverOnServerShutdown());
+ jBossConnectionFactory = createDiscoveryFactory(getDiscoveryGroupAddress(), getDiscoveryGroupPort());
}
else
{
@@ -1461,46 +1435,6 @@
sessionFactory = jBossConnectionFactory.getCoreFactory();
}
- private Object getTransportParam(String[] conf)
- {
- Object val = null;
- if ("Integer".equals(conf[2]))
- {
- try
- {
- val = Integer.parseInt(conf[1]);
- }
- catch (NumberFormatException e)
- {// ok warning at end wll pick up
- }
- }
- else if ("Long".equals(conf[2]))
- {
- try
- {
- val = Long.parseLong(conf[1]);
- }
- catch (NumberFormatException e)
- {// ok warning at end wll pick up
- }
- }
- else if ("Boolean".equals(conf[2]))
- {
- try
- {
- val = Boolean.parseBoolean(conf[1]);
- }
- catch (NumberFormatException e)
- {// ok warning at end wll pick up
- }
- }
- else if ("String".equals(conf[2]))
- {
- val = conf[2];
- }
- return val;
- }
-
public JBossConnectionFactory getJBossConnectionFactory() throws ResourceException
{
if (!configured.getAndSet(true))
Modified: trunk/src/main/org/jboss/messaging/ra/JBMSessionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMSessionFactoryImpl.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/ra/JBMSessionFactoryImpl.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -40,13 +40,11 @@
import javax.jms.Topic;
import javax.jms.TopicSession;
import javax.jms.XAQueueSession;
-import javax.jms.XATopicSession;
import javax.jms.XASession;
+import javax.jms.XATopicSession;
import javax.naming.Reference;
import javax.resource.Referenceable;
-import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
-import javax.resource.spi.ManagedConnectionFactory;
import org.jboss.messaging.core.logging.Logger;
Modified: trunk/src/main/org/jboss/messaging/ra/Util.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/Util.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/ra/Util.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -21,6 +21,9 @@
*/
package org.jboss.messaging.ra;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.naming.Context;
/**
@@ -151,4 +154,25 @@
{
return context.lookup(name);
}
+
+ public static Map<String, Object> parseConfig(String config)
+ {
+ HashMap<String, Object> result = new HashMap<String, Object>();
+
+ String elements[] = config.split(";");
+
+ for (String element: elements)
+ {
+ String expression[] = element.split("=");
+
+ if (expression.length != 2)
+ {
+ throw new IllegalArgumentException("Invalid expression " + element + " at " + config);
+ }
+
+ result.put(expression[0].trim(), expression[1].trim());
+ }
+
+ return result;
+ }
}
Modified: trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -23,7 +23,9 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.Destination;
@@ -41,6 +43,9 @@
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.jms.JBossDestination;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.JBossTopic;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
import org.jboss.messaging.ra.JBMResourceAdapter;
import org.jboss.messaging.ra.Util;
import org.jboss.messaging.utils.SimpleString;
@@ -110,11 +115,13 @@
private List<JBMMessageHandler> handlers = new ArrayList<JBMMessageHandler>();
+ private JBossConnectionFactory factory;
+
static
{
try
{
- ONMESSAGE = MessageListener.class.getMethod("onMessage", new Class[]{Message.class});
+ ONMESSAGE = MessageListener.class.getMethod("onMessage", new Class[] { Message.class });
}
catch (Exception e)
{
@@ -282,7 +289,6 @@
teardown();
}
-
/**
* Setup the activation
*
@@ -292,10 +298,13 @@
{
log.debug("Setting up " + spec);
+ setupCF();
+
setupDestination();
for (int i = 0; i < spec.getMaxSessionInt(); i++)
{
- ClientSession session = setupSession(spec.getUser(), spec.getPassword(), spec.getClientId());
+ ClientSession session = setupSession();
+
JBMMessageHandler handler = new JBMMessageHandler(this, session);
handler.setup();
session.start();
@@ -320,8 +329,18 @@
log.debug("Tearing down complete " + this);
}
-
-
+ protected void setupCF() throws Exception
+ {
+ if (spec.getConnectorClassName() == null)
+ {
+ this.factory = ra.getJBossConnectionFactory();
+ }
+ else
+ {
+ this.factory = ra.createRemoteFactory(spec.getConnectorClassName(), spec.getParsedConnectionParameters());
+ }
+ }
+
/**
* Setup a session
*
@@ -331,13 +350,20 @@
* @return The connection
* @throws Exception Thrown if an error occurs
*/
- protected ClientSession setupSession(String user, String pass, String clientID) throws Exception
+ protected ClientSession setupSession() throws Exception
{
ClientSession result = null;
try
{
- result = ra.createSession(spec.getAcknowledgeModeInt(), user, pass, ra.getPreAcknowledge(), ra.getDupsOKBatchSize(), ra.getTransactionBatchSize(), isDeliveryTransacted);
+ result = ra.createSession(this.factory.getCoreFactory(),
+ spec.getAcknowledgeModeInt(),
+ spec.getUser(),
+ spec.getPassword(),
+ ra.getPreAcknowledge(),
+ ra.getDupsOKBatchSize(),
+ ra.getTransactionBatchSize(),
+ isDeliveryTransacted);
log.debug("Using queue connection " + result);
@@ -358,7 +384,7 @@
}
if (t instanceof Exception)
{
- throw (Exception) t;
+ throw (Exception)t;
}
throw new RuntimeException("Error configuring connection", t);
}
@@ -395,14 +421,34 @@
}
log.debug("Retrieving destination " + destinationName + " of type " + destinationType.getName());
- destination = (JBossDestination) Util.lookup(ctx, destinationName, destinationType);
+ try
+ {
+ destination = (JBossDestination)Util.lookup(ctx, destinationName, destinationType);
+ }
+ catch (Exception e)
+ {
+ if (destinationName == null)
+ {
+ System.out.println("destination is null, rethrowing exception");
+ throw e;
+ }
+ // If there is no binding on naming, we will just create a new instance
+ if (isTopic)
+ {
+ destination = new JBossTopic(destinationName.substring(destinationName.lastIndexOf('/') + 1));
+ }
+ else
+ {
+ destination = new JBossQueue(destinationName.substring(destinationName.lastIndexOf('/') + 1));
+ }
+ }
}
else
{
log.debug("Destination type not defined");
log.debug("Retrieving destination " + destinationName + " of type " + Destination.class.getName());
- destination = (JBossDestination) Util.lookup(ctx, destinationName, Destination.class);
+ destination = (JBossDestination)Util.lookup(ctx, destinationName, Destination.class);
if (destination instanceof Topic)
{
isTopic = true;
@@ -432,13 +478,10 @@
{
buffer.append(" connection=").append(session);
}*/
- //if (pool != null)
- //buffer.append(" pool=").append(pool.getClass().getName());
+ // if (pool != null)
+ // buffer.append(" pool=").append(pool.getClass().getName());
buffer.append(" transacted=").append(isDeliveryTransacted);
buffer.append(')');
return buffer.toString();
}
}
-
-
-
Modified: trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivationSpec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivationSpec.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivationSpec.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -21,8 +21,12 @@
*/
package org.jboss.messaging.ra.inflow;
+import java.util.HashMap;
+import java.util.Map;
+
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.ra.JBMResourceAdapter;
+import org.jboss.messaging.ra.Util;
import javax.jms.Session;
import javax.resource.ResourceException;
@@ -32,10 +36,12 @@
/**
* The activation spec
+ * These properties are set on the MDB ActivactionProperties
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
* @version $Revision: $
*/
public class JBMActivationSpec implements ActivationSpec
@@ -45,7 +51,15 @@
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
+
+ /** The transport config, changing the default configured from the RA */
+ private Map<String, Object> connectionParameters = new HashMap<String, Object>();
+
+ public String strConnectionParameters;
+ /** The transport type, changing the default configured from the RA */
+ private String connectorClassName;
+
/** The resource adapter */
private JBMResourceAdapter ra;
@@ -238,7 +252,7 @@
if (trace)
log.trace("setMessageSelector(" + value + ")");
- this.messageSelector = messageSelector;
+ this.messageSelector = value;
}
/**
@@ -793,6 +807,38 @@
}
/**
+ * @return the connectionParameters
+ */
+ public String getConnectionParameters()
+ {
+ return strConnectionParameters;
+ }
+
+ public Map<String, Object> getParsedConnectionParameters()
+ {
+ return connectionParameters;
+ }
+
+ public void setConnectionParameters(String configuration)
+ {
+ this.strConnectionParameters = configuration;
+ this.connectionParameters = Util.parseConfig(configuration);
+ }
+
+ /**
+ * @return the connectorClassName
+ */
+ public String getConnectorClassName()
+ {
+ return connectorClassName;
+ }
+
+ public void setConnectorClassName(String value)
+ {
+ this.connectorClassName = value;
+ }
+
+ /**
* Get a string representation
* @return The value
*/
@@ -823,7 +869,7 @@
buffer.append(')');
return buffer.toString();
}
-
+
//here for backwards compatibilty
public void setUseDLQ(boolean b)
{
Modified: trunk/src/main/org/jboss/messaging/utils/ConfigurationHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/utils/ConfigurationHelper.java 2009-04-24 22:54:50 UTC (rev 6565)
+++ trunk/src/main/org/jboss/messaging/utils/ConfigurationHelper.java 2009-04-24 23:01:47 UTC (rev 6566)
@@ -53,9 +53,7 @@
{
if (prop instanceof String == false)
{
- log.warn("Property " + propName + " must be a String");
-
- return def;
+ return prop.toString();
}
else
{
@@ -79,6 +77,12 @@
}
else
{
+ // The resource adapter will aways send Strings, hence the conversion here
+ if (prop instanceof String)
+ {
+ return Integer.valueOf((String)prop);
+ }
+ else
if (prop instanceof Integer == false)
{
log.warn("Property " + propName + " must be an Integer");
@@ -108,6 +112,12 @@
}
else
{
+ // The resource adapter will aways send Strings, hence the conversion here
+ if (prop instanceof String)
+ {
+ return Long.valueOf((String)prop);
+ }
+ else
if (prop instanceof Long == false)
{
log.warn("Property " + propName + " must be an Long");
@@ -137,6 +147,12 @@
}
else
{
+ // The resource adapter will aways send Strings, hence the conversion here
+ if (prop instanceof String)
+ {
+ return Boolean.valueOf((String)prop);
+ }
+ else
if (prop instanceof Boolean == false)
{
log.warn("Property " + propName + " must be a Boolean");
More information about the jboss-cvs-commits
mailing list