You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2014/11/19 00:38:20 UTC
[27/52] [abbrv] [partial] activemq-6 git commit: ACTIVEMQ6-4 Rename
HornetQ* classes to ActiveMQ*
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRABundle.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRABundle.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRABundle.java
new file mode 100644
index 0000000..42953b2
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRABundle.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+
+import org.apache.activemq.api.core.ActiveMQIllegalStateException;
+import org.jboss.logging.annotations.Cause;
+import org.jboss.logging.annotations.Message;
+import org.jboss.logging.annotations.MessageBundle;
+import org.jboss.logging.Messages;
+
+import javax.jms.JMSException;
+import javax.jms.JMSRuntimeException;
+import javax.resource.NotSupportedException;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ * 3/12/12
+ *
+ * Logger Code 15
+ *
+ * each message id must be 6 digits long starting with 15, the 3rd digit should be 9
+ *
+ * so 159000 to 159999
+ */
+@MessageBundle(projectCode = "AMQ")
+public interface ActiveMQRABundle
+{
+ /** Error message for strict behaviour */
+ String ISE = "This method is not applicable inside the application server. See the JEE spec, e.g. JEE 7 Section 6.7";
+
+ ActiveMQRABundle BUNDLE = Messages.getBundle(ActiveMQRABundle.class);
+
+ @Message(id = 159000, value = "Error decoding password using codec instance", format = Message.Format.MESSAGE_FORMAT)
+ ActiveMQIllegalStateException errorDecodingPassword(@Cause Exception e);
+
+ @Message(id = 159001, value = "MDB cannot be deployed as it has no Activation Spec. Please provide an Activation!", format = Message.Format.MESSAGE_FORMAT)
+ NotSupportedException noActivationSpec();
+
+ @Message(id = 159002, value = "Please provide a destination for the MDB", format = Message.Format.MESSAGE_FORMAT)
+ IllegalArgumentException noDestinationName();
+
+ @Message(id = 159003, value = ISE, format = Message.Format.MESSAGE_FORMAT)
+ JMSRuntimeException illegalJEEMethod();
+
+ @Message(id = 159004, value = "Invalid Session Mode SESSION_TRANSACTED", format = Message.Format.MESSAGE_FORMAT)
+ JMSRuntimeException invalidSessionTransactedModeRuntime();
+
+ @Message(id = 159005, value = "Invalid Session Mode CLIENT_ACKNOWLEDGE", format = Message.Format.MESSAGE_FORMAT)
+ JMSRuntimeException invalidClientAcknowledgeModeRuntime();
+
+ @Message(id = 159006, value = "Invalid Session Mode {0}", format = Message.Format.MESSAGE_FORMAT)
+ JMSRuntimeException invalidAcknowledgeMode(int sessionMode);
+
+ @Message(id = 159007, value = "Invalid Session Mode SESSION_TRANSACTED", format = Message.Format.MESSAGE_FORMAT)
+ JMSException invalidSessionTransactedMode();
+
+ @Message(id = 159008, value = "Invalid Session Mode CLIENT_ACKNOWLEDGE", format = Message.Format.MESSAGE_FORMAT)
+ JMSException invalidClientAcknowledgeMode();
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRABytesMessage.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRABytesMessage.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRABytesMessage.java
new file mode 100644
index 0000000..c4a24c7
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRABytesMessage.java
@@ -0,0 +1,455 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import java.util.Arrays;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+
+
+/**
+ * A wrapper for a message
+ *
+ * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
+ */
+public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMessage
+{
+ /** Whether trace is enabled */
+ private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
+
+ /**
+ * Create a new wrapper
+ * @param message the message
+ * @param session the session
+ */
+ public ActiveMQRABytesMessage(final BytesMessage message, final ActiveMQRASession session)
+ {
+ super(message, session);
+
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor(" + message + ", " + session + ")");
+ }
+ }
+
+ /**
+ * Get body length
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public long getBodyLength() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getBodyLength()");
+ }
+
+ return ((BytesMessage)message).getBodyLength();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public boolean readBoolean() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readBoolean()");
+ }
+
+ return ((BytesMessage)message).readBoolean();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public byte readByte() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readByte()");
+ }
+
+ return ((BytesMessage)message).readByte();
+ }
+
+ /**
+ * Read
+ * @param value The value
+ * @param length The length
+ * @return The result
+ * @exception JMSException Thrown if an error occurs
+ */
+ public int readBytes(final byte[] value, final int length) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readBytes(" + Arrays.toString(value) + ", " + length + ")");
+ }
+
+ return ((BytesMessage)message).readBytes(value, length);
+ }
+
+ /**
+ * Read
+ * @param value The value
+ * @return The result
+ * @exception JMSException Thrown if an error occurs
+ */
+ public int readBytes(final byte[] value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readBytes(" + Arrays.toString(value) + ")");
+ }
+
+ return ((BytesMessage)message).readBytes(value);
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public char readChar() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readChar()");
+ }
+
+ return ((BytesMessage)message).readChar();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public double readDouble() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readDouble()");
+ }
+
+ return ((BytesMessage)message).readDouble();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public float readFloat() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readFloat()");
+ }
+
+ return ((BytesMessage)message).readFloat();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public int readInt() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readInt()");
+ }
+
+ return ((BytesMessage)message).readInt();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public long readLong() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readLong()");
+ }
+
+ return ((BytesMessage)message).readLong();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public short readShort() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readShort()");
+ }
+
+ return ((BytesMessage)message).readShort();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public int readUnsignedByte() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readUnsignedByte()");
+ }
+
+ return ((BytesMessage)message).readUnsignedByte();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public int readUnsignedShort() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readUnsignedShort()");
+ }
+
+ return ((BytesMessage)message).readUnsignedShort();
+ }
+
+ /**
+ * Read
+ * @return The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public String readUTF() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("readUTF()");
+ }
+
+ return ((BytesMessage)message).readUTF();
+ }
+
+ /**
+ * Reset
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void reset() throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("reset()");
+ }
+
+ ((BytesMessage)message).reset();
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeBoolean(final boolean value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeBoolean(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeBoolean(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeByte(final byte value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeByte(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeByte(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @param offset The offset
+ * @param length The length
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeBytes(final byte[] value, final int offset, final int length) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeBytes(" + Arrays.toString(value) + ", " + offset + ", " + length + ")");
+ }
+
+ ((BytesMessage)message).writeBytes(value, offset, length);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeBytes(final byte[] value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeBytes(" + Arrays.toString(value) + ")");
+ }
+
+ ((BytesMessage)message).writeBytes(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeChar(final char value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeChar(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeChar(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeDouble(final double value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeDouble(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeDouble(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeFloat(final float value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeFloat(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeFloat(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeInt(final int value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeInt(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeInt(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeLong(final long value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeLong(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeLong(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeObject(final Object value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeObject(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeObject(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeShort(final short value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeShort(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeShort(value);
+ }
+
+ /**
+ * Write
+ * @param value The value
+ * @exception JMSException Thrown if an error occurs
+ */
+ public void writeUTF(final String value) throws JMSException
+ {
+ if (ActiveMQRABytesMessage.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("writeUTF(" + value + ")");
+ }
+
+ ((BytesMessage)message).writeUTF(value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionFactory.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionFactory.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionFactory.java
new file mode 100644
index 0000000..0c1869e
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionFactory.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import javax.jms.XAQueueConnectionFactory;
+import javax.jms.XATopicConnectionFactory;
+import javax.resource.Referenceable;
+import javax.resource.ResourceException;
+import java.io.Serializable;
+
+import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
+
+/**
+ * An aggregate interface for the JMS connection factories
+ *
+ * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen@jboss.com">Jesper Pedersen</a>
+ */
+public interface ActiveMQRAConnectionFactory extends XAQueueConnectionFactory,
+ XATopicConnectionFactory, Serializable, Referenceable
+{
+ /**
+ * Connection factory capable of handling connections
+ */
+ int CONNECTION = 0;
+
+ /**
+ * Connection factory capable of handling queues
+ */
+ int QUEUE_CONNECTION = 1;
+
+ /**
+ * Connection factory capable of handling topics
+ */
+ int TOPIC_CONNECTION = 2;
+
+ /**
+ * Connection factory capable of handling XA connections
+ */
+ int XA_CONNECTION = 3;
+
+ /**
+ * Connection factory capable of handling XA queues
+ */
+ int XA_QUEUE_CONNECTION = 4;
+
+ /**
+ * Connection factory capable of handling XA topics
+ */
+ int XA_TOPIC_CONNECTION = 5;
+
+ ActiveMQConnectionFactory getDefaultFactory() throws ResourceException;
+
+ ActiveMQResourceAdapter getResourceAdapter();
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionFactoryImpl.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionFactoryImpl.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionFactoryImpl.java
new file mode 100644
index 0000000..b0d6d00
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionFactoryImpl.java
@@ -0,0 +1,570 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import javax.jms.Connection;
+import javax.jms.JMSContext;
+import javax.jms.JMSException;
+import javax.jms.JMSRuntimeException;
+import javax.jms.JMSSecurityException;
+import javax.jms.JMSSecurityRuntimeException;
+import javax.jms.QueueConnection;
+import javax.jms.Session;
+import javax.jms.TopicConnection;
+import javax.jms.XAConnection;
+import javax.jms.XAJMSContext;
+import javax.jms.XAQueueConnection;
+import javax.jms.XATopicConnection;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+
+import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.jms.referenceable.ConnectionFactoryObjectFactory;
+import org.apache.activemq.jms.referenceable.SerializableObjectRefAddr;
+
+/**
+ * The connection factory
+ *
+ * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
+ */
+public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFactory
+{
+ /**
+ * Serial version UID
+ */
+ static final long serialVersionUID = 7981708919479859360L;
+ private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
+
+ /**
+ * The managed connection factory
+ */
+ private final ActiveMQRAManagedConnectionFactory mcf;
+
+ /**
+ * The connection manager
+ */
+ private ConnectionManager cm;
+
+ /**
+ * Naming reference
+ */
+ private Reference reference;
+
+ /**
+ * Constructor
+ *
+ * @param mcf The managed connection factory
+ * @param cm The connection manager
+ */
+ public ActiveMQRAConnectionFactoryImpl(final ActiveMQRAManagedConnectionFactory mcf, final ConnectionManager cm)
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor(" + mcf + ", " + cm + ")");
+ }
+
+ this.mcf = mcf;
+
+ if (cm == null)
+ {
+ // This is standalone usage, no appserver
+ this.cm = new ActiveMQRAConnectionManager();
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created new ConnectionManager=" + this.cm);
+ }
+ }
+ else
+ {
+ this.cm = cm;
+ }
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Using ManagedConnectionFactory=" + mcf + ", ConnectionManager=" + cm);
+ }
+ }
+
+ /**
+ * Set the reference
+ *
+ * @param reference The reference
+ */
+ public void setReference(final Reference reference)
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setReference(" + reference + ")");
+ }
+
+ this.reference = reference;
+ }
+
+ /**
+ * Get the reference
+ *
+ * @return The reference
+ */
+ public Reference getReference()
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getReference()");
+ }
+ if (reference == null)
+ {
+ try
+ {
+ reference = new Reference(this.getClass().getCanonicalName(),
+ new SerializableObjectRefAddr("ActiveMQ-CF", this),
+ ConnectionFactoryObjectFactory.class.getCanonicalName(),
+ null);
+ }
+ catch (NamingException e)
+ {
+ ActiveMQRALogger.LOGGER.errorCreatingReference(e);
+ }
+ }
+
+ return reference;
+
+ }
+
+ /**
+ * Create a queue connection
+ *
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public QueueConnection createQueueConnection() throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createQueueConnection()");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf,
+ cm,
+ getResourceAdapter().getTM(),
+ ActiveMQRAConnectionFactory.QUEUE_CONNECTION);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created queue connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a queue connection
+ *
+ * @param userName The user name
+ * @param password The password
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public QueueConnection createQueueConnection(final String userName, final String password) throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createQueueConnection(" + userName + ", ****)");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf,
+ cm,
+ getResourceAdapter().getTM(),
+ ActiveMQRAConnectionFactory.QUEUE_CONNECTION);
+ s.setUserName(userName);
+ s.setPassword(password);
+
+ validateUser(s);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created queue connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a topic connection
+ *
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public TopicConnection createTopicConnection() throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createTopicConnection()");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf,
+ cm,
+ getResourceAdapter().getTM(),
+ ActiveMQRAConnectionFactory.TOPIC_CONNECTION);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created topic connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a topic connection
+ *
+ * @param userName The user name
+ * @param password The password
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public TopicConnection createTopicConnection(final String userName, final String password) throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createTopicConnection(" + userName + ", ****)");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf,
+ cm,
+ getResourceAdapter().getTM(),
+ ActiveMQRAConnectionFactory.TOPIC_CONNECTION);
+ s.setUserName(userName);
+ s.setPassword(password);
+ validateUser(s);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created topic connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a connection
+ *
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public Connection createConnection() throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createConnection()");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.CONNECTION);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a connection
+ *
+ * @param userName The user name
+ * @param password The password
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public Connection createConnection(final String userName, final String password) throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createConnection(" + userName + ", ****)");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.CONNECTION);
+ s.setUserName(userName);
+ s.setPassword(password);
+
+ validateUser(s);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a XA queue connection
+ *
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public XAQueueConnection createXAQueueConnection() throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createXAQueueConnection()");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf,
+ cm,
+ getResourceAdapter().getTM(),
+ ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created queue connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a XA queue connection
+ *
+ * @param userName The user name
+ * @param password The password
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public XAQueueConnection createXAQueueConnection(final String userName, final String password) throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createXAQueueConnection(" + userName + ", ****)");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf,
+ cm,
+ getResourceAdapter().getTM(),
+ ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION);
+ s.setUserName(userName);
+ s.setPassword(password);
+ validateUser(s);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created queue connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a XA topic connection
+ *
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public XATopicConnection createXATopicConnection() throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createXATopicConnection()");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf,
+ cm,
+ getResourceAdapter().getTM(),
+ ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created topic connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a XA topic connection
+ *
+ * @param userName The user name
+ * @param password The password
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public XATopicConnection createXATopicConnection(final String userName, final String password) throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createXATopicConnection(" + userName + ", ****)");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf,
+ cm,
+ getResourceAdapter().getTM(),
+ ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION);
+ s.setUserName(userName);
+ s.setPassword(password);
+ validateUser(s);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created topic connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a XA connection
+ *
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public XAConnection createXAConnection() throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createXAConnection()");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_CONNECTION);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created connection: " + s);
+ }
+
+ return s;
+ }
+
+ /**
+ * Create a XA connection
+ *
+ * @param userName The user name
+ * @param password The password
+ * @return The connection
+ * @throws JMSException Thrown if the operation fails
+ */
+ public XAConnection createXAConnection(final String userName, final String password) throws JMSException
+ {
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("createXAConnection(" + userName + ", ****)");
+ }
+
+ ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_CONNECTION);
+ s.setUserName(userName);
+ s.setPassword(password);
+ validateUser(s);
+
+ if (ActiveMQRAConnectionFactoryImpl.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Created connection: " + s);
+ }
+
+ return s;
+ }
+
+ @Override
+ public JMSContext createContext()
+ {
+ return createContext(null, null);
+ }
+
+ @Override
+ public JMSContext createContext(String userName, String password)
+ {
+ return createContext(userName, password, Session.AUTO_ACKNOWLEDGE);
+ }
+
+ @Override
+ public JMSContext createContext(String userName, String password, int sessionMode)
+ {
+ @SuppressWarnings("resource")
+ ActiveMQRASessionFactoryImpl conn = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.CONNECTION);
+ conn.setUserName(userName);
+ conn.setPassword(password);
+ try
+ {
+ validateUser(conn);
+ }
+ catch (JMSSecurityException e)
+ {
+ JMSSecurityRuntimeException e2 = new JMSSecurityRuntimeException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ catch (JMSException e)
+ {
+ JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ return conn.createContext(sessionMode);
+ }
+
+ @Override
+ public JMSContext createContext(int sessionMode)
+ {
+ return createContext(null, null, sessionMode);
+ }
+
+ @Override
+ public XAJMSContext createXAContext()
+ {
+ return createXAContext(null, null);
+ }
+
+ @Override
+ public XAJMSContext createXAContext(String userName, String password)
+ {
+ ActiveMQRASessionFactoryImpl conn = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_CONNECTION);
+ conn.setUserName(userName);
+ conn.setPassword(password);
+ try
+ {
+ validateUser(conn);
+ }
+ catch (JMSSecurityException e)
+ {
+ JMSSecurityRuntimeException e2 = new JMSSecurityRuntimeException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ catch (JMSException e)
+ {
+ JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ return conn.createXAContext();
+ }
+
+ private void validateUser(ActiveMQRASessionFactoryImpl s) throws JMSException
+ {
+ Session session = s.createSession();
+ session.close();
+ }
+
+ @Override
+ public ActiveMQConnectionFactory getDefaultFactory() throws ResourceException
+ {
+ return ((ActiveMQResourceAdapter) mcf.getResourceAdapter()).getDefaultActiveMQConnectionFactory();
+ }
+
+ @Override
+ public ActiveMQResourceAdapter getResourceAdapter()
+ {
+ return (ActiveMQResourceAdapter) mcf.getResourceAdapter();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionManager.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionManager.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionManager.java
new file mode 100644
index 0000000..d41d9c7
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionManager.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+
+import org.apache.activemq.utils.ConcurrentHashSet;
+
+
+/**
+ * The connection manager used in non-managed environments.
+ *
+ * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
+ */
+public class ActiveMQRAConnectionManager implements ConnectionManager
+{
+ /** Serial version UID */
+ static final long serialVersionUID = 4409118162975011014L;
+ /** Trace enabled */
+ private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
+
+ /**
+ * Constructor
+ */
+ public ActiveMQRAConnectionManager()
+ {
+ if (ActiveMQRAConnectionManager.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor()");
+ }
+ }
+
+ ConcurrentHashSet<ManagedConnection> connections = new ConcurrentHashSet<>();
+
+ /**
+ * Allocates a connection
+ * @param mcf The managed connection factory
+ * @param cxRequestInfo The connection request information
+ * @return The connection
+ * @exception ResourceException Thrown if there is a problem obtaining the connection
+ */
+ public Object allocateConnection(final ManagedConnectionFactory mcf, final ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ if (ActiveMQRAConnectionManager.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("allocateConnection(" + mcf + ", " + cxRequestInfo + ")");
+ }
+
+ ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo);
+ Object c = mc.getConnection(null, cxRequestInfo);
+
+ if (ActiveMQRAConnectionManager.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("Allocated connection: " + c + ", with managed connection: " + mc);
+ }
+
+ connections.add(mc);
+ return c;
+ }
+
+ public void stop()
+ {
+ for (ManagedConnection conn : connections)
+ {
+ try
+ {
+ conn.destroy();
+ }
+ catch (Throwable e)
+ {
+
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionMetaData.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionMetaData.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionMetaData.java
new file mode 100644
index 0000000..a2dbe98
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionMetaData.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.jms.ConnectionMetaData;
+
+
+/**
+ * This class implements javax.jms.ConnectionMetaData
+ *
+ * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
+ */
+public class ActiveMQRAConnectionMetaData implements ConnectionMetaData
+{
+ /** Trace enabled */
+ private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
+
+ /**
+ * Constructor
+ */
+ public ActiveMQRAConnectionMetaData()
+ {
+ if (ActiveMQRAConnectionMetaData.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor()");
+ }
+ }
+
+ /**
+ * Get the JMS version
+ * @return The version
+ */
+ public String getJMSVersion()
+ {
+ if (ActiveMQRAConnectionMetaData.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getJMSVersion()");
+ }
+
+ return "2.0";
+ }
+
+ /**
+ * Get the JMS major version
+ * @return The major version
+ */
+ public int getJMSMajorVersion()
+ {
+ if (ActiveMQRAConnectionMetaData.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getJMSMajorVersion()");
+ }
+
+ return 2;
+ }
+
+ /**
+ * Get the JMS minor version
+ * @return The minor version
+ */
+ public int getJMSMinorVersion()
+ {
+ if (ActiveMQRAConnectionMetaData.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getJMSMinorVersion()");
+ }
+
+ return 0;
+ }
+
+ /**
+ * Get the JMS provider name
+ * @return The name
+ */
+ public String getJMSProviderName()
+ {
+ if (ActiveMQRAConnectionMetaData.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getJMSProviderName()");
+ }
+
+ return "ActiveMQ";
+ }
+
+ /**
+ * Get the provider version
+ * @return The version
+ */
+ public String getProviderVersion()
+ {
+ if (ActiveMQRAConnectionMetaData.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getJMSProviderName()");
+ }
+
+ return "2.4";
+ }
+
+ /**
+ * Get the provider major version
+ * @return The version
+ */
+ public int getProviderMajorVersion()
+ {
+ if (ActiveMQRAConnectionMetaData.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getProviderMajorVersion()");
+ }
+
+ return 2;
+ }
+
+ /**
+ * Get the provider minor version
+ * @return The version
+ */
+ public int getProviderMinorVersion()
+ {
+ if (ActiveMQRAConnectionMetaData.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getProviderMinorVersion()");
+ }
+
+ return 4;
+ }
+
+ /**
+ * Get the JMS XPropertyNames
+ * @return The names
+ */
+ public Enumeration<Object> getJMSXPropertyNames()
+ {
+ Vector<Object> v = new Vector<Object>();
+ v.add("JMSXGroupID");
+ v.add("JMSXGroupSeq");
+ v.add("JMSXDeliveryCount");
+ return v.elements();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionRequestInfo.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionRequestInfo.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionRequestInfo.java
new file mode 100644
index 0000000..9a37a5d
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAConnectionRequestInfo.java
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import javax.jms.Session;
+import javax.resource.spi.ConnectionRequestInfo;
+
+
+/**
+ * Connection request information
+ *
+ * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo
+{
+ /** Trace enabled */
+ private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
+
+ /** The user name */
+ private String userName;
+
+ /** The password */
+ private String password;
+
+ /** The client id */
+ private String clientID;
+
+ /** The type */
+ private final int type;
+
+ /** Use transactions */
+ private final boolean transacted;
+
+ /** The acknowledge mode */
+ private final int acknowledgeMode;
+
+ /**
+ * Constructor
+ * @param prop The resource adapter properties
+ * @param type The connection type
+ */
+ public ActiveMQRAConnectionRequestInfo(final ActiveMQRAProperties prop, final int type)
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor(" + prop + ")");
+ }
+
+ userName = prop.getUserName();
+ password = prop.getPassword();
+ clientID = prop.getClientID();
+ this.type = type;
+ transacted = true;
+ acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
+ }
+
+ /**
+ * Constructor
+ * @param transacted Use transactions
+ * @param acknowledgeMode The acknowledge mode
+ * @param type The connection type
+ */
+ public ActiveMQRAConnectionRequestInfo(final boolean transacted, final int acknowledgeMode, final int type)
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor(" + transacted +
+ ", " +
+ acknowledgeMode +
+ ", " +
+ type +
+ ")");
+ }
+
+ this.transacted = transacted;
+ this.acknowledgeMode = acknowledgeMode;
+ this.type = type;
+ }
+
+ /**
+ * Fill in default values if they are missing
+ * @param prop The resource adapter properties
+ */
+ public void setDefaults(final ActiveMQRAProperties prop)
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setDefaults(" + prop + ")");
+ }
+
+ if (userName == null)
+ {
+ userName = prop.getUserName();
+ }
+ if (password == null)
+ {
+ password = prop.getPassword();
+ }
+ if (clientID == null)
+ {
+ clientID = prop.getClientID();
+ }
+ }
+
+ /**
+ * Get the user name
+ * @return The value
+ */
+ public String getUserName()
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getUserName()");
+ }
+
+ return userName;
+ }
+
+ /**
+ * Set the user name
+ * @param userName The value
+ */
+ public void setUserName(final String userName)
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setUserName(" + userName + ")");
+ }
+
+ this.userName = userName;
+ }
+
+ /**
+ * Get the password
+ * @return The value
+ */
+ public String getPassword()
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getPassword()");
+ }
+
+ return password;
+ }
+
+ /**
+ * Set the password
+ * @param password The value
+ */
+ public void setPassword(final String password)
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setPassword(****)");
+ }
+
+ this.password = password;
+ }
+
+ /**
+ * Get the client id
+ * @return The value
+ */
+ public String getClientID()
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getClientID()");
+ }
+
+ return clientID;
+ }
+
+ /**
+ * Set the client id
+ * @param clientID The value
+ */
+ public void setClientID(final String clientID)
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setClientID(" + clientID + ")");
+ }
+
+ this.clientID = clientID;
+ }
+
+ /**
+ * Get the connection type
+ * @return The type
+ */
+ public int getType()
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getType()");
+ }
+
+ return type;
+ }
+
+ /**
+ * Use transactions
+ * @return True if transacted; otherwise false
+ */
+ public boolean isTransacted()
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("isTransacted() " + transacted);
+ }
+
+ return transacted;
+ }
+
+ /**
+ * Get the acknowledge mode
+ * @return The mode
+ */
+ public int getAcknowledgeMode()
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getAcknowledgeMode()");
+ }
+
+ return acknowledgeMode;
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ * @param obj Object with which to compare
+ * @return True if this object is the same as the obj argument; false otherwise.
+ */
+ @Override
+ public boolean equals(final Object obj)
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("equals(" + obj + ")");
+ }
+
+ if (obj == null)
+ {
+ return false;
+ }
+
+ if (obj instanceof ActiveMQRAConnectionRequestInfo)
+ {
+ ActiveMQRAConnectionRequestInfo you = (ActiveMQRAConnectionRequestInfo)obj;
+ return ActiveMQRaUtils.compare(userName, you.getUserName()) && ActiveMQRaUtils.compare(password, you.getPassword()) &&
+ ActiveMQRaUtils.compare(clientID, you.getClientID()) &&
+ type == you.getType() &&
+ transacted == you.isTransacted() &&
+ acknowledgeMode == you.getAcknowledgeMode();
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Return the hash code for the object
+ * @return The hash code
+ */
+ @Override
+ public int hashCode()
+ {
+ if (ActiveMQRAConnectionRequestInfo.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("hashCode()");
+ }
+
+ int hash = 7;
+
+ hash += 31 * hash + (userName != null ? userName.hashCode() : 0);
+ hash += 31 * hash + (password != null ? password.hashCode() : 0);
+ hash += 31 * hash + Integer.valueOf(type).hashCode();
+ hash += 31 * hash + (transacted ? 1 : 0);
+ hash += 31 * hash + Integer.valueOf(acknowledgeMode).hashCode();
+
+ return hash;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ActiveMQRAConnectionRequestInfo[type=" + type +
+ ", transacted=" + transacted + ", acknowledgeMode=" + acknowledgeMode +
+ ", clientID=" + clientID + ", userName=" + userName + ", password=****]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRACredential.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRACredential.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRACredential.java
new file mode 100644
index 0000000..69fee4b
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRACredential.java
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import java.io.Serializable;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Set;
+
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.SecurityException;
+import javax.resource.spi.security.PasswordCredential;
+import javax.security.auth.Subject;
+
+
+/**
+ * Credential information
+ *
+ * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
+ * @version $Revision: 71554 $
+ */
+public class ActiveMQRACredential implements Serializable
+{
+ /** Serial version UID */
+ static final long serialVersionUID = 210476602237497193L;
+
+ private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
+
+ /** The user name */
+ private String userName;
+
+ /** The password */
+ private String password;
+
+ /**
+ * Private constructor
+ */
+ private ActiveMQRACredential()
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor()");
+ }
+ }
+
+ /**
+ * Get the user name
+ * @return The value
+ */
+ public String getUserName()
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getUserName()");
+ }
+
+ return userName;
+ }
+
+ /**
+ * Set the user name
+ * @param userName The value
+ */
+ private void setUserName(final String userName)
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setUserName(" + userName + ")");
+ }
+
+ this.userName = userName;
+ }
+
+ /**
+ * Get the password
+ * @return The value
+ */
+ public String getPassword()
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getPassword()");
+ }
+
+ return password;
+ }
+
+ /**
+ * Set the password
+ * @param password The value
+ */
+ private void setPassword(final String password)
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setPassword(****)");
+ }
+
+ this.password = password;
+ }
+
+ /**
+ * Get credentials
+ * @param mcf The managed connection factory
+ * @param subject The subject
+ * @param info The connection request info
+ * @return The credentials
+ * @exception SecurityException Thrown if the credentials can't be retrieved
+ */
+ public static ActiveMQRACredential getCredential(final ManagedConnectionFactory mcf,
+ final Subject subject,
+ final ConnectionRequestInfo info) throws SecurityException
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getCredential(" + mcf + ", " + subject + ", " + info + ")");
+ }
+
+ ActiveMQRACredential jc = new ActiveMQRACredential();
+ if (subject == null && info != null)
+ {
+ jc.setUserName(((ActiveMQRAConnectionRequestInfo)info).getUserName());
+ jc.setPassword(((ActiveMQRAConnectionRequestInfo)info).getPassword());
+ }
+ else if (subject != null)
+ {
+ PasswordCredential pwdc = GetCredentialAction.getCredential(subject, mcf);
+
+ if (pwdc == null)
+ {
+ throw new SecurityException("No password credentials found");
+ }
+
+ jc.setUserName(pwdc.getUserName());
+ jc.setPassword(new String(pwdc.getPassword()));
+ }
+ else
+ {
+ throw new SecurityException("No Subject or ConnectionRequestInfo set, could not get credentials");
+ }
+
+ return jc;
+ }
+
+ /**
+ * String representation
+ * @return The representation
+ */
+ @Override
+ public String toString()
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("toString()");
+ }
+
+ return super.toString() + "{ username=" + userName + ", password=**** }";
+ }
+
+ /**
+ * Privileged class to get credentials
+ */
+ private static class GetCredentialAction implements PrivilegedAction<PasswordCredential>
+ {
+ /** The subject */
+ private final Subject subject;
+
+ /** The managed connection factory */
+ private final ManagedConnectionFactory mcf;
+
+ /**
+ * Constructor
+ * @param subject The subject
+ * @param mcf The managed connection factory
+ */
+ GetCredentialAction(final Subject subject, final ManagedConnectionFactory mcf)
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor(" + subject + ", " + mcf + ")");
+ }
+
+ this.subject = subject;
+ this.mcf = mcf;
+ }
+
+ /**
+ * Run
+ * @return The credential
+ */
+ public PasswordCredential run()
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("run()");
+ }
+
+ Set<PasswordCredential> creds = subject.getPrivateCredentials(PasswordCredential.class);
+ PasswordCredential pwdc = null;
+
+ for (PasswordCredential curCred : creds)
+ {
+ if (curCred.getManagedConnectionFactory().equals(mcf))
+ {
+ pwdc = curCred;
+ break;
+ }
+ }
+ return pwdc;
+ }
+
+ /**
+ * Get credentials
+ * @param subject The subject
+ * @param mcf The managed connection factory
+ * @return The credential
+ */
+ static PasswordCredential getCredential(final Subject subject, final ManagedConnectionFactory mcf)
+ {
+ if (ActiveMQRACredential.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getCredential(" + subject + ", " + mcf + ")");
+ }
+
+ GetCredentialAction action = new GetCredentialAction(subject, mcf);
+ return AccessController.doPrivileged(action);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAJMSContext.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAJMSContext.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAJMSContext.java
new file mode 100644
index 0000000..b02e623
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAJMSContext.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import org.apache.activemq.jms.client.ActiveMQConnectionForContext;
+import org.apache.activemq.jms.client.ActiveMQJMSContext;
+import org.apache.activemq.jms.client.ThreadAwareContext;
+
+import javax.jms.ExceptionListener;
+import javax.jms.JMSContext;
+
+public class ActiveMQRAJMSContext extends ActiveMQJMSContext
+{
+ public ActiveMQRAJMSContext(ActiveMQConnectionForContext connection, int ackMode, ThreadAwareContext threadAwareContext)
+ {
+ super(connection, ackMode, threadAwareContext);
+ }
+
+ public ActiveMQRAJMSContext(ActiveMQConnectionForContext connection, ThreadAwareContext threadAwareContext)
+ {
+ super(connection, threadAwareContext);
+ }
+
+ @Override
+ public JMSContext createContext(int sessionMode)
+ {
+ throw ActiveMQRABundle.BUNDLE.illegalJEEMethod();
+ }
+
+ @Override
+ public void stop()
+ {
+ throw ActiveMQRABundle.BUNDLE.illegalJEEMethod();
+ }
+
+ @Override
+ public void setClientID(String clientID)
+ {
+ throw ActiveMQRABundle.BUNDLE.illegalJEEMethod();
+ }
+
+ @Override
+ public void setExceptionListener(ExceptionListener listener)
+ {
+ throw ActiveMQRABundle.BUNDLE.illegalJEEMethod();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRALocalTransaction.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRALocalTransaction.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRALocalTransaction.java
new file mode 100644
index 0000000..8de68ee
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRALocalTransaction.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import javax.jms.JMSException;
+import javax.resource.ResourceException;
+import javax.resource.spi.LocalTransaction;
+
+
+/**
+ * JMS Local transaction
+ *
+ * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
+ */
+public class ActiveMQRALocalTransaction implements LocalTransaction
+{
+ /** Trace enabled */
+ private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
+
+ /** The managed connection */
+ private final ActiveMQRAManagedConnection mc;
+
+ /**
+ * Constructor
+ * @param mc The managed connection
+ */
+ public ActiveMQRALocalTransaction(final ActiveMQRAManagedConnection mc)
+ {
+ if (ActiveMQRALocalTransaction.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor(" + mc + ")");
+ }
+
+ this.mc = mc;
+ }
+
+ /**
+ * Begin
+ * @exception ResourceException Thrown if the operation fails
+ */
+ public void begin() throws ResourceException
+ {
+ if (ActiveMQRALocalTransaction.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("begin()");
+ }
+
+ // mc.setInManagedTx(true);
+ }
+
+ /**
+ * Commit
+ * @exception ResourceException Thrown if the operation fails
+ */
+ public void commit() throws ResourceException
+ {
+ if (ActiveMQRALocalTransaction.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("commit()");
+ }
+
+ mc.lock();
+ try
+ {
+ if (mc.getSession().getTransacted())
+ {
+ mc.getSession().commit();
+ }
+ }
+ catch (JMSException e)
+ {
+ throw new ResourceException("Could not commit LocalTransaction", e);
+ }
+ finally
+ {
+ //mc.setInManagedTx(false);
+ mc.unlock();
+ }
+ }
+
+ /**
+ * Rollback
+ * @exception ResourceException Thrown if the operation fails
+ */
+ public void rollback() throws ResourceException
+ {
+ if (ActiveMQRALocalTransaction.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("rollback()");
+ }
+
+ mc.lock();
+ try
+ {
+ if (mc.getSession().getTransacted())
+ {
+ mc.getSession().rollback();
+ }
+ }
+ catch (JMSException ex)
+ {
+ throw new ResourceException("Could not rollback LocalTransaction", ex);
+ }
+ finally
+ {
+ //mc.setInManagedTx(false);
+ mc.unlock();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRALogger.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRALogger.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRALogger.java
new file mode 100644
index 0000000..8c0cf18
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRALogger.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.apache.activemq.ra;
+
+import org.apache.activemq.ra.inflow.ActiveMQActivationSpec;
+import org.jboss.logging.BasicLogger;
+import org.jboss.logging.Logger;
+import org.jboss.logging.annotations.Cause;
+import org.jboss.logging.annotations.LogMessage;
+import org.jboss.logging.annotations.Message;
+import org.jboss.logging.annotations.MessageLogger;
+
+/**
+ * Logger Code 15
+ * <p/>
+ * each message id must be 6 digits long starting with 15, the 3rd digit donates
+ * the level so
+ * <p/>
+ * <pre>
+ * INF0 1
+ * WARN 2
+ * DEBUG 3
+ * ERROR 4
+ * TRACE 5
+ * FATAL 6
+ * </pre>
+ * <p/>
+ * so an INFO message would be 151000 to 151999
+ *
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a> 3/15/12
+ */
+@MessageLogger(projectCode = "AMQ")
+public interface ActiveMQRALogger extends BasicLogger
+{
+ /**
+ * The default logger.
+ */
+ ActiveMQRALogger LOGGER = Logger.getMessageLogger(ActiveMQRALogger.class, ActiveMQRALogger.class.getPackage().getName());
+
+ @LogMessage(level = Logger.Level.INFO)
+ @Message(id = 151000, value = "awaiting topic/queue creation {0}", format = Message.Format.MESSAGE_FORMAT)
+ void awaitingTopicQueueCreation(String destination);
+
+ @LogMessage(level = Logger.Level.INFO)
+ @Message(id = 151001, value = "Attempting to reconnect {0}", format = Message.Format.MESSAGE_FORMAT)
+ void attemptingReconnect(ActiveMQActivationSpec spec);
+
+ @LogMessage(level = Logger.Level.INFO)
+ @Message(id = 151002, value = "Reconnected with ActiveMQ", format = Message.Format.MESSAGE_FORMAT)
+ void reconnected();
+
+ @LogMessage(level = Logger.Level.INFO)
+ @Message(id = 151003, value = "ActiveMQ resource adaptor stopped", format = Message.Format.MESSAGE_FORMAT)
+ void raStopped();
+
+ @LogMessage(level = Logger.Level.INFO)
+ @Message(id = 151004, value = "Instantiating {0} \"{1}\" directly since UseJNDI=false.", format = Message.Format.MESSAGE_FORMAT)
+ void instantiatingDestination(String destinationType, String destination);
+
+ @LogMessage(level = Logger.Level.INFO)
+ @Message(id = 151005, value = "awaiting ActiveMQ Server availability", format = Message.Format.MESSAGE_FORMAT)
+ void awaitingJMSServerCreation();
+
+ @LogMessage(level = Logger.Level.WARN)
+ @Message(id = 152000, value = "It wasn''t possible to lookup for a Transaction Manager through the configured properties TransactionManagerLocatorClass and TransactionManagerLocatorMethod\nActiveMQ Resource Adapter won''t be able to set and verify transaction timeouts in certain cases.", format = Message.Format.MESSAGE_FORMAT)
+ void noTXLocator();
+
+ @LogMessage(level = Logger.Level.WARN)
+ @Message(id = 152001, value = "problem resetting ActiveMQ xa session after failure", format = Message.Format.MESSAGE_FORMAT)
+ void problemResettingXASession();
+
+ @LogMessage(level = Logger.Level.WARN)
+ @Message(id = 152002, value = "Unable to roll local transaction back", format = Message.Format.MESSAGE_FORMAT)
+ void unableToRollbackTX();
+
+ @LogMessage(level = Logger.Level.WARN)
+ @Message(id = 152003, value = "unable to reset session after failure", format = Message.Format.MESSAGE_FORMAT)
+ void unableToResetSession();
+
+ @LogMessage(level = Logger.Level.WARN)
+ @Message(id = 152004, value = "Handling JMS exception failure", format = Message.Format.MESSAGE_FORMAT)
+ void handlingJMSFailure(@Cause Exception e);
+
+ @LogMessage(level = Logger.Level.WARN)
+ @Message(id = 152005, value = "Failure in ActiveMQ activation {0}", format = Message.Format.MESSAGE_FORMAT)
+ void failureInActivation(@Cause Throwable t, ActiveMQActivationSpec spec);
+
+ @LogMessage(level = Logger.Level.WARN)
+ @Message(id = 152006, value = "Unable to call after delivery", format = Message.Format.MESSAGE_FORMAT)
+ void unableToCallAfterDelivery(@Cause Exception e);
+
+ @LogMessage(level = Logger.Level.ERROR)
+ @Message(id = 154000, value = "Error while creating object Reference.", format = Message.Format.MESSAGE_FORMAT)
+ void errorCreatingReference(@Cause Exception e);
+
+ @LogMessage(level = Logger.Level.ERROR)
+ @Message(id = 154001, value = "Unable to stop ActiveMQ resource adapter.", format = Message.Format.MESSAGE_FORMAT)
+ void errorStoppingRA(@Cause Exception e);
+
+ @LogMessage(level = Logger.Level.ERROR)
+ @Message(id = 154003, value = "Unable to reconnect {0}", format = Message.Format.MESSAGE_FORMAT)
+ void errorReconnecting(@Cause Throwable t, ActiveMQActivationSpec spec);
+
+ @LogMessage(level = Logger.Level.ERROR)
+ @Message(id = 154004, value = "Failed to deliver message", format = Message.Format.MESSAGE_FORMAT)
+ void errorDeliveringMessage(@Cause Throwable t);
+
+ @LogMessage(level = Logger.Level.DEBUG)
+ @Message(id = 153001, value = "using different ActiveMQRAConnectionFactory", format = Message.Format.MESSAGE_FORMAT)
+ void warnDifferentConnectionfactory();
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAMCFProperties.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAMCFProperties.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAMCFProperties.java
new file mode 100644
index 0000000..13db7a6
--- /dev/null
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAMCFProperties.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import java.io.Serializable;
+
+import javax.jms.Queue;
+import javax.jms.Topic;
+
+
+/**
+ * The MCF default properties - these are set in the <tx-connection-factory> at the jms-ds.xml
+ *
+ * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties implements Serializable
+{
+ /**
+ * Serial version UID
+ */
+ static final long serialVersionUID = -5951352236582886862L;
+ /**
+ * Trace enabled
+ */
+ private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
+
+ /**
+ * The queue type
+ */
+ private static final String QUEUE_TYPE = Queue.class.getName();
+
+ /**
+ * The topic type
+ */
+ private static final String TOPIC_TYPE = Topic.class.getName();
+
+
+ private String strConnectorClassName;
+
+ public String strConnectionParameters;
+
+ /**
+ * The connection type
+ */
+ private int type = ActiveMQRAConnectionFactory.CONNECTION;
+
+ /**
+ * Use tryLock
+ */
+ private Integer useTryLock;
+
+ /**
+ * Constructor
+ */
+ public ActiveMQRAMCFProperties()
+ {
+ if (ActiveMQRAMCFProperties.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("constructor()");
+ }
+
+ useTryLock = null;
+ }
+
+ /**
+ * Get the connection type
+ *
+ * @return The type
+ */
+ public int getType()
+ {
+ if (ActiveMQRAMCFProperties.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getType()");
+ }
+
+ return type;
+ }
+
+ public String getConnectorClassName()
+ {
+ return strConnectorClassName;
+ }
+
+ public void setConnectorClassName(final String connectorClassName)
+ {
+ if (ActiveMQRAMCFProperties.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setConnectorClassName(" + connectorClassName + ")");
+ }
+
+ strConnectorClassName = connectorClassName;
+
+ setParsedConnectorClassNames(ActiveMQRaUtils.parseConnectorConnectorConfig(connectorClassName));
+ }
+ /**
+ * @return the connectionParameters
+ */
+ public String getStrConnectionParameters()
+ {
+ return strConnectionParameters;
+ }
+
+ public void setConnectionParameters(final String configuration)
+ {
+ strConnectionParameters = configuration;
+ setParsedConnectionParameters(ActiveMQRaUtils.parseConfig(configuration));
+ }
+
+ /**
+ * Set the default session type.
+ *
+ * @param defaultType either javax.jms.Topic or javax.jms.Queue
+ */
+ public void setSessionDefaultType(final String defaultType)
+ {
+ if (ActiveMQRAMCFProperties.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setSessionDefaultType(" + type + ")");
+ }
+
+ if (defaultType.equals(ActiveMQRAMCFProperties.QUEUE_TYPE))
+ {
+ type = ActiveMQRAConnectionFactory.QUEUE_CONNECTION;
+ }
+ else if (defaultType.equals(ActiveMQRAMCFProperties.TOPIC_TYPE))
+ {
+ type = ActiveMQRAConnectionFactory.TOPIC_CONNECTION;
+ }
+ else
+ {
+ type = ActiveMQRAConnectionFactory.CONNECTION;
+ }
+ }
+
+ /**
+ * Get the default session type.
+ *
+ * @return The default session type
+ */
+ public String getSessionDefaultType()
+ {
+ if (ActiveMQRAMCFProperties.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getSessionDefaultType()");
+ }
+
+ if (type == ActiveMQRAConnectionFactory.CONNECTION)
+ {
+ return "BOTH";
+ }
+ else if (type == ActiveMQRAConnectionFactory.QUEUE_CONNECTION)
+ {
+ return ActiveMQRAMCFProperties.TOPIC_TYPE;
+ }
+ else
+ {
+ return ActiveMQRAMCFProperties.QUEUE_TYPE;
+ }
+ }
+
+ /**
+ * Get the useTryLock.
+ *
+ * @return the useTryLock.
+ */
+ public Integer getUseTryLock()
+ {
+ if (ActiveMQRAMCFProperties.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("getUseTryLock()");
+ }
+
+ return useTryLock;
+ }
+
+ /**
+ * Set the useTryLock.
+ *
+ * @param useTryLock the useTryLock.
+ */
+ public void setUseTryLock(final Integer useTryLock)
+ {
+ if (ActiveMQRAMCFProperties.trace)
+ {
+ ActiveMQRALogger.LOGGER.trace("setUseTryLock(" + useTryLock + ")");
+ }
+
+ this.useTryLock = useTryLock;
+ }
+}