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 2015/08/10 17:13:19 UTC
[20/53] [abbrv] [partial] activemq-artemis git commit: automatic
checkstyle change
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java
index 7cf7519..2fd03fc 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java
@@ -24,8 +24,7 @@ import org.apache.activemq.artemis.api.core.management.Parameter;
/**
* A JMSSserverControl is used to manage ActiveMQ Artemis JMS server.
*/
-public interface JMSServerControl
-{
+public interface JMSServerControl {
// Attributes ----------------------------------------------------
/**
@@ -107,7 +106,8 @@ public interface JMSServerControl
* @return {@code true} if the queue was destroyed, {@code false} else
*/
@Operation(desc = "Destroy a JMS Queue", impact = MBeanOperationInfo.ACTION)
- boolean destroyQueue(@Parameter(name = "name", desc = "Name of the queue to destroy") String name, @Parameter(name = "removeConsumers", desc = "disconnect any consumers connected to this queue") boolean removeConsumers) throws Exception;
+ boolean destroyQueue(@Parameter(name = "name", desc = "Name of the queue to destroy") String name,
+ @Parameter(name = "removeConsumers", desc = "disconnect any consumers connected to this queue") boolean removeConsumers) throws Exception;
/**
* Creates a JMS Topic.
@@ -132,7 +132,8 @@ public interface JMSServerControl
* @return {@code true} if the topic was destroyed, {@code false} else
*/
@Operation(desc = "Destroy a JMS Topic", impact = MBeanOperationInfo.ACTION)
- boolean destroyTopic(@Parameter(name = "name", desc = "Name of the topic to destroy") String name, @Parameter(name = "removeConsumers", desc = "disconnect any consumers connected to this queue") boolean removeConsumers) throws Exception;
+ boolean destroyTopic(@Parameter(name = "name", desc = "Name of the topic to destroy") String name,
+ @Parameter(name = "removeConsumers", desc = "disconnect any consumers connected to this queue") boolean removeConsumers) throws Exception;
/**
* Destroys a JMS Topic with the specified name.
@@ -208,7 +209,6 @@ public interface JMSServerControl
@Parameter(name = "failoverOnInitialConnection", desc = "failoverOnInitialConnection") boolean failoverOnInitialConnection,
@Parameter(name = "groupId", desc = "groupId") String groupId) throws Exception;
-
@Operation(desc = "Create a JMS ConnectionFactory", impact = MBeanOperationInfo.ACTION)
void createConnectionFactory(@Parameter(name = "name") String name,
@Parameter(name = "ha") boolean ha,
@@ -246,7 +246,6 @@ public interface JMSServerControl
@Parameter(name = "failoverOnInitialConnection", desc = "failoverOnInitialConnection") boolean failoverOnInitialConnection,
@Parameter(name = "groupId", desc = "groupId") String groupId) throws Exception;
-
@Operation(desc = "Destroy a JMS ConnectionFactory", impact = MBeanOperationInfo.ACTION)
void destroyConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to destroy") String name) throws Exception;
@@ -358,7 +357,6 @@ public interface JMSServerControl
@Operation(desc = "List all the prepared transaction, sorted by date, oldest first, with details, in HTML format", impact = MBeanOperationInfo.INFO)
String listPreparedTransactionDetailsAsHTML() throws Exception;
-
/**
* List all the prepared transaction, sorted by date,
* oldest first, with details, in HTML format
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSSessionInfo.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSSessionInfo.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSSessionInfo.java
index f1faf37..56829c9 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSSessionInfo.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSSessionInfo.java
@@ -20,40 +20,34 @@ import org.apache.activemq.artemis.utils.json.JSONArray;
import org.apache.activemq.artemis.utils.json.JSONException;
import org.apache.activemq.artemis.utils.json.JSONObject;
-public class JMSSessionInfo
-{
+public class JMSSessionInfo {
+
private final String sessionID;
private final long creationTime;
- public JMSSessionInfo(String sessionID, long creationTime)
- {
+ public JMSSessionInfo(String sessionID, long creationTime) {
this.sessionID = sessionID;
this.creationTime = creationTime;
}
- public static JMSSessionInfo[] from(final String jsonString) throws JSONException
- {
+ public static JMSSessionInfo[] from(final String jsonString) throws JSONException {
JSONArray array = new JSONArray(jsonString);
JMSSessionInfo[] infos = new JMSSessionInfo[array.length()];
- for (int i = 0; i < array.length(); i++)
- {
+ for (int i = 0; i < array.length(); i++) {
JSONObject obj = array.getJSONObject(i);
- JMSSessionInfo info = new JMSSessionInfo(obj.getString("sessionID"),
- obj.getLong("creationTime"));
+ JMSSessionInfo info = new JMSSessionInfo(obj.getString("sessionID"), obj.getLong("creationTime"));
infos[i] = info;
}
return infos;
}
- public String getSessionID()
- {
+ public String getSessionID() {
return sessionID;
}
- public long getCreationTime()
- {
+ public long getCreationTime() {
return creationTime;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/SubscriptionInfo.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/SubscriptionInfo.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/SubscriptionInfo.java
index cf83b44..66d04b6 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/SubscriptionInfo.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/SubscriptionInfo.java
@@ -23,8 +23,8 @@ import org.apache.activemq.artemis.utils.json.JSONObject;
* Helper class to create Java Objects from the
* JSON serialization returned by {@link TopicControl#listAllSubscriptionsAsJSON()} and related methods.
*/
-public class SubscriptionInfo
-{
+public class SubscriptionInfo {
+
private final String queueName;
private final String clientID;
@@ -45,20 +45,12 @@ public class SubscriptionInfo
* Returns an array of SubscriptionInfo corresponding to the JSON serialization returned
* by {@link TopicControl#listAllSubscriptionsAsJSON()} and related methods.
*/
- public static SubscriptionInfo[] from(final String jsonString) throws Exception
- {
+ public static SubscriptionInfo[] from(final String jsonString) throws Exception {
JSONArray array = new JSONArray(jsonString);
SubscriptionInfo[] infos = new SubscriptionInfo[array.length()];
- for (int i = 0; i < array.length(); i++)
- {
+ for (int i = 0; i < array.length(); i++) {
JSONObject sub = array.getJSONObject(i);
- SubscriptionInfo info = new SubscriptionInfo(sub.getString("queueName"),
- sub.optString("clientID", null),
- sub.optString("name", null),
- sub.getBoolean("durable"),
- sub.optString("selector", null),
- sub.getInt("messageCount"),
- sub.getInt("deliveringCount"));
+ SubscriptionInfo info = new SubscriptionInfo(sub.getString("queueName"), sub.optString("clientID", null), sub.optString("name", null), sub.getBoolean("durable"), sub.optString("selector", null), sub.getInt("messageCount"), sub.getInt("deliveringCount"));
infos[i] = info;
}
@@ -73,8 +65,7 @@ public class SubscriptionInfo
final boolean durable,
final String selector,
final int messageCount,
- final int deliveringCount)
- {
+ final int deliveringCount) {
this.queueName = queueName;
this.clientID = clientID;
this.name = name;
@@ -89,56 +80,49 @@ public class SubscriptionInfo
/**
* Returns the name of the ActiveMQ Artemis core queue corresponding to this subscription.
*/
- public String getQueueName()
- {
+ public String getQueueName() {
return queueName;
}
/**
* Returns the client ID of this subscription or {@code null}.
*/
- public String getClientID()
- {
+ public String getClientID() {
return clientID;
}
/**
* Returns the name of this subscription.
*/
- public String getName()
- {
+ public String getName() {
return name;
}
/**
* Returns whether this subscription is durable.
*/
- public boolean isDurable()
- {
+ public boolean isDurable() {
return durable;
}
/**
* Returns the JMS message selector associated to this subscription.
*/
- public String getSelector()
- {
+ public String getSelector() {
return selector;
}
/**
* Returns the number of messages currently held by this subscription.
*/
- public int getMessageCount()
- {
+ public int getMessageCount() {
return messageCount;
}
/**
* Returns the number of messages currently delivered to this subscription.
*/
- public int getDeliveringCount()
- {
+ public int getDeliveringCount() {
return deliveringCount;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/TopicControl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/TopicControl.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/TopicControl.java
index 86df7e7..f70c321 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/TopicControl.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/TopicControl.java
@@ -26,8 +26,7 @@ import org.apache.activemq.artemis.api.core.management.Parameter;
/**
* A TopicControl is used to manage a JMS Topic.
*/
-public interface TopicControl extends DestinationControl
-{
+public interface TopicControl extends DestinationControl {
/**
* Returns the number of (durable and non-durable) subscribers for this topic.
@@ -66,8 +65,6 @@ public interface TopicControl extends DestinationControl
@Operation(desc = "Adds the queue to another Registry binding")
void addBinding(@Parameter(name = "binding", desc = "the name of the binding for Registry") String binding) throws Exception;
-
-
// Operations ----------------------------------------------------
/**
@@ -133,8 +130,8 @@ public interface TopicControl extends DestinationControl
*/
@Operation(desc = "Count the number of messages matching the filter for the given subscription")
int countMessagesForSubscription(@Parameter(name = "clientID", desc = "the client ID") String clientID,
- @Parameter(name = "subscriptionName", desc = "the name of the durable subscription") String subscriptionName,
- @Parameter(name = "filter", desc = "a JMS filter (can be empty)") String filter) throws Exception;
+ @Parameter(name = "subscriptionName", desc = "the name of the durable subscription") String subscriptionName,
+ @Parameter(name = "filter", desc = "a JMS filter (can be empty)") String filter) throws Exception;
/**
* Drops the subscription specified by the specified client ID and subscription name.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java
index 6717c8f..72770a4 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java
@@ -56,8 +56,8 @@ import static org.apache.activemq.artemis.reader.BytesMessageUtil.bytesWriteUTF;
/**
* ActiveMQ Artemis implementation of a JMS {@link BytesMessage}.
*/
-public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessage
-{
+public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessage {
+
// Static -------------------------------------------------------
public static final byte TYPE = Message.BYTES_TYPE;
@@ -70,32 +70,28 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
/**
* This constructor is used to construct messages prior to sending
*/
- protected ActiveMQBytesMessage(final ClientSession session)
- {
+ protected ActiveMQBytesMessage(final ClientSession session) {
super(ActiveMQBytesMessage.TYPE, session);
}
/**
* Constructor on receipt at client side
*/
- protected ActiveMQBytesMessage(final ClientMessage message, final ClientSession session)
- {
+ protected ActiveMQBytesMessage(final ClientMessage message, final ClientSession session) {
super(message, session);
}
/**
* Foreign message constructor
*/
- public ActiveMQBytesMessage(final BytesMessage foreign, final ClientSession session) throws JMSException
- {
+ public ActiveMQBytesMessage(final BytesMessage foreign, final ClientSession session) throws JMSException {
super(foreign, ActiveMQBytesMessage.TYPE, session);
foreign.reset();
byte[] buffer = new byte[1024];
int n = foreign.readBytes(buffer);
- while (n != -1)
- {
+ while (n != -1) {
writeBytes(buffer, 0, n);
n = foreign.readBytes(buffer);
}
@@ -103,149 +99,115 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
// BytesMessage implementation -----------------------------------
- public boolean readBoolean() throws JMSException
- {
+ public boolean readBoolean() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadBoolean(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public byte readByte() throws JMSException
- {
+ public byte readByte() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadByte(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public int readUnsignedByte() throws JMSException
- {
+ public int readUnsignedByte() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadUnsignedByte(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public short readShort() throws JMSException
- {
+ public short readShort() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadShort(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public int readUnsignedShort() throws JMSException
- {
+ public int readUnsignedShort() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadUnsignedShort(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public char readChar() throws JMSException
- {
+ public char readChar() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadChar(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public int readInt() throws JMSException
- {
+ public int readInt() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadInt(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public long readLong() throws JMSException
- {
+ public long readLong() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadLong(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public float readFloat() throws JMSException
- {
+ public float readFloat() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadFloat(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public double readDouble() throws JMSException
- {
+ public double readDouble() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadDouble(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
- public String readUTF() throws JMSException
- {
+ public String readUTF() throws JMSException {
checkRead();
- try
- {
+ try {
return bytesReadUTF(message);
}
- catch (IndexOutOfBoundsException e)
- {
+ catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
- catch (Exception e)
- {
+ catch (Exception e) {
JMSException je = new JMSException("Failed to get UTF");
je.setLinkedException(e);
je.initCause(e);
@@ -253,76 +215,63 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
- public int readBytes(final byte[] value) throws JMSException
- {
+ public int readBytes(final byte[] value) throws JMSException {
checkRead();
return bytesReadBytes(message, value);
}
- public int readBytes(final byte[] value, final int length) throws JMSException
- {
+ public int readBytes(final byte[] value, final int length) throws JMSException {
checkRead();
return bytesReadBytes(message, value, length);
}
- public void writeBoolean(final boolean value) throws JMSException
- {
+ public void writeBoolean(final boolean value) throws JMSException {
checkWrite();
bytesWriteBoolean(message, value);
}
- public void writeByte(final byte value) throws JMSException
- {
+ public void writeByte(final byte value) throws JMSException {
checkWrite();
bytesWriteByte(message, value);
}
- public void writeShort(final short value) throws JMSException
- {
+ public void writeShort(final short value) throws JMSException {
checkWrite();
bytesWriteShort(message, value);
}
- public void writeChar(final char value) throws JMSException
- {
+ public void writeChar(final char value) throws JMSException {
checkWrite();
bytesWriteChar(message, value);
}
- public void writeInt(final int value) throws JMSException
- {
+ public void writeInt(final int value) throws JMSException {
checkWrite();
bytesWriteInt(message, value);
}
- public void writeLong(final long value) throws JMSException
- {
+ public void writeLong(final long value) throws JMSException {
checkWrite();
bytesWriteLong(message, value);
}
- public void writeFloat(final float value) throws JMSException
- {
+ public void writeFloat(final float value) throws JMSException {
checkWrite();
bytesWriteFloat(message, value);
}
- public void writeDouble(final double value) throws JMSException
- {
+ public void writeDouble(final double value) throws JMSException {
checkWrite();
bytesWriteDouble(message, value);
}
- public void writeUTF(final String value) throws JMSException
- {
+ public void writeUTF(final String value) throws JMSException {
checkWrite();
- try
- {
+ try {
bytesWriteUTF(message, value);
}
- catch (Exception e)
- {
+ catch (Exception e) {
JMSException je = new JMSException("Failed to write UTF");
je.setLinkedException(e);
je.initCause(e);
@@ -331,31 +280,25 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
- public void writeBytes(final byte[] value) throws JMSException
- {
+ public void writeBytes(final byte[] value) throws JMSException {
checkWrite();
bytesWriteBytes(message, value);
}
- public void writeBytes(final byte[] value, final int offset, final int length) throws JMSException
- {
+ public void writeBytes(final byte[] value, final int offset, final int length) throws JMSException {
checkWrite();
bytesWriteBytes(message, value, offset, length);
}
- public void writeObject(final Object value) throws JMSException
- {
+ public void writeObject(final Object value) throws JMSException {
checkWrite();
- if (!bytesWriteObject(message, value))
- {
+ if (!bytesWriteObject(message, value)) {
throw new MessageFormatException("Invalid object for properties");
}
}
- public void reset() throws JMSException
- {
- if (!readOnly)
- {
+ public void reset() throws JMSException {
+ if (!readOnly) {
readOnly = true;
bodyLength = message.getBodySize();
@@ -365,70 +308,59 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
@Override
- public void doBeforeReceive() throws ActiveMQException
- {
+ public void doBeforeReceive() throws ActiveMQException {
bodyLength = message.getBodySize();
}
// ActiveMQRAMessage overrides ----------------------------------------
@Override
- public void clearBody() throws JMSException
- {
+ public void clearBody() throws JMSException {
super.clearBody();
- try
- {
+ try {
getBuffer().clear();
}
- catch (RuntimeException e)
- {
+ catch (RuntimeException e) {
JMSException e2 = new JMSException(e.getMessage());
e2.initCause(e);
throw e2;
}
}
- public long getBodyLength() throws JMSException
- {
+ public long getBodyLength() throws JMSException {
checkRead();
return bodyLength;
}
@Override
- public void doBeforeSend() throws Exception
- {
+ public void doBeforeSend() throws Exception {
reset();
}
// Public --------------------------------------------------------
@Override
- public byte getType()
- {
+ public byte getType() {
return ActiveMQBytesMessage.TYPE;
}
- private ActiveMQBuffer getBuffer()
- {
+ private ActiveMQBuffer getBuffer() {
return message.getBodyBuffer();
}
@Override
- public boolean isBodyAssignableTo(@SuppressWarnings("rawtypes")
- Class c)
- {
+ public boolean isBodyAssignableTo(@SuppressWarnings("rawtypes") Class c) {
return c.isAssignableFrom(byte[].class);
}
@Override
- protected <T> T getBodyInternal(Class<T> c)
- {
+ protected <T> T getBodyInternal(Class<T> c) {
if (bodyLength == 0)
return null;
byte[] dst = new byte[bodyLength];
message.getBodyBuffer().getBytes(MessageImpl.BODY_OFFSET, dst);
- return (T)dst;
+ return (T) dst;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
index f720abf..a1184b2 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
@@ -58,8 +58,8 @@ import org.apache.activemq.artemis.utils.VersionLoader;
* The flat implementation of {@link TopicConnection} and {@link QueueConnection} is per design,
* following the common usage of these as one flat API in JMS 1.1.
*/
-public class ActiveMQConnection extends ActiveMQConnectionForContextImpl implements TopicConnection, QueueConnection
-{
+public class ActiveMQConnection extends ActiveMQConnectionForContextImpl implements TopicConnection, QueueConnection {
+
// Constants ------------------------------------------------------------------------------------
public static final int TYPE_GENERIC_CONNECTION = 0;
@@ -127,10 +127,13 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
// Constructors ---------------------------------------------------------------------------------
- public ActiveMQConnection(final String username, final String password, final int connectionType,
- final String clientID, final int dupsOKBatchSize, final int transactionBatchSize,
- final ClientSessionFactory sessionFactory)
- {
+ public ActiveMQConnection(final String username,
+ final String password,
+ final int connectionType,
+ final String clientID,
+ final int dupsOKBatchSize,
+ final int transactionBatchSize,
+ final ClientSessionFactory sessionFactory) {
this.username = username;
this.password = password;
@@ -160,8 +163,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
* For that reason we have this method to force that nonXASession, since the JMS Javadoc
* mandates createSession to return a XASession.
*/
- public Session createNonXASession(final boolean transacted, final int acknowledgeMode) throws JMSException
- {
+ public Session createNonXASession(final boolean transacted, final int acknowledgeMode) throws JMSException {
checkClosed();
return createSessionInternal(false, transacted, acknowledgeMode, ActiveMQConnection.TYPE_GENERIC_CONNECTION);
@@ -175,8 +177,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
* For that reason we have this method to force that nonXASession, since the JMS Javadoc
* mandates createSession to return a XASession.
*/
- public Session createNonXATopicSession(final boolean transacted, final int acknowledgeMode) throws JMSException
- {
+ public Session createNonXATopicSession(final boolean transacted, final int acknowledgeMode) throws JMSException {
checkClosed();
return createSessionInternal(false, transacted, acknowledgeMode, ActiveMQConnection.TYPE_TOPIC_CONNECTION);
@@ -190,63 +191,51 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
* For that reason we have this method to force that nonXASession, since the JMS Javadoc
* mandates createSession to return a XASession.
*/
- public Session createNonXAQueueSession(final boolean transacted, final int acknowledgeMode) throws JMSException
- {
+ public Session createNonXAQueueSession(final boolean transacted, final int acknowledgeMode) throws JMSException {
checkClosed();
return createSessionInternal(false, transacted, acknowledgeMode, ActiveMQConnection.TYPE_QUEUE_CONNECTION);
}
-
// Connection implementation --------------------------------------------------------------------
- public synchronized Session createSession(final boolean transacted, final int acknowledgeMode) throws JMSException
- {
+ public synchronized Session createSession(final boolean transacted, final int acknowledgeMode) throws JMSException {
checkClosed();
return createSessionInternal(false, transacted, checkAck(transacted, acknowledgeMode), ActiveMQConnection.TYPE_GENERIC_CONNECTION);
}
- public String getClientID() throws JMSException
- {
+ public String getClientID() throws JMSException {
checkClosed();
return clientID;
}
- public void setClientID(final String clientID) throws JMSException
- {
+ public void setClientID(final String clientID) throws JMSException {
checkClosed();
- if (this.clientID != null)
- {
+ if (this.clientID != null) {
throw new IllegalStateException("Client id has already been set");
}
- if (!justCreated)
- {
+ if (!justCreated) {
throw new IllegalStateException("setClientID can only be called directly after the connection is created");
}
- try
- {
+ try {
initialSession.addUniqueMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
}
- catch (ActiveMQException e)
- {
- if (e.getType() == ActiveMQExceptionType.DUPLICATE_METADATA)
- {
+ catch (ActiveMQException e) {
+ if (e.getType() == ActiveMQExceptionType.DUPLICATE_METADATA) {
throw new InvalidClientIDException("clientID=" + clientID + " was already set into another connection");
}
}
this.clientID = clientID;
- try
- {
+ try {
this.addSessionMetaData(initialSession);
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
JMSException ex = new JMSException("Internal error setting metadata jms-client-id");
ex.setLinkedException(e);
ex.initCause(e);
@@ -256,22 +245,19 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
justCreated = false;
}
- public ConnectionMetaData getMetaData() throws JMSException
- {
+ public ConnectionMetaData getMetaData() throws JMSException {
checkClosed();
justCreated = false;
- if (metaData == null)
- {
+ if (metaData == null) {
metaData = new ActiveMQConnectionMetaData(thisVersion);
}
return metaData;
}
- public ExceptionListener getExceptionListener() throws JMSException
- {
+ public ExceptionListener getExceptionListener() throws JMSException {
checkClosed();
justCreated = false;
@@ -279,20 +265,17 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
return exceptionListener;
}
- public void setExceptionListener(final ExceptionListener listener) throws JMSException
- {
+ public void setExceptionListener(final ExceptionListener listener) throws JMSException {
checkClosed();
exceptionListener = listener;
justCreated = false;
}
- public synchronized void start() throws JMSException
- {
+ public synchronized void start() throws JMSException {
checkClosed();
- for (ActiveMQSession session : sessions)
- {
+ for (ActiveMQSession session : sessions) {
session.start();
}
@@ -300,13 +283,10 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
started = true;
}
- public synchronized void signalStopToAllSessions()
- {
- for (ActiveMQSession session : sessions)
- {
+ public synchronized void signalStopToAllSessions() {
+ for (ActiveMQSession session : sessions) {
ClientSession coreSession = session.getCoreSession();
- if (coreSession instanceof ClientSessionInternal)
- {
+ if (coreSession instanceof ClientSessionInternal) {
ClientSessionInternal internalSession = (ClientSessionInternal) coreSession;
internalSession.setStopSignal();
}
@@ -314,14 +294,12 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
}
- public synchronized void stop() throws JMSException
- {
+ public synchronized void stop() throws JMSException {
threadAwareContext.assertNotMessageListenerThread();
checkClosed();
- for (ActiveMQSession session : sessions)
- {
+ for (ActiveMQSession session : sessions) {
session.stop();
}
@@ -329,67 +307,54 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
started = false;
}
- public final synchronized void close() throws JMSException
- {
+ public final synchronized void close() throws JMSException {
threadAwareContext.assertNotCompletionListenerThread();
threadAwareContext.assertNotMessageListenerThread();
- if (closed)
- {
+ if (closed) {
return;
}
sessionFactory.close();
- try
- {
- for (ActiveMQSession session : new HashSet<ActiveMQSession>(sessions))
- {
+ try {
+ for (ActiveMQSession session : new HashSet<ActiveMQSession>(sessions)) {
session.close();
}
- try
- {
- if (!tempQueues.isEmpty())
- {
+ try {
+ if (!tempQueues.isEmpty()) {
// Remove any temporary queues
- for (SimpleString queueName : tempQueues)
- {
- if (!initialSession.isClosed())
- {
- try
- {
+ for (SimpleString queueName : tempQueues) {
+ if (!initialSession.isClosed()) {
+ try {
initialSession.deleteQueue(queueName);
}
- catch (ActiveMQException ignore)
- {
+ catch (ActiveMQException ignore) {
// Exception on deleting queue shouldn't prevent close from completing
}
}
}
}
}
- finally
- {
- if (initialSession != null)
- {
+ finally {
+ if (initialSession != null) {
initialSession.close();
}
}
closed = true;
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
- public ConnectionConsumer
- createConnectionConsumer(final Destination destination, final String messageSelector,
- final ServerSessionPool sessionPool, final int maxMessages) throws JMSException
- {
+ public ConnectionConsumer createConnectionConsumer(final Destination destination,
+ final String messageSelector,
+ final ServerSessionPool sessionPool,
+ final int maxMessages) throws JMSException {
checkClosed();
checkTempQueues(destination);
@@ -398,26 +363,23 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
return null;
}
- private void checkTempQueues(Destination destination) throws JMSException
- {
+ private void checkTempQueues(Destination destination) throws JMSException {
ActiveMQDestination jbdest = (ActiveMQDestination) destination;
- if (jbdest.isTemporary() && !containsTemporaryQueue(jbdest.getSimpleAddress()))
- {
+ if (jbdest.isTemporary() && !containsTemporaryQueue(jbdest.getSimpleAddress())) {
throw new JMSException("Can not create consumer for temporary destination " + destination +
" from another JMS connection");
}
}
- public ConnectionConsumer
- createDurableConnectionConsumer(final Topic topic, final String subscriptionName,
- final String messageSelector, final ServerSessionPool sessionPool,
- final int maxMessages) throws JMSException
- {
+ public ConnectionConsumer createDurableConnectionConsumer(final Topic topic,
+ final String subscriptionName,
+ final String messageSelector,
+ final ServerSessionPool sessionPool,
+ final int maxMessages) throws JMSException {
checkClosed();
// As spec. section 4.11
- if (connectionType == ActiveMQConnection.TYPE_QUEUE_CONNECTION)
- {
+ if (connectionType == ActiveMQConnection.TYPE_QUEUE_CONNECTION) {
String msg = "Cannot create a durable connection consumer on a QueueConnection";
throw new javax.jms.IllegalStateException(msg);
}
@@ -427,24 +389,21 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
}
@Override
- public Session createSession(int sessionMode) throws JMSException
- {
+ public Session createSession(int sessionMode) throws JMSException {
checkClosed();
return createSessionInternal(false, sessionMode == Session.SESSION_TRANSACTED, sessionMode, ActiveMQSession.TYPE_GENERIC_SESSION);
}
@Override
- public Session createSession() throws JMSException
- {
+ public Session createSession() throws JMSException {
checkClosed();
return createSessionInternal(false, false, Session.AUTO_ACKNOWLEDGE, ActiveMQSession.TYPE_GENERIC_SESSION);
}
// QueueConnection implementation ---------------------------------------------------------------
- public QueueSession createQueueSession(final boolean transacted, int acknowledgeMode) throws JMSException
- {
+ public QueueSession createQueueSession(final boolean transacted, int acknowledgeMode) throws JMSException {
checkClosed();
return createSessionInternal(false, transacted, checkAck(transacted, acknowledgeMode), ActiveMQSession.TYPE_QUEUE_SESSION);
}
@@ -453,20 +412,18 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
* I'm keeping this as static as the same check will be done within RA.
* This is to conform with TCK Tests where we must return ackMode exactly as they want if transacted=false
*/
- public static int checkAck(boolean transacted, int acknowledgeMode)
- {
- if (!transacted && acknowledgeMode == Session.SESSION_TRANSACTED)
- {
+ public static int checkAck(boolean transacted, int acknowledgeMode) {
+ if (!transacted && acknowledgeMode == Session.SESSION_TRANSACTED) {
return Session.AUTO_ACKNOWLEDGE;
}
return acknowledgeMode;
}
- public ConnectionConsumer
- createConnectionConsumer(final Queue queue, final String messageSelector,
- final ServerSessionPool sessionPool, final int maxMessages) throws JMSException
- {
+ public ConnectionConsumer createConnectionConsumer(final Queue queue,
+ final String messageSelector,
+ final ServerSessionPool sessionPool,
+ final int maxMessages) throws JMSException {
checkClosed();
checkTempQueues(queue);
return null;
@@ -474,30 +431,35 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
// TopicConnection implementation ---------------------------------------------------------------
- public TopicSession createTopicSession(final boolean transacted, final int acknowledgeMode) throws JMSException
- {
+ public TopicSession createTopicSession(final boolean transacted, final int acknowledgeMode) throws JMSException {
checkClosed();
return createSessionInternal(false, transacted, checkAck(transacted, acknowledgeMode), ActiveMQSession.TYPE_TOPIC_SESSION);
}
- public ConnectionConsumer
- createConnectionConsumer(final Topic topic, final String messageSelector,
- final ServerSessionPool sessionPool, final int maxMessages) throws JMSException
- {
+ public ConnectionConsumer createConnectionConsumer(final Topic topic,
+ final String messageSelector,
+ final ServerSessionPool sessionPool,
+ final int maxMessages) throws JMSException {
checkClosed();
checkTempQueues(topic);
return null;
}
@Override
- public ConnectionConsumer createSharedConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
- {
+ public ConnectionConsumer createSharedConnectionConsumer(Topic topic,
+ String subscriptionName,
+ String messageSelector,
+ ServerSessionPool sessionPool,
+ int maxMessages) throws JMSException {
return null; // we offer RA
}
@Override
- public ConnectionConsumer createSharedDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
- {
+ public ConnectionConsumer createSharedDurableConnectionConsumer(Topic topic,
+ String subscriptionName,
+ String messageSelector,
+ ServerSessionPool sessionPool,
+ int maxMessages) throws JMSException {
return null; // we offer RA
}
@@ -509,8 +471,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
* @param listener the listener to add
* @throws JMSException
*/
- public void setFailoverListener(final FailoverEventListener listener) throws JMSException
- {
+ public void setFailoverListener(final FailoverEventListener listener) throws JMSException {
checkClosed();
justCreated = false;
@@ -523,8 +484,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
* @return {@link FailoverEventListener} the current failover event listener for this connection
* @throws JMSException
*/
- public FailoverEventListener getFailoverListener() throws JMSException
- {
+ public FailoverEventListener getFailoverListener() throws JMSException {
checkClosed();
justCreated = false;
@@ -532,54 +492,44 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
return failoverEventListener;
}
- public void addTemporaryQueue(final SimpleString queueAddress)
- {
+ public void addTemporaryQueue(final SimpleString queueAddress) {
tempQueues.add(queueAddress);
knownDestinations.add(queueAddress);
}
- public void removeTemporaryQueue(final SimpleString queueAddress)
- {
+ public void removeTemporaryQueue(final SimpleString queueAddress) {
tempQueues.remove(queueAddress);
}
- public void addKnownDestination(final SimpleString address)
- {
+ public void addKnownDestination(final SimpleString address) {
knownDestinations.add(address);
}
- public boolean containsKnownDestination(final SimpleString address)
- {
+ public boolean containsKnownDestination(final SimpleString address) {
return knownDestinations.contains(address);
}
- public boolean containsTemporaryQueue(final SimpleString queueAddress)
- {
+ public boolean containsTemporaryQueue(final SimpleString queueAddress) {
return tempQueues.contains(queueAddress);
}
- public boolean hasNoLocal()
- {
+ public boolean hasNoLocal() {
return hasNoLocal;
}
- public void setHasNoLocal()
- {
+ public void setHasNoLocal() {
hasNoLocal = true;
}
- public SimpleString getUID()
- {
+ public SimpleString getUID() {
return uid;
}
- public void removeSession(final ActiveMQSession session)
- {
+ public void removeSession(final ActiveMQSession session) {
sessions.remove(session);
}
- public ClientSession getInitialSession()
- {
+ public ClientSession getInitialSession() {
return initialSession;
}
@@ -590,70 +540,48 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
// In case the user forgets to close the connection manually
@Override
- protected final void finalize() throws Throwable
- {
- if (!closed)
- {
+ protected final void finalize() throws Throwable {
+ if (!closed) {
ActiveMQJMSClientLogger.LOGGER.connectionLeftOpen(creationStack);
close();
}
}
- protected boolean isXA()
- {
+ protected boolean isXA() {
return false;
}
- protected final ActiveMQSession
- createSessionInternal(final boolean isXA, final boolean transacted, int acknowledgeMode, final int type) throws JMSException
- {
- if (transacted)
- {
+ protected final ActiveMQSession createSessionInternal(final boolean isXA,
+ final boolean transacted,
+ int acknowledgeMode,
+ final int type) throws JMSException {
+ if (transacted) {
acknowledgeMode = Session.SESSION_TRANSACTED;
}
- try
- {
+ try {
ClientSession session;
- if (acknowledgeMode == Session.SESSION_TRANSACTED)
- {
- session =
- sessionFactory.createSession(username, password, isXA, false, false,
- sessionFactory.getServerLocator().isPreAcknowledge(),
- transactionBatchSize);
+ if (acknowledgeMode == Session.SESSION_TRANSACTED) {
+ session = sessionFactory.createSession(username, password, isXA, false, false, sessionFactory.getServerLocator().isPreAcknowledge(), transactionBatchSize);
}
- else if (acknowledgeMode == Session.AUTO_ACKNOWLEDGE)
- {
- session =
- sessionFactory.createSession(username, password, isXA, true, true,
- sessionFactory.getServerLocator().isPreAcknowledge(), 0);
+ else if (acknowledgeMode == Session.AUTO_ACKNOWLEDGE) {
+ session = sessionFactory.createSession(username, password, isXA, true, true, sessionFactory.getServerLocator().isPreAcknowledge(), 0);
}
- else if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE)
- {
- session =
- sessionFactory.createSession(username, password, isXA, true, true,
- sessionFactory.getServerLocator().isPreAcknowledge(), dupsOKBatchSize);
+ else if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE) {
+ session = sessionFactory.createSession(username, password, isXA, true, true, sessionFactory.getServerLocator().isPreAcknowledge(), dupsOKBatchSize);
}
- else if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE)
- {
- session =
- sessionFactory.createSession(username, password, isXA, true, false,
- sessionFactory.getServerLocator().isPreAcknowledge(),
- transactionBatchSize);
+ else if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) {
+ session = sessionFactory.createSession(username, password, isXA, true, false, sessionFactory.getServerLocator().isPreAcknowledge(), transactionBatchSize);
}
- else if (acknowledgeMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE)
- {
- session =
- sessionFactory.createSession(username, password, isXA, true, false, false, transactionBatchSize);
+ else if (acknowledgeMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE) {
+ session = sessionFactory.createSession(username, password, isXA, true, false, false, transactionBatchSize);
}
- else if (acknowledgeMode == ActiveMQJMSConstants.PRE_ACKNOWLEDGE)
- {
+ else if (acknowledgeMode == ActiveMQJMSConstants.PRE_ACKNOWLEDGE) {
session = sessionFactory.createSession(username, password, isXA, true, false, true, transactionBatchSize);
}
- else
- {
+ else {
throw new JMSRuntimeException("Invalid ackmode: " + acknowledgeMode);
}
@@ -669,8 +597,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
sessions.add(jbs);
- if (started)
- {
+ if (started) {
session.start();
}
@@ -678,8 +605,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
return jbs;
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
@@ -693,30 +619,27 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
* @param type
* @return
*/
- protected ActiveMQSession createAMQSession(boolean isXA, boolean transacted, int acknowledgeMode, ClientSession session, int type)
- {
- if (isXA)
- {
+ protected ActiveMQSession createAMQSession(boolean isXA,
+ boolean transacted,
+ int acknowledgeMode,
+ ClientSession session,
+ int type) {
+ if (isXA) {
return new ActiveMQXASession(this, transacted, true, acknowledgeMode, session, type);
}
- else
- {
+ else {
return new ActiveMQSession(this, transacted, false, acknowledgeMode, session, type);
}
}
- protected final void checkClosed() throws JMSException
- {
- if (closed)
- {
+ protected final void checkClosed() throws JMSException {
+ if (closed) {
throw new IllegalStateException("Connection is closed");
}
}
- public void authorize() throws JMSException
- {
- try
- {
+ public void authorize() throws JMSException {
+ try {
initialSession = sessionFactory.createSession(username, password, false, false, false, false, 0);
addSessionMetaData(initialSession);
@@ -724,79 +647,62 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
initialSession.addFailureListener(listener);
initialSession.addFailoverListener(failoverListener);
}
- catch (ActiveMQException me)
- {
+ catch (ActiveMQException me) {
throw JMSExceptionHelper.convertFromActiveMQException(me);
}
}
- private void addSessionMetaData(ClientSession session) throws ActiveMQException
- {
+ private void addSessionMetaData(ClientSession session) throws ActiveMQException {
session.addMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY, "");
- if (clientID != null)
- {
+ if (clientID != null) {
session.addMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
}
}
- public void setReference(ActiveMQConnectionFactory factory)
- {
+ public void setReference(ActiveMQConnectionFactory factory) {
this.factoryReference = factory;
}
- public boolean isStarted()
- {
+ public boolean isStarted() {
return started;
}
-
// Inner classes --------------------------------------------------------------------------------
- private static class JMSFailureListener implements SessionFailureListener
- {
+ private static class JMSFailureListener implements SessionFailureListener {
+
private final WeakReference<ActiveMQConnection> connectionRef;
- JMSFailureListener(final ActiveMQConnection connection)
- {
+ JMSFailureListener(final ActiveMQConnection connection) {
connectionRef = new WeakReference<ActiveMQConnection>(connection);
}
@Override
- public synchronized void connectionFailed(final ActiveMQException me, boolean failedOver)
- {
- if (me == null)
- {
+ public synchronized void connectionFailed(final ActiveMQException me, boolean failedOver) {
+ if (me == null) {
return;
}
ActiveMQConnection conn = connectionRef.get();
- if (conn != null)
- {
- try
- {
+ if (conn != null) {
+ try {
final ExceptionListener exceptionListener = conn.getExceptionListener();
- if (exceptionListener != null)
- {
- final JMSException je =
- new JMSException(me.toString(), failedOver ? EXCEPTION_FAILOVER : EXCEPTION_DISCONNECT);
+ if (exceptionListener != null) {
+ final JMSException je = new JMSException(me.toString(), failedOver ? EXCEPTION_FAILOVER : EXCEPTION_DISCONNECT);
je.initCause(me);
- new Thread(new Runnable()
- {
- public void run()
- {
+ new Thread(new Runnable() {
+ public void run() {
exceptionListener.onException(je);
}
}).start();
}
}
- catch (JMSException e)
- {
- if (!conn.closed)
- {
+ catch (JMSException e) {
+ if (!conn.closed) {
ActiveMQJMSClientLogger.LOGGER.errorCallingExcListener(e);
}
}
@@ -804,54 +710,43 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
}
@Override
- public void connectionFailed(final ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID)
- {
+ public void connectionFailed(final ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID) {
connectionFailed(me, failedOver);
}
- public void beforeReconnect(final ActiveMQException me)
- {
+ public void beforeReconnect(final ActiveMQException me) {
}
}
- private static class FailoverEventListenerImpl implements FailoverEventListener
- {
+ private static class FailoverEventListenerImpl implements FailoverEventListener {
+
private final WeakReference<ActiveMQConnection> connectionRef;
- FailoverEventListenerImpl(final ActiveMQConnection connection)
- {
+ FailoverEventListenerImpl(final ActiveMQConnection connection) {
connectionRef = new WeakReference<ActiveMQConnection>(connection);
}
@Override
- public void failoverEvent(final FailoverEventType eventType)
- {
+ public void failoverEvent(final FailoverEventType eventType) {
ActiveMQConnection conn = connectionRef.get();
- if (conn != null)
- {
- try
- {
+ if (conn != null) {
+ try {
final FailoverEventListener failoverListener = conn.getFailoverListener();
- if (failoverListener != null)
- {
+ if (failoverListener != null) {
- new Thread(new Runnable()
- {
- public void run()
- {
+ new Thread(new Runnable() {
+ public void run() {
failoverListener.failoverEvent(eventType);
}
}).start();
}
}
- catch (JMSException e)
- {
- if (!conn.closed)
- {
+ catch (JMSException e) {
+ if (!conn.closed) {
ActiveMQJMSClientLogger.LOGGER.errorCallingFailoverListener(e);
}
}