You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2007/08/10 18:57:10 UTC
svn commit: r564679 [3/8] - in /activemq/trunk:
activemq-core/src/main/java/org/apache/activemq/
activemq-core/src/main/java/org/apache/activemq/broker/
activemq-core/src/main/java/org/apache/activemq/broker/jmx/
activemq-core/src/main/java/org/apache/...
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java Fri Aug 10 09:57:01 2007
@@ -48,7 +48,7 @@
*/
public class TopicRegion extends AbstractRegion {
private static final Log LOG = LogFactory.getLog(TopicRegion.class);
- protected final ConcurrentHashMap durableSubscriptions = new ConcurrentHashMap();
+ protected final ConcurrentHashMap<SubscriptionKey, DurableTopicSubscription> durableSubscriptions = new ConcurrentHashMap<SubscriptionKey, DurableTopicSubscription>();
private final LongSequenceGenerator recoveredDurableSubIdGenerator = new LongSequenceGenerator();
private final SessionId recoveredDurableSubSessionId = new SessionId(new ConnectionId("OFFLINE"), recoveredDurableSubIdGenerator.getNextSequenceId());
private boolean keepDurableSubsActive;
@@ -69,7 +69,7 @@
String clientId = context.getClientId();
String subscriptionName = info.getSubscriptionName();
SubscriptionKey key = new SubscriptionKey(clientId, subscriptionName);
- DurableTopicSubscription sub = (DurableTopicSubscription)durableSubscriptions.get(key);
+ DurableTopicSubscription sub = durableSubscriptions.get(key);
if (sub != null) {
if (sub.isActive()) {
throw new JMSException("Durable consumer is in use for client: " + clientId + " and subscriptionName: " + subscriptionName);
@@ -78,22 +78,23 @@
if (hasDurableSubChanged(info, sub.getConsumerInfo())) {
// Remove the consumer first then add it.
durableSubscriptions.remove(key);
- for (Iterator iter = destinations.values().iterator(); iter.hasNext();) {
+ for (Iterator<Destination> iter = destinations.values().iterator(); iter.hasNext();) {
Topic topic = (Topic)iter.next();
topic.deleteSubscription(context, key);
}
super.removeConsumer(context, sub.getConsumerInfo());
super.addConsumer(context, info);
- sub = (DurableTopicSubscription)durableSubscriptions.get(key);
+ sub = durableSubscriptions.get(key);
} else {
// Change the consumer id key of the durable sub.
- if (sub.getConsumerInfo().getConsumerId() != null)
+ if (sub.getConsumerInfo().getConsumerId() != null) {
subscriptions.remove(sub.getConsumerInfo().getConsumerId());
+ }
subscriptions.put(info.getConsumerId(), sub);
}
} else {
super.addConsumer(context, info);
- sub = (DurableTopicSubscription)durableSubscriptions.get(key);
+ sub = durableSubscriptions.get(key);
if (sub == null) {
throw new JMSException("Cannot use the same consumerId: " + info.getConsumerId() + " for two different durable subscriptions clientID: " + key.getClientId()
+ " subscriberName: " + key.getSubscriptionName());
@@ -110,7 +111,7 @@
if (info.isDurable()) {
SubscriptionKey key = new SubscriptionKey(context.getClientId(), info.getSubscriptionName());
- DurableTopicSubscription sub = (DurableTopicSubscription)durableSubscriptions.get(key);
+ DurableTopicSubscription sub = durableSubscriptions.get(key);
if (sub != null) {
sub.deactivate(keepDurableSubsActive);
}
@@ -121,17 +122,17 @@
}
public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception {
- SubscriptionKey key = new SubscriptionKey(info.getClientId(), info.getSubcriptionName());
- DurableTopicSubscription sub = (DurableTopicSubscription)durableSubscriptions.get(key);
+ SubscriptionKey key = new SubscriptionKey(info.getClientId(), info.getSubscriptionName());
+ DurableTopicSubscription sub = durableSubscriptions.get(key);
if (sub == null) {
- throw new InvalidDestinationException("No durable subscription exists for: " + info.getSubcriptionName());
+ throw new InvalidDestinationException("No durable subscription exists for: " + info.getSubscriptionName());
}
if (sub.isActive()) {
throw new JMSException("Durable consumer is in use");
}
durableSubscriptions.remove(key);
- for (Iterator iter = destinations.values().iterator(); iter.hasNext();) {
+ for (Iterator<Destination> iter = destinations.values().iterator(); iter.hasNext();) {
Topic topic = (Topic)iter.next();
topic.deleteSubscription(context, key);
}
@@ -146,7 +147,7 @@
protected List<Subscription> addSubscriptionsForDestination(ConnectionContext context, Destination dest) throws Exception {
List<Subscription> rc = super.addSubscriptionsForDestination(context, dest);
- HashSet<Subscription> dupChecker = new HashSet<Subscription>(rc);
+ Set<Subscription> dupChecker = new HashSet<Subscription>(rc);
TopicMessageStore store = (TopicMessageStore)dest.getMessageStore();
// Eagerly recover the durable subscriptions
@@ -160,7 +161,7 @@
// A single durable sub may be subscribing to multiple topics.
// so it might exist already.
- DurableTopicSubscription sub = (DurableTopicSubscription)durableSubscriptions.get(key);
+ DurableTopicSubscription sub = durableSubscriptions.get(key);
ConsumerInfo consumerInfo = createInactiveConsumerInfo(info);
if (sub == null) {
ConnectionContext c = new ConnectionContext();
@@ -182,8 +183,8 @@
// Now perhaps there other durable subscriptions (via wild card)
// that would match this destination..
durableSubscriptions.values();
- for (Iterator iterator = durableSubscriptions.values().iterator(); iterator.hasNext();) {
- DurableTopicSubscription sub = (DurableTopicSubscription)iterator.next();
+ for (Iterator<DurableTopicSubscription> iterator = durableSubscriptions.values().iterator(); iterator.hasNext();) {
+ DurableTopicSubscription sub = iterator.next();
// Skip over subscriptions that we allready added..
if (dupChecker.contains(sub)) {
continue;
@@ -227,7 +228,7 @@
throw new JMSException("Cannot create a durable subscription for an advisory Topic");
}
SubscriptionKey key = new SubscriptionKey(context.getClientId(), info.getSubscriptionName());
- DurableTopicSubscription sub = (DurableTopicSubscription)durableSubscriptions.get(key);
+ DurableTopicSubscription sub = durableSubscriptions.get(key);
if (sub == null) {
sub = new DurableTopicSubscription(broker, memoryManager, context, info, keepDurableSubsActive);
ActiveMQDestination destination = info.getDestination();
@@ -266,10 +267,12 @@
/**
*/
private boolean hasDurableSubChanged(ConsumerInfo info1, ConsumerInfo info2) {
- if (info1.getSelector() != null ^ info2.getSelector() != null)
+ if (info1.getSelector() != null ^ info2.getSelector() != null) {
return true;
- if (info1.getSelector() != null && !info1.getSelector().equals(info2.getSelector()))
+ }
+ if (info1.getSelector() != null && !info1.getSelector().equals(info2.getSelector())) {
return true;
+ }
return !info1.getDestination().equals(info2.getDestination());
}
@@ -277,8 +280,9 @@
Set inactiveDestinations = super.getInactiveDestinations();
for (Iterator iter = inactiveDestinations.iterator(); iter.hasNext();) {
ActiveMQDestination dest = (ActiveMQDestination)iter.next();
- if (!dest.isTopic())
+ if (!dest.isTopic()) {
iter.remove();
+ }
}
return inactiveDestinations;
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/StoreDurableSubscriberCursor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/StoreDurableSubscriberCursor.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/StoreDurableSubscriberCursor.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/StoreDurableSubscriberCursor.java Fri Aug 10 09:57:01 2007
@@ -45,7 +45,7 @@
private int pendingCount;
private String clientId;
private String subscriberName;
- private Map topics = new HashMap();
+ private Map<Destination, TopicStorePrefetch> topics = new HashMap<Destination, TopicStorePrefetch>();
private LinkedList<PendingMessageCursor> storePrefetches = new LinkedList<PendingMessageCursor>();
private boolean started;
private PendingMessageCursor nonPersistent;
@@ -129,7 +129,7 @@
public boolean isEmpty(Destination destination) {
boolean result = true;
- TopicStorePrefetch tsp = (TopicStorePrefetch)topics.get(destination);
+ TopicStorePrefetch tsp = topics.get(destination);
if (tsp != null) {
result = tsp.size() <= 0;
}
@@ -158,7 +158,7 @@
}
if (msg.isPersistent()) {
Destination dest = msg.getRegionDestination();
- TopicStorePrefetch tsp = (TopicStorePrefetch)topics.get(dest);
+ TopicStorePrefetch tsp = topics.get(dest);
if (tsp != null) {
tsp.addMessageLast(node);
}
@@ -212,14 +212,14 @@
}
public synchronized void reset() {
- for (Iterator i = storePrefetches.iterator(); i.hasNext();) {
+ for (Iterator<PendingMessageCursor> i = storePrefetches.iterator(); i.hasNext();) {
AbstractPendingMessageCursor tsp = (AbstractPendingMessageCursor)i.next();
tsp.reset();
}
}
public synchronized void release() {
- for (Iterator i = storePrefetches.iterator(); i.hasNext();) {
+ for (Iterator<PendingMessageCursor> i = storePrefetches.iterator(); i.hasNext();) {
AbstractPendingMessageCursor tsp = (AbstractPendingMessageCursor)i.next();
tsp.release();
}
@@ -230,7 +230,7 @@
}
public synchronized void setMaxBatchSize(int maxBatchSize) {
- for (Iterator i = storePrefetches.iterator(); i.hasNext();) {
+ for (Iterator<PendingMessageCursor> i = storePrefetches.iterator(); i.hasNext();) {
AbstractPendingMessageCursor tsp = (AbstractPendingMessageCursor)i.next();
tsp.setMaxBatchSize(maxBatchSize);
}
@@ -238,16 +238,16 @@
}
public synchronized void gc() {
- for (Iterator i = storePrefetches.iterator(); i.hasNext();) {
- PendingMessageCursor tsp = (PendingMessageCursor)i.next();
+ for (Iterator<PendingMessageCursor> i = storePrefetches.iterator(); i.hasNext();) {
+ PendingMessageCursor tsp = i.next();
tsp.gc();
}
}
public synchronized void setUsageManager(UsageManager usageManager) {
super.setUsageManager(usageManager);
- for (Iterator i = storePrefetches.iterator(); i.hasNext();) {
- PendingMessageCursor tsp = (PendingMessageCursor)i.next();
+ for (Iterator<PendingMessageCursor> i = storePrefetches.iterator(); i.hasNext();) {
+ PendingMessageCursor tsp = i.next();
tsp.setUsageManager(usageManager);
}
}
@@ -255,7 +255,7 @@
protected synchronized PendingMessageCursor getNextCursor() throws Exception {
if (currentCursor == null || currentCursor.isEmpty()) {
currentCursor = null;
- for (Iterator i = storePrefetches.iterator(); i.hasNext();) {
+ for (Iterator<PendingMessageCursor> i = storePrefetches.iterator(); i.hasNext();) {
AbstractPendingMessageCursor tsp = (AbstractPendingMessageCursor)i.next();
if (tsp.hasNext()) {
currentCursor = tsp;
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/group/MessageGroupHashBucket.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/group/MessageGroupHashBucket.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/group/MessageGroupHashBucket.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/group/MessageGroupHashBucket.java Fri Aug 10 09:57:01 2007
@@ -102,8 +102,9 @@
protected int getBucketNumber(String groupId) {
int bucket = groupId.hashCode() % bucketCount;
// bucket could be negative
- if (bucket < 0)
+ if (bucket < 0) {
bucket *= -1;
+ }
return bucket;
}
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/FixedCountSubscriptionRecoveryPolicy.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/FixedCountSubscriptionRecoveryPolicy.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/FixedCountSubscriptionRecoveryPolicy.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/FixedCountSubscriptionRecoveryPolicy.java Fri Aug 10 09:57:01 2007
@@ -47,8 +47,9 @@
public synchronized boolean add(ConnectionContext context, MessageReference node) throws Exception {
messages[tail++] = node;
- if (tail >= messages.length)
+ if (tail >= messages.length) {
tail = 0;
+ }
return true;
}
@@ -56,18 +57,21 @@
// Re-dispatch the last message seen.
int t = tail;
// The buffer may not have rolled over yet..., start from the front
- if (messages[t] == null)
+ if (messages[t] == null) {
t = 0;
+ }
// Well the buffer is really empty then.
- if (messages[t] == null)
+ if (messages[t] == null) {
return;
+ }
// Keep dispatching until t hit's tail again.
do {
MessageReference node = messages[t];
sub.addRecoveredMessage(context, node);
t++;
- if (t >= messages.length)
+ if (t >= messages.length) {
t = 0;
+ }
} while (t != tail);
}
@@ -92,11 +96,12 @@
}
public synchronized Message[] browse(ActiveMQDestination destination) throws Exception {
- List result = new ArrayList();
+ List<Message> result = new ArrayList<Message>();
DestinationFilter filter = DestinationFilter.parseFilter(destination);
int t = tail;
- if (messages[t] == null)
+ if (messages[t] == null) {
t = 0;
+ }
if (messages[t] != null) {
do {
MessageReference ref = messages[t];
@@ -105,11 +110,12 @@
result.add(message);
}
t++;
- if (t >= messages.length)
+ if (t >= messages.length) {
t = 0;
+ }
} while (t != tail);
}
- return (Message[])result.toArray(new Message[result.size()]);
+ return result.toArray(new Message[result.size()]);
}
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/RoundRobinDispatchPolicy.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/RoundRobinDispatchPolicy.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/RoundRobinDispatchPolicy.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/RoundRobinDispatchPolicy.java Fri Aug 10 09:57:01 2007
@@ -58,8 +58,9 @@
Subscription sub = (Subscription)iter.next();
// Only dispatch to interested subscriptions
- if (!sub.matches(node, msgContext))
+ if (!sub.matches(node, msgContext)) {
continue;
+ }
if (firstMatchingConsumer == null) {
firstMatchingConsumer = sub;
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/SimpleDispatchPolicy.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/SimpleDispatchPolicy.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/SimpleDispatchPolicy.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/SimpleDispatchPolicy.java Fri Aug 10 09:57:01 2007
@@ -37,11 +37,13 @@
Subscription sub = (Subscription)iter.next();
// Don't deliver to browsers
- if (sub.getConsumerInfo().isBrowser())
+ if (sub.getConsumerInfo().isBrowser()) {
continue;
+ }
// Only dispatch to interested subscriptions
- if (!sub.matches(node, msgContext))
+ if (!sub.matches(node, msgContext)) {
continue;
+ }
sub.add(node);
count++;
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/StrictOrderDispatchPolicy.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/StrictOrderDispatchPolicy.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/StrictOrderDispatchPolicy.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/StrictOrderDispatchPolicy.java Fri Aug 10 09:57:01 2007
@@ -50,8 +50,9 @@
Subscription sub = (Subscription)iter.next();
// Only dispatch to interested subscriptions
- if (!sub.matches(node, msgContext))
+ if (!sub.matches(node, msgContext)) {
continue;
+ }
sub.add(node);
count++;
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/virtual/VirtualDestinationInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/virtual/VirtualDestinationInterceptor.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/virtual/VirtualDestinationInterceptor.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/virtual/VirtualDestinationInterceptor.java Fri Aug 10 09:57:01 2007
@@ -42,7 +42,7 @@
public Destination intercept(Destination destination) {
Set virtualDestinations = destinationMap.get(destination.getActiveMQDestination());
- List destinations = new ArrayList();
+ List<Destination> destinations = new ArrayList<Destination>();
for (Iterator iter = virtualDestinations.iterator(); iter.hasNext();) {
VirtualDestination virtualDestination = (VirtualDestination)iter.next();
Destination newNestination = virtualDestination.intercept(destination);
@@ -50,7 +50,7 @@
}
if (!destinations.isEmpty()) {
if (destinations.size() == 1) {
- return (Destination)destinations.get(0);
+ return destinations.get(0);
} else {
// should rarely be used but here just in case
return createCompositeDestination(destination, destinations);
@@ -72,11 +72,11 @@
}
}
- protected Destination createCompositeDestination(Destination destination, final List destinations) {
+ protected Destination createCompositeDestination(Destination destination, final List<Destination> destinations) {
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();
+ for (Iterator<Destination> iter = destinations.iterator(); iter.hasNext();) {
+ Destination destination = iter.next();
destination.send(context, messageSend);
}
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandMessageListener.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandMessageListener.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandMessageListener.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandMessageListener.java Fri Aug 10 09:57:01 2007
@@ -16,10 +16,7 @@
*/
package org.apache.activemq.broker.util;
-import org.apache.activemq.command.ActiveMQTextMessage;
-import org.apache.activemq.util.FactoryFinder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.io.IOException;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -28,9 +25,11 @@
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
+
+import org.apache.activemq.command.ActiveMQTextMessage;
+import org.apache.activemq.util.FactoryFinder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* @version $Revision: $
@@ -51,7 +50,7 @@
LOG.debug("Received command: " + message);
}
if (message instanceof TextMessage) {
- TextMessage request = (TextMessage) message;
+ TextMessage request = (TextMessage)message;
try {
Destination replyTo = message.getJMSReplyTo();
if (replyTo == null) {
@@ -61,12 +60,10 @@
Message response = processCommand(request);
addReplyHeaders(request, response);
getProducer().send(replyTo, response);
- }
- catch (Exception e) {
+ } catch (Exception e) {
LOG.error("Failed to process message due to: " + e + ". Message: " + message, e);
}
- }
- else {
+ } else {
LOG.warn("Ignoring invalid message: " + message);
}
}
@@ -88,7 +85,8 @@
}
/**
- * Processes an incoming command from a console and returning the text to output
+ * Processes an incoming command from a console and returning the text to
+ * output
*/
public String processCommandText(String line) throws Exception {
TextMessage request = new ActiveMQTextMessage();
@@ -118,6 +116,6 @@
private CommandHandler createHandler() throws IllegalAccessException, IOException, ClassNotFoundException, InstantiationException {
FactoryFinder factoryFinder = new FactoryFinder("META-INF/services/org/apache/activemq/broker/");
- return (CommandHandler) factoryFinder.newInstance("agent");
+ return (CommandHandler)factoryFinder.newInstance("agent");
}
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/UDPTraceBrokerPlugin.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/UDPTraceBrokerPlugin.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/UDPTraceBrokerPlugin.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/UDPTraceBrokerPlugin.java Fri Aug 10 09:57:01 2007
@@ -87,8 +87,9 @@
public void start() throws Exception {
super.start();
- if (getWireFormat() == null)
+ if (getWireFormat() == null) {
throw new IllegalArgumentException("Wireformat must be specifed.");
+ }
if (address == null) {
address = createSocketAddress(destination);
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/ConnectionDotFileInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/ConnectionDotFileInterceptor.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/ConnectionDotFileInterceptor.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/ConnectionDotFileInterceptor.java Fri Aug 10 09:57:01 2007
@@ -57,8 +57,8 @@
private MBeanServer mbeanServer;
// until we have some MBeans for producers, lets do it all ourselves
- private Map producers = new HashMap();
- private Map producerDestinations = new HashMap();
+ private Map<ProducerId, ProducerInfo> producers = new HashMap<ProducerId, ProducerInfo>();
+ private Map<ProducerId, Set> producerDestinations = new HashMap<ProducerId, Set>();
private Object lock = new Object();
public ConnectionDotFileInterceptor(Broker next, String file, boolean redrawOnRemove) throws MalformedObjectNameException {
@@ -109,9 +109,9 @@
ProducerId producerId = messageSend.getProducerId();
ActiveMQDestination destination = messageSend.getDestination();
synchronized (lock) {
- Set destinations = (Set)producerDestinations.get(producerId);
+ Set<ActiveMQDestination> destinations = producerDestinations.get(producerId);
if (destinations == null) {
- destinations = new HashSet();
+ destinations = new HashSet<ActiveMQDestination>();
}
producerDestinations.put(producerId, destinations);
destinations.add(destination);
@@ -127,9 +127,9 @@
writer.println("node [style = \"rounded,filled\", fillcolor = yellow, fontname=\"Helvetica-Oblique\"];");
writer.println();
- Map clients = new HashMap();
- Map queues = new HashMap();
- Map topics = new HashMap();
+ Map<String, String> clients = new HashMap<String, String>();
+ Map<String, String> queues = new HashMap<String, String>();
+ Map<String, String> topics = new HashMap<String, String>();
printSubscribers(writer, clients, queues, "queue_", brokerView.getQueueSubscribers());
writer.println();
@@ -152,7 +152,7 @@
}
}
- protected void printProducers(PrintWriter writer, Map clients, Map queues, Map topics) {
+ protected void printProducers(PrintWriter writer, Map<String, String> clients, Map<String, String> queues, Map<String, String> topics) {
synchronized (lock) {
for (Iterator iter = producerDestinations.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry)iter.next();
@@ -163,7 +163,7 @@
}
}
- protected void printProducers(PrintWriter writer, Map clients, Map queues, Map topics, ProducerId producerId, Set destinationSet) {
+ protected void printProducers(PrintWriter writer, Map<String, String> clients, Map<String, String> queues, Map<String, String> topics, ProducerId producerId, Set destinationSet) {
for (Iterator iter = destinationSet.iterator(); iter.hasNext();) {
ActiveMQDestination destination = (ActiveMQDestination)iter.next();
@@ -206,7 +206,7 @@
}
}
- protected void printSubscribers(PrintWriter writer, Map clients, Map destinations, String type, ObjectName[] subscribers) {
+ protected void printSubscribers(PrintWriter writer, Map<String, String> clients, Map<String, String> destinations, String type, ObjectName[] subscribers) {
for (int i = 0; i < subscribers.length; i++) {
ObjectName name = subscribers[i];
SubscriptionViewMBean subscriber = (SubscriptionViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, SubscriptionViewMBean.class, true);
@@ -246,7 +246,7 @@
}
}
- protected void writeLabels(PrintWriter writer, String color, String prefix, Map map) {
+ protected void writeLabels(PrintWriter writer, String color, String prefix, Map<String, String> map) {
for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry)iter.next();
String id = (String)entry.getKey();
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java Fri Aug 10 09:57:01 2007
@@ -36,9 +36,11 @@
* @version $Revision: $
*/
public class CamelMessageProducer extends ActiveMQMessageProducerSupport {
+
+ protected Producer producer;
+
private final CamelDestination destination;
private final Endpoint endpoint;
- protected Producer producer;
private boolean closed;
public CamelMessageProducer(CamelDestination destination, Endpoint endpoint, ActiveMQSession session) throws JMSException {
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBytesMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBytesMessage.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBytesMessage.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQBytesMessage.java Fri Aug 10 09:57:01 2007
@@ -817,8 +817,9 @@
checkWriteOnlyBody();
if (dataIn == null) {
ByteSequence data = getContent();
- if (data == null)
+ if (data == null) {
data = new ByteSequence(new byte[] {}, 0, 0);
+ }
InputStream is = new ByteArrayInputStream(data);
if (isCompressed()) {
// keep track of the real length of the content if
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java Fri Aug 10 09:57:01 2007
@@ -22,6 +22,7 @@
import java.io.ObjectOutput;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
@@ -41,10 +42,7 @@
* @openwire:marshaller
* @version $Revision: 1.10 $
*/
-public abstract class ActiveMQDestination extends JNDIBaseStorable implements DataStructure, Destination,
- Externalizable, Comparable {
-
- private static final long serialVersionUID = -3885260014960795889L;
+public abstract class ActiveMQDestination extends JNDIBaseStorable implements DataStructure, Destination, Externalizable, Comparable {
public static final String PATH_SEPERATOR = ".";
public static final char COMPOSITE_SEPERATOR = ',';
@@ -62,13 +60,27 @@
public static final String TEMP_DESTINATION_NAME_PREFIX = "ID:";
+ private static final long serialVersionUID = -3885260014960795889L;
+
protected String physicalName;
protected transient ActiveMQDestination[] compositeDestinations;
protected transient String[] destinationPaths;
protected transient boolean isPattern;
protected transient int hashValue;
- protected Map options;
+ protected Map<String, String> options;
+
+ public ActiveMQDestination() {
+ }
+
+ protected ActiveMQDestination(String name) {
+ setPhysicalName(name);
+ }
+
+ public ActiveMQDestination(ActiveMQDestination composites[]) {
+ setCompositeDestinations(composites);
+ }
+
// static helper methods for working with destinations
// -------------------------------------------------------------------------
@@ -99,18 +111,24 @@
}
public static ActiveMQDestination transform(Destination dest) throws JMSException {
- if (dest == null)
+ if (dest == null) {
return null;
- if (dest instanceof ActiveMQDestination)
+ }
+ if (dest instanceof ActiveMQDestination) {
return (ActiveMQDestination)dest;
- if (dest instanceof TemporaryQueue)
+ }
+ if (dest instanceof TemporaryQueue) {
return new ActiveMQTempQueue(((TemporaryQueue)dest).getQueueName());
- if (dest instanceof TemporaryTopic)
+ }
+ if (dest instanceof TemporaryTopic) {
return new ActiveMQTempTopic(((TemporaryTopic)dest).getTopicName());
- if (dest instanceof Queue)
+ }
+ if (dest instanceof Queue) {
return new ActiveMQQueue(((Queue)dest).getQueueName());
- if (dest instanceof Topic)
+ }
+ if (dest instanceof Topic) {
return new ActiveMQTopic(((Topic)dest).getTopicName());
+ }
throw new JMSException("Could not transform the destination into a ActiveMQ destination: " + dest);
}
@@ -131,17 +149,6 @@
}
}
- public ActiveMQDestination() {
- }
-
- protected ActiveMQDestination(String name) {
- setPhysicalName(name);
- }
-
- public ActiveMQDestination(ActiveMQDestination composites[]) {
- setCompositeDestinations(composites);
- }
-
public int compareTo(Object that) {
if (that instanceof ActiveMQDestination) {
return compare(this, (ActiveMQDestination)that);
@@ -169,8 +176,9 @@
StringBuffer sb = new StringBuffer();
for (int i = 0; i < destinations.length; i++) {
- if (i != 0)
+ if (i != 0) {
sb.append(COMPOSITE_SEPERATOR);
+ }
if (getDestinationType() == destinations[i].getDestinationType()) {
sb.append(destinations[i].getPhysicalName());
} else {
@@ -181,8 +189,9 @@
}
public String getQualifiedName() {
- if (isComposite())
+ if (isComposite()) {
return physicalName;
+ }
return getQualifiedPrefix() + physicalName;
}
@@ -221,8 +230,7 @@
try {
options = URISupport.parseQuery(optstring);
} catch (URISyntaxException e) {
- throw new IllegalArgumentException("Invalid destination name: " + physicalName
- + ", it's options are not encoded properly: " + e);
+ throw new IllegalArgumentException("Invalid destination name: " + physicalName + ", it's options are not encoded properly: " + e);
}
}
this.physicalName = physicalName;
@@ -230,12 +238,13 @@
this.hashValue = 0;
if (composite) {
// Check to see if it is a composite.
- ArrayList<String> l = new ArrayList<String>();
+ List<String> l = new ArrayList<String>();
StringTokenizer iter = new StringTokenizer(physicalName, "" + COMPOSITE_SEPERATOR);
while (iter.hasMoreTokens()) {
String name = iter.nextToken().trim();
- if (name.length() == 0)
+ if (name.length() == 0) {
continue;
+ }
l.add(name);
}
if (l.size() > 1) {
@@ -254,15 +263,17 @@
public String[] getDestinationPaths() {
- if (destinationPaths != null)
+ if (destinationPaths != null) {
return destinationPaths;
+ }
- ArrayList l = new ArrayList();
+ List<String> l = new ArrayList<String>();
StringTokenizer iter = new StringTokenizer(physicalName, PATH_SEPERATOR);
while (iter.hasMoreTokens()) {
String name = iter.nextToken().trim();
- if (name.length() == 0)
+ if (name.length() == 0) {
continue;
+ }
l.add(name);
}
@@ -286,10 +297,12 @@
}
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || getClass() != o.getClass())
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
+ }
ActiveMQDestination d = (ActiveMQDestination)o;
return physicalName.equals(d.physicalName);
@@ -331,7 +344,7 @@
}
}
- public Map getOptions() {
+ public Map<String, String> getOptions() {
return options;
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java Fri Aug 10 09:57:01 2007
@@ -99,7 +99,7 @@
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_MAP_MESSAGE;
- protected transient Map map = new HashMap();
+ protected transient Map<String, Object> map = new HashMap<String, Object>();
public Message copy() {
ActiveMQMapMessage copy = new ActiveMQMapMessage();
@@ -474,7 +474,7 @@
* @return an enumeration of all the names in this <CODE>MapMessage</CODE>
* @throws JMSException
*/
- public Enumeration getMapNames() throws JMSException {
+ public Enumeration<String> getMapNames() throws JMSException {
initializeReading();
return Collections.enumeration(map.keySet());
}
@@ -732,7 +732,7 @@
return super.toString() + " ActiveMQMapMessage{ " + "theTable = " + map + " }";
}
- public Map getContentMap() throws JMSException {
+ public Map<String, Object> getContentMap() throws JMSException {
initializeReading();
return map;
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java Fri Aug 10 09:57:01 2007
@@ -45,12 +45,14 @@
public class ActiveMQMessage extends Message implements org.apache.activemq.Message {
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_MESSAGE;
+ private static final Map<String, PropertySetter> JMS_PROPERTY_SETERS = new HashMap<String, PropertySetter>();
+
+ protected transient Callback acknowledgeCallback;
public byte getDataStructureType() {
return DATA_STRUCTURE_TYPE;
}
- protected transient Callback acknowledgeCallback;
public Message copy() {
ActiveMQMessage copy = new ActiveMQMessage();
@@ -73,10 +75,12 @@
}
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || o.getClass() != getClass())
+ }
+ if (o == null || o.getClass() != getClass()) {
return false;
+ }
ActiveMQMessage msg = (ActiveMQMessage)o;
MessageId oMsg = msg.getMessageId();
@@ -273,7 +277,7 @@
public Enumeration getPropertyNames() throws JMSException {
try {
- return new Vector(this.getProperties().keySet()).elements();
+ return new Vector<String>(this.getProperties().keySet()).elements();
} catch (IOException e) {
throw JMSExceptionSupport.create(e);
}
@@ -283,7 +287,6 @@
void set(Message message, Object value) throws MessageFormatException;
}
- private static final HashMap JMS_PROPERTY_SETERS = new HashMap();
static {
JMS_PROPERTY_SETERS.put("JMSXDeliveryCount", new PropertySetter() {
public void set(Message message, Object value) throws MessageFormatException {
@@ -391,7 +394,7 @@
}
checkValidObject(value);
- PropertySetter setter = (PropertySetter)JMS_PROPERTY_SETERS.get(name);
+ PropertySetter setter = JMS_PROPERTY_SETERS.get(name);
if (setter != null) {
setter.set(this, value);
@@ -416,7 +419,7 @@
protected void checkValidObject(Object value) throws MessageFormatException {
- boolean valid = value instanceof Boolean || value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long ;
+ 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) {
@@ -445,8 +448,9 @@
public boolean getBooleanProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
- if (value == null)
+ if (value == null) {
return false;
+ }
Boolean rc = (Boolean)TypeConversionSupport.convert(value, Boolean.class);
if (rc == null) {
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a boolean");
@@ -456,8 +460,9 @@
public byte getByteProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
- if (value == null)
+ if (value == null) {
throw new NumberFormatException("property " + name + " was null");
+ }
Byte rc = (Byte)TypeConversionSupport.convert(value, Byte.class);
if (rc == null) {
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a byte");
@@ -467,8 +472,9 @@
public short getShortProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
- if (value == null)
+ if (value == null) {
throw new NumberFormatException("property " + name + " was null");
+ }
Short rc = (Short)TypeConversionSupport.convert(value, Short.class);
if (rc == null) {
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a short");
@@ -478,8 +484,9 @@
public int getIntProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
- if (value == null)
+ if (value == null) {
throw new NumberFormatException("property " + name + " was null");
+ }
Integer rc = (Integer)TypeConversionSupport.convert(value, Integer.class);
if (rc == null) {
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as an integer");
@@ -489,8 +496,9 @@
public long getLongProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
- if (value == null)
+ if (value == null) {
throw new NumberFormatException("property " + name + " was null");
+ }
Long rc = (Long)TypeConversionSupport.convert(value, Long.class);
if (rc == null) {
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a long");
@@ -500,8 +508,9 @@
public float getFloatProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
- if (value == null)
+ if (value == null) {
throw new NullPointerException("property " + name + " was null");
+ }
Float rc = (Float)TypeConversionSupport.convert(value, Float.class);
if (rc == null) {
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a float");
@@ -511,8 +520,9 @@
public double getDoubleProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
- if (value == null)
+ if (value == null) {
throw new NullPointerException("property " + name + " was null");
+ }
Double rc = (Double)TypeConversionSupport.convert(value, Double.class);
if (rc == null) {
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a double");
@@ -527,8 +537,9 @@
value = getUserID();
}
}
- if (value == null)
+ if (value == null) {
return null;
+ }
String rc = (String)TypeConversionSupport.convert(value, String.class);
if (rc == null) {
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a String");
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java Fri Aug 10 09:57:01 2007
@@ -63,10 +63,10 @@
* @see javax.jms.TextMessage
*/
public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMessage {
- static final ClassLoader ACTIVEMQ_CLASSLOADER = ActiveMQObjectMessage.class.getClassLoader(); // TODO
- // verify
- // classloader
+
+ // TODO: verify classloader
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_OBJECT_MESSAGE;
+ static final ClassLoader ACTIVEMQ_CLASSLOADER = ActiveMQObjectMessage.class.getClassLoader();
protected transient Serializable object;
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQQueue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQQueue.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQQueue.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQQueue.java Fri Aug 10 09:57:01 2007
@@ -29,18 +29,18 @@
*/
public class ActiveMQQueue extends ActiveMQDestination implements Queue {
- private static final long serialVersionUID = -3885260014960795889L;
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_QUEUE;
+ private static final long serialVersionUID = -3885260014960795889L;
public ActiveMQQueue() {
}
- public byte getDataStructureType() {
- return DATA_STRUCTURE_TYPE;
- }
-
public ActiveMQQueue(String name) {
super(name);
+ }
+
+ public byte getDataStructureType() {
+ return DATA_STRUCTURE_TYPE;
}
public boolean isQueue() {
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempQueue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempQueue.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempQueue.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempQueue.java Fri Aug 10 09:57:01 2007
@@ -25,8 +25,8 @@
*/
public class ActiveMQTempQueue extends ActiveMQTempDestination implements TemporaryQueue {
- private static final long serialVersionUID = 6683049467527633867L;
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_TEMP_QUEUE;
+ private static final long serialVersionUID = 6683049467527633867L;
public ActiveMQTempQueue() {
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempTopic.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempTopic.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempTopic.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempTopic.java Fri Aug 10 09:57:01 2007
@@ -25,8 +25,8 @@
*/
public class ActiveMQTempTopic extends ActiveMQTempDestination implements TemporaryTopic {
- private static final long serialVersionUID = -4325596784597300253L;
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_TEMP_TOPIC;
+ private static final long serialVersionUID = -4325596784597300253L;
public ActiveMQTempTopic() {
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTopic.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTopic.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTopic.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTopic.java Fri Aug 10 09:57:01 2007
@@ -27,8 +27,8 @@
*/
public class ActiveMQTopic extends ActiveMQDestination implements Topic {
- private static final long serialVersionUID = 7300307405896488588L;
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_TOPIC;
+ private static final long serialVersionUID = 7300307405896488588L;
public ActiveMQTopic() {
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/BaseEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/BaseEndpoint.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/BaseEndpoint.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/BaseEndpoint.java Fri Aug 10 09:57:01 2007
@@ -24,7 +24,7 @@
public class BaseEndpoint implements Endpoint {
private String name;
- BrokerInfo brokerInfo;
+ private BrokerInfo brokerInfo;
public BaseEndpoint(String name) {
this.name = name;
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Command.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Command.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Command.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Command.java Fri Aug 10 09:57:01 2007
@@ -19,44 +19,53 @@
import org.apache.activemq.state.CommandVisitor;
/**
- * The Command Pattern so that we can send and receive commands
- * on the different transports
- *
+ * The Command Pattern so that we can send and receive commands on the different
+ * transports
+ *
* @version $Revision: 1.7 $
*/
public interface Command extends DataStructure {
-
+
void setCommandId(int value);
-
+
/**
* @return the unique ID of this request used to map responses to requests
*/
int getCommandId();
-
+
void setResponseRequired(boolean responseRequired);
+
boolean isResponseRequired();
-
+
boolean isResponse();
+
boolean isMessageDispatch();
+
boolean isBrokerInfo();
+
boolean isWireFormatInfo();
+
boolean isMessage();
+
boolean isMessageAck();
+
boolean isMessageDispatchNotification();
+
boolean isShutdownInfo();
- Response visit( CommandVisitor visitor) throws Exception;
+ Response visit(CommandVisitor visitor) throws Exception;
/**
- * The endpoint within the transport where this message came from which could be null if the
- * transport only supports a single endpoint.
+ * The endpoint within the transport where this message came from which
+ * could be null if the transport only supports a single endpoint.
*/
Endpoint getFrom();
void setFrom(Endpoint from);
/**
- * The endpoint within the transport where this message is going to - null means all endpoints.
+ * The endpoint within the transport where this message is going to - null
+ * means all endpoints.
*/
Endpoint getTo();
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConnectionError.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConnectionError.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConnectionError.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConnectionError.java Fri Aug 10 09:57:01 2007
@@ -27,8 +27,8 @@
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.CONNECTION_ERROR;
- protected ConnectionId connectionId;
- Throwable exception;
+ private ConnectionId connectionId;
+ private Throwable exception;
public byte getDataStructureType() {
return DATA_STRUCTURE_TYPE;
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConnectionId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConnectionId.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConnectionId.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConnectionId.java Fri Aug 10 09:57:01 2007
@@ -54,10 +54,12 @@
}
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || o.getClass() != ConnectionId.class)
+ }
+ if (o == null || o.getClass() != ConnectionId.class) {
return false;
+ }
ConnectionId id = (ConnectionId)o;
return value.equals(id.value);
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConsumerId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConsumerId.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConsumerId.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ConsumerId.java Fri Aug 10 09:57:01 2007
@@ -62,10 +62,12 @@
}
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || o.getClass() != ConsumerId.class)
+ }
+ if (o == null || o.getClass() != ConsumerId.class) {
return false;
+ }
ConsumerId id = (ConsumerId)o;
return sessionId == id.sessionId && value == id.value && connectionId.equals(id.connectionId);
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DataArrayResponse.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DataArrayResponse.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DataArrayResponse.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DataArrayResponse.java Fri Aug 10 09:57:01 2007
@@ -22,9 +22,10 @@
*/
public class DataArrayResponse extends Response {
+ public static final byte DATA_STRUCTURE_TYPE = CommandTypes.DATA_ARRAY_RESPONSE;
+
DataStructure data[];
- public static final byte DATA_STRUCTURE_TYPE = CommandTypes.DATA_ARRAY_RESPONSE;
public DataArrayResponse() {
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DataResponse.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DataResponse.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DataResponse.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DataResponse.java Fri Aug 10 09:57:01 2007
@@ -23,9 +23,9 @@
*/
public class DataResponse extends Response {
- DataStructure data;
-
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.DATA_RESPONSE;
+
+ DataStructure data;
public DataResponse() {
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ExceptionResponse.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ExceptionResponse.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ExceptionResponse.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ExceptionResponse.java Fri Aug 10 09:57:01 2007
@@ -22,9 +22,9 @@
*/
public class ExceptionResponse extends Response {
- Throwable exception;
-
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.EXCEPTION_RESPONSE;
+
+ Throwable exception;
public ExceptionResponse() {
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/IntegerResponse.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/IntegerResponse.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/IntegerResponse.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/IntegerResponse.java Fri Aug 10 09:57:01 2007
@@ -22,9 +22,9 @@
*/
public class IntegerResponse extends Response {
- int result;
-
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.INTEGER_RESPONSE;
+
+ int result;
public IntegerResponse() {
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/LocalTransactionId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/LocalTransactionId.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/LocalTransactionId.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/LocalTransactionId.java Fri Aug 10 09:57:01 2007
@@ -69,10 +69,12 @@
}
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || o.getClass() != LocalTransactionId.class)
+ }
+ if (o == null || o.getClass() != LocalTransactionId.class) {
return false;
+ }
LocalTransactionId tx = (LocalTransactionId)o;
return value == tx.value && connectionId.equals(tx.connectionId);
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java Fri Aug 10 09:57:01 2007
@@ -72,17 +72,17 @@
protected int redeliveryCounter;
protected int size;
- protected Map properties;
+ protected Map<String, Object> properties;
protected boolean readOnlyProperties;
protected boolean readOnlyBody;
protected transient boolean recievedByDFBridge;
+ protected boolean droppable;
private transient short referenceCount;
private transient ActiveMQConnection connection;
private transient org.apache.activemq.broker.region.Destination regionDestination;
private BrokerId[] brokerPath;
- protected boolean droppable;
private BrokerId[] cluster;
public abstract Message copy();
@@ -109,7 +109,7 @@
copy.groupSequence = groupSequence;
if (properties != null) {
- copy.properties = new HashMap(properties);
+ copy.properties = new HashMap<String, Object>(properties);
} else {
copy.properties = properties;
}
@@ -139,17 +139,20 @@
public Object getProperty(String name) throws IOException {
if (properties == null) {
- if (marshalledProperties == null)
+ if (marshalledProperties == null) {
return null;
+ }
properties = unmarsallProperties(marshalledProperties);
}
return properties.get(name);
}
- public Map getProperties() throws IOException {
+ @SuppressWarnings("unchecked")
+ public Map<String, Object> getProperties() throws IOException {
if (properties == null) {
- if (marshalledProperties == null)
+ if (marshalledProperties == null) {
return Collections.EMPTY_MAP;
+ }
properties = unmarsallProperties(marshalledProperties);
}
return Collections.unmodifiableMap(properties);
@@ -168,7 +171,7 @@
protected void lazyCreateProperties() throws IOException {
if (properties == null) {
if (marshalledProperties == null) {
- properties = new HashMap();
+ properties = new HashMap<String, Object>();
} else {
properties = unmarsallProperties(marshalledProperties);
marshalledProperties = null;
@@ -176,7 +179,7 @@
}
}
- private Map unmarsallProperties(ByteSequence marshalledProperties) throws IOException {
+ private Map<String, Object> unmarsallProperties(ByteSequence marshalledProperties) throws IOException {
return MarshallingSupport.unmarshalPrimitiveMap(new DataInputStream(new ByteArrayInputStream(marshalledProperties)));
}
@@ -578,8 +581,9 @@
size = getSize();
}
- if (rc == 1 && regionDestination != null)
+ if (rc == 1 && regionDestination != null) {
regionDestination.getUsageManager().increaseUsage(size);
+ }
// System.out.println(" + "+getDestination()+" :::: "+getMessageId()+"
// "+rc);
@@ -594,9 +598,9 @@
size = getSize();
}
- if (rc == 0 && regionDestination != null)
+ if (rc == 0 && regionDestination != null) {
regionDestination.getUsageManager().decreaseUsage(size);
-
+ }
// System.out.println(" - "+getDestination()+" :::: "+getMessageId()+"
// "+rc);
@@ -606,10 +610,12 @@
public int getSize() {
if (size <= AVERAGE_MESSAGE_SIZE_OVERHEAD) {
size = AVERAGE_MESSAGE_SIZE_OVERHEAD;
- if (marshalledProperties != null)
+ if (marshalledProperties != null) {
size += marshalledProperties.getLength();
- if (content != null)
+ }
+ if (content != null) {
size += content.getLength();
+ }
}
return size;
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/MessageId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/MessageId.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/MessageId.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/MessageId.java Fri Aug 10 09:57:01 2007
@@ -81,10 +81,12 @@
}
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || o.getClass() != getClass())
+ }
+ if (o == null || o.getClass() != getClass()) {
return false;
+ }
MessageId id = (MessageId)o;
return producerSequenceId == id.producerSequenceId && producerId.equals(id.producerId);
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/NetworkBridgeFilter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/NetworkBridgeFilter.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/NetworkBridgeFilter.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/NetworkBridgeFilter.java Fri Aug 10 09:57:01 2007
@@ -106,8 +106,9 @@
public static boolean contains(BrokerId[] brokerPath, BrokerId brokerId) {
if (brokerPath != null && brokerId != null) {
for (int i = 0; i < brokerPath.length; i++) {
- if (brokerId.equals(brokerPath[i]))
+ if (brokerId.equals(brokerPath[i])) {
return true;
+ }
}
}
return false;
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ProducerId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ProducerId.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ProducerId.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ProducerId.java Fri Aug 10 09:57:01 2007
@@ -72,10 +72,12 @@
}
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || o.getClass() != ProducerId.class)
+ }
+ if (o == null || o.getClass() != ProducerId.class) {
return false;
+ }
ProducerId id = (ProducerId)o;
return sessionId == id.sessionId && value == id.value && connectionId.equals(id.connectionId);
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/SessionId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/SessionId.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/SessionId.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/SessionId.java Fri Aug 10 09:57:01 2007
@@ -70,10 +70,12 @@
}
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || o.getClass() != SessionId.class)
+ }
+ if (o == null || o.getClass() != SessionId.class) {
return false;
+ }
SessionId id = (SessionId)o;
return value == id.value && connectionId.equals(id.connectionId);
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/WireFormatInfo.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/WireFormatInfo.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/WireFormatInfo.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/WireFormatInfo.java Fri Aug 10 09:57:01 2007
@@ -32,21 +32,20 @@
import org.apache.activemq.wireformat.WireFormat;
/**
- *
* @openwire:marshaller code="1"
* @version $Revision$
*/
public class WireFormatInfo implements Command, MarshallAware {
- private static final int MAX_PROPERTY_SIZE = 1024 * 4;
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.WIREFORMAT_INFO;
+ private static final int MAX_PROPERTY_SIZE = 1024 * 4;
private static final byte MAGIC[] = new byte[] {'A', 'c', 't', 'i', 'v', 'e', 'M', 'Q'};
protected byte magic[] = MAGIC;
protected int version;
protected ByteSequence marshalledProperties;
- protected transient Map properties;
+ protected transient Map<String, Object> properties;
private transient Endpoint from;
private transient Endpoint to;
@@ -126,17 +125,20 @@
public Object getProperty(String name) throws IOException {
if (properties == null) {
- if (marshalledProperties == null)
+ if (marshalledProperties == null) {
return null;
+ }
properties = unmarsallProperties(marshalledProperties);
}
return properties.get(name);
}
- public Map getProperties() throws IOException {
+ @SuppressWarnings("unchecked")
+ public Map<String, Object> getProperties() throws IOException {
if (properties == null) {
- if (marshalledProperties == null)
+ if (marshalledProperties == null) {
return Collections.EMPTY_MAP;
+ }
properties = unmarsallProperties(marshalledProperties);
}
return Collections.unmodifiableMap(properties);
@@ -155,7 +157,7 @@
protected void lazyCreateProperties() throws IOException {
if (properties == null) {
if (marshalledProperties == null) {
- properties = new HashMap();
+ properties = new HashMap<String, Object>();
} else {
properties = unmarsallProperties(marshalledProperties);
marshalledProperties = null;
@@ -163,10 +165,8 @@
}
}
- private Map unmarsallProperties(ByteSequence marshalledProperties) throws IOException {
- return MarshallingSupport
- .unmarshalPrimitiveMap(new DataInputStream(new ByteArrayInputStream(marshalledProperties)),
- MAX_PROPERTY_SIZE);
+ private Map<String, Object> unmarsallProperties(ByteSequence marshalledProperties) throws IOException {
+ return MarshallingSupport.unmarshalPrimitiveMap(new DataInputStream(new ByteArrayInputStream(marshalledProperties)), MAX_PROPERTY_SIZE);
}
public void beforeMarshall(WireFormat wireFormat) throws IOException {
@@ -280,13 +280,12 @@
}
public String toString() {
- Map p = null;
+ Map<String, Object> p = null;
try {
p = getProperties();
- } catch (IOException e) {
+ } catch (IOException ignore) {
}
- return "WireFormatInfo { version=" + version + ", properties=" + p + ", magic=" + toString(magic)
- + "}";
+ return "WireFormatInfo { version=" + version + ", properties=" + p + ", magic=" + toString(magic) + "}";
}
private String toString(byte[] data) {
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java Fri Aug 10 09:57:01 2007
@@ -117,23 +117,26 @@
}
private static int hash(byte[] bytes, int hash) {
- for (int i = 0, size = bytes.length; i < size; i++) {
+ int size = bytes.length;
+ for (int i = 0; i < size; i++) {
hash ^= bytes[i] << ((i % 4) * 8);
}
return hash;
}
public boolean equals(Object o) {
- if (o == null || o.getClass() != XATransactionId.class)
+ if (o == null || o.getClass() != XATransactionId.class) {
return false;
+ }
XATransactionId xid = (XATransactionId)o;
return xid.formatId == formatId && Arrays.equals(xid.globalTransactionId, globalTransactionId)
&& Arrays.equals(xid.branchQualifier, branchQualifier);
}
public int compareTo(Object o) {
- if (o == null || o.getClass() != XATransactionId.class)
+ if (o == null || o.getClass() != XATransactionId.class) {
return -1;
+ }
XATransactionId xid = (XATransactionId)o;
return getTransactionKey().compareTo(xid.getTransactionKey());
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java Fri Aug 10 09:57:01 2007
@@ -18,6 +18,7 @@
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.regex.Pattern;
import javax.jms.JMSException;
@@ -29,17 +30,24 @@
*/
public abstract class ComparisonExpression extends BinaryExpression implements BooleanExpression {
+ private static final Set<Character> REGEXP_CONTROL_CHARS = new HashSet<Character>();
+
+ /**
+ * @param left
+ * @param right
+ */
+ public ComparisonExpression(Expression left, Expression right) {
+ super(left, right);
+ }
+
public static BooleanExpression createBetween(Expression value, Expression left, Expression right) {
- return LogicExpression.createAND(createGreaterThanEqual(value, left), createLessThanEqual(value,
- right));
+ return LogicExpression.createAND(createGreaterThanEqual(value, left), createLessThanEqual(value, right));
}
public static BooleanExpression createNotBetween(Expression value, Expression left, Expression right) {
return LogicExpression.createOR(createLessThan(value, left), createGreaterThan(value, right));
}
- private static final HashSet REGEXP_CONTROL_CHARS = new HashSet();
-
static {
REGEXP_CONTROL_CHARS.add(Character.valueOf('.'));
REGEXP_CONTROL_CHARS.add(Character.valueOf('\\'));
@@ -138,9 +146,7 @@
public static BooleanExpression createLike(Expression left, String right, String escape) {
if (escape != null && escape.length() != 1) {
- throw new RuntimeException(
- "The ESCAPE string litteral is invalid. It can only be one character. Litteral used: "
- + escape);
+ throw new RuntimeException("The ESCAPE string litteral is invalid. It can only be one character. Litteral used: " + escape);
}
int c = -1;
if (escape != null) {
@@ -156,16 +162,18 @@
public static BooleanExpression createInFilter(Expression left, List elements) {
- if (!(left instanceof PropertyExpression))
+ if (!(left instanceof PropertyExpression)) {
throw new RuntimeException("Expected a property for In expression, got: " + left);
+ }
return UnaryExpression.createInExpression((PropertyExpression)left, elements, false);
}
public static BooleanExpression createNotInFilter(Expression left, List elements) {
- if (!(left instanceof PropertyExpression))
+ if (!(left instanceof PropertyExpression)) {
throw new RuntimeException("Expected a property for In expression, got: " + left);
+ }
return UnaryExpression.createInExpression((PropertyExpression)left, elements, true);
}
@@ -286,8 +294,9 @@
public static void checkLessThanOperand(Expression expr) {
if (expr instanceof ConstantExpression) {
Object value = ((ConstantExpression)expr).getValue();
- if (value instanceof Number)
+ if (value instanceof Number) {
return;
+ }
// Else it's boolean or a String..
throw new RuntimeException("Value '" + expr + "' cannot be compared.");
@@ -306,33 +315,26 @@
public static void checkEqualOperand(Expression expr) {
if (expr instanceof ConstantExpression) {
Object value = ((ConstantExpression)expr).getValue();
- if (value == null)
+ if (value == null) {
throw new RuntimeException("'" + expr + "' cannot be compared.");
+ }
}
}
/**
- *
* @param left
* @param right
*/
private static void checkEqualOperandCompatability(Expression left, Expression right) {
if (left instanceof ConstantExpression && right instanceof ConstantExpression) {
- if (left instanceof BooleanExpression && !(right instanceof BooleanExpression))
+ if (left instanceof BooleanExpression && !(right instanceof BooleanExpression)) {
throw new RuntimeException("'" + left + "' cannot be compared with '" + right + "'");
+ }
}
}
- /**
- * @param left
- * @param right
- */
- public ComparisonExpression(Expression left, Expression right) {
- super(left, right);
- }
-
public Object evaluate(MessageEvaluationContext message) throws JMSException {
- Comparable lv = (Comparable)left.evaluate(message);
+ Comparable<Comparable> lv = (Comparable)left.evaluate(message);
if (lv == null) {
return null;
}
@@ -344,8 +346,8 @@
}
protected Boolean compare(Comparable lv, Comparable rv) {
- Class lc = lv.getClass();
- Class rc = rv.getClass();
+ Class<? extends Comparable> lc = lv.getClass();
+ Class<? extends Comparable> rc = rv.getClass();
// If the the objects are not of the same type,
// try to convert up to allow the comparison.
if (lc != rc) {
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ConstantExpression.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ConstantExpression.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ConstantExpression.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ConstantExpression.java Fri Aug 10 09:57:01 2007
@@ -47,8 +47,9 @@
public static ConstantExpression createFromDecimal(String text) {
// Strip off the 'l' or 'L' if needed.
- if (text.endsWith("l") || text.endsWith("L"))
+ if (text.endsWith("l") || text.endsWith("L")) {
text = text.substring(0, text.length() - 1);
+ }
Number value;
try {
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/DestinationFilter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/DestinationFilter.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/DestinationFilter.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/DestinationFilter.java Fri Aug 10 09:57:01 2007
@@ -40,8 +40,9 @@
public boolean matches(MessageEvaluationContext message) throws JMSException {
try {
- if (message.isDropped())
+ if (message.isDropped()) {
return false;
+ }
return matches(message.getMessage().getDestination());
} catch (IOException e) {
throw JMSExceptionSupport.create(e);
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/DestinationPath.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/DestinationPath.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/DestinationPath.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/DestinationPath.java Fri Aug 10 09:57:01 2007
@@ -34,7 +34,7 @@
protected static final char SEPARATOR = '.';
public static String[] getDestinationPaths(String subject) {
- List list = new ArrayList();
+ List<String> list = new ArrayList<String>();
int previous = 0;
int lastIndex = subject.length() - 1;
while (true) {
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/LogicExpression.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/LogicExpression.java?view=diff&rev=564679&r1=564678&r2=564679
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/LogicExpression.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/LogicExpression.java Fri Aug 10 09:57:01 2007
@@ -25,6 +25,14 @@
*/
public abstract class LogicExpression extends BinaryExpression implements BooleanExpression {
+ /**
+ * @param left
+ * @param right
+ */
+ public LogicExpression(BooleanExpression left, BooleanExpression right) {
+ super(left, right);
+ }
+
public static BooleanExpression createOR(BooleanExpression lvalue, BooleanExpression rvalue) {
return new LogicExpression(lvalue, rvalue) {
@@ -54,8 +62,9 @@
Boolean lv = (Boolean)left.evaluate(message);
// Can we do an AND shortcut??
- if (lv == null)
+ if (lv == null) {
return null;
+ }
if (!lv.booleanValue()) {
return Boolean.FALSE;
}
@@ -68,14 +77,6 @@
return "AND";
}
};
- }
-
- /**
- * @param left
- * @param right
- */
- public LogicExpression(BooleanExpression left, BooleanExpression right) {
- super(left, right);
}
public abstract Object evaluate(MessageEvaluationContext message) throws JMSException;