diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java index c18381af70..7bb50cc4c7 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java @@ -41,7 +41,6 @@ import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.ExceptionListener; import javax.jms.IllegalStateException; -import javax.jms.InvalidDestinationException; import javax.jms.JMSException; import javax.jms.Queue; import javax.jms.QueueConnection; @@ -290,8 +289,8 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon checkClosedOrFailed(); ensureConnectionInfoSent(); boolean doSessionAsync = alwaysSessionAsync || sessions.size() > 0 || transacted || acknowledgeMode == Session.CLIENT_ACKNOWLEDGE; - return new ActiveMQSession(this, getNextSessionId(), (transacted ? Session.SESSION_TRANSACTED : (acknowledgeMode == Session.SESSION_TRANSACTED - ? Session.AUTO_ACKNOWLEDGE : acknowledgeMode)), dispatchAsync, alwaysSessionAsync); + return new ActiveMQSession(this, getNextSessionId(), transacted ? Session.SESSION_TRANSACTED : (acknowledgeMode == Session.SESSION_TRANSACTED + ? Session.AUTO_ACKNOWLEDGE : acknowledgeMode), dispatchAsync, alwaysSessionAsync); } /** @@ -1168,10 +1167,11 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon Response response = (Response)this.transport.request(command); if (response.isException()) { ExceptionResponse er = (ExceptionResponse)response; - if (er.getException() instanceof JMSException) + if (er.getException() instanceof JMSException) { throw (JMSException)er.getException(); - else + } else { throw JMSExceptionSupport.create(er.getException()); + } } return response; } catch (IOException e) { @@ -1196,10 +1196,11 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon Response response = (Response)this.transport.request(command, timeout); if (response != null && response.isException()) { ExceptionResponse er = (ExceptionResponse)response; - if (er.getException() instanceof JMSException) + if (er.getException() instanceof JMSException) { throw (JMSException)er.getException(); - else + } else { throw JMSExceptionSupport.create(er.getException()); + } } return response; } catch (IOException e) { @@ -1361,9 +1362,9 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon * @throws IllegalStateException if the connection is in used. */ public void changeUserInfo(String userName, String password) throws JMSException { - if (isConnectionInfoSentToBroker) + if (isConnectionInfoSentToBroker) { throw new IllegalStateException("changeUserInfo used Connection is not allowed"); - + } this.info.setUserName(userName); this.info.setPassword(password); } @@ -1374,8 +1375,9 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon */ public String getResourceManagerId() throws JMSException { waitForBrokerInfo(); - if (brokerInfo == null) + if (brokerInfo == null) { throw new JMSException("Connection failed before Broker info was received."); + } return brokerInfo.getBrokerId().getValue(); } @@ -1580,8 +1582,6 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon onAsyncException(error.getException()); } }); - new Thread("Async error worker") { - }.start(); return null; } @@ -1633,8 +1633,9 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon if (!closed.get() && !closing.get()) { if (this.exceptionListener != null) { - if (!(error instanceof JMSException)) + if (!(error instanceof JMSException)) { error = JMSExceptionSupport.create(error); + } final JMSException e = (JMSException)error; asyncConnectionThread.execute(new Runnable() { @@ -1744,8 +1745,9 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon // If we are not watching the advisories.. then // we will assume that the temp destination does exist. - if (advisoryConsumer == null) + if (advisoryConsumer == null) { return false; + } return !activeTempDestinations.contains(dest); } diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java index 4105862965..8cf024a9f0 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java @@ -16,6 +16,23 @@ */ package org.apache.activemq; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadFactory; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.QueueConnection; +import javax.jms.QueueConnectionFactory; +import javax.jms.TopicConnection; +import javax.jms.TopicConnectionFactory; +import javax.naming.Context; + import org.apache.activemq.blob.BlobTransferPolicy; import org.apache.activemq.jndi.JNDIBaseStorable; import org.apache.activemq.management.JMSStatsImpl; @@ -29,22 +46,6 @@ import org.apache.activemq.util.JMSExceptionSupport; import org.apache.activemq.util.URISupport; import org.apache.activemq.util.URISupport.CompositeData; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.QueueConnection; -import javax.jms.QueueConnectionFactory; -import javax.jms.TopicConnection; -import javax.jms.TopicConnectionFactory; -import javax.naming.Context; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.Executor; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadFactory; - /** * A ConnectionFactory is an an Administered object, and is used for creating * Connections.

This class also implements QueueConnectionFactory and diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionMetaData.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionMetaData.java index e244cbf5ce..5884174975 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionMetaData.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionMetaData.java @@ -28,7 +28,7 @@ import javax.jms.ConnectionMetaData; * the Connection object. */ -public class ActiveMQConnectionMetaData implements ConnectionMetaData { +public final class ActiveMQConnectionMetaData implements ConnectionMetaData { public static final String PROVIDER_VERSION; public static final int PROVIDER_MAJOR_VERSION; diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java index 78e59a5639..c58744cc2b 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java @@ -16,7 +16,29 @@ */ package org.apache.activemq; -import org.apache.activemq.command.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.jms.IllegalStateException; +import javax.jms.InvalidDestinationException; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; + +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ActiveMQMessage; +import org.apache.activemq.command.ActiveMQTempDestination; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.command.ConsumerInfo; +import org.apache.activemq.command.MessageAck; +import org.apache.activemq.command.MessageDispatch; +import org.apache.activemq.command.MessagePull; import org.apache.activemq.management.JMSConsumerStatsImpl; import org.apache.activemq.management.StatsCapable; import org.apache.activemq.management.StatsImpl; @@ -29,18 +51,6 @@ import org.apache.activemq.util.JMSExceptionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.jms.IllegalStateException; -import javax.jms.*; -import javax.jms.Message; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - /** * A client uses a MessageConsumer object to receive messages * from a destination. A MessageConsumer object is created by @@ -612,7 +622,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC Thread.currentThread().interrupt(); } } - if ((session.isTransacted() || session.isDupsOkAcknowledge())) { + if (session.isTransacted() || session.isDupsOkAcknowledge()) { acknowledge(); } if (session.isClientAcknowledge()) { @@ -885,7 +895,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC } } if (!unconsumedMessages.isClosed()) { - if (this.info.isBrowser() || session.connection.isDuplicate(this, md.getMessage()) == false) { + if (this.info.isBrowser() || !session.connection.isDuplicate(this, md.getMessage())) { if (listener != null && unconsumedMessages.isRunning()) { ActiveMQMessage message = createActiveMQMessage(md); beforeMessageIsConsumed(md); diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageProducer.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageProducer.java index 71433021c8..c3bbf25c14 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageProducer.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageProducer.java @@ -16,6 +16,15 @@ */ package org.apache.activemq; +import java.util.HashMap; +import java.util.concurrent.atomic.AtomicLong; + +import javax.jms.Destination; +import javax.jms.IllegalStateException; +import javax.jms.InvalidDestinationException; +import javax.jms.JMSException; +import javax.jms.Message; + import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ProducerAck; import org.apache.activemq.command.ProducerId; @@ -26,14 +35,6 @@ import org.apache.activemq.management.StatsImpl; import org.apache.activemq.memory.UsageManager; import org.apache.activemq.util.IntrospectionSupport; -import javax.jms.Destination; -import javax.jms.IllegalStateException; -import javax.jms.InvalidDestinationException; -import javax.jms.JMSException; -import javax.jms.Message; -import java.util.HashMap; -import java.util.concurrent.atomic.AtomicLong; - /** * A client uses a MessageProducer object to send messages to a * destination. A MessageProducer object is created by passing a @@ -139,14 +140,14 @@ public class ActiveMQMessageProducer extends ActiveMQMessageProducerSupport impl * to some internal error. */ public void close() throws JMSException { - if (closed == false) { + if (!closed) { dispose(); this.session.asyncSendPacket(info.createRemoveCommand()); } } public void dispose() { - if (closed == false) { + if (!closed) { this.session.removeProducer(this); closed = true; } diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageProducerSupport.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageProducerSupport.java index 242fd1c36d..59309a0664 100644 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageProducerSupport.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageProducerSupport.java @@ -16,9 +16,12 @@ */ package org.apache.activemq; -import javax.jms.*; +import javax.jms.DeliveryMode; +import javax.jms.Destination; import javax.jms.IllegalStateException; +import javax.jms.JMSException; import javax.jms.Message; +import javax.jms.MessageProducer; /** * A useful base class for implementing a {@link MessageProducer} @@ -194,7 +197,7 @@ public abstract class ActiveMQMessageProducerSupport implements MessageProducer, * @see javax.jms.Message#DEFAULT_TIME_TO_LIVE */ public void setTimeToLive(long timeToLive) throws JMSException { - if (timeToLive < 0l) { + if (timeToLive < 0L) { throw new IllegalStateException("cannot set a negative timeToLive"); } checkClosed(); diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageTransformation.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageTransformation.java index 9af7a8cd98..1b769e64c5 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageTransformation.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageTransformation.java @@ -20,10 +20,10 @@ import java.util.Enumeration; import javax.jms.BytesMessage; import javax.jms.Destination; -import javax.jms.MessageEOFException; import javax.jms.JMSException; import javax.jms.MapMessage; import javax.jms.Message; +import javax.jms.MessageEOFException; import javax.jms.ObjectMessage; import javax.jms.Queue; import javax.jms.StreamMessage; diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQOutputStream.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQOutputStream.java index 37c218de3b..0a56bb8d9d 100644 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQOutputStream.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQOutputStream.java @@ -72,7 +72,7 @@ public class ActiveMQOutputStream extends OutputStream implements Disposable { } public void close() throws IOException { - if (closed == false) { + if (!closed) { flushBuffer(); try { // Send an EOS style empty message to signal EOS. @@ -86,7 +86,7 @@ public class ActiveMQOutputStream extends OutputStream implements Disposable { } public void dispose() { - if (closed == false) { + if (!closed) { this.connection.removeOutputStream(this); closed = true; } diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java index 178eab3444..ec06768384 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java @@ -17,6 +17,7 @@ package org.apache.activemq; import java.util.Enumeration; +import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.IllegalStateException; import javax.jms.JMSException; @@ -28,8 +29,6 @@ import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ConsumerId; import org.apache.activemq.command.MessageDispatch; -import java.util.concurrent.atomic.AtomicBoolean; - /** * A client uses a QueueBrowser object to look at messages on a * queue without removing them.

diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java index 10dd380948..01b6ecf7b8 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java @@ -29,8 +29,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.BytesMessage; import javax.jms.Destination; import javax.jms.IllegalStateException; -import javax.jms.InvalidDestinationException; -import javax.jms.InvalidSelectorException; import javax.jms.JMSException; import javax.jms.MapMessage; import javax.jms.Message; @@ -52,11 +50,32 @@ import javax.jms.Topic; import javax.jms.TopicPublisher; import javax.jms.TopicSession; import javax.jms.TopicSubscriber; -import javax.jms.TransactionRolledBackException; import org.apache.activemq.blob.BlobTransferPolicy; import org.apache.activemq.blob.BlobUploader; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ActiveMQBlobMessage; +import org.apache.activemq.command.ActiveMQBytesMessage; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ActiveMQMapMessage; +import org.apache.activemq.command.ActiveMQMessage; +import org.apache.activemq.command.ActiveMQObjectMessage; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.command.ActiveMQStreamMessage; +import org.apache.activemq.command.ActiveMQTempDestination; +import org.apache.activemq.command.ActiveMQTempQueue; +import org.apache.activemq.command.ActiveMQTempTopic; +import org.apache.activemq.command.ActiveMQTextMessage; +import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.command.Command; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.command.MessageAck; +import org.apache.activemq.command.MessageDispatch; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.command.ProducerId; +import org.apache.activemq.command.Response; +import org.apache.activemq.command.SessionId; +import org.apache.activemq.command.SessionInfo; +import org.apache.activemq.command.TransactionId; import org.apache.activemq.management.JMSSessionStatsImpl; import org.apache.activemq.management.StatsCapable; import org.apache.activemq.management.StatsImpl; diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQTopicPublisher.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQTopicPublisher.java index 9bbc42c6d0..d2712c062f 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQTopicPublisher.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQTopicPublisher.java @@ -17,17 +17,12 @@ package org.apache.activemq; -import org.apache.activemq.command.ActiveMQDestination; - -import javax.jms.Destination; -import javax.jms.InvalidDestinationException; import javax.jms.JMSException; import javax.jms.Message; -import javax.jms.MessageFormatException; -import javax.jms.Session; import javax.jms.Topic; import javax.jms.TopicPublisher; -import javax.jms.TopicSession; + +import org.apache.activemq.command.ActiveMQDestination; /** * A client uses a TopicPublisher object to publish messages on diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQTopicSubscriber.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQTopicSubscriber.java index cb8bf8d33b..689efddcf5 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQTopicSubscriber.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQTopicSubscriber.java @@ -17,13 +17,13 @@ package org.apache.activemq; -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.command.ConsumerId; - import javax.jms.JMSException; import javax.jms.Topic; import javax.jms.TopicSubscriber; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ConsumerId; + /** * A client uses a TopicSubscriber object to receive messages * that have been published to a topic. A TopicSubscriber object diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQXAConnectionFactory.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQXAConnectionFactory.java index 65bde01ed2..d788cdbad5 100644 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQXAConnectionFactory.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQXAConnectionFactory.java @@ -16,8 +16,7 @@ */ package org.apache.activemq; -import org.apache.activemq.management.JMSStatsImpl; -import org.apache.activemq.transport.Transport; +import java.net.URI; import javax.jms.JMSException; import javax.jms.XAConnection; @@ -27,7 +26,8 @@ import javax.jms.XAQueueConnectionFactory; import javax.jms.XATopicConnection; import javax.jms.XATopicConnectionFactory; -import java.net.URI; +import org.apache.activemq.management.JMSStatsImpl; +import org.apache.activemq.transport.Transport; /** * A factory of {@link XAConnection} instances diff --git a/activemq-core/src/main/java/org/apache/activemq/BlobMessage.java b/activemq-core/src/main/java/org/apache/activemq/BlobMessage.java index c08b58b1c9..50352ab9c9 100644 --- a/activemq-core/src/main/java/org/apache/activemq/BlobMessage.java +++ b/activemq-core/src/main/java/org/apache/activemq/BlobMessage.java @@ -16,11 +16,12 @@ */ package org.apache.activemq; -import javax.jms.JMSException; -import java.net.URL; -import java.net.MalformedURLException; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; + +import javax.jms.JMSException; /** * Represents a message which has a typically out of band Binary Large Object diff --git a/activemq-core/src/main/java/org/apache/activemq/CustomDestination.java b/activemq-core/src/main/java/org/apache/activemq/CustomDestination.java index 2db8be6a2b..49a059fcfa 100644 --- a/activemq-core/src/main/java/org/apache/activemq/CustomDestination.java +++ b/activemq-core/src/main/java/org/apache/activemq/CustomDestination.java @@ -17,13 +17,13 @@ package org.apache.activemq; import javax.jms.Destination; +import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; -import javax.jms.TopicSubscriber; import javax.jms.QueueReceiver; -import javax.jms.TopicPublisher; import javax.jms.QueueSender; -import javax.jms.JMSException; +import javax.jms.TopicPublisher; +import javax.jms.TopicSubscriber; /** * Represents a hook to allow the support of custom destinations diff --git a/activemq-core/src/main/java/org/apache/activemq/MessageTransformer.java b/activemq-core/src/main/java/org/apache/activemq/MessageTransformer.java index fd40987197..275da2ced5 100644 --- a/activemq-core/src/main/java/org/apache/activemq/MessageTransformer.java +++ b/activemq-core/src/main/java/org/apache/activemq/MessageTransformer.java @@ -16,13 +16,11 @@ */ package org.apache.activemq; -import org.apache.activemq.command.ActiveMQMessage; - -import javax.jms.Message; -import javax.jms.Session; -import javax.jms.MessageProducer; import javax.jms.JMSException; +import javax.jms.Message; import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; /** * A plugin strategy for transforming a message before it is sent by the JMS client or before it is diff --git a/activemq-core/src/main/java/org/apache/activemq/TransactionContext.java b/activemq-core/src/main/java/org/apache/activemq/TransactionContext.java index 384e8edc3b..3145022901 100755 --- a/activemq-core/src/main/java/org/apache/activemq/TransactionContext.java +++ b/activemq-core/src/main/java/org/apache/activemq/TransactionContext.java @@ -19,6 +19,7 @@ package org.apache.activemq; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; +import java.util.concurrent.ConcurrentHashMap; import javax.jms.JMSException; import javax.jms.TransactionInProgressException; @@ -29,20 +30,18 @@ import javax.transaction.xa.Xid; import org.apache.activemq.command.ConnectionId; import org.apache.activemq.command.DataArrayResponse; +import org.apache.activemq.command.DataStructure; import org.apache.activemq.command.IntegerResponse; import org.apache.activemq.command.LocalTransactionId; import org.apache.activemq.command.TransactionId; import org.apache.activemq.command.TransactionInfo; import org.apache.activemq.command.XATransactionId; -import org.apache.activemq.command.DataStructure; import org.apache.activemq.transaction.Synchronization; import org.apache.activemq.util.JMSExceptionSupport; import org.apache.activemq.util.LongSequenceGenerator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.concurrent.ConcurrentHashMap; - /** * A TransactionContext provides the means to control a JMS transaction. It * provides a local transaction interface and also an XAResource interface.

diff --git a/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java b/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java index cfee6ea157..815227bfef 100755 --- a/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java +++ b/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java @@ -16,8 +16,8 @@ */ package org.apache.activemq.advisory; -import java.io.IOException; import java.util.Iterator; +import java.util.concurrent.ConcurrentHashMap; import org.apache.activemq.broker.Broker; import org.apache.activemq.broker.BrokerFilter; @@ -42,8 +42,6 @@ import org.apache.activemq.util.LongSequenceGenerator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.concurrent.ConcurrentHashMap; - /** * This broker filter handles tracking the state of the broker for purposes of * publishing advisory messages to advisory consumers. diff --git a/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisorySupport.java b/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisorySupport.java index 778b7164c7..a5d928db83 100755 --- a/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisorySupport.java +++ b/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisorySupport.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.advisory; +import javax.jms.Destination; + import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQTopic; -import javax.jms.Destination; - public class AdvisorySupport { public static final String ADVISORY_TOPIC_PREFIX = "ActiveMQ.Advisory."; @@ -102,8 +102,9 @@ public class AdvisorySupport { return TEMP_QUEUE_ADVISORY_TOPIC; case ActiveMQDestination.TEMP_TOPIC_TYPE: return TEMP_TOPIC_ADVISORY_TOPIC; + default: + throw new RuntimeException("Unknown destination type: " + destination.getDestinationType()); } - throw new RuntimeException("Unknown destination type: " + destination.getDestinationType()); } public static boolean isDestinationAdvisoryTopic(ActiveMQDestination destination) { diff --git a/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEvent.java b/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEvent.java index 3512bc0bfe..1b012f0679 100644 --- a/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEvent.java +++ b/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEvent.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.advisory; -import org.apache.activemq.command.ConsumerId; +import java.util.EventObject; import javax.jms.Destination; -import java.util.EventObject; +import org.apache.activemq.command.ConsumerId; /** * An event when the number of consumers on a given destination changes. diff --git a/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEventSource.java b/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEventSource.java index c1a987d8e7..b7fb5ad2d3 100644 --- a/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEventSource.java +++ b/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEventSource.java @@ -19,6 +19,14 @@ package org.apache.activemq.advisory; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.Session; + import org.apache.activemq.Service; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQMessage; @@ -29,14 +37,6 @@ import org.apache.activemq.command.RemoveInfo; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.Session; - /** * An object which can be used to listen to the number of active consumers * available on a given destination. @@ -82,27 +82,24 @@ public class ConsumerEventSource implements Service, MessageListener { public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { - ActiveMQMessage activeMessage = (ActiveMQMessage) message; + ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ConsumerInfo) { count = consumerCount.incrementAndGet(); count = extractConsumerCountFromMessage(message, count); - fireConsumerEvent(new ConsumerStartedEvent(this, destination, (ConsumerInfo) command, count)); - } - else if (command instanceof RemoveInfo) { - RemoveInfo removeInfo = (RemoveInfo) command; + fireConsumerEvent(new ConsumerStartedEvent(this, destination, (ConsumerInfo)command, count)); + } else if (command instanceof RemoveInfo) { + RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isConsumerRemove()) { count = consumerCount.decrementAndGet(); count = extractConsumerCountFromMessage(message, count); - fireConsumerEvent(new ConsumerStoppedEvent(this, destination, (ConsumerId) removeInfo.getObjectId(), count)); + fireConsumerEvent(new ConsumerStoppedEvent(this, destination, (ConsumerId)removeInfo.getObjectId(), count)); } - } - else { + } else { log.warn("Unknown command: " + command); } - } - else { + } else { log.warn("Unknown message type: " + message + ". Message ignored"); } } @@ -116,12 +113,11 @@ public class ConsumerEventSource implements Service, MessageListener { try { Object value = message.getObjectProperty("consumerCount"); if (value instanceof Number) { - Number n = (Number) value; + Number n = (Number)value; return n.intValue(); } log.warn("No consumerCount header available on the message: " + message); - } - catch (Exception e) { + } catch (Exception e) { log.warn("Failed to extract consumerCount from message: " + message + ".Reason: " + e, e); } return count; diff --git a/activemq-core/src/main/java/org/apache/activemq/advisory/ProducerEvent.java b/activemq-core/src/main/java/org/apache/activemq/advisory/ProducerEvent.java index 14407aec75..35d298e8bb 100644 --- a/activemq-core/src/main/java/org/apache/activemq/advisory/ProducerEvent.java +++ b/activemq-core/src/main/java/org/apache/activemq/advisory/ProducerEvent.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.advisory; -import org.apache.activemq.command.ProducerId; +import java.util.EventObject; import javax.jms.Destination; -import java.util.EventObject; +import org.apache.activemq.command.ProducerId; /** * An event when the number of producers on a given destination changes. diff --git a/activemq-core/src/main/java/org/apache/activemq/advisory/ProducerEventSource.java b/activemq-core/src/main/java/org/apache/activemq/advisory/ProducerEventSource.java index bd8b03019a..6cf02a9fd5 100644 --- a/activemq-core/src/main/java/org/apache/activemq/advisory/ProducerEventSource.java +++ b/activemq-core/src/main/java/org/apache/activemq/advisory/ProducerEventSource.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.advisory; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -23,6 +26,7 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; + import org.apache.activemq.Service; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQMessage; @@ -32,8 +36,6 @@ import org.apache.activemq.command.ProducerInfo; import org.apache.activemq.command.RemoveInfo; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; /** * An object which can be used to listen to the number of active consumers @@ -80,27 +82,24 @@ public class ProducerEventSource implements Service, MessageListener { public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { - ActiveMQMessage activeMessage = (ActiveMQMessage) message; + ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ProducerInfo) { count = producerCount.incrementAndGet(); count = extractProducerCountFromMessage(message, count); - fireProducerEvent(new ProducerStartedEvent(this, destination, (ProducerInfo) command, count)); - } - else if (command instanceof RemoveInfo) { - RemoveInfo removeInfo = (RemoveInfo) command; + fireProducerEvent(new ProducerStartedEvent(this, destination, (ProducerInfo)command, count)); + } else if (command instanceof RemoveInfo) { + RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isProducerRemove()) { count = producerCount.decrementAndGet(); count = extractProducerCountFromMessage(message, count); - fireProducerEvent(new ProducerStoppedEvent(this, destination, (ProducerId) removeInfo.getObjectId(), count)); + fireProducerEvent(new ProducerStoppedEvent(this, destination, (ProducerId)removeInfo.getObjectId(), count)); } - } - else { + } else { log.warn("Unknown command: " + command); } - } - else { + } else { log.warn("Unknown message type: " + message + ". Message ignored"); } } @@ -109,12 +108,11 @@ public class ProducerEventSource implements Service, MessageListener { try { Object value = message.getObjectProperty("producerCount"); if (value instanceof Number) { - Number n = (Number) value; + Number n = (Number)value; return n.intValue(); } log.warn("No producerCount header available on the message: " + message); - } - catch (Exception e) { + } catch (Exception e) { log.warn("Failed to extract producerCount from message: " + message + ".Reason: " + e, e); } return count; diff --git a/activemq-core/src/main/java/org/apache/activemq/blob/BlobUploadStrategy.java b/activemq-core/src/main/java/org/apache/activemq/blob/BlobUploadStrategy.java index 5b75b15d9c..f27920642d 100644 --- a/activemq-core/src/main/java/org/apache/activemq/blob/BlobUploadStrategy.java +++ b/activemq-core/src/main/java/org/apache/activemq/blob/BlobUploadStrategy.java @@ -16,14 +16,15 @@ */ package org.apache.activemq.blob; -import org.apache.activemq.command.ActiveMQBlobMessage; - -import javax.jms.JMSException; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import javax.jms.JMSException; + +import org.apache.activemq.command.ActiveMQBlobMessage; + /** * Represents a strategy of uploading a file/stream to some remote * diff --git a/activemq-core/src/main/java/org/apache/activemq/blob/BlobUploader.java b/activemq-core/src/main/java/org/apache/activemq/blob/BlobUploader.java index f3107b5fe0..c0bdcaec90 100644 --- a/activemq-core/src/main/java/org/apache/activemq/blob/BlobUploader.java +++ b/activemq-core/src/main/java/org/apache/activemq/blob/BlobUploader.java @@ -16,17 +16,18 @@ */ package org.apache.activemq.blob; -import org.apache.activemq.command.ActiveMQBlobMessage; - -import javax.jms.JMSException; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import javax.jms.JMSException; + +import org.apache.activemq.command.ActiveMQBlobMessage; + /** * A helper class to represent a required upload of a BLOB to some remote URL - * + * * @version $Revision: $ */ public class BlobUploader { @@ -35,7 +36,6 @@ public class BlobUploader { private File file; private InputStream in; - public BlobUploader(BlobTransferPolicy blobTransferPolicy, InputStream in) { this.blobTransferPolicy = blobTransferPolicy; this.in = in; @@ -49,13 +49,11 @@ public class BlobUploader { public URL upload(ActiveMQBlobMessage message) throws JMSException, IOException { if (file != null) { return getStrategy().uploadFile(message, file); - } - else { + } else { return getStrategy().uploadStream(message, in); } } - public BlobTransferPolicy getBlobTransferPolicy() { return blobTransferPolicy; } diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java index f7a8450f2b..44f5ae9c4f 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java @@ -30,9 +30,11 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; + import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; + import org.apache.activemq.ActiveMQConnectionMetaData; import org.apache.activemq.Service; import org.apache.activemq.advisory.AdvisoryBroker; @@ -77,10 +79,10 @@ import org.apache.activemq.transport.TransportFactory; import org.apache.activemq.transport.TransportServer; import org.apache.activemq.transport.vm.VMTransportFactory; import org.apache.activemq.util.IOExceptionSupport; +import org.apache.activemq.util.IOHelper; import org.apache.activemq.util.JMXSupport; import org.apache.activemq.util.ServiceStopper; import org.apache.activemq.util.URISupport; -import org.apache.activemq.util.IOHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java b/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java index a59910faf6..ada088e424 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java @@ -16,9 +16,9 @@ */ package org.apache.activemq.broker; +import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.broker.region.MessageReference; import org.apache.activemq.command.ConnectionId; @@ -29,8 +29,6 @@ import org.apache.activemq.security.MessageAuthorizationPolicy; import org.apache.activemq.security.SecurityContext; import org.apache.activemq.transaction.Transaction; -import java.io.IOException; - /** * Used to hold context information needed to process requests sent to a broker. * diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java b/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java index 0f471efe3a..d61b20889f 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.broker; -import org.apache.activemq.command.ActiveMQDestination; - import javax.jms.JMSException; +import org.apache.activemq.command.ActiveMQDestination; + /** * An exception thrown if a destination is attempted to be created when it already exists. * diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/PropertiesBrokerFactory.java b/activemq-core/src/main/java/org/apache/activemq/broker/PropertiesBrokerFactory.java index f68c7afa9a..63df6fac8e 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/PropertiesBrokerFactory.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/PropertiesBrokerFactory.java @@ -16,18 +16,18 @@ */ package org.apache.activemq.broker; -import org.apache.activemq.util.IntrospectionSupport; - import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; import java.net.URI; import java.net.URL; -import java.net.MalformedURLException; import java.util.Map; import java.util.Properties; +import org.apache.activemq.util.IntrospectionSupport; + /** * A {@link BrokerFactoryHandler} which uses a properties file to configure the * broker's various policies. diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/SslBrokerService.java b/activemq-core/src/main/java/org/apache/activemq/broker/SslBrokerService.java index c6a21ecfe4..6253005cba 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/SslBrokerService.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/SslBrokerService.java @@ -17,10 +17,6 @@ package org.apache.activemq.broker; -import org.apache.activemq.transport.TransportFactory; -import org.apache.activemq.transport.TransportServer; -import org.apache.activemq.transport.tcp.SslTransportFactory; - import java.io.IOException; import java.net.URI; import java.security.KeyManagementException; @@ -29,6 +25,10 @@ import java.security.SecureRandom; import javax.net.ssl.KeyManager; import javax.net.ssl.TrustManager; +import org.apache.activemq.transport.TransportFactory; +import org.apache.activemq.transport.TransportServer; +import org.apache.activemq.transport.tcp.SslTransportFactory; + /** * A BrokerService that allows access to the key and trust managers used by SSL * connections. There is no reason to use this class unless SSL is being used diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/TransactionBroker.java b/activemq-core/src/main/java/org/apache/activemq/broker/TransactionBroker.java index e884856f4c..eacb5d2725 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/TransactionBroker.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/TransactionBroker.java @@ -16,8 +16,15 @@ */ package org.apache.activemq.broker; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import javax.jms.JMSException; +import javax.transaction.xa.XAException; + import org.apache.activemq.ActiveMQMessageAudit; import org.apache.activemq.command.ConnectionInfo; import org.apache.activemq.command.LocalTransactionId; @@ -36,15 +43,6 @@ import org.apache.activemq.util.WrappedException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.jms.JMSException; - -import javax.transaction.xa.XAException; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; - /** * This broker filter handles the transaction related operations in the Broker * interface. diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java index 0d5ebb32f2..b67f102fcf 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java @@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; + import org.apache.activemq.Service; import org.apache.activemq.broker.ft.MasterBroker; import org.apache.activemq.broker.region.ConnectionStatistics; @@ -97,8 +98,7 @@ import org.apache.commons.logging.LogFactory; public class TransportConnection implements Service, Connection, Task, CommandVisitor { private static final Log LOG = LogFactory.getLog(TransportConnection.class); - private static final Log TRANSPORTLOG = LogFactory.getLog(TransportConnection.class.getName() - + ".Transport"); + private static final Log TRANSPORTLOG = LogFactory.getLog(TransportConnection.class.getName() + ".Transport"); private static final Log SERVICELOG = LogFactory.getLog(TransportConnection.class.getName() + ".Service"); // Keeps track of the broker and connector that created this connection. protected final Broker broker; @@ -191,8 +191,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi * @param taskRunnerFactory - can be null if you want direct dispatch to the * transport else commands are sent async. */ - public TransportConnection(TransportConnector connector, final Transport transport, Broker broker, - TaskRunnerFactory taskRunnerFactory) { + public TransportConnection(TransportConnector connector, final Transport transport, Broker broker, TaskRunnerFactory taskRunnerFactory) { this.connector = connector; this.broker = broker; RegionBroker rb = (RegionBroker)broker.getAdaptor(RegionBroker.class); @@ -272,8 +271,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi else if (e.getClass() == BrokerStoppedException.class) { if (!disposed.get()) { if (SERVICELOG.isDebugEnabled()) - SERVICELOG - .debug("Broker has been stopped. Notifying client and closing his connection."); + SERVICELOG.debug("Broker has been stopped. Notifying client and closing his connection."); ConnectionError ce = new ConnectionError(); ce.setException(e); dispatchSync(ce); @@ -403,8 +401,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi } TransactionState transactionState = cs.getTransactionState(info.getTransactionId()); if (transactionState == null) - throw new IllegalStateException("Cannot prepare a transaction that had not been started: " - + info.getTransactionId()); + throw new IllegalStateException("Cannot prepare a transaction that had not been started: " + info.getTransactionId()); // Avoid dups. if (!transactionState.isPrepared()) { transactionState.setPrepared(true); @@ -473,8 +470,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi return broker.messagePull(lookupConnectionState(pull.getConsumerId()).getContext(), pull); } - public Response processMessageDispatchNotification(MessageDispatchNotification notification) - throws Exception { + public Response processMessageDispatchNotification(MessageDispatchNotification notification) throws Exception { broker.processDispatchNotification(notification); return null; } @@ -503,9 +499,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi TransportConnectionState cs = lookupConnectionState(connectionId); SessionState ss = cs.getSessionState(sessionId); if (ss == null) - throw new IllegalStateException( - "Cannot add a producer to a session that had not been registered: " - + sessionId); + throw new IllegalStateException("Cannot add a producer to a session that had not been registered: " + sessionId); // Avoid replaying dup commands if (!ss.getProducerIds().contains(info.getProducerId())) { broker.addProducer(cs.getContext(), info); @@ -524,9 +518,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi TransportConnectionState cs = lookupConnectionState(connectionId); SessionState ss = cs.getSessionState(sessionId); if (ss == null) - throw new IllegalStateException( - "Cannot remove a producer from a session that had not been registered: " - + sessionId); + throw new IllegalStateException("Cannot remove a producer from a session that had not been registered: " + sessionId); ProducerState ps = ss.removeProducer(id); if (ps == null) throw new IllegalStateException("Cannot remove a producer that had not been registered: " + id); @@ -541,9 +533,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi TransportConnectionState cs = lookupConnectionState(connectionId); SessionState ss = cs.getSessionState(sessionId); if (ss == null) - throw new IllegalStateException( - "Cannot add a consumer to a session that had not been registered: " - + sessionId); + throw new IllegalStateException("Cannot add a consumer to a session that had not been registered: " + sessionId); // Avoid replaying dup commands if (!ss.getConsumerIds().contains(info.getConsumerId())) { broker.addConsumer(cs.getContext(), info); @@ -562,9 +552,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi TransportConnectionState cs = lookupConnectionState(connectionId); SessionState ss = cs.getSessionState(sessionId); if (ss == null) - throw new IllegalStateException( - "Cannot remove a consumer from a session that had not been registered: " - + sessionId); + throw new IllegalStateException("Cannot remove a consumer from a session that had not been registered: " + sessionId); ConsumerState consumerState = ss.removeConsumer(id); if (consumerState == null) throw new IllegalStateException("Cannot remove a consumer that had not been registered: " + id); @@ -641,8 +629,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi if (state.getConnection() != this) { LOG.debug("Killing previous stale connection: " + state.getConnection().getRemoteAddress()); state.getConnection().stop(); - LOG.debug("Connection " + getRemoteAddress() + " taking over previous connection: " - + state.getConnection().getRemoteAddress()); + LOG.debug("Connection " + getRemoteAddress() + " taking over previous connection: " + state.getConnection().getRemoteAddress()); state.setConnection(this); state.reset(info); } @@ -765,8 +752,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi } protected void processDispatch(Command command) throws IOException { - final MessageDispatch messageDispatch = (MessageDispatch)(command.isMessageDispatch() - ? command : null); + final MessageDispatch messageDispatch = (MessageDispatch)(command.isMessageDispatch() ? command : null); try { if (!disposed.get()) { if (messageDispatch != null) { @@ -846,8 +832,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi transport.start(); if (taskRunnerFactory != null) { - taskRunner = taskRunnerFactory.createTaskRunner(this, "ActiveMQ Connection Dispatcher: " - + getRemoteAddress()); + taskRunner = taskRunnerFactory.createTaskRunner(this, "ActiveMQ Connection Dispatcher: " + getRemoteAddress()); } else { taskRunner = null; } @@ -1114,8 +1099,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi uri = URISupport.createURIWithQuery(uri, URISupport.createQueryString(map)); Transport localTransport = TransportFactory.connect(uri); Transport remoteBridgeTransport = new ResponseCorrelator(transport); - duplexBridge = NetworkBridgeFactory.createBridge(config, localTransport, - remoteBridgeTransport); + duplexBridge = NetworkBridgeFactory.createBridge(config, localTransport, remoteBridgeTransport); // now turn duplex off this side info.setDuplexConnection(false); duplexBridge.setCreatedByDuplex(true); @@ -1180,8 +1164,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi ProducerState producerState = ss.getProducerState(id); if (producerState != null && producerState.getInfo() != null) { ProducerInfo info = producerState.getInfo(); - result.setMutable(info.getDestination() == null - || info.getDestination().isComposite()); + result.setMutable(info.getDestination() == null || info.getDestination().isComposite()); } } producerExchanges.put(id, result); @@ -1285,8 +1268,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi // // ///////////////////////////////////////////////////////////////// - protected TransportConnectionState registerConnectionState(ConnectionId connectionId, - TransportConnectionState state) { + protected TransportConnectionState registerConnectionState(ConnectionId connectionId, TransportConnectionState state) { TransportConnectionState rc = connectionState; connectionState = state; return rc; @@ -1309,44 +1291,35 @@ public class TransportConnection implements Service, Connection, Task, CommandVi protected TransportConnectionState lookupConnectionState(String connectionId) { TransportConnectionState cs = connectionState; if (cs == null) - throw new IllegalStateException( - "Cannot lookup a connectionId for a connection that had not been registered: " - + connectionId); + throw new IllegalStateException("Cannot lookup a connectionId for a connection that had not been registered: " + connectionId); return cs; } protected TransportConnectionState lookupConnectionState(ConsumerId id) { TransportConnectionState cs = connectionState; if (cs == null) - throw new IllegalStateException( - "Cannot lookup a consumer from a connection that had not been registered: " - + id.getParentId().getParentId()); + throw new IllegalStateException("Cannot lookup a consumer from a connection that had not been registered: " + id.getParentId().getParentId()); return cs; } protected TransportConnectionState lookupConnectionState(ProducerId id) { TransportConnectionState cs = connectionState; if (cs == null) - throw new IllegalStateException( - "Cannot lookup a producer from a connection that had not been registered: " - + id.getParentId().getParentId()); + throw new IllegalStateException("Cannot lookup a producer from a connection that had not been registered: " + id.getParentId().getParentId()); return cs; } protected TransportConnectionState lookupConnectionState(SessionId id) { TransportConnectionState cs = connectionState; if (cs == null) - throw new IllegalStateException( - "Cannot lookup a session from a connection that had not been registered: " - + id.getParentId()); + throw new IllegalStateException("Cannot lookup a session from a connection that had not been registered: " + id.getParentId()); return cs; } protected TransportConnectionState lookupConnectionState(ConnectionId connectionId) { TransportConnectionState cs = connectionState; if (cs == null) - throw new IllegalStateException("Cannot lookup a connection that had not been registered: " - + connectionId); + throw new IllegalStateException("Cannot lookup a connection that had not been registered: " + connectionId); return cs; } diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java index 00956998d4..6fab60019a 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.Iterator; +import java.util.concurrent.CopyOnWriteArrayList; import javax.management.MBeanServer; import javax.management.ObjectName; @@ -40,8 +41,6 @@ import org.apache.activemq.util.ServiceSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.concurrent.CopyOnWriteArrayList; - /** * @org.apache.xbean.XBean * @version $Revision: 1.6 $ diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/TransportStatusDetector.java b/activemq-core/src/main/java/org/apache/activemq/broker/TransportStatusDetector.java index b144a89b96..06546b7d2a 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/TransportStatusDetector.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/TransportStatusDetector.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.broker; +import java.util.Iterator; +import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.atomic.AtomicBoolean; @@ -24,9 +26,6 @@ import org.apache.activemq.ThreadPriorities; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.Iterator; -import java.util.Set; - /** * Used to provide information on the status of the Connection * diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java b/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java index 8700f78acd..e1522cbffa 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.Service; import org.apache.activemq.broker.BrokerService; @@ -43,7 +44,6 @@ import org.apache.activemq.util.ServiceStopper; import org.apache.activemq.util.ServiceSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.concurrent.atomic.AtomicBoolean; /** * Connects a Slave Broker to a Master when using Virtual - * Topics. + * href="http://activemq.apache.org/virtual-destinations.html">Virtual Topics. * * @org.apache.xbean.XBean - * * @version $Revision$ */ public class VirtualDestinationInterceptor implements DestinationInterceptor { @@ -46,15 +44,14 @@ public class VirtualDestinationInterceptor implements DestinationInterceptor { Set virtualDestinations = destinationMap.get(destination.getActiveMQDestination()); List destinations = new ArrayList(); for (Iterator iter = virtualDestinations.iterator(); iter.hasNext();) { - VirtualDestination virtualDestination = (VirtualDestination) iter.next(); + VirtualDestination virtualDestination = (VirtualDestination)iter.next(); Destination newNestination = virtualDestination.intercept(destination); destinations.add(newNestination); } if (!destinations.isEmpty()) { if (destinations.size() == 1) { - return (Destination) destinations.get(0); - } - else { + return (Destination)destinations.get(0); + } else { // should rarely be used but here just in case return createCompositeDestination(destination, destinations); } @@ -79,7 +76,7 @@ public class VirtualDestinationInterceptor implements DestinationInterceptor { return new DestinationFilter(destination) { public void send(ProducerBrokerExchange context, Message messageSend) throws Exception { for (Iterator iter = destinations.iterator(); iter.hasNext();) { - Destination destination = (Destination) iter.next(); + Destination destination = (Destination)iter.next(); destination.send(context, messageSend); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java b/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java index 47bc6ca224..ac0f01f230 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java @@ -16,16 +16,6 @@ */ package org.apache.activemq.broker.util; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.Service; -import org.apache.activemq.advisory.AdvisorySupport; -import org.apache.activemq.util.ServiceStopper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.FactoryBean; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -33,9 +23,19 @@ import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.Session; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.Service; +import org.apache.activemq.advisory.AdvisorySupport; +import org.apache.activemq.util.ServiceStopper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; + /** * An agent which listens to commands on a JMS destination - * + * * @version $Revision$ * @org.apache.xbean.XBean */ @@ -50,7 +50,6 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean, private Session session; private MessageConsumer consumer; - public void start() throws Exception { session = getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE); listener = new CommandMessageListener(session); @@ -68,8 +67,7 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean, try { consumer.close(); consumer = null; - } - catch (JMSException e) { + } catch (JMSException e) { stopper.onException(this, e); } } @@ -77,8 +75,7 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean, try { session.close(); session = null; - } - catch (JMSException e) { + } catch (JMSException e) { stopper.onException(this, e); } } @@ -86,15 +83,15 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean, try { connection.close(); connection = null; - } - catch (JMSException e) { + } catch (JMSException e) { stopper.onException(this, e); } } stopper.throwFirstException(); } - // the following methods ensure that we are created on startup and the lifecycles respected + // the following methods ensure that we are created on startup and the + // lifecycles respected // TODO there must be a simpler way? public void afterPropertiesSet() throws Exception { start(); @@ -116,10 +113,8 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean, return true; } - - // Properties - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- public String getBrokerUrl() { return brokerUrl; } diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandHandler.java b/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandHandler.java index be3c1a2de6..331bb597a1 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandHandler.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandHandler.java @@ -17,7 +17,6 @@ package org.apache.activemq.broker.util; import javax.jms.TextMessage; -import javax.jms.JMSException; /** * Represents a processor of text based commands diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/util/LoggingBrokerPlugin.java b/activemq-core/src/main/java/org/apache/activemq/broker/util/LoggingBrokerPlugin.java index aeb430245e..437106550e 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/util/LoggingBrokerPlugin.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/util/LoggingBrokerPlugin.java @@ -17,7 +17,6 @@ package org.apache.activemq.broker.util; import org.apache.activemq.broker.BrokerPluginSupport; -import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ConsumerBrokerExchange; import org.apache.activemq.broker.ProducerBrokerExchange; import org.apache.activemq.command.Message; diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java b/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java index a8711bc45d..549ea0fb93 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.broker.view; +import java.io.FileWriter; +import java.io.PrintWriter; + import org.apache.activemq.broker.Broker; import org.apache.activemq.broker.BrokerFilter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.io.FileWriter; -import java.io.PrintWriter; - /** * Useful base class * @@ -46,8 +46,7 @@ public abstract class DotFileInterceptorSupport extends BrokerFilter { PrintWriter writer = new PrintWriter(new FileWriter(file)); try { generateFile(writer); - } - finally { + } finally { writer.close(); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/camel/CamelDestination.java b/activemq-core/src/main/java/org/apache/activemq/camel/CamelDestination.java index fbf5f6825f..6f44706f99 100644 --- a/activemq-core/src/main/java/org/apache/activemq/camel/CamelDestination.java +++ b/activemq-core/src/main/java/org/apache/activemq/camel/CamelDestination.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.camel; -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.ActiveMQSession; -import org.apache.activemq.CustomDestination; -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.Endpoint; -import org.apache.camel.component.jms.JmsBinding; - import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; @@ -32,6 +24,14 @@ import javax.jms.QueueSender; import javax.jms.TopicPublisher; import javax.jms.TopicSubscriber; +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQSession; +import org.apache.activemq.CustomDestination; +import org.apache.camel.CamelContext; +import org.apache.camel.CamelContextAware; +import org.apache.camel.Endpoint; +import org.apache.camel.component.jms.JmsBinding; + /** * @version $Revision: $ */ diff --git a/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageConsumer.java b/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageConsumer.java index d1bc2ecfa2..960d531133 100644 --- a/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageConsumer.java +++ b/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageConsumer.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.camel; +import javax.jms.IllegalStateException; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; + import org.apache.activemq.ActiveMQSession; import org.apache.activemq.util.JMSExceptionSupport; import org.apache.camel.Consumer; @@ -24,13 +30,10 @@ import org.apache.camel.Exchange; import org.apache.camel.PollingConsumer; import org.apache.camel.Processor; -import javax.jms.*; -import javax.jms.IllegalStateException; - /** - * A JMS {@link javax.jms.MessageConsumer} which consumes message exchanges from a - * Camel {@link Endpoint} - * + * A JMS {@link javax.jms.MessageConsumer} which consumes message exchanges from + * a Camel {@link Endpoint} + * * @version $Revision: $ */ public class CamelMessageConsumer implements MessageConsumer { @@ -62,11 +65,9 @@ public class CamelMessageConsumer implements MessageConsumer { if (pollingConsumer != null) { pollingConsumer.stop(); } - } - catch (JMSException e) { + } catch (JMSException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw JMSExceptionSupport.create(e); } } @@ -99,7 +100,7 @@ public class CamelMessageConsumer implements MessageConsumer { } // Properties - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- public CamelDestination getDestination() { return destination; @@ -122,7 +123,7 @@ public class CamelMessageConsumer implements MessageConsumer { } // Implementation methods - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- protected PollingConsumer getPollingConsumer() throws JMSException { try { @@ -131,11 +132,9 @@ public class CamelMessageConsumer implements MessageConsumer { pollingConsumer.start(); } return pollingConsumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw JMSExceptionSupport.create(e); } } @@ -144,8 +143,7 @@ public class CamelMessageConsumer implements MessageConsumer { if (exchange != null) { Message message = destination.getBinding().makeJmsMessage(exchange, session); return message; - } - else { + } else { return null; } } @@ -160,11 +158,9 @@ public class CamelMessageConsumer implements MessageConsumer { }); answer.start(); return answer; - } - catch (JMSException e) { + } catch (JMSException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw JMSExceptionSupport.create(e); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java b/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java index 8202b4179b..26f0f83700 100644 --- a/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java +++ b/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.camel; +import javax.jms.Destination; +import javax.jms.IllegalStateException; +import javax.jms.JMSException; +import javax.jms.Message; + import org.apache.activemq.ActiveMQMessageProducerSupport; import org.apache.activemq.ActiveMQSession; import org.apache.activemq.util.JMSExceptionSupport; @@ -24,11 +29,6 @@ import org.apache.camel.Producer; import org.apache.camel.component.jms.JmsExchange; import org.apache.camel.util.ObjectHelper; -import javax.jms.Destination; -import javax.jms.IllegalStateException; -import javax.jms.JMSException; -import javax.jms.Message; - /** * A JMS {@link javax.jms.MessageProducer} which sends message exchanges to a * Camel {@link Endpoint} @@ -47,11 +47,9 @@ public class CamelMessageProducer extends ActiveMQMessageProducerSupport { this.endpoint = endpoint; try { this.producer = endpoint.createProducer(); - } - catch (JMSException e) { + } catch (JMSException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw JMSExceptionSupport.create(e); } } @@ -69,33 +67,28 @@ public class CamelMessageProducer extends ActiveMQMessageProducerSupport { closed = true; try { producer.stop(); - } - catch (JMSException e) { + } catch (JMSException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw JMSExceptionSupport.create(e); } } } public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException { - CamelDestination camelDestination = null; + CamelDestination camelDestination = null; if (ObjectHelper.equals(destination, this.destination)) { camelDestination = this.destination; - } - else { + } else { // TODO support any CamelDestination? throw new IllegalArgumentException("Invalid destination setting: " + destination + " when expected: " + this.destination); } try { JmsExchange exchange = new JmsExchange(endpoint.getContext(), camelDestination.getBinding(), message); producer.process(exchange); - } - catch (JMSException e) { + } catch (JMSException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw JMSExceptionSupport.create(e); } } @@ -105,4 +98,4 @@ public class CamelMessageProducer extends ActiveMQMessageProducerSupport { throw new IllegalStateException("The producer is closed"); } } -} \ No newline at end of file +} diff --git a/activemq-core/src/main/java/org/apache/activemq/camel/CamelQueue.java b/activemq-core/src/main/java/org/apache/activemq/camel/CamelQueue.java index 940a944e98..4a4c218733 100644 --- a/activemq-core/src/main/java/org/apache/activemq/camel/CamelQueue.java +++ b/activemq-core/src/main/java/org/apache/activemq/camel/CamelQueue.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.camel; -import org.apache.activemq.ActiveMQSession; - import javax.jms.JMSException; import javax.jms.Queue; -import javax.jms.QueueSender; import javax.jms.QueueReceiver; +import javax.jms.QueueSender; + +import org.apache.activemq.ActiveMQSession; /** * A JMS {@link Queue} object which refers to a Camel endpoint diff --git a/activemq-core/src/main/java/org/apache/activemq/camel/CamelQueueReceiver.java b/activemq-core/src/main/java/org/apache/activemq/camel/CamelQueueReceiver.java index fc3355ae69..f22b7d749d 100644 --- a/activemq-core/src/main/java/org/apache/activemq/camel/CamelQueueReceiver.java +++ b/activemq-core/src/main/java/org/apache/activemq/camel/CamelQueueReceiver.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.camel; -import org.apache.activemq.ActiveMQSession; -import org.apache.camel.Endpoint; - import javax.jms.JMSException; import javax.jms.Queue; import javax.jms.QueueReceiver; +import org.apache.activemq.ActiveMQSession; +import org.apache.camel.Endpoint; + /** * A JMS {@link javax.jms.QueueReceiver} which consumes message exchanges from a * Camel {@link org.apache.camel.Endpoint} diff --git a/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopic.java b/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopic.java index 9c4a82e0bf..86ccb6b864 100644 --- a/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopic.java +++ b/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopic.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.camel; -import org.apache.activemq.ActiveMQSession; - import javax.jms.JMSException; import javax.jms.Topic; import javax.jms.TopicPublisher; import javax.jms.TopicSubscriber; +import org.apache.activemq.ActiveMQSession; + /** * A JMS {@link javax.jms.Topic} object which refers to a Camel endpoint * diff --git a/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopicPublisher.java b/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopicPublisher.java index f054af6b97..0e9210f795 100644 --- a/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopicPublisher.java +++ b/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopicPublisher.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.camel; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.Topic; +import javax.jms.TopicPublisher; + import org.apache.activemq.ActiveMQSession; import org.apache.camel.Endpoint; -import javax.jms.JMSException; -import javax.jms.TopicPublisher; -import javax.jms.Topic; -import javax.jms.Message; - /** * A JMS {@link javax.jms.TopicPublisher} which sends message exchanges to a * Camel {@link Endpoint} diff --git a/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopicSubscriber.java b/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopicSubscriber.java index 77406f060d..7c958b4513 100644 --- a/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopicSubscriber.java +++ b/activemq-core/src/main/java/org/apache/activemq/camel/CamelTopicSubscriber.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.camel; -import org.apache.activemq.ActiveMQSession; -import org.apache.camel.Endpoint; - import javax.jms.JMSException; import javax.jms.Topic; import javax.jms.TopicSubscriber; +import org.apache.activemq.ActiveMQSession; +import org.apache.camel.Endpoint; + /** * A JMS {@link javax.jms.TopicSubscriber} which consumes message exchanges from a * Camel {@link Endpoint} diff --git a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBlobMessage.java b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBlobMessage.java index e47763c509..0e831f1b53 100644 --- a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBlobMessage.java +++ b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBlobMessage.java @@ -16,19 +16,20 @@ */ package org.apache.activemq.command; -import org.apache.activemq.BlobMessage; -import org.apache.activemq.blob.BlobUploader; -import org.apache.activemq.util.JMSExceptionSupport; - -import javax.jms.JMSException; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import javax.jms.JMSException; + +import org.apache.activemq.BlobMessage; +import org.apache.activemq.blob.BlobUploader; +import org.apache.activemq.util.JMSExceptionSupport; + /** * An implementation of {@link BlobMessage} for out of band BLOB transfer - * + * * @version $Revision: $ * @openwire:marshaller code="29" */ @@ -45,7 +46,6 @@ public class ActiveMQBlobMessage extends ActiveMQMessage implements BlobMessage private transient BlobUploader blobUploader; private transient URL url; - public Message copy() { ActiveMQBlobMessage copy = new ActiveMQBlobMessage(); copy(copy); @@ -76,8 +76,9 @@ public class ActiveMQBlobMessage extends ActiveMQMessage implements BlobMessage } /** - * The MIME type of the BLOB which can be used to apply different content types to messages. - * + * The MIME type of the BLOB which can be used to apply different content + * types to messages. + * * @openwire:property version=3 cache=true */ public String getMimeType() { @@ -96,8 +97,9 @@ public class ActiveMQBlobMessage extends ActiveMQMessage implements BlobMessage } /** - * The name of the attachment which can be useful information if transmitting files over ActiveMQ - * + * The name of the attachment which can be useful information if + * transmitting files over ActiveMQ + * * @openwire:property version=3 cache=false */ public void setName(String name) { @@ -131,8 +133,7 @@ public class ActiveMQBlobMessage extends ActiveMQMessage implements BlobMessage if (url == null && remoteBlobUrl != null) { try { url = new URL(remoteBlobUrl); - } - catch (MalformedURLException e) { + } catch (MalformedURLException e) { throw JMSExceptionSupport.create(e); } } @@ -144,7 +145,6 @@ public class ActiveMQBlobMessage extends ActiveMQMessage implements BlobMessage remoteBlobUrl = url != null ? url.toExternalForm() : null; } - public BlobUploader getBlobUploader() { return blobUploader; } @@ -156,13 +156,13 @@ public class ActiveMQBlobMessage extends ActiveMQMessage implements BlobMessage public void onSend() throws JMSException { super.onSend(); - // lets ensure we upload the BLOB first out of band before we send the message + // lets ensure we upload the BLOB first out of band before we send the + // message if (blobUploader != null) { try { URL value = blobUploader.upload(this); setURL(value); - } - catch (IOException e) { + } catch (IOException e) { throw JMSExceptionSupport.create(e); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBytesMessage.java b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBytesMessage.java index b0dcf5322f..237448c971 100755 --- a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBytesMessage.java +++ b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBytesMessage.java @@ -16,17 +16,29 @@ */ package org.apache.activemq.command; -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.util.ByteArrayInputStream; -import org.apache.activemq.util.ByteArrayOutputStream; -import org.apache.activemq.util.*; - -import javax.jms.*; -import java.io.*; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.EOFException; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; +import javax.jms.BytesMessage; +import javax.jms.JMSException; +import javax.jms.MessageFormatException; +import javax.jms.MessageNotReadableException; + +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.util.ByteArrayInputStream; +import org.apache.activemq.util.ByteArrayOutputStream; +import org.apache.activemq.util.ByteSequence; +import org.apache.activemq.util.ByteSequenceData; +import org.apache.activemq.util.JMSExceptionSupport; + /** * A BytesMessage object is used to send a message containing a * stream of uninterpreted bytes. It inherits from the Message diff --git a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java index bb04a187e7..ac39b265b9 100755 --- a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java +++ b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java @@ -16,9 +16,15 @@ */ package org.apache.activemq.command; -import org.apache.activemq.jndi.JNDIBaseStorable; -import org.apache.activemq.util.IntrospectionSupport; -import org.apache.activemq.util.URISupport; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Map; +import java.util.Properties; +import java.util.StringTokenizer; import javax.jms.Destination; import javax.jms.JMSException; @@ -26,16 +32,10 @@ import javax.jms.Queue; import javax.jms.TemporaryQueue; import javax.jms.TemporaryTopic; import javax.jms.Topic; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; -import java.util.StringTokenizer; + +import org.apache.activemq.jndi.JNDIBaseStorable; +import org.apache.activemq.util.IntrospectionSupport; +import org.apache.activemq.util.URISupport; /** * @openwire:marshaller diff --git a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java index c589ba1c69..29d785f627 100755 --- a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java +++ b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java @@ -142,7 +142,6 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage { * Builds the message body from data * * @throws JMSException - * * @throws IOException */ private void loadContent() throws JMSException { @@ -503,7 +502,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage { */ public void setBoolean(String name, boolean value) throws JMSException { initializeWriting(); - put(name, (value) ? Boolean.TRUE : Boolean.FALSE); + put(name, value ? Boolean.TRUE : Boolean.FALSE); } /** diff --git a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java index ec067c3c71..64d3a2179a 100755 --- a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java +++ b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java @@ -415,8 +415,11 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess } protected void checkValidObject(Object value) throws MessageFormatException { - if (!(value instanceof Boolean || value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long || value instanceof Float - || value instanceof Double || value instanceof Character || value instanceof String || value == null)) { + + boolean valid = value instanceof Boolean || value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long ; + valid = valid || value instanceof Float || value instanceof Double || value instanceof Character || value instanceof String || value == null; + + if (!valid) { ActiveMQConnection conn = getConnection(); // conn is null if we are in the broker rather than a JMS client diff --git a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java index 16f4973556..a564f16d6f 100755 --- a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java +++ b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java @@ -17,15 +17,6 @@ package org.apache.activemq.command; -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.util.ByteArrayInputStream; -import org.apache.activemq.util.ByteArrayOutputStream; -import org.apache.activemq.util.ByteSequence; -import org.apache.activemq.util.ClassLoadingAwareObjectInputStream; -import org.apache.activemq.util.JMSExceptionSupport; - -import javax.jms.JMSException; -import javax.jms.ObjectMessage; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -36,6 +27,16 @@ import java.io.Serializable; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; +import javax.jms.JMSException; +import javax.jms.ObjectMessage; + +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.util.ByteArrayInputStream; +import org.apache.activemq.util.ByteArrayOutputStream; +import org.apache.activemq.util.ByteSequence; +import org.apache.activemq.util.ClassLoadingAwareObjectInputStream; +import org.apache.activemq.util.JMSExceptionSupport; + /** * An ObjectMessage object is used to send a message that * contains a serializable object in the Java programming language ("Java diff --git a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java index 9daaa67ee8..660bb0956a 100755 --- a/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java +++ b/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java @@ -16,17 +16,6 @@ */ package org.apache.activemq.command; -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.util.ByteArrayInputStream; -import org.apache.activemq.util.ByteArrayOutputStream; -import org.apache.activemq.util.ByteSequence; -import org.apache.activemq.util.JMSExceptionSupport; -import org.apache.activemq.util.MarshallingSupport; -import org.apache.activemq.wireformat.WireFormat; - -import javax.jms.JMSException; -import javax.jms.MessageNotWriteableException; -import javax.jms.TextMessage; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -35,6 +24,18 @@ import java.io.OutputStream; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; +import javax.jms.JMSException; +import javax.jms.MessageNotWriteableException; +import javax.jms.TextMessage; + +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.util.ByteArrayInputStream; +import org.apache.activemq.util.ByteArrayOutputStream; +import org.apache.activemq.util.ByteSequence; +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.MarshallingSupport; +import org.apache.activemq.wireformat.WireFormat; + /** * @openwire:marshaller code="28" * @version $Revision$ diff --git a/activemq-core/src/main/java/org/apache/activemq/command/RemoveSubscriptionInfo.java b/activemq-core/src/main/java/org/apache/activemq/command/RemoveSubscriptionInfo.java index f4775ecbea..d236f29c3b 100755 --- a/activemq-core/src/main/java/org/apache/activemq/command/RemoveSubscriptionInfo.java +++ b/activemq-core/src/main/java/org/apache/activemq/command/RemoveSubscriptionInfo.java @@ -19,19 +19,17 @@ package org.apache.activemq.command; import org.apache.activemq.state.CommandVisitor; /** - * * @openwire:marshaller code="9" * @version $Revision: 1.7 $ */ public class RemoveSubscriptionInfo extends BaseCommand { - public static final byte DATA_STRUCTURE_TYPE=CommandTypes.REMOVE_SUBSCRIPTION_INFO; + public static final byte DATA_STRUCTURE_TYPE = CommandTypes.REMOVE_SUBSCRIPTION_INFO; protected ConnectionId connectionId; protected String clientId; protected String subscriptionName; - public byte getDataStructureType() { return DATA_STRUCTURE_TYPE; } @@ -42,6 +40,7 @@ public class RemoveSubscriptionInfo extends BaseCommand { public ConnectionId getConnectionId() { return connectionId; } + public void setConnectionId(ConnectionId connectionId) { this.connectionId = connectionId; } @@ -60,7 +59,7 @@ public class RemoveSubscriptionInfo extends BaseCommand { public void setSubcriptionName(String subscriptionName) { this.subscriptionName = subscriptionName; } - + public String getSubscriptionName() { return subscriptionName; } @@ -81,7 +80,7 @@ public class RemoveSubscriptionInfo extends BaseCommand { } public Response visit(CommandVisitor visitor) throws Exception { - return visitor.processRemoveSubscription( this ); + return visitor.processRemoveSubscription(this); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/command/Response.java b/activemq-core/src/main/java/org/apache/activemq/command/Response.java index f2d25c6b8c..c1072aa0c1 100755 --- a/activemq-core/src/main/java/org/apache/activemq/command/Response.java +++ b/activemq-core/src/main/java/org/apache/activemq/command/Response.java @@ -23,10 +23,10 @@ import org.apache.activemq.state.CommandVisitor; * @version $Revision: 1.6 $ */ public class Response extends BaseCommand { - - public static final byte DATA_STRUCTURE_TYPE=CommandTypes.RESPONSE; + + public static final byte DATA_STRUCTURE_TYPE = CommandTypes.RESPONSE; int correlationId; - + public byte getDataStructureType() { return DATA_STRUCTURE_TYPE; } @@ -37,11 +37,11 @@ public class Response extends BaseCommand { public int getCorrelationId() { return correlationId; } - + public void setCorrelationId(int responseId) { this.correlationId = responseId; } - + public boolean isResponse() { return true; } diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/CompositeDestinationFilter.java b/activemq-core/src/main/java/org/apache/activemq/filter/CompositeDestinationFilter.java index f208c17b68..74e5352e01 100755 --- a/activemq-core/src/main/java/org/apache/activemq/filter/CompositeDestinationFilter.java +++ b/activemq-core/src/main/java/org/apache/activemq/filter/CompositeDestinationFilter.java @@ -20,11 +20,11 @@ import org.apache.activemq.command.ActiveMQDestination; /** * A {@link DestinationFilter} used for composite destinations - * + * * @version $Revision: 1.3 $ */ public class CompositeDestinationFilter extends DestinationFilter { - + private DestinationFilter filters[]; public CompositeDestinationFilter(ActiveMQDestination destination) { @@ -32,7 +32,7 @@ public class CompositeDestinationFilter extends DestinationFilter { filters = new DestinationFilter[destinations.length]; for (int i = 0; i < destinations.length; i++) { ActiveMQDestination childDestination = destinations[i]; - filters[i]= DestinationFilter.parseFilter(childDestination); + filters[i] = DestinationFilter.parseFilter(childDestination); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMap.java b/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMap.java index 6fcad088b2..0527725c0f 100755 --- a/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMap.java +++ b/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMap.java @@ -51,8 +51,7 @@ public class DestinationMap { * or composite destinations this will typically be a List of matching * values. * - * @param key - * the destination to lookup + * @param key the destination to lookup * @return a List of matching values or an empty list if there are no * matching values. */ @@ -64,9 +63,8 @@ public class DestinationMap { ActiveMQDestination childDestination = destinations[i]; Object value = get(childDestination); if (value instanceof Set) { - answer.addAll((Set) value); - } - else if (value != null) { + answer.addAll((Set)value); + } else if (value != null) { answer.add(value); } } @@ -108,7 +106,7 @@ public class DestinationMap { public int getTopicRootChildCount() { return topicRootNode.getChildCount(); } - + public int getQueueRootChildCount() { return queueRootNode.getChildCount(); } @@ -121,7 +119,6 @@ public class DestinationMap { return topicRootNode; } - // Implementation methods // ------------------------------------------------------------------------- @@ -131,13 +128,12 @@ public class DestinationMap { */ protected void setEntries(List entries) { for (Iterator iter = entries.iterator(); iter.hasNext();) { - Object element = (Object) iter.next(); + Object element = (Object)iter.next(); Class type = getEntryClass(); if (type.isInstance(element)) { - DestinationMapEntry entry = (DestinationMapEntry) element; + DestinationMapEntry entry = (DestinationMapEntry)element; put(entry.getDestination(), entry.getValue()); - } - else { + } else { throw new IllegalArgumentException("Each entry must be an instance of type: " + type.getName() + " but was: " + element); } } @@ -162,14 +158,14 @@ public class DestinationMap { /** * @param key - * @return + * @return */ public Set removeAll(ActiveMQDestination key) { Set rc = new HashSet(); if (key.isComposite()) { ActiveMQDestination[] destinations = key.getCompositeDestinations(); for (int i = 0; i < destinations.length; i++) { - rc.add( removeAll(destinations[i]) ); + rc.add(removeAll(destinations[i])); } return rc; } @@ -183,8 +179,7 @@ public class DestinationMap { * no matching value. If there are multiple values, the results are sorted * and the last item (the biggest) is returned. * - * @param destination - * the destination to find the value for + * @param destination the destination to find the value for * @return the largest matching value or null if no value matches */ public Object chooseValue(ActiveMQDestination destination) { @@ -202,8 +197,7 @@ public class DestinationMap { protected DestinationMapNode getRootNode(ActiveMQDestination key) { if (key.isQueue()) { return queueRootNode; - } - else { + } else { return topicRootNode; } } diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMapEntry.java b/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMapEntry.java index 03f1fe1aa1..4505d441a3 100644 --- a/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMapEntry.java +++ b/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMapEntry.java @@ -31,16 +31,13 @@ public abstract class DestinationMapEntry implements InitializingBean, Comparabl private ActiveMQDestination destination; - public int compareTo(Object that) { if (that instanceof DestinationMapEntry) { - DestinationMapEntry thatEntry = (DestinationMapEntry) that; + DestinationMapEntry thatEntry = (DestinationMapEntry)that; return ActiveMQDestination.compare(destination, thatEntry.destination); - } - else if (that == null) { + } else if (that == null) { return 1; - } - else { + } else { return getClass().getName().compareTo(that.getClass().getName()); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMapNode.java b/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMapNode.java index 9030ae9429..d433734871 100755 --- a/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMapNode.java +++ b/activemq-core/src/main/java/org/apache/activemq/filter/DestinationMapNode.java @@ -20,10 +20,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Iterator; /** * An implementation class used to implement {@link DestinationMap} diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/DestinationPath.java b/activemq-core/src/main/java/org/apache/activemq/filter/DestinationPath.java index 281773ee7e..d6488e505c 100755 --- a/activemq-core/src/main/java/org/apache/activemq/filter/DestinationPath.java +++ b/activemq-core/src/main/java/org/apache/activemq/filter/DestinationPath.java @@ -27,7 +27,7 @@ import org.apache.activemq.command.Message; /** * Helper class for decomposing a Destination into a number of paths - * + * * @version $Revision: 1.3 $ */ public class DestinationPath { @@ -61,7 +61,7 @@ public class DestinationPath { /** * Converts the paths to a single String seperated by dots. - * + * * @param paths * @return */ @@ -74,8 +74,7 @@ public class DestinationPath { String path = paths[i]; if (path == null) { buffer.append("*"); - } - else { + } else { buffer.append(path); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/LogicExpression.java b/activemq-core/src/main/java/org/apache/activemq/filter/LogicExpression.java index bf15b64d98..9910ee155f 100755 --- a/activemq-core/src/main/java/org/apache/activemq/filter/LogicExpression.java +++ b/activemq-core/src/main/java/org/apache/activemq/filter/LogicExpression.java @@ -27,17 +27,17 @@ public abstract class LogicExpression extends BinaryExpression implements Boolea public static BooleanExpression createOR(BooleanExpression lvalue, BooleanExpression rvalue) { return new LogicExpression(lvalue, rvalue) { - + public Object evaluate(MessageEvaluationContext message) throws JMSException { - - Boolean lv = (Boolean) left.evaluate(message); + + Boolean lv = (Boolean)left.evaluate(message); // Can we do an OR shortcut?? - if (lv !=null && lv.booleanValue()) { + if (lv != null && lv.booleanValue()) { return Boolean.TRUE; } - - Boolean rv = (Boolean) right.evaluate(message); - return rv==null ? null : rv; + + Boolean rv = (Boolean)right.evaluate(message); + return rv == null ? null : rv; } public String getExpressionSymbol() { @@ -51,7 +51,7 @@ public abstract class LogicExpression extends BinaryExpression implements Boolea public Object evaluate(MessageEvaluationContext message) throws JMSException { - Boolean lv = (Boolean) left.evaluate(message); + Boolean lv = (Boolean)left.evaluate(message); // Can we do an AND shortcut?? if (lv == null) @@ -60,7 +60,7 @@ public abstract class LogicExpression extends BinaryExpression implements Boolea return Boolean.FALSE; } - Boolean rv = (Boolean) right.evaluate(message); + Boolean rv = (Boolean)right.evaluate(message); return rv == null ? null : rv; } @@ -82,7 +82,7 @@ public abstract class LogicExpression extends BinaryExpression implements Boolea public boolean matches(MessageEvaluationContext message) throws JMSException { Object object = evaluate(message); - return object!=null && object==Boolean.TRUE; + return object != null && object == Boolean.TRUE; } } diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/XalanXPathEvaluator.java b/activemq-core/src/main/java/org/apache/activemq/filter/XalanXPathEvaluator.java index f3caf311ff..bb09b4cd86 100755 --- a/activemq-core/src/main/java/org/apache/activemq/filter/XalanXPathEvaluator.java +++ b/activemq-core/src/main/java/org/apache/activemq/filter/XalanXPathEvaluator.java @@ -28,9 +28,11 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.apache.activemq.command.Message; import org.apache.activemq.util.ByteArrayInputStream; import org.apache.xpath.CachedXPathAPI; + +import org.xml.sax.InputSource; + import org.w3c.dom.Document; import org.w3c.dom.traversal.NodeIterator; -import org.xml.sax.InputSource; public class XalanXPathEvaluator implements XPathExpression.XPathEvaluator { diff --git a/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java b/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java index 20c2f8bfe7..197e019473 100755 --- a/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java +++ b/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; +import java.util.concurrent.ConcurrentHashMap; -import javax.jms.ConnectionFactory; import javax.jms.Queue; import javax.jms.Topic; import javax.naming.Context; @@ -33,12 +33,9 @@ import javax.naming.NamingException; import javax.naming.spi.InitialContextFactory; import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.Broker; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; -import java.util.concurrent.ConcurrentHashMap; - /** * A factory of the ActiveMQ InitialContext which contains * {@link ConnectionFactory} instances as well as a child context called diff --git a/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java b/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java index 16307e2541..b145ab3675 100644 --- a/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java +++ b/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java @@ -16,12 +16,13 @@ */ package org.apache.activemq.jndi; -import javax.naming.Context; -import javax.naming.NamingException; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; +import javax.naming.Context; +import javax.naming.NamingException; + /** * This implementation of InitialContextFactory should be used * when ActiveMQ is used as WebSphere Generic JMS Provider. It is proved that it @@ -30,7 +31,8 @@ import java.util.Map; * only if it begins with java.naming or javax.naming prefix. Additionaly * provider url for the JMS provider can not contain ',' character that is * necessary when the list of nodes is provided. So the role of this class is to - * transform properties before passing it to ActiveMQInitialContextFactory. + * transform properties before passing it to + * ActiveMQInitialContextFactory. * * @author Pawel Tucholski */ @@ -53,8 +55,7 @@ public class ActiveMQWASInitialContextFactory extends ActiveMQInitialContextFact *

  • (java.naming.provider.url,url1;url2)=>java.naming.provider.url,url1,url1) *