More checkstyle fixes

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@563982 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2007-08-08 18:56:59 +00:00
parent 43ba1be188
commit f812e34179
452 changed files with 17426 additions and 17633 deletions

View File

@ -32,7 +32,6 @@ import javax.jms.TemporaryTopic;
import javax.jms.TextMessage; import javax.jms.TextMessage;
import javax.jms.Topic; import javax.jms.Topic;
import org.apache.activemq.command.ActiveMQBytesMessage; import org.apache.activemq.command.ActiveMQBytesMessage;
import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQMapMessage; import org.apache.activemq.command.ActiveMQMapMessage;
@ -46,7 +45,8 @@ import org.apache.activemq.command.ActiveMQTextMessage;
import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.command.ActiveMQTopic;
/** /**
* A helper class for converting normal JMS interfaces into ActiveMQ specific ones. * A helper class for converting normal JMS interfaces into ActiveMQ specific
* ones.
* *
* @version $Revision: 1.1 $ * @version $Revision: 1.1 $
*/ */
@ -55,8 +55,10 @@ public class ActiveMQMessageTransformation {
/** /**
* Creates a an available JMS message from another provider. * Creates a an available JMS message from another provider.
* *
* @param destination - Destination to be converted into ActiveMQ's implementation. * @param destination - Destination to be converted into ActiveMQ's
* @return ActiveMQDestination - ActiveMQ's implementation of the destination. * implementation.
* @return ActiveMQDestination - ActiveMQ's implementation of the
* destination.
* @throws JMSException if an error occurs * @throws JMSException if an error occurs
*/ */
public static ActiveMQDestination transformDestination(Destination destination) throws JMSException { public static ActiveMQDestination transformDestination(Destination destination) throws JMSException {
@ -66,18 +68,14 @@ public class ActiveMQMessageTransformation {
if (destination instanceof ActiveMQDestination) { if (destination instanceof ActiveMQDestination) {
return (ActiveMQDestination)destination; return (ActiveMQDestination)destination;
} } else {
else {
if (destination instanceof TemporaryQueue) { if (destination instanceof TemporaryQueue) {
activeMQDestination = new ActiveMQTempQueue(((Queue)destination).getQueueName()); activeMQDestination = new ActiveMQTempQueue(((Queue)destination).getQueueName());
} } else if (destination instanceof TemporaryTopic) {
else if (destination instanceof TemporaryTopic) {
activeMQDestination = new ActiveMQTempTopic(((Topic)destination).getTopicName()); activeMQDestination = new ActiveMQTempTopic(((Topic)destination).getTopicName());
} } else if (destination instanceof Queue) {
else if (destination instanceof Queue) {
activeMQDestination = new ActiveMQQueue(((Queue)destination).getQueueName()); activeMQDestination = new ActiveMQQueue(((Queue)destination).getQueueName());
} } else if (destination instanceof Topic) {
else if (destination instanceof Topic) {
activeMQDestination = new ActiveMQTopic(((Topic)destination).getTopicName()); activeMQDestination = new ActiveMQTopic(((Topic)destination).getTopicName());
} }
} }
@ -86,17 +84,19 @@ public class ActiveMQMessageTransformation {
return activeMQDestination; return activeMQDestination;
} }
/** /**
* Creates a fast shallow copy of the current ActiveMQMessage or creates a whole new * Creates a fast shallow copy of the current ActiveMQMessage or creates a
* message instance from an available JMS message from another provider. * whole new message instance from an available JMS message from another
* provider.
* *
* @param message - Message to be converted into ActiveMQ's implementation. * @param message - Message to be converted into ActiveMQ's implementation.
* @param connection * @param connection
* @return ActiveMQMessage - ActiveMQ's implementation object of the message. * @return ActiveMQMessage - ActiveMQ's implementation object of the
* message.
* @throws JMSException if an error occurs * @throws JMSException if an error occurs
*/ */
public static final ActiveMQMessage transformMessage(Message message, ActiveMQConnection connection) throws JMSException { public static final ActiveMQMessage transformMessage(Message message, ActiveMQConnection connection)
throws JMSException {
if (message instanceof ActiveMQMessage) { if (message instanceof ActiveMQMessage) {
return (ActiveMQMessage)message; return (ActiveMQMessage)message;
@ -174,7 +174,8 @@ public class ActiveMQMessageTransformation {
} }
/** /**
* Copies the standard JMS and user defined properties from the givem message to the specified message * Copies the standard JMS and user defined properties from the givem
* message to the specified message
* *
* @param fromMessage the message to take the properties from * @param fromMessage the message to take the properties from
* @param toMesage the message to add the properties to * @param toMesage the message to add the properties to

View File

@ -16,22 +16,20 @@
*/ */
package org.apache.activemq; package org.apache.activemq;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ConsumerId;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.Queue; import javax.jms.Queue;
import javax.jms.QueueReceiver; import javax.jms.QueueReceiver;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ConsumerId;
/** /**
* A client uses a <CODE>QueueReceiver</CODE> object to receive messages that * A client uses a <CODE>QueueReceiver</CODE> object to receive messages that
* have been delivered to a queue. * have been delivered to a queue. <p/>
* <p/>
* <P> * <P>
* Although it is possible to have multiple <CODE>QueueReceiver</CODE> s for * Although it is possible to have multiple <CODE>QueueReceiver</CODE> s for
* the same queue, the JMS API does not define how messages are distributed * the same queue, the JMS API does not define how messages are distributed
* between the <CODE>QueueReceiver</CODE>s. * between the <CODE>QueueReceiver</CODE>s. <p/>
* <p/>
* <P> * <P>
* If a <CODE>QueueReceiver</CODE> specifies a message selector, the messages * If a <CODE>QueueReceiver</CODE> specifies a message selector, the messages
* that are not selected remain on the queue. By definition, a message selector * that are not selected remain on the queue. By definition, a message selector
@ -39,13 +37,13 @@ import javax.jms.QueueReceiver;
* the skipped messages are eventually read, the total ordering of the reads * the skipped messages are eventually read, the total ordering of the reads
* does not retain the partial order defined by each message producer. Only * does not retain the partial order defined by each message producer. Only
* <CODE>QueueReceiver</CODE> s without a message selector will read messages * <CODE>QueueReceiver</CODE> s without a message selector will read messages
* in message producer order. * in message producer order. <p/>
* <p/>
* <P> * <P>
* Creating a <CODE>MessageConsumer</CODE> provides the same features as * Creating a <CODE>MessageConsumer</CODE> provides the same features as
* creating a <CODE>QueueReceiver</CODE>. A <CODE>MessageConsumer</CODE> * creating a <CODE>QueueReceiver</CODE>. A <CODE>MessageConsumer</CODE>
* object is recommended for creating new code. The <CODE>QueueReceiver * object is recommended for creating new code. The <CODE>QueueReceiver
* </CODE> is provided to support existing code. * </CODE>
* is provided to support existing code.
* *
* @see javax.jms.Session#createConsumer(javax.jms.Destination, String) * @see javax.jms.Session#createConsumer(javax.jms.Destination, String)
* @see javax.jms.Session#createConsumer(javax.jms.Destination) * @see javax.jms.Session#createConsumer(javax.jms.Destination)
@ -54,8 +52,7 @@ import javax.jms.QueueReceiver;
* @see javax.jms.MessageConsumer * @see javax.jms.MessageConsumer
*/ */
public class ActiveMQQueueReceiver extends ActiveMQMessageConsumer implements public class ActiveMQQueueReceiver extends ActiveMQMessageConsumer implements QueueReceiver {
QueueReceiver {
/** /**
* @param theSession * @param theSession
@ -66,18 +63,20 @@ public class ActiveMQQueueReceiver extends ActiveMQMessageConsumer implements
* @param asyncDispatch * @param asyncDispatch
* @throws JMSException * @throws JMSException
*/ */
protected ActiveMQQueueReceiver(ActiveMQSession theSession, protected ActiveMQQueueReceiver(ActiveMQSession theSession, ConsumerId consumerId,
ConsumerId consumerId, ActiveMQDestination destination, String selector, int prefetch, int maximumPendingMessageCount, boolean asyncDispatch) ActiveMQDestination destination, String selector, int prefetch,
int maximumPendingMessageCount, boolean asyncDispatch)
throws JMSException { throws JMSException {
super(theSession, consumerId, destination, null, selector, prefetch, maximumPendingMessageCount, false, false, asyncDispatch); super(theSession, consumerId, destination, null, selector, prefetch, maximumPendingMessageCount,
false, false, asyncDispatch);
} }
/** /**
* Gets the <CODE>Queue</CODE> associated with this queue receiver. * Gets the <CODE>Queue</CODE> associated with this queue receiver.
* *
* @return this receiver's <CODE>Queue</CODE> * @return this receiver's <CODE>Queue</CODE>
* @throws JMSException if the JMS provider fails to get the queue for this queue * @throws JMSException if the JMS provider fails to get the queue for this
* receiver due to some internal error. * queue receiver due to some internal error.
*/ */
public Queue getQueue() throws JMSException { public Queue getQueue() throws JMSException {

View File

@ -26,41 +26,40 @@ import org.apache.activemq.command.ActiveMQDestination;
/** /**
* A client uses a <CODE>QueueSender</CODE> object to send messages to a * A client uses a <CODE>QueueSender</CODE> object to send messages to a
* queue. * queue. <p/>
* <p/>
* <P> * <P>
* Normally, the <CODE>Queue</CODE> is specified when a <CODE>QueueSender * Normally, the <CODE>Queue</CODE> is specified when a <CODE>QueueSender
* </CODE> is created. In this case, an attempt to use the <CODE>send</CODE> * </CODE>
* methods for an unidentified <CODE>QueueSender</CODE> will throw a <CODE> * is created. In this case, an attempt to use the <CODE>send</CODE> methods
* for an unidentified <CODE>QueueSender</CODE> will throw a <CODE>
* java.lang.UnsupportedOperationException</CODE>. * java.lang.UnsupportedOperationException</CODE>.
* <p/> * <p/>
* <P> * <P>
* If the <CODE>QueueSender</CODE> is created with an unidentified <CODE> * If the <CODE>QueueSender</CODE> is created with an unidentified <CODE>
* Queue</CODE>, an attempt to use the <CODE>send</CODE> methods that * Queue</CODE>,
* assume that the <CODE>Queue</CODE> has been identified will throw a <CODE> * an attempt to use the <CODE>send</CODE> methods that assume that the
* <CODE>Queue</CODE> has been identified will throw a <CODE>
* java.lang.UnsupportedOperationException</CODE>. * java.lang.UnsupportedOperationException</CODE>.
* <p/> * <p/>
* <P> * <P>
* During the execution of its <CODE>send</CODE> method, a message must not * During the execution of its <CODE>send</CODE> method, a message must not be
* be changed by other threads within the client. If the message is modified, * changed by other threads within the client. If the message is modified, the
* the result of the <CODE>send</CODE> is undefined. * result of the <CODE>send</CODE> is undefined. <p/>
* <p/>
* <P> * <P>
* After sending a message, a client may retain and modify it without affecting * After sending a message, a client may retain and modify it without affecting
* the message that has been sent. The same message object may be sent multiple * the message that has been sent. The same message object may be sent multiple
* times. * times. <p/>
* <p/>
* <P> * <P>
* The following message headers are set as part of sending a message: <code>JMSDestination</code>, * The following message headers are set as part of sending a message:
* <code>JMSDeliveryMode</code>,<code>JMSExpiration</code>,<code>JMSPriority</code>, * <code>JMSDestination</code>, <code>JMSDeliveryMode</code>,<code>JMSExpiration</code>,<code>JMSPriority</code>,
* <code>JMSMessageID</code> and <code>JMSTimeStamp</code>. When the * <code>JMSMessageID</code> and <code>JMSTimeStamp</code>. When the
* message is sent, the values of these headers are ignored. After the * message is sent, the values of these headers are ignored. After the
* completion of the <CODE>send</CODE>, the headers hold the values * completion of the <CODE>send</CODE>, the headers hold the values specified
* specified by the method sending the message. It is possible for the <code>send</code> * by the method sending the message. It is possible for the <code>send</code>
* method not to set <code>JMSMessageID</code> and <code>JMSTimeStamp</code> * method not to set <code>JMSMessageID</code> and <code>JMSTimeStamp</code>
* if the setting of these headers is explicitly disabled by the <code>MessageProducer.setDisableMessageID</code> * if the setting of these headers is explicitly disabled by the
* or <code>MessageProducer.setDisableMessageTimestamp</code> method. * <code>MessageProducer.setDisableMessageID</code> or
* <p/> * <code>MessageProducer.setDisableMessageTimestamp</code> method. <p/>
* <P> * <P>
* Creating a <CODE>MessageProducer</CODE> provides the same features as * Creating a <CODE>MessageProducer</CODE> provides the same features as
* creating a <CODE>QueueSender</CODE>. A <CODE>MessageProducer</CODE> * creating a <CODE>QueueSender</CODE>. A <CODE>MessageProducer</CODE>
@ -75,9 +74,7 @@ public class ActiveMQQueueSender extends ActiveMQMessageProducer implements Queu
protected ActiveMQQueueSender(ActiveMQSession session, ActiveMQDestination destination) protected ActiveMQQueueSender(ActiveMQSession session, ActiveMQDestination destination)
throws JMSException { throws JMSException {
super(session, super(session, session.getNextProducerId(), destination);
session.getNextProducerId(),
destination);
} }
/** /**
@ -93,10 +90,9 @@ public class ActiveMQQueueSender extends ActiveMQMessageProducer implements Queu
} }
/** /**
* Sends a message to a queue for an unidentified message producer. Uses * Sends a message to a queue for an unidentified message producer. Uses the
* the <CODE>QueueSender</CODE>'s default delivery mode, priority, and * <CODE>QueueSender</CODE>'s default delivery mode, priority, and time
* time to live. * to live. <p/>
* <p/>
* <P> * <P>
* Typically, a message producer is assigned a queue at creation time; * Typically, a message producer is assigned a queue at creation time;
* however, the JMS API also supports unidentified message producers, which * however, the JMS API also supports unidentified message producers, which
@ -104,8 +100,8 @@ public class ActiveMQQueueSender extends ActiveMQMessageProducer implements Queu
* *
* @param queue the queue to send this message to * @param queue the queue to send this message to
* @param message the message to send * @param message the message to send
* @throws JMSException if the JMS provider fails to send the message due to some * @throws JMSException if the JMS provider fails to send the message due to
* internal error. * some internal error.
* @see javax.jms.MessageProducer#getDeliveryMode() * @see javax.jms.MessageProducer#getDeliveryMode()
* @see javax.jms.MessageProducer#getTimeToLive() * @see javax.jms.MessageProducer#getTimeToLive()
* @see javax.jms.MessageProducer#getPriority() * @see javax.jms.MessageProducer#getPriority()
@ -117,8 +113,7 @@ public class ActiveMQQueueSender extends ActiveMQMessageProducer implements Queu
/** /**
* Sends a message to a queue for an unidentified message producer, * Sends a message to a queue for an unidentified message producer,
* specifying delivery mode, priority and time to live. * specifying delivery mode, priority and time to live. <p/>
* <p/>
* <P> * <P>
* Typically, a message producer is assigned a queue at creation time; * Typically, a message producer is assigned a queue at creation time;
* however, the JMS API also supports unidentified message producers, which * however, the JMS API also supports unidentified message producers, which
@ -129,16 +124,12 @@ public class ActiveMQQueueSender extends ActiveMQMessageProducer implements Queu
* @param deliveryMode the delivery mode to use * @param deliveryMode the delivery mode to use
* @param priority the priority for this message * @param priority the priority for this message
* @param timeToLive the message's lifetime (in milliseconds) * @param timeToLive the message's lifetime (in milliseconds)
* @throws JMSException if the JMS provider fails to send the message due to some * @throws JMSException if the JMS provider fails to send the message due to
* internal error. * some internal error.
*/ */
public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive)
throws JMSException { throws JMSException {
super.send(queue, super.send(queue, message, deliveryMode, priority, timeToLive);
message,
deliveryMode,
priority,
timeToLive);
} }
} }

View File

@ -96,8 +96,8 @@ public class ActiveMQSessionExecutor implements Task {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} else { } else {
while (iterate()) while (iterate()) {
; }
} }
} }
} }
@ -128,10 +128,11 @@ public class ActiveMQSessionExecutor implements Task {
synchronized void start() { synchronized void start() {
if (!messageQueue.isRunning()) { if (!messageQueue.isRunning()) {
messageQueue.start(); messageQueue.start();
if (hasUncomsumedMessages()) if (hasUncomsumedMessages()) {
wakeup(); wakeup();
} }
} }
}
void stop() throws JMSException { void stop() throws JMSException {
try { try {

View File

@ -104,8 +104,9 @@ public class ActiveMQTopicSession implements TopicSession {
* @throws JMSException * @throws JMSException
*/ */
public MessageConsumer createConsumer(Destination destination) throws JMSException { public MessageConsumer createConsumer(Destination destination) throws JMSException {
if (destination instanceof Queue) if (destination instanceof Queue) {
throw new InvalidDestinationException("Queues are not supported by a TopicSession"); throw new InvalidDestinationException("Queues are not supported by a TopicSession");
}
return next.createConsumer(destination); return next.createConsumer(destination);
} }
@ -116,8 +117,9 @@ public class ActiveMQTopicSession implements TopicSession {
* @throws JMSException * @throws JMSException
*/ */
public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException { public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException {
if (destination instanceof Queue) if (destination instanceof Queue) {
throw new InvalidDestinationException("Queues are not supported by a TopicSession"); throw new InvalidDestinationException("Queues are not supported by a TopicSession");
}
return next.createConsumer(destination, messageSelector); return next.createConsumer(destination, messageSelector);
} }
@ -129,8 +131,9 @@ public class ActiveMQTopicSession implements TopicSession {
* @throws JMSException * @throws JMSException
*/ */
public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean NoLocal) throws JMSException { public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean NoLocal) throws JMSException {
if (destination instanceof Queue) if (destination instanceof Queue) {
throw new InvalidDestinationException("Queues are not supported by a TopicSession"); throw new InvalidDestinationException("Queues are not supported by a TopicSession");
}
return next.createConsumer(destination, messageSelector, NoLocal); return next.createConsumer(destination, messageSelector, NoLocal);
} }
@ -195,8 +198,9 @@ public class ActiveMQTopicSession implements TopicSession {
* @throws JMSException * @throws JMSException
*/ */
public MessageProducer createProducer(Destination destination) throws JMSException { public MessageProducer createProducer(Destination destination) throws JMSException {
if (destination instanceof Queue) if (destination instanceof Queue) {
throw new InvalidDestinationException("Queues are not supported by a TopicSession"); throw new InvalidDestinationException("Queues are not supported by a TopicSession");
}
return next.createProducer(destination); return next.createProducer(destination);
} }

View File

@ -20,8 +20,8 @@ import javax.jms.JMSException;
/** /**
* Provides a uniform interface that can be used to close all the JMS obejcts * Provides a uniform interface that can be used to close all the JMS obejcts
* that provide a close() method. Useful for when you want to collect * that provide a close() method. Useful for when you want to collect a
* a heterogeous set of JMS object in a collection to be closed at a later time. * heterogeous set of JMS object in a collection to be closed at a later time.
* *
* @version $Revision: 1.2 $ * @version $Revision: 1.2 $
*/ */
@ -30,7 +30,8 @@ public interface Closeable {
/** /**
* Closes a JMS object. * Closes a JMS object.
* <P> * <P>
* Many JMS objects are closeable such as Connections, Sessions, Consumers and Producers. * Many JMS objects are closeable such as Connections, Sessions, Consumers
* and Producers.
* *
* @throws JMSException if the JMS provider fails to close the object due to * @throws JMSException if the JMS provider fails to close the object due to
* some internal error. * some internal error.

View File

@ -27,26 +27,30 @@ import javax.jms.JMSException;
import javax.jms.Topic; import javax.jms.Topic;
/** /**
* The StreamConnection interface allows you to send and receive * The StreamConnection interface allows you to send and receive data from a
* data from a Destination in using standard java InputStream and OutputStream * Destination in using standard java InputStream and OutputStream objects. It's
* objects. It's best use case is to send and receive large amounts of data * best use case is to send and receive large amounts of data that would be to
* that would be to large to hold in a single JMS message. * large to hold in a single JMS message.
* *
* @version $Revision$ * @version $Revision$
*/ */
public interface StreamConnection extends Connection { public interface StreamConnection extends Connection {
public InputStream createInputStream(Destination dest) throws JMSException; public InputStream createInputStream(Destination dest) throws JMSException;
public InputStream createInputStream(Destination dest, String messageSelector) throws JMSException; public InputStream createInputStream(Destination dest, String messageSelector) throws JMSException;
public InputStream createInputStream(Destination dest, String messageSelector, boolean noLocal) throws JMSException; public InputStream createInputStream(Destination dest, String messageSelector, boolean noLocal) throws JMSException;
public InputStream createDurableInputStream(Topic dest, String name) throws JMSException; public InputStream createDurableInputStream(Topic dest, String name) throws JMSException;
public InputStream createDurableInputStream(Topic dest, String name, String messageSelector) throws JMSException; public InputStream createDurableInputStream(Topic dest, String name, String messageSelector) throws JMSException;
public InputStream createDurableInputStream(Topic dest, String name, String messageSelector, boolean noLocal) throws JMSException; public InputStream createDurableInputStream(Topic dest, String name, String messageSelector, boolean noLocal) throws JMSException;
public OutputStream createOutputStream(Destination dest) throws JMSException; public OutputStream createOutputStream(Destination dest) throws JMSException;
public OutputStream createOutputStream(Destination dest, Map streamProperties, int deliveryMode,
int priority, long timeToLive) throws JMSException; public OutputStream createOutputStream(Destination dest, Map streamProperties, int deliveryMode, int priority, long timeToLive) throws JMSException;
/** /**
* Unsubscribes a durable subscription that has been created by a client. * Unsubscribes a durable subscription that has been created by a client.
@ -55,17 +59,16 @@ public interface StreamConnection extends Connection {
* subscriber by its provider. * subscriber by its provider.
* <P> * <P>
* It is erroneous for a client to delete a durable subscription while there * It is erroneous for a client to delete a durable subscription while there
* is an active <CODE>MessageConsumer </CODE> or <CODE>TopicSubscriber</CODE> * is an active <CODE>MessageConsumer </CODE> or
* for the subscription, or while a consumed message is part of a pending * <CODE>TopicSubscriber</CODE> for the subscription, or while a consumed
* transaction or has not been acknowledged in the session. * message is part of a pending transaction or has not been acknowledged in
* the session.
* *
* @param name * @param name the name used to identify this subscription
* the name used to identify this subscription * @throws JMSException if the session fails to unsubscribe to the durable
* @throws JMSException
* if the session fails to unsubscribe to the durable
* subscription due to some internal error. * subscription due to some internal error.
* @throws InvalidDestinationException * @throws InvalidDestinationException if an invalid subscription name is
* if an invalid subscription name is specified. * specified.
* @since 1.1 * @since 1.1
*/ */
public void unsubscribe(String name) throws JMSException; public void unsubscribe(String name) throws JMSException;

View File

@ -50,18 +50,20 @@ public class AdvisorySupport {
} }
public static ActiveMQTopic getConsumerAdvisoryTopic(ActiveMQDestination destination) { public static ActiveMQTopic getConsumerAdvisoryTopic(ActiveMQDestination destination) {
if (destination.isQueue()) if (destination.isQueue()) {
return new ActiveMQTopic(QUEUE_CONSUMER_ADVISORY_TOPIC_PREFIX + destination.getPhysicalName()); return new ActiveMQTopic(QUEUE_CONSUMER_ADVISORY_TOPIC_PREFIX + destination.getPhysicalName());
else } else {
return new ActiveMQTopic(TOPIC_CONSUMER_ADVISORY_TOPIC_PREFIX + destination.getPhysicalName()); return new ActiveMQTopic(TOPIC_CONSUMER_ADVISORY_TOPIC_PREFIX + destination.getPhysicalName());
} }
}
public static ActiveMQTopic getProducerAdvisoryTopic(ActiveMQDestination destination) { public static ActiveMQTopic getProducerAdvisoryTopic(ActiveMQDestination destination) {
if (destination.isQueue()) if (destination.isQueue()) {
return new ActiveMQTopic(QUEUE_PRODUCER_ADVISORY_TOPIC_PREFIX + destination.getPhysicalName()); return new ActiveMQTopic(QUEUE_PRODUCER_ADVISORY_TOPIC_PREFIX + destination.getPhysicalName());
else } else {
return new ActiveMQTopic(TOPIC_PRODUCER_ADVISORY_TOPIC_PREFIX + destination.getPhysicalName()); return new ActiveMQTopic(TOPIC_PRODUCER_ADVISORY_TOPIC_PREFIX + destination.getPhysicalName());
} }
}
public static ActiveMQTopic getExpiredMessageTopic(ActiveMQDestination destination) { public static ActiveMQTopic getExpiredMessageTopic(ActiveMQDestination destination) {
if (destination.isQueue()) { if (destination.isQueue()) {

View File

@ -30,8 +30,8 @@ import javax.jms.JMSException;
import org.apache.activemq.command.ActiveMQBlobMessage; import org.apache.activemq.command.ActiveMQBlobMessage;
/** /**
* A default implementation of {@link BlobUploadStrategy} which uses the URL class to upload * A default implementation of {@link BlobUploadStrategy} which uses the URL
* files or streams to a remote URL * class to upload files or streams to a remote URL
*/ */
public class DefaultBlobUploadStrategy implements BlobUploadStrategy { public class DefaultBlobUploadStrategy implements BlobUploadStrategy {
private BlobTransferPolicy transferPolicy; private BlobTransferPolicy transferPolicy;
@ -51,7 +51,8 @@ public class DefaultBlobUploadStrategy implements BlobUploadStrategy {
connection.setRequestMethod("PUT"); connection.setRequestMethod("PUT");
connection.setDoOutput(true); connection.setDoOutput(true);
// use chunked mode or otherwise URLConnection loads everything into memory // use chunked mode or otherwise URLConnection loads everything into
// memory
// (chunked mode not supported before JRE 1.5) // (chunked mode not supported before JRE 1.5)
connection.setChunkedStreamingMode(transferPolicy.getBufferSize()); connection.setChunkedStreamingMode(transferPolicy.getBufferSize());
@ -66,8 +67,8 @@ public class DefaultBlobUploadStrategy implements BlobUploadStrategy {
fis.close(); fis.close();
if (!isSuccessfulCode(connection.getResponseCode())) { if (!isSuccessfulCode(connection.getResponseCode())) {
throw new IOException("PUT was not successful: " throw new IOException("PUT was not successful: " + connection.getResponseCode() + " "
+ connection.getResponseCode() + " " + connection.getResponseMessage()); + connection.getResponseMessage());
} }
return url; return url;
@ -82,8 +83,8 @@ public class DefaultBlobUploadStrategy implements BlobUploadStrategy {
connection.disconnect(); connection.disconnect();
if (!isSuccessfulCode(connection.getResponseCode())) { if (!isSuccessfulCode(connection.getResponseCode())) {
throw new IOException("DELETE was not successful: " throw new IOException("DELETE was not successful: " + connection.getResponseCode() + " "
+ connection.getResponseCode() + " " + connection.getResponseMessage()); + connection.getResponseMessage());
} }
} }

View File

@ -23,15 +23,16 @@ import org.apache.activemq.util.FactoryFinder;
import org.apache.activemq.util.IOExceptionSupport; import org.apache.activemq.util.IOExceptionSupport;
/** /**
* A helper class to create a fully configured broker service using a URI. * A helper class to create a fully configured broker service using a URI. The
* The list of currently supported URI syntaxes is described * list of currently supported URI syntaxes is described <a
* <a href="http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html">here</a> * href="http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html">here</a>
* *
* @version $Revision$ * @version $Revision$
*/ */
public class BrokerFactory { public class BrokerFactory {
static final private FactoryFinder brokerFactoryHandlerFinder = new FactoryFinder("META-INF/services/org/apache/activemq/broker/"); static final private FactoryFinder brokerFactoryHandlerFinder = new FactoryFinder(
"META-INF/services/org/apache/activemq/broker/");
public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException { public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException {
try { try {
@ -43,6 +44,7 @@ public class BrokerFactory {
/** /**
* Creates a broker from a URI configuration * Creates a broker from a URI configuration
*
* @param brokerURI the URI scheme to configure the broker * @param brokerURI the URI scheme to configure the broker
* @throws Exception * @throws Exception
*/ */
@ -52,14 +54,17 @@ public class BrokerFactory {
/** /**
* Creates a broker from a URI configuration * Creates a broker from a URI configuration
*
* @param brokerURI the URI scheme to configure the broker * @param brokerURI the URI scheme to configure the broker
* @param startBroker whether or not the broker should have its {@link BrokerService#start()} method called after construction * @param startBroker whether or not the broker should have its
* {@link BrokerService#start()} method called after
* construction
* @throws Exception * @throws Exception
*/ */
public static BrokerService createBroker(URI brokerURI, boolean startBroker) throws Exception { public static BrokerService createBroker(URI brokerURI, boolean startBroker) throws Exception {
if( brokerURI.getScheme() == null ) if (brokerURI.getScheme() == null) {
throw new IllegalArgumentException("Invalid broker URI, no scheme specified: " + brokerURI); throw new IllegalArgumentException("Invalid broker URI, no scheme specified: " + brokerURI);
}
BrokerFactoryHandler handler = createBrokerFactoryHandler(brokerURI.getScheme()); BrokerFactoryHandler handler = createBrokerFactoryHandler(brokerURI.getScheme());
BrokerService broker = handler.createBroker(brokerURI); BrokerService broker = handler.createBroker(brokerURI);
if (startBroker) { if (startBroker) {
@ -68,9 +73,9 @@ public class BrokerFactory {
return broker; return broker;
} }
/** /**
* Creates a broker from a URI configuration * Creates a broker from a URI configuration
*
* @param brokerURI the URI scheme to configure the broker * @param brokerURI the URI scheme to configure the broker
* @throws Exception * @throws Exception
*/ */
@ -78,16 +83,17 @@ public class BrokerFactory {
return createBroker(new URI(brokerURI)); return createBroker(new URI(brokerURI));
} }
/** /**
* Creates a broker from a URI configuration * Creates a broker from a URI configuration
*
* @param brokerURI the URI scheme to configure the broker * @param brokerURI the URI scheme to configure the broker
* @param startBroker whether or not the broker should have its {@link BrokerService#start()} method called after construction * @param startBroker whether or not the broker should have its
* {@link BrokerService#start()} method called after
* construction
* @throws Exception * @throws Exception
*/ */
public static BrokerService createBroker(String brokerURI, boolean startBroker) throws Exception { public static BrokerService createBroker(String brokerURI, boolean startBroker) throws Exception {
return createBroker(new URI(brokerURI), startBroker); return createBroker(new URI(brokerURI), startBroker);
} }
} }

View File

@ -17,7 +17,8 @@
package org.apache.activemq.broker; package org.apache.activemq.broker;
/** /**
* This exception is thrown by the broker when you try to use it after it has been stopped. * This exception is thrown by the broker when you try to use it after it has
* been stopped.
* *
* @author chirino * @author chirino
*/ */

View File

@ -24,7 +24,6 @@ import org.apache.activemq.command.Command;
import org.apache.activemq.command.Response; import org.apache.activemq.command.Response;
/** /**
*
* @version $Revision: 1.5 $ * @version $Revision: 1.5 $
*/ */
public interface Connection extends Service { public interface Connection extends Service {
@ -37,8 +36,7 @@ public interface Connection extends Service {
/** /**
* Sends a message to the client. * Sends a message to the client.
* *
* @param message * @param message the message to send to the client.
* the message to send to the client.
*/ */
public void dispatchSync(Command message); public void dispatchSync(Command message);

View File

@ -97,7 +97,8 @@ import org.apache.commons.logging.LogFactory;
public class TransportConnection implements Service, Connection, Task, CommandVisitor { public class TransportConnection implements Service, Connection, Task, CommandVisitor {
private static final Log LOG = LogFactory.getLog(TransportConnection.class); 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"); private static final Log SERVICELOG = LogFactory.getLog(TransportConnection.class.getName() + ".Service");
// Keeps track of the broker and connector that created this connection. // Keeps track of the broker and connector that created this connection.
protected final Broker broker; protected final Broker broker;
@ -190,7 +191,8 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
* @param taskRunnerFactory - can be null if you want direct dispatch to the * @param taskRunnerFactory - can be null if you want direct dispatch to the
* transport else commands are sent async. * 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.connector = connector;
this.broker = broker; this.broker = broker;
RegionBroker rb = (RegionBroker)broker.getAdaptor(RegionBroker.class); RegionBroker rb = (RegionBroker)broker.getAdaptor(RegionBroker.class);
@ -270,7 +272,8 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
else if (e.getClass() == BrokerStoppedException.class) { else if (e.getClass() == BrokerStoppedException.class) {
if (!disposed.get()) { if (!disposed.get()) {
if (SERVICELOG.isDebugEnabled()) 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(); ConnectionError ce = new ConnectionError();
ce.setException(e); ce.setException(e);
dispatchSync(ce); dispatchSync(ce);
@ -400,7 +403,8 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
} }
TransactionState transactionState = cs.getTransactionState(info.getTransactionId()); TransactionState transactionState = cs.getTransactionState(info.getTransactionId());
if (transactionState == null) 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. // Avoid dups.
if (!transactionState.isPrepared()) { if (!transactionState.isPrepared()) {
transactionState.setPrepared(true); transactionState.setPrepared(true);
@ -469,7 +473,8 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
return broker.messagePull(lookupConnectionState(pull.getConsumerId()).getContext(), pull); 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); broker.processDispatchNotification(notification);
return null; return null;
} }
@ -498,7 +503,9 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
TransportConnectionState cs = lookupConnectionState(connectionId); TransportConnectionState cs = lookupConnectionState(connectionId);
SessionState ss = cs.getSessionState(sessionId); SessionState ss = cs.getSessionState(sessionId);
if (ss == null) 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 // Avoid replaying dup commands
if (!ss.getProducerIds().contains(info.getProducerId())) { if (!ss.getProducerIds().contains(info.getProducerId())) {
broker.addProducer(cs.getContext(), info); broker.addProducer(cs.getContext(), info);
@ -517,7 +524,9 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
TransportConnectionState cs = lookupConnectionState(connectionId); TransportConnectionState cs = lookupConnectionState(connectionId);
SessionState ss = cs.getSessionState(sessionId); SessionState ss = cs.getSessionState(sessionId);
if (ss == null) 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); ProducerState ps = ss.removeProducer(id);
if (ps == null) if (ps == null)
throw new IllegalStateException("Cannot remove a producer that had not been registered: " + id); throw new IllegalStateException("Cannot remove a producer that had not been registered: " + id);
@ -532,7 +541,9 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
TransportConnectionState cs = lookupConnectionState(connectionId); TransportConnectionState cs = lookupConnectionState(connectionId);
SessionState ss = cs.getSessionState(sessionId); SessionState ss = cs.getSessionState(sessionId);
if (ss == null) 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 // Avoid replaying dup commands
if (!ss.getConsumerIds().contains(info.getConsumerId())) { if (!ss.getConsumerIds().contains(info.getConsumerId())) {
broker.addConsumer(cs.getContext(), info); broker.addConsumer(cs.getContext(), info);
@ -551,7 +562,9 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
TransportConnectionState cs = lookupConnectionState(connectionId); TransportConnectionState cs = lookupConnectionState(connectionId);
SessionState ss = cs.getSessionState(sessionId); SessionState ss = cs.getSessionState(sessionId);
if (ss == null) 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); ConsumerState consumerState = ss.removeConsumer(id);
if (consumerState == null) if (consumerState == null)
throw new IllegalStateException("Cannot remove a consumer that had not been registered: " + id); throw new IllegalStateException("Cannot remove a consumer that had not been registered: " + id);
@ -628,7 +641,8 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
if (state.getConnection() != this) { if (state.getConnection() != this) {
LOG.debug("Killing previous stale connection: " + state.getConnection().getRemoteAddress()); LOG.debug("Killing previous stale connection: " + state.getConnection().getRemoteAddress());
state.getConnection().stop(); 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.setConnection(this);
state.reset(info); state.reset(info);
} }
@ -751,7 +765,8 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
} }
protected void processDispatch(Command command) throws IOException { protected void processDispatch(Command command) throws IOException {
final MessageDispatch messageDispatch = (MessageDispatch)(command.isMessageDispatch() ? command : null); final MessageDispatch messageDispatch = (MessageDispatch)(command.isMessageDispatch()
? command : null);
try { try {
if (!disposed.get()) { if (!disposed.get()) {
if (messageDispatch != null) { if (messageDispatch != null) {
@ -831,7 +846,8 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
transport.start(); transport.start();
if (taskRunnerFactory != null) { if (taskRunnerFactory != null) {
taskRunner = taskRunnerFactory.createTaskRunner(this, "ActiveMQ Connection Dispatcher: " + getRemoteAddress()); taskRunner = taskRunnerFactory.createTaskRunner(this, "ActiveMQ Connection Dispatcher: "
+ getRemoteAddress());
} else { } else {
taskRunner = null; taskRunner = null;
} }
@ -1098,7 +1114,8 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
uri = URISupport.createURIWithQuery(uri, URISupport.createQueryString(map)); uri = URISupport.createURIWithQuery(uri, URISupport.createQueryString(map));
Transport localTransport = TransportFactory.connect(uri); Transport localTransport = TransportFactory.connect(uri);
Transport remoteBridgeTransport = new ResponseCorrelator(transport); Transport remoteBridgeTransport = new ResponseCorrelator(transport);
duplexBridge = NetworkBridgeFactory.createBridge(config, localTransport, remoteBridgeTransport); duplexBridge = NetworkBridgeFactory.createBridge(config, localTransport,
remoteBridgeTransport);
// now turn duplex off this side // now turn duplex off this side
info.setDuplexConnection(false); info.setDuplexConnection(false);
duplexBridge.setCreatedByDuplex(true); duplexBridge.setCreatedByDuplex(true);
@ -1163,7 +1180,8 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
ProducerState producerState = ss.getProducerState(id); ProducerState producerState = ss.getProducerState(id);
if (producerState != null && producerState.getInfo() != null) { if (producerState != null && producerState.getInfo() != null) {
ProducerInfo info = producerState.getInfo(); ProducerInfo info = producerState.getInfo();
result.setMutable(info.getDestination() == null || info.getDestination().isComposite()); result.setMutable(info.getDestination() == null
|| info.getDestination().isComposite());
} }
} }
producerExchanges.put(id, result); producerExchanges.put(id, result);
@ -1267,7 +1285,8 @@ 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; TransportConnectionState rc = connectionState;
connectionState = state; connectionState = state;
return rc; return rc;
@ -1290,35 +1309,44 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
protected TransportConnectionState lookupConnectionState(String connectionId) { protected TransportConnectionState lookupConnectionState(String connectionId) {
TransportConnectionState cs = connectionState; TransportConnectionState cs = connectionState;
if (cs == null) 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; return cs;
} }
protected TransportConnectionState lookupConnectionState(ConsumerId id) { protected TransportConnectionState lookupConnectionState(ConsumerId id) {
TransportConnectionState cs = connectionState; TransportConnectionState cs = connectionState;
if (cs == null) 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; return cs;
} }
protected TransportConnectionState lookupConnectionState(ProducerId id) { protected TransportConnectionState lookupConnectionState(ProducerId id) {
TransportConnectionState cs = connectionState; TransportConnectionState cs = connectionState;
if (cs == null) 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; return cs;
} }
protected TransportConnectionState lookupConnectionState(SessionId id) { protected TransportConnectionState lookupConnectionState(SessionId id) {
TransportConnectionState cs = connectionState; TransportConnectionState cs = connectionState;
if (cs == null) 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; return cs;
} }
protected TransportConnectionState lookupConnectionState(ConnectionId connectionId) { protected TransportConnectionState lookupConnectionState(ConnectionId connectionId) {
TransportConnectionState cs = connectionState; TransportConnectionState cs = connectionState;
if (cs == null) 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; return cs;
} }

View File

@ -64,15 +64,19 @@ public class BrokerView implements BrokerViewMBean {
public long getTotalEnqueueCount() { public long getTotalEnqueueCount() {
return broker.getDestinationStatistics().getEnqueues().getCount(); return broker.getDestinationStatistics().getEnqueues().getCount();
} }
public long getTotalDequeueCount() { public long getTotalDequeueCount() {
return broker.getDestinationStatistics().getDequeues().getCount(); return broker.getDestinationStatistics().getDequeues().getCount();
} }
public long getTotalConsumerCount() { public long getTotalConsumerCount() {
return broker.getDestinationStatistics().getConsumers().getCount(); return broker.getDestinationStatistics().getConsumers().getCount();
} }
public long getTotalMessageCount() { public long getTotalMessageCount() {
return broker.getDestinationStatistics().getMessages().getCount(); return broker.getDestinationStatistics().getMessages().getCount();
} }
public long getTotalMessagesCached() { public long getTotalMessagesCached() {
return broker.getDestinationStatistics().getMessagesCached().getCount(); return broker.getDestinationStatistics().getMessagesCached().getCount();
} }
@ -80,9 +84,11 @@ public class BrokerView implements BrokerViewMBean {
public int getMemoryPercentageUsed() { public int getMemoryPercentageUsed() {
return brokerService.getMemoryManager().getPercentUsage(); return brokerService.getMemoryManager().getPercentUsage();
} }
public long getMemoryLimit() { public long getMemoryLimit() {
return brokerService.getMemoryManager().getLimit(); return brokerService.getMemoryManager().getLimit();
} }
public void setMemoryLimit(long limit) { public void setMemoryLimit(long limit) {
brokerService.getMemoryManager().setLimit(limit); brokerService.getMemoryManager().setLimit(limit);
} }
@ -103,7 +109,6 @@ public class BrokerView implements BrokerViewMBean {
return broker.getDestinationStatistics().isEnabled(); return broker.getDestinationStatistics().isEnabled();
} }
public void terminateJVM(int exitCode) { public void terminateJVM(int exitCode) {
System.exit(exitCode); System.exit(exitCode);
} }
@ -157,14 +162,17 @@ public class BrokerView implements BrokerViewMBean {
} }
public void removeTopic(String name) throws Exception { public void removeTopic(String name) throws Exception {
broker.removeDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQTopic(name), 1000); broker.removeDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQTopic(name),
1000);
} }
public void removeQueue(String name) throws Exception { public void removeQueue(String name) throws Exception {
broker.removeDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQQueue(name), 1000); broker.removeDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQQueue(name),
1000);
} }
public ObjectName createDurableSubscriber(String clientId, String subscriberName, String topicName, String selector) throws Exception { public ObjectName createDurableSubscriber(String clientId, String subscriberName, String topicName,
String selector) throws Exception {
ConnectionContext context = new ConnectionContext(); ConnectionContext context = new ConnectionContext();
context.setBroker(broker); context.setBroker(broker);
context.setClientId(clientId); context.setClientId(clientId);
@ -195,10 +203,9 @@ public class BrokerView implements BrokerViewMBean {
broker.removeSubscription(context, info); broker.removeSubscription(context, info);
} }
/** /**
* Returns the broker's administration connection context used for configuring the broker * Returns the broker's administration connection context used for
* at startup * configuring the broker at startup
*/ */
public static ConnectionContext getConnectionContext(Broker broker) { public static ConnectionContext getConnectionContext(Broker broker) {
ConnectionContext adminConnectionContext = broker.getAdminConnectionContext(); ConnectionContext adminConnectionContext = broker.getAdminConnectionContext();
@ -210,9 +217,10 @@ public class BrokerView implements BrokerViewMBean {
} }
/** /**
* Factory method to create the new administration connection context object. * Factory method to create the new administration connection context
* Note this method is here rather than inside a default broker implementation to * object. Note this method is here rather than inside a default broker
* ensure that the broker reference inside it is the outer most interceptor * implementation to ensure that the broker reference inside it is the outer
* most interceptor
*/ */
protected static ConnectionContext createAdminConnectionContext(Broker broker) { protected static ConnectionContext createAdminConnectionContext(Broker broker) {
ConnectionContext context = new ConnectionContext(); ConnectionContext context = new ConnectionContext();

View File

@ -48,7 +48,6 @@ public class ConnectionView implements ConnectionViewMBean {
return connection.isBlocked(); return connection.isBlocked();
} }
/** /**
* @return true if the Connection is connected * @return true if the Connection is connected
*/ */
@ -63,7 +62,6 @@ public class ConnectionView implements ConnectionViewMBean {
return connection.isActive(); return connection.isActive();
} }
/** /**
* Returns the number of messages to be dispatched to this connection * Returns the number of messages to be dispatched to this connection
*/ */

View File

@ -49,8 +49,9 @@ public class ManagedTransportConnection extends TransportConnection {
private ObjectName byClientIdName; private ObjectName byClientIdName;
private ObjectName byAddressName; private ObjectName byAddressName;
public ManagedTransportConnection(TransportConnector connector, Transport transport, Broker broker, TaskRunnerFactory factory, MBeanServer server, public ManagedTransportConnection(TransportConnector connector, Transport transport, Broker broker,
ObjectName connectorName) throws IOException { TaskRunnerFactory factory, MBeanServer server, ObjectName connectorName)
throws IOException {
super(connector, transport, broker, factory); super(connector, transport, broker, factory);
this.server = server; this.server = server;
this.connectorName = connectorName; this.connectorName = connectorName;
@ -110,8 +111,7 @@ public class ManagedTransportConnection extends TransportConnection {
if (name != null) { if (name != null) {
try { try {
server.unregisterMBean(name); server.unregisterMBean(name);
} } catch (Throwable e) {
catch (Throwable e) {
log.warn("Failed to unregister mbean: " + name); log.warn("Failed to unregister mbean: " + name);
log.debug("Failure reason: " + e, e); log.debug("Failure reason: " + e, e);
} }
@ -122,16 +122,13 @@ public class ManagedTransportConnection extends TransportConnection {
// Build the object name for the destination // Build the object name for the destination
Hashtable map = connectorName.getKeyPropertyList(); Hashtable map = connectorName.getKeyPropertyList();
try { try {
return new ObjectName( return new ObjectName(connectorName.getDomain() + ":" + "BrokerName="
connectorName.getDomain()+":"+ + JMXSupport.encodeObjectNamePart((String)map.get("BrokerName")) + ","
"BrokerName="+JMXSupport.encodeObjectNamePart((String) map.get("BrokerName"))+","+ + "Type=Connection," + "ConnectorName="
"Type=Connection,"+ + JMXSupport.encodeObjectNamePart((String)map.get("ConnectorName")) + ","
"ConnectorName="+JMXSupport.encodeObjectNamePart((String) map.get("ConnectorName"))+","+ + "ViewType=" + JMXSupport.encodeObjectNamePart(type) + "," + "Name="
"ViewType="+JMXSupport.encodeObjectNamePart(type)+","+ + JMXSupport.encodeObjectNamePart(value));
"Name="+JMXSupport.encodeObjectNamePart(value) } catch (Throwable e) {
);
}
catch (Throwable e) {
throw IOExceptionSupport.create(e); throw IOExceptionSupport.create(e);
} }
} }
@ -140,18 +137,14 @@ public class ManagedTransportConnection extends TransportConnection {
// Build the object name for the destination // Build the object name for the destination
Hashtable map = connectorName.getKeyPropertyList(); Hashtable map = connectorName.getKeyPropertyList();
try { try {
return new ObjectName( return new ObjectName(connectorName.getDomain() + ":" + "BrokerName="
connectorName.getDomain()+":"+ + JMXSupport.encodeObjectNamePart((String)map.get("BrokerName")) + ","
"BrokerName="+JMXSupport.encodeObjectNamePart((String) map.get("BrokerName"))+","+ + "Type=Connection," + "ConnectorName="
"Type=Connection,"+ + JMXSupport.encodeObjectNamePart((String)map.get("ConnectorName")) + ","
"ConnectorName="+JMXSupport.encodeObjectNamePart((String) map.get("ConnectorName"))+","+ + "Connection=" + JMXSupport.encodeObjectNamePart(value));
"Connection="+JMXSupport.encodeObjectNamePart(value) } catch (Throwable e) {
);
}
catch (Throwable e) {
throw IOExceptionSupport.create(e); throw IOExceptionSupport.create(e);
} }
} }
} }

View File

@ -21,23 +21,41 @@ import org.apache.activemq.Service;
public interface NetworkConnectorViewMBean extends Service { public interface NetworkConnectorViewMBean extends Service {
public String getName(); public String getName();
public int getNetworkTTL(); public int getNetworkTTL();
public int getPrefetchSize(); public int getPrefetchSize();
public String getUserName(); public String getUserName();
public boolean isBridgeTempDestinations(); public boolean isBridgeTempDestinations();
public boolean isConduitSubscriptions(); public boolean isConduitSubscriptions();
public boolean isDecreaseNetworkConsumerPriority(); public boolean isDecreaseNetworkConsumerPriority();
public boolean isDispatchAsync(); public boolean isDispatchAsync();
public boolean isDynamicOnly(); public boolean isDynamicOnly();
public void setBridgeTempDestinations(boolean bridgeTempDestinations); public void setBridgeTempDestinations(boolean bridgeTempDestinations);
public void setConduitSubscriptions(boolean conduitSubscriptions); public void setConduitSubscriptions(boolean conduitSubscriptions);
public void setDispatchAsync(boolean dispatchAsync); public void setDispatchAsync(boolean dispatchAsync);
public void setDynamicOnly(boolean dynamicOnly); public void setDynamicOnly(boolean dynamicOnly);
public void setNetworkTTL(int networkTTL); public void setNetworkTTL(int networkTTL);
public void setPassword(String password); public void setPassword(String password);
public void setPrefetchSize(int prefetchSize); public void setPrefetchSize(int prefetchSize);
public void setUserName(String userName); public void setUserName(String userName);
public String getPassword(); public String getPassword();
public void setDecreaseNetworkConsumerPriority(boolean decreaseNetworkConsumerPriority); public void setDecreaseNetworkConsumerPriority(boolean decreaseNetworkConsumerPriority);
} }

View File

@ -22,20 +22,17 @@ import org.apache.activemq.command.ConsumerInfo;
import javax.jms.InvalidSelectorException; import javax.jms.InvalidSelectorException;
/** /**
* @version $Revision: 1.5 $ * @version $Revision: 1.5 $
*/ */
public class SubscriptionView implements SubscriptionViewMBean { public class SubscriptionView implements SubscriptionViewMBean {
protected final Subscription subscription; protected final Subscription subscription;
protected final String clientId; protected final String clientId;
/** /**
* Constructor * Constructor
*
* @param subs * @param subs
*/ */
public SubscriptionView(String clientId, Subscription subs) { public SubscriptionView(String clientId, Subscription subs) {
@ -105,8 +102,7 @@ public class SubscriptionView implements SubscriptionViewMBean {
public void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException { public void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException {
if (subscription != null) { if (subscription != null) {
subscription.setSelector(selector); subscription.setSelector(selector);
} } else {
else {
throw new UnsupportedOperationException("No subscription object"); throw new UnsupportedOperationException("No subscription object");
} }
} }
@ -155,8 +151,8 @@ public class SubscriptionView implements SubscriptionViewMBean {
} }
/** /**
* The subscription should release as may references as it can to help the garbage collector * The subscription should release as may references as it can to help the
* reclaim memory. * garbage collector reclaim memory.
*/ */
public void gc() { public void gc() {
if (subscription != null) { if (subscription != null) {
@ -180,7 +176,6 @@ public class SubscriptionView implements SubscriptionViewMBean {
return info != null ? info.isExclusive() : false; return info != null ? info.isExclusive() : false;
} }
/** /**
* @return whether or not the subscriber is durable (persistent) * @return whether or not the subscriber is durable (persistent)
*/ */
@ -197,10 +192,11 @@ public class SubscriptionView implements SubscriptionViewMBean {
return info != null ? info.isNoLocal() : false; return info != null ? info.isNoLocal() : false;
} }
/** /**
* @return the maximum number of pending messages allowed in addition to the prefetch size. If enabled * @return the maximum number of pending messages allowed in addition to the
* to a non-zero value then this will perform eviction of messages for slow consumers on non-durable topics. * prefetch size. If enabled to a non-zero value then this will
* perform eviction of messages for slow consumers on non-durable
* topics.
*/ */
public int getMaximumPendingMessageLimit() { public int getMaximumPendingMessageLimit() {
ConsumerInfo info = getConsumerInfo(); ConsumerInfo info = getConsumerInfo();
@ -216,7 +212,8 @@ public class SubscriptionView implements SubscriptionViewMBean {
} }
/** /**
* @return the name of the consumer which is only used for durable consumers. * @return the name of the consumer which is only used for durable
* consumers.
*/ */
public String getSubcriptionName() { public String getSubcriptionName() {
ConsumerInfo info = getConsumerInfo(); ConsumerInfo info = getConsumerInfo();

View File

@ -27,32 +27,37 @@ import org.apache.activemq.command.Message;
import org.apache.activemq.command.MessageAck; import org.apache.activemq.command.MessageAck;
import org.apache.activemq.memory.UsageManager; import org.apache.activemq.memory.UsageManager;
import org.apache.activemq.store.MessageStore; import org.apache.activemq.store.MessageStore;
import org.apache.activemq.store.TopicMessageStore;
/** /**
*
* @version $Revision: 1.12 $ * @version $Revision: 1.12 $
*/ */
public interface Destination extends Service { public interface Destination extends Service {
void addSubscription(ConnectionContext context, Subscription sub) throws Exception; void addSubscription(ConnectionContext context, Subscription sub) throws Exception;
void removeSubscription(ConnectionContext context, Subscription sub) throws Exception; void removeSubscription(ConnectionContext context, Subscription sub) throws Exception;
void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception; void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception;
boolean lock(MessageReference node, LockOwner lockOwner); boolean lock(MessageReference node, LockOwner lockOwner);
void acknowledge(ConnectionContext context, Subscription sub, final MessageAck ack, final MessageReference node) throws IOException; void acknowledge(ConnectionContext context, Subscription sub, final MessageAck ack, final MessageReference node) throws IOException;
void gc(); void gc();
ActiveMQDestination getActiveMQDestination(); ActiveMQDestination getActiveMQDestination();
UsageManager getUsageManager(); UsageManager getUsageManager();
void dispose(ConnectionContext context) throws IOException; void dispose(ConnectionContext context) throws IOException;
DestinationStatistics getDestinationStatistics(); DestinationStatistics getDestinationStatistics();
DeadLetterStrategy getDeadLetterStrategy(); DeadLetterStrategy getDeadLetterStrategy();
public Message[] browse(); public Message[] browse();
public String getName(); public String getName();
public MessageStore getMessageStore(); public MessageStore getMessageStore();
} }

View File

@ -16,6 +16,10 @@
*/ */
package org.apache.activemq.broker.region; package org.apache.activemq.broker.region;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
import org.apache.activemq.broker.Broker; import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.broker.ProducerBrokerExchange; import org.apache.activemq.broker.ProducerBrokerExchange;
@ -26,10 +30,6 @@ import org.apache.activemq.command.MessageAck;
import org.apache.activemq.memory.UsageManager; import org.apache.activemq.memory.UsageManager;
import org.apache.activemq.store.MessageStore; import org.apache.activemq.store.MessageStore;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
/** /**
* *
* @version $Revision$ * @version $Revision$
@ -42,7 +42,8 @@ public class DestinationFilter implements Destination {
this.next = next; this.next = next;
} }
public void acknowledge(ConnectionContext context, Subscription sub, MessageAck ack, MessageReference node) throws IOException { public void acknowledge(ConnectionContext context, Subscription sub, MessageAck ack, MessageReference node)
throws IOException {
next.acknowledge(context, sub, ack, node); next.acknowledge(context, sub, ack, node);
} }
@ -105,7 +106,8 @@ public class DestinationFilter implements Destination {
/** /**
* Sends a message to the given destination which may be a wildcard * Sends a message to the given destination which may be a wildcard
*/ */
protected void send(ProducerBrokerExchange context, Message message, ActiveMQDestination destination) throws Exception { protected void send(ProducerBrokerExchange context, Message message, ActiveMQDestination destination)
throws Exception {
Broker broker = context.getConnectionContext().getBroker(); Broker broker = context.getConnectionContext().getBroker();
Set destinations = broker.getDestinations(destination); Set destinations = broker.getDestinations(destination);

View File

@ -26,8 +26,7 @@ import org.apache.activemq.command.MessageId;
/** /**
* Only used by the {@link QueueMessageReference#NULL_MESSAGE} * Only used by the {@link QueueMessageReference#NULL_MESSAGE}
*/ */
final class NullMessageReference implements final class NullMessageReference implements QueueMessageReference {
QueueMessageReference {
private ActiveMQMessage message = new ActiveMQMessage(); private ActiveMQMessage message = new ActiveMQMessage();
private volatile int references; private volatile int references;

View File

@ -30,7 +30,8 @@ public class QueueBrowserSubscription extends QueueSubscription {
boolean browseDone; boolean browseDone;
public QueueBrowserSubscription(Broker broker,ConnectionContext context, ConsumerInfo info) throws InvalidSelectorException { public QueueBrowserSubscription(Broker broker, ConnectionContext context, ConsumerInfo info)
throws InvalidSelectorException {
super(broker, context, info); super(broker, context, info);
} }
@ -39,13 +40,9 @@ public class QueueBrowserSubscription extends QueueSubscription {
} }
public synchronized String toString() { public synchronized String toString() {
return return "QueueBrowserSubscription:" + " consumer=" + info.getConsumerId() + ", destinations="
"QueueBrowserSubscription:" + + destinations.size() + ", dispatched=" + dispatched.size() + ", delivered="
" consumer="+info.getConsumerId()+ + this.prefetchExtension + ", pending=" + getPendingQueueSize();
", destinations="+destinations.size()+
", dispatched="+dispatched.size()+
", delivered="+this.prefetchExtension+
", pending="+getPendingQueueSize();
} }
public void browseDone() throws Exception { public void browseDone() throws Exception {
@ -60,7 +57,8 @@ public class QueueBrowserSubscription extends QueueSubscription {
/** /**
* Since we are a browser we don't really remove the message from the queue. * Since we are a browser we don't really remove the message from the queue.
*/ */
protected void acknowledge(ConnectionContext context, final MessageAck ack, final MessageReference n) throws IOException { protected void acknowledge(ConnectionContext context, final MessageAck ack, final MessageReference n)
throws IOException {
} }
} }

View File

@ -33,23 +33,22 @@ import java.util.Set;
*/ */
public class QueueRegion extends AbstractRegion { public class QueueRegion extends AbstractRegion {
public QueueRegion(RegionBroker broker, DestinationStatistics destinationStatistics,
UsageManager memoryManager, TaskRunnerFactory taskRunnerFactory,
public QueueRegion(RegionBroker broker,DestinationStatistics destinationStatistics, UsageManager memoryManager, TaskRunnerFactory taskRunnerFactory,
DestinationFactory destinationFactory) { DestinationFactory destinationFactory) {
super(broker, destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory); super(broker, destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory);
} }
public String toString() { public String toString() {
return "QueueRegion: destinations=" + destinations.size() + ", subscriptions=" + subscriptions.size() + ", memory=" + memoryManager.getPercentUsage() return "QueueRegion: destinations=" + destinations.size() + ", subscriptions=" + subscriptions.size()
+ "%"; + ", memory=" + memoryManager.getPercentUsage() + "%";
} }
protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info) throws InvalidSelectorException { protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info)
throws InvalidSelectorException {
if (info.isBrowser()) { if (info.isBrowser()) {
return new QueueBrowserSubscription(broker, context, info); return new QueueBrowserSubscription(broker, context, info);
} } else {
else {
return new QueueSubscription(broker, context, info); return new QueueSubscription(broker, context, info);
} }
} }

View File

@ -60,12 +60,12 @@ import org.apache.commons.logging.LogFactory;
* @version $Revision: 1.21 $ * @version $Revision: 1.21 $
*/ */
public class Topic implements Destination { public class Topic implements Destination {
private static final Log log = LogFactory.getLog(Topic.class); private static final Log LOG = LogFactory.getLog(Topic.class);
protected final ActiveMQDestination destination; protected final ActiveMQDestination destination;
protected final CopyOnWriteArrayList consumers = new CopyOnWriteArrayList(); protected final CopyOnWriteArrayList consumers = new CopyOnWriteArrayList();
protected final Valve dispatchValve = new Valve(true); protected final Valve dispatchValve = new Valve(true);
protected final TopicMessageStore store;// this could be NULL! (If an // this could be NULL! (If an advisory)
// advsiory) protected final TopicMessageStore store;
protected final UsageManager usageManager; protected final UsageManager usageManager;
protected final DestinationStatistics destinationStatistics = new DestinationStatistics(); protected final DestinationStatistics destinationStatistics = new DestinationStatistics();
@ -349,8 +349,8 @@ public class Topic implements Destination {
// The usage manager could have delayed us by the time // The usage manager could have delayed us by the time
// we unblock the message could have expired.. // we unblock the message could have expired..
if (message.isExpired()) { if (message.isExpired()) {
if (log.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
log.debug("Expired message: " + message); LOG.debug("Expired message: " + message);
} }
return; return;
} }
@ -468,7 +468,7 @@ public class Topic implements Destination {
} }
} }
} catch (Throwable e) { } catch (Throwable e) {
log.warn("Failed to browse Topic: " + getActiveMQDestination().getPhysicalName(), e); LOG.warn("Failed to browse Topic: " + getActiveMQDestination().getPhysicalName(), e);
} }
return (Message[])result.toArray(new Message[result.size()]); return (Message[])result.toArray(new Message[result.size()]);
} }

View File

@ -19,11 +19,11 @@ import org.apache.activemq.broker.region.cursors.FilePendingMessageCursor;
import org.apache.activemq.broker.region.cursors.PendingMessageCursor; import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
import org.apache.activemq.kaha.Store; import org.apache.activemq.kaha.Store;
/** /**
* Creates a FilePendingMessageCursor * Creates a FilePendingMessageCursor *
* * *
* @org.apache.xbean.XBean element="fileQueueCursor" description="Pending messages paged in from file" * @org.apache.xbean.XBean element="fileQueueCursor" description="Pending
* messages paged in from file"
* *
* @version $Revision$ * @version $Revision$
*/ */
@ -33,11 +33,11 @@ public class FilePendingQueueMessageStoragePolicy implements PendingQueueMessage
* @param queue * @param queue
* @param tmpStore * @param tmpStore
* @return the cursor * @return the cursor
* @see org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy#getQueuePendingMessageCursor(org.apache.openjpa.lib.util.concurrent.Queue, org.apache.activemq.kaha.Store) * @see org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy#getQueuePendingMessageCursor(org.apache.openjpa.lib.util.concurrent.Queue,
* org.apache.activemq.kaha.Store)
*/ */
public PendingMessageCursor getQueuePendingMessageCursor(Queue queue, Store tmpStore) { public PendingMessageCursor getQueuePendingMessageCursor(Queue queue, Store tmpStore) {
return new FilePendingMessageCursor("PendingCursor:" + queue.getName(), tmpStore); return new FilePendingMessageCursor("PendingCursor:" + queue.getName(), tmpStore);
} }
} }

View File

@ -17,12 +17,11 @@ import org.apache.activemq.broker.region.cursors.FilePendingMessageCursor;
import org.apache.activemq.broker.region.cursors.PendingMessageCursor; import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
import org.apache.activemq.kaha.Store; import org.apache.activemq.kaha.Store;
/** /**
* Creates a PendIngMessageCursor for Durable subscribers * Creates a PendIngMessageCursor for Durable subscribers *
* * *
* @org.apache.xbean.XBean element="fileCursor" description="Pending messages for durable subscribers * @org.apache.xbean.XBean element="fileCursor" description="Pending messages
* held in temporary files" * for durable subscribers held in temporary files"
* *
* @version $Revision$ * @version $Revision$
*/ */
@ -33,9 +32,11 @@ public class FilePendingSubscriberMessageStoragePolicy implements PendingSubscri
* @param tmpStorage * @param tmpStorage
* @param maxBatchSize * @param maxBatchSize
* @return a Cursor * @return a Cursor
* @see org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy#getSubscriberPendingMessageCursor(java.lang.String, org.apache.activemq.kaha.Store, int) * @see org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy#getSubscriberPendingMessageCursor(java.lang.String,
* org.apache.activemq.kaha.Store, int)
*/ */
public PendingMessageCursor getSubscriberPendingMessageCursor(String name,Store tmpStorage,int maxBatchSize){ public PendingMessageCursor getSubscriberPendingMessageCursor(String name, Store tmpStorage,
int maxBatchSize) {
return new FilePendingMessageCursor("PendingCursor:" + name, tmpStorage); return new FilePendingMessageCursor("PendingCursor:" + name, tmpStorage);
} }
} }

View File

@ -19,11 +19,11 @@ import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
import org.apache.activemq.broker.region.cursors.StoreQueueCursor; import org.apache.activemq.broker.region.cursors.StoreQueueCursor;
import org.apache.activemq.kaha.Store; import org.apache.activemq.kaha.Store;
/** /**
* Creates a StoreQueueCursor * Creates a StoreQueueCursor *
* * *
* @org.apache.xbean.XBean element="storeCursor" description="Pending messages paged in from the Store" * @org.apache.xbean.XBean element="storeCursor" description="Pending messages
* paged in from the Store"
* *
* @version $Revision$ * @version $Revision$
*/ */
@ -33,11 +33,11 @@ public class StorePendingQueueMessageStoragePolicy implements PendingQueueMessag
* @param queue * @param queue
* @param tmpStore * @param tmpStore
* @return the cursor * @return the cursor
* @see org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy#getQueuePendingMessageCursor(org.apache.openjpa.lib.util.concurrent.Queue, org.apache.activemq.kaha.Store) * @see org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy#getQueuePendingMessageCursor(org.apache.openjpa.lib.util.concurrent.Queue,
* org.apache.activemq.kaha.Store)
*/ */
public PendingMessageCursor getQueuePendingMessageCursor(Queue queue, Store tmpStore) { public PendingMessageCursor getQueuePendingMessageCursor(Queue queue, Store tmpStore) {
return new StoreQueueCursor(queue, tmpStore); return new StoreQueueCursor(queue, tmpStore);
} }
} }

View File

@ -20,9 +20,10 @@ import org.apache.activemq.broker.region.cursors.VMPendingMessageCursor;
import org.apache.activemq.kaha.Store; import org.apache.activemq.kaha.Store;
/** /**
* Creates a VMPendingMessageCursor * Creates a VMPendingMessageCursor *
* * *
* @org.apache.xbean.XBean element="vmQueueCursor" description="Pending messages held in the JVM" * @org.apache.xbean.XBean element="vmQueueCursor" description="Pending messages
* held in the JVM"
* *
* @version $Revision$ * @version $Revision$
*/ */

View File

@ -17,11 +17,11 @@ import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
import org.apache.activemq.broker.region.cursors.VMPendingMessageCursor; import org.apache.activemq.broker.region.cursors.VMPendingMessageCursor;
import org.apache.activemq.kaha.Store; import org.apache.activemq.kaha.Store;
/** /**
* Creates a VMPendingMessageCursor * Creates a VMPendingMessageCursor *
* * *
* @org.apache.xbean.XBean element="vmCursor" description="Pending messages held in the JVM" * @org.apache.xbean.XBean element="vmCursor" description="Pending messages held
* in the JVM"
* *
* @version $Revision$ * @version $Revision$
*/ */
@ -32,9 +32,11 @@ public class VMPendingSubscriberMessageStoragePolicy implements PendingSubscribe
* @param tmpStorage * @param tmpStorage
* @param maxBatchSize * @param maxBatchSize
* @return a Cursor * @return a Cursor
* @see org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy#getSubscriberPendingMessageCursor(java.lang.String, org.apache.activemq.kaha.Store, int) * @see org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy#getSubscriberPendingMessageCursor(java.lang.String,
* org.apache.activemq.kaha.Store, int)
*/ */
public PendingMessageCursor getSubscriberPendingMessageCursor(String name,Store tmpStorage,int maxBatchSize){ public PendingMessageCursor getSubscriberPendingMessageCursor(String name, Store tmpStorage,
int maxBatchSize) {
return new VMPendingMessageCursor(); return new VMPendingMessageCursor();
} }
} }

View File

@ -23,7 +23,8 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
/** /**
* A Broker interceptor which allows you to trace all operations to a Multicast socket. * A Broker interceptor which allows you to trace all operations to a Multicast
* socket.
* *
* @org.apache.xbean.XBean * @org.apache.xbean.XBean
* *

View File

@ -20,16 +20,15 @@ import org.apache.activemq.broker.BrokerPluginSupport;
import org.apache.activemq.broker.ProducerBrokerExchange; import org.apache.activemq.broker.ProducerBrokerExchange;
import org.apache.activemq.command.Message; import org.apache.activemq.command.Message;
/** /**
* A Broker interceptor which updates a JMS Client's timestamp on the message * A Broker interceptor which updates a JMS Client's timestamp on the message
* with a broker timestamp. Useful when the clocks on client machines are known to * with a broker timestamp. Useful when the clocks on client machines are known
* not be correct and you can only trust the time set on the broker machines. * to not be correct and you can only trust the time set on the broker machines.
* *
* Enabling this plugin will break JMS compliance since the timestamp that the producer * Enabling this plugin will break JMS compliance since the timestamp that the
* sees on the messages after as send() will be different from the timestamp the consumer * producer sees on the messages after as send() will be different from the
* will observe when he receives the message. This plugin is not enabled in the default * timestamp the consumer will observe when he receives the message. This plugin
* ActiveMQ configuration. * is not enabled in the default ActiveMQ configuration.
* *
* @org.apache.xbean.XBean element="timeStampingBrokerPlugin" * @org.apache.xbean.XBean element="timeStampingBrokerPlugin"
* *
@ -37,7 +36,8 @@ import org.apache.activemq.command.Message;
*/ */
public class TimeStampingBrokerPlugin extends BrokerPluginSupport { public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception { public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception {
if (message.getTimestamp() > 0 && (message.getBrokerPath() == null || message.getBrokerPath().length == 0)) { if (message.getTimestamp() > 0
&& (message.getBrokerPath() == null || message.getBrokerPath().length == 0)) {
// timestamp not been disabled and has not passed through a network // timestamp not been disabled and has not passed through a network
message.setTimestamp(System.currentTimeMillis()); message.setTimestamp(System.currentTimeMillis());
} }

View File

@ -16,6 +16,10 @@
*/ */
package org.apache.activemq.broker.view; package org.apache.activemq.broker.view;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Iterator;
import org.apache.activemq.broker.Broker; import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.broker.region.Destination; import org.apache.activemq.broker.region.Destination;
@ -23,12 +27,7 @@ import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.filter.DestinationMap; import org.apache.activemq.filter.DestinationMap;
import org.apache.activemq.filter.DestinationMapNode; import org.apache.activemq.filter.DestinationMapNode;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Iterator;
/** /**
*
* @version $Revision: $ * @version $Revision: $
*/ */
public class DestinationDotFileInterceptor extends DotFileInterceptorSupport { public class DestinationDotFileInterceptor extends DotFileInterceptorSupport {
@ -45,13 +44,11 @@ public class DestinationDotFileInterceptor extends DotFileInterceptorSupport {
return answer; return answer;
} }
public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception {
throws Exception {
super.removeDestination(context, destination, timeout); super.removeDestination(context, destination, timeout);
generateFile(); generateFile();
} }
protected void generateFile(PrintWriter writer) throws Exception { protected void generateFile(PrintWriter writer) throws Exception {
ActiveMQDestination[] destinations = getDestinations(); ActiveMQDestination[] destinations = getDestinations();
@ -106,8 +103,7 @@ public class DestinationDotFileInterceptor extends DotFileInterceptorSupport {
String label = path; String label = path;
if (prefix.equals("topic")) { if (prefix.equals("topic")) {
label = "Topics"; label = "Topics";
} } else if (prefix.equals("queue")) {
else if (prefix.equals("queue")) {
label = "Queues"; label = "Queues";
} }
writer.print("[ label = \""); writer.print("[ label = \"");
@ -143,7 +139,6 @@ public class DestinationDotFileInterceptor extends DotFileInterceptorSupport {
} }
} }
protected String getPath(DestinationMapNode node) { protected String getPath(DestinationMapNode node) {
String path = node.getPath(); String path = node.getPath();
if (path.equals("*")) { if (path.equals("*")) {

View File

@ -16,17 +16,17 @@
*/ */
package org.apache.activemq.camel; package org.apache.activemq.camel;
import org.apache.activemq.ActiveMQSession;
import org.apache.camel.Endpoint;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.Message; import javax.jms.Message;
import javax.jms.Queue; import javax.jms.Queue;
import javax.jms.QueueSender; import javax.jms.QueueSender;
import org.apache.activemq.ActiveMQSession;
import org.apache.camel.Endpoint;
/** /**
* A JMS {@link javax.jms.QueueSender} which sends message exchanges to a * A JMS {@link javax.jms.QueueSender} which sends message exchanges to a Camel
* Camel {@link org.apache.camel.Endpoint} * {@link org.apache.camel.Endpoint}
* *
* @version $Revision: $ * @version $Revision: $
*/ */
@ -36,7 +36,6 @@ public class CamelQueueSender extends CamelMessageProducer implements QueueSende
super(destination, endpoint, session); super(destination, endpoint, session);
} }
/** /**
* Gets the queue associated with this <CODE>QueueSender</CODE>. * Gets the queue associated with this <CODE>QueueSender</CODE>.
* *
@ -50,19 +49,17 @@ public class CamelQueueSender extends CamelMessageProducer implements QueueSende
} }
/** /**
* Sends a message to a queue for an unidentified message producer. Uses * Sends a message to a queue for an unidentified message producer. Uses the
* the <CODE>QueueSender</CODE>'s default delivery mode, priority, and * <CODE>QueueSender</CODE>'s default delivery mode, priority, and time
* time to live. * to live. <p/> <p/> Typically, a message producer is assigned a queue at
* <p/> * creation time; however, the JMS API also supports unidentified message
* <p/> * producers, which require that the queue be supplied every time a message
* Typically, a message producer is assigned a queue at creation time; * is sent.
* however, the JMS API also supports unidentified message producers, which
* require that the queue be supplied every time a message is sent.
* *
* @param queue the queue to send this message to * @param queue the queue to send this message to
* @param message the message to send * @param message the message to send
* @throws JMSException if the JMS provider fails to send the message due to some * @throws JMSException if the JMS provider fails to send the message due to
* internal error. * some internal error.
* @see javax.jms.MessageProducer#getDeliveryMode() * @see javax.jms.MessageProducer#getDeliveryMode()
* @see javax.jms.MessageProducer#getTimeToLive() * @see javax.jms.MessageProducer#getTimeToLive()
* @see javax.jms.MessageProducer#getPriority() * @see javax.jms.MessageProducer#getPriority()
@ -74,28 +71,21 @@ public class CamelQueueSender extends CamelMessageProducer implements QueueSende
/** /**
* Sends a message to a queue for an unidentified message producer, * Sends a message to a queue for an unidentified message producer,
* specifying delivery mode, priority and time to live. * specifying delivery mode, priority and time to live. <p/> <p/> Typically,
* <p/> * a message producer is assigned a queue at creation time; however, the JMS
* <p/> * API also supports unidentified message producers, which require that the
* Typically, a message producer is assigned a queue at creation time; * queue be supplied every time a message is sent.
* however, the JMS API also supports unidentified message producers, which
* require that the queue be supplied every time a message is sent.
* *
* @param queue the queue to send this message to * @param queue the queue to send this message to
* @param message the message to send * @param message the message to send
* @param deliveryMode the delivery mode to use * @param deliveryMode the delivery mode to use
* @param priority the priority for this message * @param priority the priority for this message
* @param timeToLive the message's lifetime (in milliseconds) * @param timeToLive the message's lifetime (in milliseconds)
* @throws JMSException if the JMS provider fails to send the message due to some * @throws JMSException if the JMS provider fails to send the message due to
* internal error. * some internal error.
*/ */
public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException {
throws JMSException { super.send(queue, message, deliveryMode, priority, timeToLive);
super.send(queue,
message,
deliveryMode,
priority,
timeToLive);
} }
} }

View File

@ -41,7 +41,8 @@ import java.util.StringTokenizer;
* @openwire:marshaller * @openwire:marshaller
* @version $Revision: 1.10 $ * @version $Revision: 1.10 $
*/ */
abstract public class ActiveMQDestination extends JNDIBaseStorable implements DataStructure, Destination, Externalizable, Comparable { abstract public class ActiveMQDestination extends JNDIBaseStorable implements DataStructure, Destination,
Externalizable, Comparable {
private static final long serialVersionUID = -3885260014960795889L; private static final long serialVersionUID = -3885260014960795889L;
@ -196,7 +197,8 @@ abstract public class ActiveMQDestination extends JNDIBaseStorable implements Da
public void setPhysicalName(String physicalName) { public void setPhysicalName(String physicalName) {
final int len = physicalName.length(); final int len = physicalName.length();
int p = -1;// options offset // options offset
int p = -1;
boolean composite = false; boolean composite = false;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
char c = physicalName.charAt(i); char c = physicalName.charAt(i);
@ -219,7 +221,8 @@ abstract public class ActiveMQDestination extends JNDIBaseStorable implements Da
try { try {
options = URISupport.parseQuery(optstring); options = URISupport.parseQuery(optstring);
} catch (URISyntaxException e) { } 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; this.physicalName = physicalName;

View File

@ -42,32 +42,50 @@ import org.apache.activemq.util.MarshallingSupport;
import org.apache.activemq.wireformat.WireFormat; import org.apache.activemq.wireformat.WireFormat;
/** /**
* A <CODE>MapMessage</CODE> object is used to send a set of name-value pairs. The names are <CODE>String</CODE> * A <CODE>MapMessage</CODE> object is used to send a set of name-value pairs.
* objects, and the values are primitive data types in the Java programming language. The names must have a value that * The names are <CODE>String</CODE> objects, and the values are primitive
* is not null, and not an empty string. The entries can be accessed sequentially or randomly by name. The order of the * data types in the Java programming language. The names must have a value that
* entries is undefined. <CODE>MapMessage</CODE> inherits from the <CODE>Message</CODE> interface and adds a message * is not null, and not an empty string. The entries can be accessed
* body that contains a Map. <P> The primitive types can be read or written explicitly using methods for each type. They * sequentially or randomly by name. The order of the entries is undefined.
* may also be read or written generically as objects. For instance, a call to <CODE>MapMessage.setInt("foo", 6)</CODE> * <CODE>MapMessage</CODE> inherits from the <CODE>Message</CODE> interface
* is equivalent to <CODE> MapMessage.setObject("foo", new Integer(6))</CODE>. Both forms are provided, because the * and adds a message body that contains a Map.
* explicit form is convenient for static programming, and the object form is needed when types are not known at compile * <P>
* time. <P> When a client receives a <CODE>MapMessage</CODE>, it is in read-only mode. If a client attempts to write to * The primitive types can be read or written explicitly using methods for each
* the message at this point, a <CODE>MessageNotWriteableException</CODE> is thrown. If <CODE>clearBody</CODE> is * type. They may also be read or written generically as objects. For instance,
* called, the message can now be both read from and written to. <P> <CODE>MapMessage</CODE> objects support the * a call to <CODE>MapMessage.setInt("foo", 6)</CODE> is equivalent to
* following conversion table. The marked cases must be supported. The unmarked cases must throw a * <CODE> MapMessage.setObject("foo", new Integer(6))</CODE>. Both forms are
* <CODE>JMSException</CODE>. The <CODE>String</CODE> -to-primitive conversions may throw a runtime exception if the * provided, because the explicit form is convenient for static programming, and
* primitive's <CODE>valueOf()</CODE> method does not accept it as a valid <CODE> String</CODE> representation of the * the object form is needed when types are not known at compile time.
* primitive. <P> A value written as the row type can be read as the column type. * <P>
* <p/> * When a client receives a <CODE>MapMessage</CODE>, it is in read-only mode.
* <PRE>| | boolean byte short char int long float double String byte[] |---------------------------------------------------------------------- * If a client attempts to write to the message at this point, a
* <CODE>MessageNotWriteableException</CODE> is thrown. If
* <CODE>clearBody</CODE> is called, the message can now be both read from and
* written to.
* <P>
* <CODE>MapMessage</CODE> objects support the following conversion table. The
* marked cases must be supported. The unmarked cases must throw a
* <CODE>JMSException</CODE>. The <CODE>String</CODE> -to-primitive
* conversions may throw a runtime exception if the primitive's
* <CODE>valueOf()</CODE> method does not accept it as a valid
* <CODE> String</CODE> representation of the primitive.
* <P>
* A value written as the row type can be read as the column type. <p/>
*
* <PRE>
* | | boolean byte short char int long float double String byte[] |----------------------------------------------------------------------
* |boolean | X X |byte | X X X X X |short | X X X X |char | X X |int | X X X |long | X X |float | X X X |double | X X * |boolean | X X |byte | X X X X X |short | X X X X |char | X X |int | X X X |long | X X |float | X X X |double | X X
* |String | X X X X X X X X |byte[] | X |---------------------------------------------------------------------- * |String | X X X X X X X X |byte[] | X |----------------------------------------------------------------------
* <p/> * &lt;p/&gt;
* </PRE> * </PRE>
*
* <p/> * <p/>
* <P> Attempting to read a null value as a primitive type must be treated as calling the primitive's corresponding * <P>
* <code>valueOf(String)</code> conversion method with a null value. Since <code>char</code> does not support a * Attempting to read a null value as a primitive type must be treated as
* <code>String</code> conversion, attempting to read a null value as a <code>char</code> must throw a * calling the primitive's corresponding <code>valueOf(String)</code>
* <code>NullPointerException</code>. * conversion method with a null value. Since <code>char</code> does not
* support a <code>String</code> conversion, attempting to read a null value
* as a <code>char</code> must throw a <code>NullPointerException</code>.
* *
* @openwire:marshaller code="25" * @openwire:marshaller code="25"
* @see javax.jms.Session#createMapMessage() * @see javax.jms.Session#createMapMessage()
@ -122,6 +140,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
/** /**
* Builds the message body from data * Builds the message body from data
*
* @throws JMSException * @throws JMSException
* *
* @throws IOException * @throws IOException
@ -151,11 +170,13 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
return "jms/map-message"; return "jms/map-message";
} }
/** /**
* Clears out the message body. Clearing a message's body does not clear its header values or property entries. <P> * Clears out the message body. Clearing a message's body does not clear its
* If this message body was read-only, calling this method leaves the message body in the same state as an empty * header values or property entries.
* body in a newly created message. * <P>
* If this message body was read-only, calling this method leaves the
* message body in the same state as an empty body in a newly created
* message.
*/ */
public void clearBody() throws JMSException { public void clearBody() throws JMSException {
super.clearBody(); super.clearBody();
@ -167,7 +188,8 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>boolean</CODE> * @param name the name of the <CODE>boolean</CODE>
* @return the <CODE>boolean</CODE> value with the specified name * @return the <CODE>boolean</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public boolean getBoolean(String name) throws JMSException { public boolean getBoolean(String name) throws JMSException {
@ -191,7 +213,8 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>byte</CODE> * @param name the name of the <CODE>byte</CODE>
* @return the <CODE>byte</CODE> value with the specified name * @return the <CODE>byte</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public byte getByte(String name) throws JMSException { public byte getByte(String name) throws JMSException {
@ -215,7 +238,8 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>short</CODE> * @param name the name of the <CODE>short</CODE>
* @return the <CODE>short</CODE> value with the specified name * @return the <CODE>short</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public short getShort(String name) throws JMSException { public short getShort(String name) throws JMSException {
@ -242,7 +266,8 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the Unicode character * @param name the name of the Unicode character
* @return the Unicode character value with the specified name * @return the Unicode character value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public char getChar(String name) throws JMSException { public char getChar(String name) throws JMSException {
@ -263,7 +288,8 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>int</CODE> * @param name the name of the <CODE>int</CODE>
* @return the <CODE>int</CODE> value with the specified name * @return the <CODE>int</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public int getInt(String name) throws JMSException { public int getInt(String name) throws JMSException {
@ -293,7 +319,8 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>long</CODE> * @param name the name of the <CODE>long</CODE>
* @return the <CODE>long</CODE> value with the specified name * @return the <CODE>long</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public long getLong(String name) throws JMSException { public long getLong(String name) throws JMSException {
@ -326,7 +353,8 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>float</CODE> * @param name the name of the <CODE>float</CODE>
* @return the <CODE>float</CODE> value with the specified name * @return the <CODE>float</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public float getFloat(String name) throws JMSException { public float getFloat(String name) throws JMSException {
@ -350,7 +378,8 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>double</CODE> * @param name the name of the <CODE>double</CODE>
* @return the <CODE>double</CODE> value with the specified name * @return the <CODE>double</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public double getDouble(String name) throws JMSException { public double getDouble(String name) throws JMSException {
@ -376,9 +405,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* Returns the <CODE>String</CODE> value with the specified name. * Returns the <CODE>String</CODE> value with the specified name.
* *
* @param name the name of the <CODE>String</CODE> * @param name the name of the <CODE>String</CODE>
* @return the <CODE>String</CODE> value with the specified name; if there is no item by this name, a null value is * @return the <CODE>String</CODE> value with the specified name; if there
* returned * is no item by this name, a null value is returned
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public String getString(String name) throws JMSException { public String getString(String name) throws JMSException {
@ -398,9 +428,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* Returns the byte array value with the specified name. * Returns the byte array value with the specified name.
* *
* @param name the name of the byte array * @param name the name of the byte array
* @return a copy of the byte array value with the specified name; if there is no item by this name, a null value is * @return a copy of the byte array value with the specified name; if there
* returned. * is no item by this name, a null value is returned.
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid. * @throws MessageFormatException if this type conversion is invalid.
*/ */
public byte[] getBytes(String name) throws JMSException { public byte[] getBytes(String name) throws JMSException {
@ -414,16 +445,23 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
} }
/** /**
* Returns the value of the object with the specified name. <P> This method can be used to return, in objectified * Returns the value of the object with the specified name.
* format, an object in the Java programming language ("Java object") that had been stored in the Map with the * <P>
* equivalent <CODE>setObject</CODE> method call, or its equivalent primitive <CODE>set <I>type </I></CODE> method. * This method can be used to return, in objectified format, an object in
* <P> Note that byte values are returned as <CODE>byte[]</CODE>, not <CODE>Byte[]</CODE>. * the Java programming language ("Java object") that had been stored in the
* Map with the equivalent <CODE>setObject</CODE> method call, or its
* equivalent primitive <CODE>set <I>type </I></CODE> method.
* <P>
* Note that byte values are returned as <CODE>byte[]</CODE>, not
* <CODE>Byte[]</CODE>.
* *
* @param name the name of the Java object * @param name the name of the Java object
* @return a copy of the Java object value with the specified name, in objectified format (for example, if the * @return a copy of the Java object value with the specified name, in
* object was set as an <CODE>int</CODE>, an <CODE>Integer</CODE> is returned); if there is no item by this * objectified format (for example, if the object was set as an
* name, a null value is returned * <CODE>int</CODE>, an <CODE>Integer</CODE> is returned); if
* @throws JMSException if the JMS provider fails to read the message due to some internal error. * there is no item by this name, a null value is returned
* @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
*/ */
public Object getObject(String name) throws JMSException { public Object getObject(String name) throws JMSException {
initializeReading(); initializeReading();
@ -431,7 +469,8 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
} }
/** /**
* Returns an <CODE>Enumeration</CODE> of all the names in the <CODE>MapMessage</CODE> object. * Returns an <CODE>Enumeration</CODE> of all the names in the
* <CODE>MapMessage</CODE> object.
* *
* @return an enumeration of all the names in this <CODE>MapMessage</CODE> * @return an enumeration of all the names in this <CODE>MapMessage</CODE>
* @throws JMSException * @throws JMSException
@ -456,8 +495,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>boolean</CODE> * @param name the name of the <CODE>boolean</CODE>
* @param value the <CODE>boolean</CODE> value to set in the Map * @param value the <CODE>boolean</CODE> value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setBoolean(String name, boolean value) throws JMSException { public void setBoolean(String name, boolean value) throws JMSException {
@ -470,8 +511,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>byte</CODE> * @param name the name of the <CODE>byte</CODE>
* @param value the <CODE>byte</CODE> value to set in the Map * @param value the <CODE>byte</CODE> value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setByte(String name, byte value) throws JMSException { public void setByte(String name, byte value) throws JMSException {
@ -484,8 +527,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>short</CODE> * @param name the name of the <CODE>short</CODE>
* @param value the <CODE>short</CODE> value to set in the Map * @param value the <CODE>short</CODE> value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setShort(String name, short value) throws JMSException { public void setShort(String name, short value) throws JMSException {
@ -498,8 +543,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the Unicode character * @param name the name of the Unicode character
* @param value the Unicode character value to set in the Map * @param value the Unicode character value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setChar(String name, char value) throws JMSException { public void setChar(String name, char value) throws JMSException {
@ -512,8 +559,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>int</CODE> * @param name the name of the <CODE>int</CODE>
* @param value the <CODE>int</CODE> value to set in the Map * @param value the <CODE>int</CODE> value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setInt(String name, int value) throws JMSException { public void setInt(String name, int value) throws JMSException {
@ -526,8 +575,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>long</CODE> * @param name the name of the <CODE>long</CODE>
* @param value the <CODE>long</CODE> value to set in the Map * @param value the <CODE>long</CODE> value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setLong(String name, long value) throws JMSException { public void setLong(String name, long value) throws JMSException {
@ -540,8 +591,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>float</CODE> * @param name the name of the <CODE>float</CODE>
* @param value the <CODE>float</CODE> value to set in the Map * @param value the <CODE>float</CODE> value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setFloat(String name, float value) throws JMSException { public void setFloat(String name, float value) throws JMSException {
@ -554,8 +607,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>double</CODE> * @param name the name of the <CODE>double</CODE>
* @param value the <CODE>double</CODE> value to set in the Map * @param value the <CODE>double</CODE> value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setDouble(String name, double value) throws JMSException { public void setDouble(String name, double value) throws JMSException {
@ -568,8 +623,10 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* *
* @param name the name of the <CODE>String</CODE> * @param name the name of the <CODE>String</CODE>
* @param value the <CODE>String</CODE> value to set in the Map * @param value the <CODE>String</CODE> value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setString(String name, String value) throws JMSException { public void setString(String name, String value) throws JMSException {
@ -581,10 +638,13 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* Sets a byte array value with the specified name into the Map. * Sets a byte array value with the specified name into the Map.
* *
* @param name the name of the byte array * @param name the name of the byte array
* @param value the byte array value to set in the Map; the array is copied so that the value for <CODE>name </CODE> * @param value the byte array value to set in the Map; the array is copied
* will not be altered by future modifications * so that the value for <CODE>name </CODE> will not be
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * altered by future modifications
* @throws NullPointerException if the name is null, or if the name is an empty string. * @throws JMSException if the JMS provider fails to write the message due
* to some internal error.
* @throws NullPointerException if the name is null, or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setBytes(String name, byte[] value) throws JMSException { public void setBytes(String name, byte[] value) throws JMSException {
@ -597,14 +657,17 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
} }
/** /**
* Sets a portion of the byte array value with the specified name into the Map. * Sets a portion of the byte array value with the specified name into the
* Map.
* *
* @param name the name of the byte array * @param name the name of the byte array
* @param value the byte array value to set in the Map * @param value the byte array value to set in the Map
* @param offset the initial offset within the byte array * @param offset the initial offset within the byte array
* @param length the number of bytes to use * @param length the number of bytes to use
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
public void setBytes(String name, byte[] value, int offset, int length) throws JMSException { public void setBytes(String name, byte[] value, int offset, int length) throws JMSException {
@ -615,14 +678,18 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
} }
/** /**
* Sets an object value with the specified name into the Map. <P> This method works only for the objectified * Sets an object value with the specified name into the Map.
* primitive object types (<code>Integer</code>,<code>Double</code>, <code>Long</code> &nbsp;...), * <P>
* <code>String</code> objects, and byte arrays. * This method works only for the objectified primitive object types (<code>Integer</code>,<code>Double</code>,
* <code>Long</code> &nbsp;...), <code>String</code> objects, and byte
* arrays.
* *
* @param name the name of the Java object * @param name the name of the Java object
* @param value the Java object value to set in the Map * @param value the Java object value to set in the Map
* @throws JMSException if the JMS provider fails to write the message due to some internal error. * @throws JMSException if the JMS provider fails to write the message due
* @throws IllegalArgumentException if the name is null or if the name is an empty string. * to some internal error.
* @throws IllegalArgumentException if the name is null or if the name is an
* empty string.
* @throws MessageFormatException if the object is invalid. * @throws MessageFormatException if the object is invalid.
* @throws MessageNotWriteableException if the message is in read-only mode. * @throws MessageNotWriteableException if the message is in read-only mode.
*/ */
@ -640,11 +707,13 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
} }
/** /**
* Indicates whether an item exists in this <CODE>MapMessage</CODE> object. * Indicates whether an item exists in this <CODE>MapMessage</CODE>
* object.
* *
* @param name the name of the item to test * @param name the name of the item to test
* @return true if the item exists * @return true if the item exists
* @throws JMSException if the JMS provider fails to determine if the item exists due to some internal error. * @throws JMSException if the JMS provider fails to determine if the item
* exists due to some internal error.
*/ */
public boolean itemExists(String name) throws JMSException { public boolean itemExists(String name) throws JMSException {
initializeReading(); initializeReading();
@ -661,9 +730,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
} }
public String toString() { public String toString() {
return super.toString() + " ActiveMQMapMessage{ " + return super.toString() + " ActiveMQMapMessage{ " + "theTable = " + map + " }";
"theTable = " + map +
" }";
} }
public Map getContentMap() throws JMSException { public Map getContentMap() throws JMSException {

View File

@ -17,9 +17,6 @@
package org.apache.activemq.command; package org.apache.activemq.command;
import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.util.ByteArrayInputStream; import org.apache.activemq.util.ByteArrayInputStream;
import org.apache.activemq.util.ByteArrayOutputStream; import org.apache.activemq.util.ByteArrayOutputStream;
@ -40,16 +37,20 @@ import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream; import java.util.zip.InflaterInputStream;
/** /**
* An <CODE>ObjectMessage</CODE> object is used to send a message that contains a serializable object in the Java * An <CODE>ObjectMessage</CODE> object is used to send a message that
* programming language ("Java object"). It inherits from the <CODE>Message</CODE> interface and adds a body containing * contains a serializable object in the Java programming language ("Java
* a single reference to an object. Only <CODE>Serializable</CODE> Java objects can be used. * object"). It inherits from the <CODE>Message</CODE> interface and adds a
* <p/> * body containing a single reference to an object. Only
* <P>If a collection of Java objects must be sent, one of the <CODE>Collection</CODE> classes provided since JDK 1.2 * <CODE>Serializable</CODE> Java objects can be used. <p/>
* can be used. * <P>
* <p/> * If a collection of Java objects must be sent, one of the
* <P>When a client receives an <CODE>ObjectMessage</CODE>, it is in read-only mode. If a client attempts to write to * <CODE>Collection</CODE> classes provided since JDK 1.2 can be used. <p/>
* the message at this point, a <CODE>MessageNotWriteableException</CODE> is thrown. If <CODE>clearBody</CODE> is * <P>
* called, the message can now be both read from and written to. * When a client receives an <CODE>ObjectMessage</CODE>, it is in read-only
* mode. If a client attempts to write to the message at this point, a
* <CODE>MessageNotWriteableException</CODE> is thrown. If
* <CODE>clearBody</CODE> is called, the message can now be both read from and
* written to.
* *
* @openwire:marshaller code="26" * @openwire:marshaller code="26"
* @see javax.jms.Session#createObjectMessage() * @see javax.jms.Session#createObjectMessage()
@ -61,7 +62,9 @@ import java.util.zip.InflaterInputStream;
* @see javax.jms.TextMessage * @see javax.jms.TextMessage
*/ */
public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMessage { public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMessage {
static final ClassLoader ACTIVEMQ_CLASSLOADER = ActiveMQObjectMessage.class.getClassLoader(); //TODO verify classloader static final ClassLoader ACTIVEMQ_CLASSLOADER = ActiveMQObjectMessage.class.getClassLoader(); // TODO
// verify
// classloader
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_OBJECT_MESSAGE; public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_OBJECT_MESSAGE;
protected transient Serializable object; protected transient Serializable object;
@ -110,14 +113,16 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
return "jms/object-message"; return "jms/object-message";
} }
/** /**
* Clears out the message body. Clearing a message's body does not clear its header values or property entries. * Clears out the message body. Clearing a message's body does not clear its
* <p/> * header values or property entries. <p/>
* <P>If this message body was read-only, calling this method leaves the message body in the same state as an empty * <P>
* body in a newly created message. * If this message body was read-only, calling this method leaves the
* message body in the same state as an empty body in a newly created
* message.
* *
* @throws JMSException if the JMS provider fails to clear the message body due to some internal error. * @throws JMSException if the JMS provider fails to clear the message body
* due to some internal error.
*/ */
public void clearBody() throws JMSException { public void clearBody() throws JMSException {
@ -126,16 +131,18 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
} }
/** /**
* Sets the serializable object containing this message's data. It is important to note that an * Sets the serializable object containing this message's data. It is
* <CODE>ObjectMessage</CODE> contains a snapshot of the object at the time <CODE>setObject()</CODE> is called; * important to note that an <CODE>ObjectMessage</CODE> contains a
* subsequent modifications of the object will have no effect on the <CODE>ObjectMessage</CODE> body. * snapshot of the object at the time <CODE>setObject()</CODE> is called;
* subsequent modifications of the object will have no effect on the
* <CODE>ObjectMessage</CODE> body.
* *
* @param newObject the message's data * @param newObject the message's data
* @throws JMSException if the JMS provider fails to set the object due to some internal error. * @throws JMSException if the JMS provider fails to set the object due to
* @throws javax.jms.MessageFormatException * some internal error.
* if object serialization fails. * @throws javax.jms.MessageFormatException if object serialization fails.
* @throws javax.jms.MessageNotWriteableException * @throws javax.jms.MessageNotWriteableException if the message is in
* if the message is in read-only mode. * read-only mode.
*/ */
public void setObject(Serializable newObject) throws JMSException { public void setObject(Serializable newObject) throws JMSException {
@ -148,9 +155,9 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
} }
} }
/** /**
* Gets the serializable object containing this message's data. The default value is null. * Gets the serializable object containing this message's data. The default
* value is null.
* *
* @return the serializable object containing this message's data * @return the serializable object containing this message's data
* @throws JMSException * @throws JMSException
@ -181,7 +188,8 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
public void onMessageRolledBack() { public void onMessageRolledBack() {
super.onMessageRolledBack(); super.onMessageRolledBack();
// lets force the object to be deserialized again - as we could have changed the object // lets force the object to be deserialized again - as we could have
// changed the object
object = null; object = null;
} }

View File

@ -21,7 +21,8 @@ import javax.jms.Queue;
/** /**
* *
* @org.apache.xbean.XBean element="queue" description="An ActiveMQ Queue Destination" * @org.apache.xbean.XBean element="queue" description="An ActiveMQ Queue
* Destination"
* *
* @openwire:marshaller code="100" * @openwire:marshaller code="100"
* @version $Revision: 1.5 $ * @version $Revision: 1.5 $

View File

@ -1130,8 +1130,9 @@ public class ActiveMQStreamMessage extends ActiveMQMessage implements StreamMess
checkWriteOnlyBody(); checkWriteOnlyBody();
if (this.dataIn == null) { if (this.dataIn == null) {
ByteSequence data = getContent(); ByteSequence data = getContent();
if (data == null) if (data == null) {
data = new ByteSequence(new byte[] {}, 0, 0); data = new ByteSequence(new byte[] {}, 0, 0);
}
InputStream is = new ByteArrayInputStream(data); InputStream is = new ByteArrayInputStream(data);
if (isCompressed()) { if (isCompressed()) {
is = new InflaterInputStream(is); is = new InflaterInputStream(is);

View File

@ -39,7 +39,6 @@ public class ActiveMQTempTopic extends ActiveMQTempDestination implements Tempor
super(connectionId.getValue(), sequenceId); super(connectionId.getValue(), sequenceId);
} }
public byte getDataStructureType() { public byte getDataStructureType() {
return DATA_STRUCTURE_TYPE; return DATA_STRUCTURE_TYPE;
} }

View File

@ -138,8 +138,9 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
public int getSize() { public int getSize() {
if (size == 0 && content == null && text != null) { if (size == 0 && content == null && text != null) {
size = AVERAGE_MESSAGE_SIZE_OVERHEAD; size = AVERAGE_MESSAGE_SIZE_OVERHEAD;
if (marshalledProperties != null) if (marshalledProperties != null) {
size += marshalledProperties.getLength(); size += marshalledProperties.getLength();
}
size = text.length() * 2; size = text.length() * 2;
} }
return super.getSize(); return super.getSize();

View File

@ -37,10 +37,12 @@ public class BrokerId implements DataStructure {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) if (this == o) {
return true; return true;
if (o == null || o.getClass() != BrokerId.class) }
if (o == null || o.getClass() != BrokerId.class) {
return false; return false;
}
BrokerId id = (BrokerId)o; BrokerId id = (BrokerId)o;
return value.equals(id.value); return value.equals(id.value);
} }

View File

@ -18,7 +18,6 @@ package org.apache.activemq.command;
import org.apache.activemq.state.CommandVisitor; import org.apache.activemq.state.CommandVisitor;
/** /**
* *
* @openwire:marshaller code="16" * @openwire:marshaller code="16"
@ -56,6 +55,7 @@ public class ConnectionError extends BaseCommand {
public ConnectionId getConnectionId() { public ConnectionId getConnectionId() {
return connectionId; return connectionId;
} }
public void setConnectionId(ConnectionId connectionId) { public void setConnectionId(ConnectionId connectionId) {
this.connectionId = connectionId; this.connectionId = connectionId;
} }

View File

@ -18,7 +18,6 @@ package org.apache.activemq.command;
import org.apache.activemq.state.CommandVisitor; import org.apache.activemq.state.CommandVisitor;
/** /**
* *
* @openwire:marshaller code="3" * @openwire:marshaller code="3"
@ -40,6 +39,7 @@ public class ConnectionInfo extends BaseCommand {
public ConnectionInfo() { public ConnectionInfo() {
} }
public ConnectionInfo(ConnectionId connectionId) { public ConnectionInfo(ConnectionId connectionId) {
this.connectionId = connectionId; this.connectionId = connectionId;
} }
@ -64,6 +64,7 @@ public class ConnectionInfo extends BaseCommand {
public ConnectionId getConnectionId() { public ConnectionId getConnectionId() {
return connectionId; return connectionId;
} }
public void setConnectionId(ConnectionId connectionId) { public void setConnectionId(ConnectionId connectionId) {
this.connectionId = connectionId; this.connectionId = connectionId;
} }
@ -74,6 +75,7 @@ public class ConnectionInfo extends BaseCommand {
public String getClientId() { public String getClientId() {
return clientId; return clientId;
} }
public void setClientId(String clientId) { public void setClientId(String clientId) {
this.clientId = clientId; this.clientId = clientId;
} }
@ -90,6 +92,7 @@ public class ConnectionInfo extends BaseCommand {
public String getPassword() { public String getPassword() {
return password; return password;
} }
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
@ -100,6 +103,7 @@ public class ConnectionInfo extends BaseCommand {
public String getUserName() { public String getUserName() {
return userName; return userName;
} }
public void setUserName(String userName) { public void setUserName(String userName) {
this.userName = userName; this.userName = userName;
} }
@ -112,6 +116,7 @@ public class ConnectionInfo extends BaseCommand {
public BrokerId[] getBrokerPath() { public BrokerId[] getBrokerPath() {
return brokerPath; return brokerPath;
} }
public void setBrokerPath(BrokerId[] brokerPath) { public void setBrokerPath(BrokerId[] brokerPath) {
this.brokerPath = brokerPath; this.brokerPath = brokerPath;
} }
@ -119,24 +124,28 @@ public class ConnectionInfo extends BaseCommand {
public Response visit(CommandVisitor visitor) throws Exception { public Response visit(CommandVisitor visitor) throws Exception {
return visitor.processAddConnection(this); return visitor.processAddConnection(this);
} }
/** /**
* @openwire:property version=1 * @openwire:property version=1
*/ */
public boolean isBrokerMasterConnector() { public boolean isBrokerMasterConnector() {
return brokerMasterConnector; return brokerMasterConnector;
} }
/** /**
* @param brokerMasterConnector The brokerMasterConnector to set. * @param brokerMasterConnector The brokerMasterConnector to set.
*/ */
public void setBrokerMasterConnector(boolean slaveBroker) { public void setBrokerMasterConnector(boolean slaveBroker) {
this.brokerMasterConnector = slaveBroker; this.brokerMasterConnector = slaveBroker;
} }
/** /**
* @openwire:property version=1 * @openwire:property version=1
*/ */
public boolean isManageable() { public boolean isManageable() {
return manageable; return manageable;
} }
/** /**
* @param manageable The manageable to set. * @param manageable The manageable to set.
*/ */
@ -146,8 +155,8 @@ public class ConnectionInfo extends BaseCommand {
/** /**
* Transports may wish to associate additional data with the connection. For * Transports may wish to associate additional data with the connection. For
* example, an SSL transport may use this field to attach the client certificates * example, an SSL transport may use this field to attach the client
* used when the conection was established. * certificates used when the conection was established.
* *
* @return the transport context. * @return the transport context.
*/ */
@ -157,8 +166,8 @@ public class ConnectionInfo extends BaseCommand {
/** /**
* Transports may wish to associate additional data with the connection. For * Transports may wish to associate additional data with the connection. For
* example, an SSL transport may use this field to attach the client certificates * example, an SSL transport may use this field to attach the client
* used when the conection was established. * certificates used when the conection was established.
* *
* @param transportContext value used to set the transport context * @param transportContext value used to set the transport context
*/ */

View File

@ -46,12 +46,15 @@ public class ConsumerInfo extends BaseCommand {
protected byte priority; protected byte priority;
protected BrokerId[] brokerPath; protected BrokerId[] brokerPath;
protected boolean optimizedAcknowledge; protected boolean optimizedAcknowledge;
protected transient int currentPrefetchSize;// used by the broker // used by the broker
protected boolean noRangeAcks; // if true, the consumer will not send range protected transient int currentPrefetchSize;
// if true, the consumer will not send range
protected boolean noRangeAcks;
// acks. // acks.
protected BooleanExpression additionalPredicate; protected BooleanExpression additionalPredicate;
protected transient boolean networkSubscription; // this subscription protected transient boolean networkSubscription; // this subscription
// originated from a // originated from a
// network connection // network connection

View File

@ -29,6 +29,7 @@ public class DataResponse extends Response {
public DataResponse() { public DataResponse() {
} }
public DataResponse(DataStructure data) { public DataResponse(DataStructure data) {
this.data = data; this.data = data;
} }
@ -43,6 +44,7 @@ public class DataResponse extends Response {
public DataStructure getData() { public DataStructure getData() {
return data; return data;
} }
public void setData(DataStructure data) { public void setData(DataStructure data) {
this.data = data; this.data = data;
} }

View File

@ -18,7 +18,6 @@ package org.apache.activemq.command;
import org.apache.activemq.state.CommandVisitor; import org.apache.activemq.state.CommandVisitor;
/** /**
* *
* @openwire:marshaller code="21" * @openwire:marshaller code="21"
@ -51,6 +50,7 @@ public class MessageDispatch extends BaseCommand {
public ConsumerId getConsumerId() { public ConsumerId getConsumerId() {
return consumerId; return consumerId;
} }
public void setConsumerId(ConsumerId consumerId) { public void setConsumerId(ConsumerId consumerId) {
this.consumerId = consumerId; this.consumerId = consumerId;
} }
@ -61,6 +61,7 @@ public class MessageDispatch extends BaseCommand {
public ActiveMQDestination getDestination() { public ActiveMQDestination getDestination() {
return destination; return destination;
} }
public void setDestination(ActiveMQDestination destination) { public void setDestination(ActiveMQDestination destination) {
this.destination = destination; this.destination = destination;
} }
@ -71,6 +72,7 @@ public class MessageDispatch extends BaseCommand {
public Message getMessage() { public Message getMessage() {
return message; return message;
} }
public void setMessage(Message message) { public void setMessage(Message message) {
this.message = message; this.message = message;
} }
@ -78,6 +80,7 @@ public class MessageDispatch extends BaseCommand {
public long getDeliverySequenceId() { public long getDeliverySequenceId() {
return deliverySequenceId; return deliverySequenceId;
} }
public void setDeliverySequenceId(long deliverySequenceId) { public void setDeliverySequenceId(long deliverySequenceId) {
this.deliverySequenceId = deliverySequenceId; this.deliverySequenceId = deliverySequenceId;
} }
@ -88,6 +91,7 @@ public class MessageDispatch extends BaseCommand {
public int getRedeliveryCounter() { public int getRedeliveryCounter() {
return redeliveryCounter; return redeliveryCounter;
} }
public void setRedeliveryCounter(int deliveryCounter) { public void setRedeliveryCounter(int deliveryCounter) {
this.redeliveryCounter = deliveryCounter; this.redeliveryCounter = deliveryCounter;
} }

View File

@ -66,6 +66,7 @@ public class ProducerInfo extends BaseCommand {
public ProducerId getProducerId() { public ProducerId getProducerId() {
return producerId; return producerId;
} }
public void setProducerId(ProducerId producerId) { public void setProducerId(ProducerId producerId) {
this.producerId = producerId; this.producerId = producerId;
} }
@ -76,6 +77,7 @@ public class ProducerInfo extends BaseCommand {
public ActiveMQDestination getDestination() { public ActiveMQDestination getDestination() {
return destination; return destination;
} }
public void setDestination(ActiveMQDestination destination) { public void setDestination(ActiveMQDestination destination) {
this.destination = destination; this.destination = destination;
} }
@ -94,6 +96,7 @@ public class ProducerInfo extends BaseCommand {
public BrokerId[] getBrokerPath() { public BrokerId[] getBrokerPath() {
return brokerPath; return brokerPath;
} }
public void setBrokerPath(BrokerId[] brokerPath) { public void setBrokerPath(BrokerId[] brokerPath) {
this.brokerPath = brokerPath; this.brokerPath = brokerPath;
} }
@ -103,9 +106,9 @@ public class ProducerInfo extends BaseCommand {
} }
/** /**
* If the broker should dispatch messages from this producer async. Since sync * If the broker should dispatch messages from this producer async. Since
* dispatch could potentally block the producer thread, this could be an important * sync dispatch could potentally block the producer thread, this could be
* setting for the producer. * an important setting for the producer.
* *
* @openwire:property version=2 * @openwire:property version=2
*/ */
@ -118,9 +121,9 @@ public class ProducerInfo extends BaseCommand {
} }
/** /**
* Used to configure the producer window size. A producer will * Used to configure the producer window size. A producer will send up to
* send up to the configured window size worth of payload data to * the configured window size worth of payload data to the broker before
* the broker before waiting for an Ack that allows him to send more. * waiting for an Ack that allows him to send more.
* *
* @openwire:property version=3 * @openwire:property version=3
*/ */

View File

@ -38,6 +38,7 @@ public class RemoveInfo extends BaseCommand {
public RemoveInfo() { public RemoveInfo() {
} }
public RemoveInfo(DataStructure objectId) { public RemoveInfo(DataStructure objectId) {
this.objectId = objectId; this.objectId = objectId;
} }

View File

@ -75,8 +75,7 @@ public class SessionId implements DataStructure {
if (o == null || o.getClass() != SessionId.class) if (o == null || o.getClass() != SessionId.class)
return false; return false;
SessionId id = (SessionId)o; SessionId id = (SessionId)o;
return value==id.value return value == id.value && connectionId.equals(id.connectionId);
&& connectionId.equals(id.connectionId);
} }
public byte getDataStructureType() { public byte getDataStructureType() {
@ -89,6 +88,7 @@ public class SessionId implements DataStructure {
public String getConnectionId() { public String getConnectionId() {
return connectionId; return connectionId;
} }
public void setConnectionId(String connectionId) { public void setConnectionId(String connectionId) {
this.connectionId = connectionId; this.connectionId = connectionId;
} }
@ -99,6 +99,7 @@ public class SessionId implements DataStructure {
public long getValue() { public long getValue() {
return value; return value;
} }
public void setValue(long sessionId) { public void setValue(long sessionId) {
this.value = sessionId; this.value = sessionId;
} }

View File

@ -51,6 +51,7 @@ public class SessionInfo extends BaseCommand {
public SessionId getSessionId() { public SessionId getSessionId() {
return sessionId; return sessionId;
} }
public void setSessionId(SessionId sessionId) { public void setSessionId(SessionId sessionId) {
this.sessionId = sessionId; this.sessionId = sessionId;
} }

View File

@ -39,5 +39,4 @@ public class ShutdownInfo extends BaseCommand {
return true; return true;
} }
} }

View File

@ -18,7 +18,6 @@ package org.apache.activemq.command;
import org.apache.activemq.util.IntrospectionSupport; import org.apache.activemq.util.IntrospectionSupport;
/** /**
* Used to represent a durable subscription. * Used to represent a durable subscription.
* *
@ -51,8 +50,8 @@ public class SubscriptionInfo implements DataStructure {
} }
/** /**
* This is the a resolved destination that the subscription is receiving messages from. * This is the a resolved destination that the subscription is receiving
* This will never be a pattern or a composite destination. * messages from. This will never be a pattern or a composite destination.
* *
* @openwire:property version=1 cache=true * @openwire:property version=1 cache=true
*/ */
@ -84,8 +83,8 @@ public class SubscriptionInfo implements DataStructure {
} }
/** /**
* @param subscriptionName * @param subscriptionName *
* * @deprecated * @deprecated
*/ */
public void setSubcriptionName(String subscriptionName) { public void setSubcriptionName(String subscriptionName) {
this.subscriptionName = subscriptionName; this.subscriptionName = subscriptionName;
@ -117,19 +116,24 @@ public class SubscriptionInfo implements DataStructure {
boolean result = false; boolean result = false;
if (obj instanceof SubscriptionInfo) { if (obj instanceof SubscriptionInfo) {
SubscriptionInfo other = (SubscriptionInfo)obj; SubscriptionInfo other = (SubscriptionInfo)obj;
result=(clientId==null&&other.clientId==null||clientId!=null&&other.clientId!=null result = (clientId == null && other.clientId == null || clientId != null
&& other.clientId != null
&& clientId.equals(other.clientId)) && clientId.equals(other.clientId))
&& (subscriptionName == null && other.subscriptionName == null || subscriptionName != null && (subscriptionName == null && other.subscriptionName == null || subscriptionName != null
&&other.subscriptionName!=null&&subscriptionName.equals(other.subscriptionName)); && other.subscriptionName != null
&& subscriptionName
.equals(other.subscriptionName));
} }
return result; return result;
} }
/** /**
* The destination the client originally subscribed to.. This may not match the {@see getDestination} method * The destination the client originally subscribed to.. This may not match
* if the subscribed destination uses patterns or composites. * the {@see getDestination} method if the subscribed destination uses
* patterns or composites.
* *
* If the subscribed destinationis not set, this just ruturns the desitination. * If the subscribed destinationis not set, this just ruturns the
* desitination.
* *
* @openwire:property version=3 * @openwire:property version=3
*/ */

View File

@ -29,7 +29,6 @@ public class TransactionInfo extends BaseCommand {
public static final byte DATA_STRUCTURE_TYPE = CommandTypes.TRANSACTION_INFO; public static final byte DATA_STRUCTURE_TYPE = CommandTypes.TRANSACTION_INFO;
public static final byte BEGIN = 0; public static final byte BEGIN = 0;
public static final byte PREPARE = 1; public static final byte PREPARE = 1;
public static final byte COMMIT_ONE_PHASE = 2; public static final byte COMMIT_ONE_PHASE = 2;
@ -62,6 +61,7 @@ public class TransactionInfo extends BaseCommand {
public ConnectionId getConnectionId() { public ConnectionId getConnectionId() {
return connectionId; return connectionId;
} }
public void setConnectionId(ConnectionId connectionId) { public void setConnectionId(ConnectionId connectionId) {
this.connectionId = connectionId; this.connectionId = connectionId;
} }
@ -72,6 +72,7 @@ public class TransactionInfo extends BaseCommand {
public TransactionId getTransactionId() { public TransactionId getTransactionId() {
return transactionId; return transactionId;
} }
public void setTransactionId(TransactionId transactionId) { public void setTransactionId(TransactionId transactionId) {
this.transactionId = transactionId; this.transactionId = transactionId;
} }
@ -82,6 +83,7 @@ public class TransactionInfo extends BaseCommand {
public byte getType() { public byte getType() {
return type; return type;
} }
public void setType(byte type) { public void setType(byte type) {
this.type = type; this.type = type;
} }

View File

@ -68,6 +68,7 @@ public class WireFormatInfo implements Command, MarshallAware {
public byte[] getMagic() { public byte[] getMagic() {
return magic; return magic;
} }
public void setMagic(byte[] magic) { public void setMagic(byte[] magic) {
this.magic = magic; this.magic = magic;
} }
@ -78,6 +79,7 @@ public class WireFormatInfo implements Command, MarshallAware {
public int getVersion() { public int getVersion() {
return version; return version;
} }
public void setVersion(int version) { public void setVersion(int version) {
this.version = version; this.version = version;
} }
@ -88,6 +90,7 @@ public class WireFormatInfo implements Command, MarshallAware {
public ByteSequence getMarshalledProperties() { public ByteSequence getMarshalledProperties() {
return marshalledProperties; return marshalledProperties;
} }
public void setMarshalledProperties(ByteSequence marshalledProperties) { public void setMarshalledProperties(ByteSequence marshalledProperties) {
this.marshalledProperties = marshalledProperties; this.marshalledProperties = marshalledProperties;
} }
@ -104,7 +107,8 @@ public class WireFormatInfo implements Command, MarshallAware {
} }
/** /**
* 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.
*/ */
public Endpoint getTo() { public Endpoint getTo() {
return to; return to;
@ -160,7 +164,9 @@ public class WireFormatInfo implements Command, MarshallAware {
} }
private Map unmarsallProperties(ByteSequence marshalledProperties) throws IOException { private Map unmarsallProperties(ByteSequence marshalledProperties) throws IOException {
return MarshallingSupport.unmarshalPrimitiveMap(new DataInputStream(new ByteArrayInputStream(marshalledProperties)), MAX_PROPERTY_SIZE); return MarshallingSupport
.unmarshalPrimitiveMap(new DataInputStream(new ByteArrayInputStream(marshalledProperties)),
MAX_PROPERTY_SIZE);
} }
public void beforeMarshall(WireFormat wireFormat) throws IOException { public void beforeMarshall(WireFormat wireFormat) throws IOException {
@ -183,7 +189,6 @@ public class WireFormatInfo implements Command, MarshallAware {
public void afterUnmarshall(WireFormat wireFormat) throws IOException { public void afterUnmarshall(WireFormat wireFormat) throws IOException {
} }
public boolean isValid() { public boolean isValid() {
return magic != null && Arrays.equals(magic, MAGIC); return magic != null && Arrays.equals(magic, MAGIC);
} }
@ -197,6 +202,7 @@ public class WireFormatInfo implements Command, MarshallAware {
public boolean isCacheEnabled() throws IOException { public boolean isCacheEnabled() throws IOException {
return Boolean.TRUE == getProperty("CacheEnabled"); return Boolean.TRUE == getProperty("CacheEnabled");
} }
public void setCacheEnabled(boolean cacheEnabled) throws IOException { public void setCacheEnabled(boolean cacheEnabled) throws IOException {
setProperty("CacheEnabled", cacheEnabled ? Boolean.TRUE : Boolean.FALSE); setProperty("CacheEnabled", cacheEnabled ? Boolean.TRUE : Boolean.FALSE);
} }
@ -207,6 +213,7 @@ public class WireFormatInfo implements Command, MarshallAware {
public boolean isStackTraceEnabled() throws IOException { public boolean isStackTraceEnabled() throws IOException {
return Boolean.TRUE == getProperty("StackTraceEnabled"); return Boolean.TRUE == getProperty("StackTraceEnabled");
} }
public void setStackTraceEnabled(boolean stackTraceEnabled) throws IOException { public void setStackTraceEnabled(boolean stackTraceEnabled) throws IOException {
setProperty("StackTraceEnabled", stackTraceEnabled ? Boolean.TRUE : Boolean.FALSE); setProperty("StackTraceEnabled", stackTraceEnabled ? Boolean.TRUE : Boolean.FALSE);
} }
@ -217,6 +224,7 @@ public class WireFormatInfo implements Command, MarshallAware {
public boolean isTcpNoDelayEnabled() throws IOException { public boolean isTcpNoDelayEnabled() throws IOException {
return Boolean.TRUE == getProperty("TcpNoDelayEnabled"); return Boolean.TRUE == getProperty("TcpNoDelayEnabled");
} }
public void setTcpNoDelayEnabled(boolean tcpNoDelayEnabled) throws IOException { public void setTcpNoDelayEnabled(boolean tcpNoDelayEnabled) throws IOException {
setProperty("TcpNoDelayEnabled", tcpNoDelayEnabled ? Boolean.TRUE : Boolean.FALSE); setProperty("TcpNoDelayEnabled", tcpNoDelayEnabled ? Boolean.TRUE : Boolean.FALSE);
} }
@ -227,6 +235,7 @@ public class WireFormatInfo implements Command, MarshallAware {
public boolean isSizePrefixDisabled() throws IOException { public boolean isSizePrefixDisabled() throws IOException {
return Boolean.TRUE == getProperty("SizePrefixDisabled"); return Boolean.TRUE == getProperty("SizePrefixDisabled");
} }
public void setSizePrefixDisabled(boolean prefixPacketSize) throws IOException { public void setSizePrefixDisabled(boolean prefixPacketSize) throws IOException {
setProperty("SizePrefixDisabled", prefixPacketSize ? Boolean.TRUE : Boolean.FALSE); setProperty("SizePrefixDisabled", prefixPacketSize ? Boolean.TRUE : Boolean.FALSE);
} }
@ -237,6 +246,7 @@ public class WireFormatInfo implements Command, MarshallAware {
public boolean isTightEncodingEnabled() throws IOException { public boolean isTightEncodingEnabled() throws IOException {
return Boolean.TRUE == getProperty("TightEncodingEnabled"); return Boolean.TRUE == getProperty("TightEncodingEnabled");
} }
public void setTightEncodingEnabled(boolean tightEncodingEnabled) throws IOException { public void setTightEncodingEnabled(boolean tightEncodingEnabled) throws IOException {
setProperty("TightEncodingEnabled", tightEncodingEnabled ? Boolean.TRUE : Boolean.FALSE); setProperty("TightEncodingEnabled", tightEncodingEnabled ? Boolean.TRUE : Boolean.FALSE);
} }
@ -248,6 +258,7 @@ public class WireFormatInfo implements Command, MarshallAware {
Long l = (Long)getProperty("MaxInactivityDuration"); Long l = (Long)getProperty("MaxInactivityDuration");
return l == null ? 0 : l.longValue(); return l == null ? 0 : l.longValue();
} }
public void seMaxInactivityDuration(long maxInactivityDuration) throws IOException { public void seMaxInactivityDuration(long maxInactivityDuration) throws IOException {
setProperty("MaxInactivityDuration", new Long(maxInactivityDuration)); setProperty("MaxInactivityDuration", new Long(maxInactivityDuration));
} }
@ -259,11 +270,11 @@ public class WireFormatInfo implements Command, MarshallAware {
Integer i = (Integer)getProperty("CacheSize"); Integer i = (Integer)getProperty("CacheSize");
return i == null ? 0 : i.intValue(); return i == null ? 0 : i.intValue();
} }
public void setCacheSize(int cacheSize) throws IOException { public void setCacheSize(int cacheSize) throws IOException {
setProperty("CacheSize", new Integer(cacheSize)); setProperty("CacheSize", new Integer(cacheSize));
} }
public Response visit(CommandVisitor visitor) throws Exception { public Response visit(CommandVisitor visitor) throws Exception {
return visitor.processWireFormat(this); return visitor.processWireFormat(this);
} }
@ -274,7 +285,8 @@ public class WireFormatInfo implements Command, MarshallAware {
p = getProperties(); p = getProperties();
} catch (IOException e) { } catch (IOException e) {
} }
return "WireFormatInfo { version="+version+", properties="+p+", magic="+toString(magic)+"}"; return "WireFormatInfo { version=" + version + ", properties=" + p + ", magic=" + toString(magic)
+ "}";
} }
private String toString(byte[] data) { private String toString(byte[] data) {
@ -298,35 +310,46 @@ public class WireFormatInfo implements Command, MarshallAware {
public void setCommandId(int value) { public void setCommandId(int value) {
} }
public int getCommandId() { public int getCommandId() {
return 0; return 0;
} }
public boolean isResponseRequired() { public boolean isResponseRequired() {
return false; return false;
} }
public boolean isResponse() { public boolean isResponse() {
return false; return false;
} }
public boolean isBrokerInfo() { public boolean isBrokerInfo() {
return false; return false;
} }
public boolean isMessageDispatch() { public boolean isMessageDispatch() {
return false; return false;
} }
public boolean isMessage() { public boolean isMessage() {
return false; return false;
} }
public boolean isMessageAck() { public boolean isMessageAck() {
return false; return false;
} }
public boolean isMessageDispatchNotification() { public boolean isMessageDispatchNotification() {
return false; return false;
} }
public boolean isShutdownInfo() { public boolean isShutdownInfo() {
return false; return false;
} }
public void setCachedMarshalledForm(WireFormat wireFormat, ByteSequence data) { public void setCachedMarshalledForm(WireFormat wireFormat, ByteSequence data) {
} }
public ByteSequence getCachedMarshalledForm(WireFormat wireFormat) { public ByteSequence getCachedMarshalledForm(WireFormat wireFormat) {
return null; return null;
} }

View File

@ -20,7 +20,6 @@ import java.util.Arrays;
import javax.transaction.xa.Xid; import javax.transaction.xa.Xid;
import org.apache.activemq.util.HexSupport; import org.apache.activemq.util.HexSupport;
/** /**
* @openwire:marshaller code="112" * @openwire:marshaller code="112"
* @version $Revision: 1.6 $ * @version $Revision: 1.6 $

View File

@ -44,8 +44,7 @@ public abstract class ArithmeticExpression extends BinaryExpression {
String text = (String)lvalue; String text = (String)lvalue;
String answer = text + rvalue; String answer = text + rvalue;
return answer; return answer;
} } else if (lvalue instanceof Number) {
else if (lvalue instanceof Number) {
return plus((Number)lvalue, asNumber(rvalue)); return plus((Number)lvalue, asNumber(rvalue));
} }
throw new RuntimeException("Cannot call plus operation on: " + lvalue + " and: " + rvalue); throw new RuntimeException("Cannot call plus operation on: " + lvalue + " and: " + rvalue);
@ -164,11 +163,9 @@ public abstract class ArithmeticExpression extends BinaryExpression {
private int numberType(Number left, Number right) { private int numberType(Number left, Number right) {
if (isDouble(left) || isDouble(right)) { if (isDouble(left) || isDouble(right)) {
return DOUBLE; return DOUBLE;
} } else if (left instanceof Long || right instanceof Long) {
else if (left instanceof Long || right instanceof Long) {
return LONG; return LONG;
} } else {
else {
return INTEGER; return INTEGER;
} }
} }
@ -180,8 +177,7 @@ public abstract class ArithmeticExpression extends BinaryExpression {
protected Number asNumber(Object value) { protected Number asNumber(Object value) {
if (value instanceof Number) { if (value instanceof Number) {
return (Number)value; return (Number)value;
} } else {
else {
throw new RuntimeException("Cannot convert value: " + value + " into a number"); throw new RuntimeException("Cannot convert value: " + value + " into a number");
} }
} }
@ -198,7 +194,6 @@ public abstract class ArithmeticExpression extends BinaryExpression {
return evaluate(lvalue, rvalue); return evaluate(lvalue, rvalue);
} }
/** /**
* @param lvalue * @param lvalue
* @param rvalue * @param rvalue

View File

@ -30,7 +30,8 @@ import javax.jms.JMSException;
public abstract class ComparisonExpression extends BinaryExpression implements BooleanExpression { public abstract class ComparisonExpression extends BinaryExpression implements BooleanExpression {
public static BooleanExpression createBetween(Expression value, Expression left, Expression 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) { public static BooleanExpression createNotBetween(Expression value, Expression left, Expression right) {
@ -86,18 +87,14 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
char t = like.charAt(i); char t = like.charAt(i);
regexp.append("\\x"); regexp.append("\\x");
regexp.append(Integer.toHexString(0xFFFF & t)); regexp.append(Integer.toHexString(0xFFFF & t));
} } else if (c == '%') {
else if (c == '%') {
regexp.append(".*?"); // Do a non-greedy match regexp.append(".*?"); // Do a non-greedy match
} } else if (c == '_') {
else if (c == '_') {
regexp.append("."); // match one regexp.append("."); // match one
} } else if (REGEXP_CONTROL_CHARS.contains(new Character(c))) {
else if (REGEXP_CONTROL_CHARS.contains(new Character(c))) {
regexp.append("\\x"); regexp.append("\\x");
regexp.append(Integer.toHexString(0xFFFF & c)); regexp.append(Integer.toHexString(0xFFFF & c));
} } else {
else {
regexp.append(c); regexp.append(c);
} }
} }
@ -126,7 +123,8 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
if (!(rv instanceof String)) { if (!(rv instanceof String)) {
return Boolean.FALSE; return Boolean.FALSE;
//throw new RuntimeException("LIKE can only operate on String identifiers. LIKE attemped on: '" + rv.getClass()); // throw new RuntimeException("LIKE can only operate on String
// identifiers. LIKE attemped on: '" + rv.getClass());
} }
return likePattern.matcher((String)rv).matches() ? Boolean.TRUE : Boolean.FALSE; return likePattern.matcher((String)rv).matches() ? Boolean.TRUE : Boolean.FALSE;
@ -140,7 +138,9 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
public static BooleanExpression createLike(Expression left, String right, String escape) { public static BooleanExpression createLike(Expression left, String right, String escape) {
if (escape != null && escape.length() != 1) { 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; int c = -1;
if (escape != null) { if (escape != null) {
@ -298,8 +298,8 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
} }
/** /**
* Validates that the expression can be used in == or <> expression. * Validates that the expression can be used in == or <> expression. Cannot
* Cannot not be NULL TRUE or FALSE litterals. * not be NULL TRUE or FALSE litterals.
* *
* @param expr * @param expr
*/ */
@ -323,8 +323,6 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
} }
} }
/** /**
* @param left * @param left
* @param right * @param right
@ -354,95 +352,70 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
if (lc == Byte.class) { if (lc == Byte.class) {
if (rc == Short.class) { if (rc == Short.class) {
lv = Short.valueOf(((Number)lv).shortValue()); lv = Short.valueOf(((Number)lv).shortValue());
} } else if (rc == Integer.class) {
else if (rc == Integer.class) {
lv = Integer.valueOf(((Number)lv).intValue()); lv = Integer.valueOf(((Number)lv).intValue());
} } else if (rc == Long.class) {
else if (rc == Long.class) {
lv = Long.valueOf(((Number)lv).longValue()); lv = Long.valueOf(((Number)lv).longValue());
} } else if (rc == Float.class) {
else if (rc == Float.class) {
lv = new Float(((Number)lv).floatValue()); lv = new Float(((Number)lv).floatValue());
} } else if (rc == Double.class) {
else if (rc == Double.class) {
lv = new Double(((Number)lv).doubleValue()); lv = new Double(((Number)lv).doubleValue());
} } else {
else {
return Boolean.FALSE; return Boolean.FALSE;
} }
} else if (lc == Short.class) { } else if (lc == Short.class) {
if (rc == Integer.class) { if (rc == Integer.class) {
lv = Integer.valueOf(((Number)lv).intValue()); lv = Integer.valueOf(((Number)lv).intValue());
} } else if (rc == Long.class) {
else if (rc == Long.class) {
lv = Long.valueOf(((Number)lv).longValue()); lv = Long.valueOf(((Number)lv).longValue());
} } else if (rc == Float.class) {
else if (rc == Float.class) {
lv = new Float(((Number)lv).floatValue()); lv = new Float(((Number)lv).floatValue());
} } else if (rc == Double.class) {
else if (rc == Double.class) {
lv = new Double(((Number)lv).doubleValue()); lv = new Double(((Number)lv).doubleValue());
} } else {
else {
return Boolean.FALSE; return Boolean.FALSE;
} }
} else if (lc == Integer.class) { } else if (lc == Integer.class) {
if (rc == Long.class) { if (rc == Long.class) {
lv = Long.valueOf(((Number)lv).longValue()); lv = Long.valueOf(((Number)lv).longValue());
} } else if (rc == Float.class) {
else if (rc == Float.class) {
lv = new Float(((Number)lv).floatValue()); lv = new Float(((Number)lv).floatValue());
} } else if (rc == Double.class) {
else if (rc == Double.class) {
lv = new Double(((Number)lv).doubleValue()); lv = new Double(((Number)lv).doubleValue());
} } else {
else {
return Boolean.FALSE; return Boolean.FALSE;
} }
} } else if (lc == Long.class) {
else if (lc == Long.class) {
if (rc == Integer.class) { if (rc == Integer.class) {
rv = Long.valueOf(((Number)rv).longValue()); rv = Long.valueOf(((Number)rv).longValue());
} } else if (rc == Float.class) {
else if (rc == Float.class) {
lv = new Float(((Number)lv).floatValue()); lv = new Float(((Number)lv).floatValue());
} } else if (rc == Double.class) {
else if (rc == Double.class) {
lv = new Double(((Number)lv).doubleValue()); lv = new Double(((Number)lv).doubleValue());
} } else {
else {
return Boolean.FALSE; return Boolean.FALSE;
} }
} } else if (lc == Float.class) {
else if (lc == Float.class) {
if (rc == Integer.class) { if (rc == Integer.class) {
rv = new Float(((Number)rv).floatValue()); rv = new Float(((Number)rv).floatValue());
} } else if (rc == Long.class) {
else if (rc == Long.class) {
rv = new Float(((Number)rv).floatValue()); rv = new Float(((Number)rv).floatValue());
} } else if (rc == Double.class) {
else if (rc == Double.class) {
lv = new Double(((Number)lv).doubleValue()); lv = new Double(((Number)lv).doubleValue());
} } else {
else {
return Boolean.FALSE; return Boolean.FALSE;
} }
} } else if (lc == Double.class) {
else if (lc == Double.class) {
if (rc == Integer.class) { if (rc == Integer.class) {
rv = new Double(((Number)rv).doubleValue()); rv = new Double(((Number)rv).doubleValue());
} } else if (rc == Long.class) {
else if (rc == Long.class) {
rv = new Double(((Number)rv).doubleValue()); rv = new Double(((Number)rv).doubleValue());
} } else if (rc == Float.class) {
else if (rc == Float.class) {
rv = new Float(((Number)rv).doubleValue()); rv = new Float(((Number)rv).doubleValue());
} } else {
else {
return Boolean.FALSE; return Boolean.FALSE;
} }
} } else
else
return Boolean.FALSE; return Boolean.FALSE;
} }
return asBoolean(lv.compareTo(rv)) ? Boolean.TRUE : Boolean.FALSE; return asBoolean(lv.compareTo(rv)) ? Boolean.TRUE : Boolean.FALSE;

View File

@ -31,6 +31,7 @@ public class ConstantExpression implements Expression {
public BooleanConstantExpression(Object value) { public BooleanConstantExpression(Object value) {
super(value); super(value);
} }
public boolean matches(MessageEvaluationContext message) throws JMSException { public boolean matches(MessageEvaluationContext message) throws JMSException {
Object object = evaluate(message); Object object = evaluate(message);
return object != null && object == Boolean.TRUE; return object != null && object == Boolean.TRUE;
@ -138,10 +139,9 @@ public class ConstantExpression implements Expression {
} }
/** /**
* Encodes the value of string so that it looks like it would look like * Encodes the value of string so that it looks like it would look like when
* when it was provided in a selector. * it was provided in a selector.
* *
* @param string * @param string
* @return * @return

View File

@ -24,7 +24,6 @@ import javax.jms.JMSException;
import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.util.JMSExceptionSupport; import org.apache.activemq.util.JMSExceptionSupport;
/** /**
* Represents a filter which only operates on Destinations * Represents a filter which only operates on Destinations
* *
@ -61,8 +60,7 @@ public abstract class DestinationFilter implements BooleanExpression {
String lastPath = paths[idx]; String lastPath = paths[idx];
if (lastPath.equals(ANY_DESCENDENT)) { if (lastPath.equals(ANY_DESCENDENT)) {
return new PrefixDestinationFilter(paths); return new PrefixDestinationFilter(paths);
} } else {
else {
while (idx >= 0) { while (idx >= 0) {
lastPath = paths[idx--]; lastPath = paths[idx--];
if (lastPath.equals(ANY_CHILD)) { if (lastPath.equals(ANY_CHILD)) {

View File

@ -46,8 +46,7 @@ public class DestinationMapNode implements DestinationNode {
this.parent = parent; this.parent = parent;
if (parent == null) { if (parent == null) {
pathLength = 0; pathLength = 0;
} } else {
else {
pathLength = parent.pathLength + 1; pathLength = parent.pathLength + 1;
} }
} }
@ -94,7 +93,6 @@ public class DestinationMapNode implements DestinationNode {
// } // }
// return anyChild; // return anyChild;
// } // }
/** /**
* Returns a mutable List of the values available at this node in the tree * Returns a mutable List of the values available at this node in the tree
*/ */
@ -113,7 +111,6 @@ public class DestinationMapNode implements DestinationNode {
return v; return v;
} }
public Set removeDesendentValues() { public Set removeDesendentValues() {
Set answer = new HashSet(); Set answer = new HashSet();
removeDesendentValues(answer); removeDesendentValues(answer);
@ -139,8 +136,7 @@ public class DestinationMapNode implements DestinationNode {
public void add(String[] paths, int idx, Object value) { public void add(String[] paths, int idx, Object value) {
if (idx >= paths.length) { if (idx >= paths.length) {
values.add(value); values.add(value);
} } else {
else {
// if (idx == paths.length - 1) { // if (idx == paths.length - 1) {
// getAnyChildNode().getValues().add(value); // getAnyChildNode().getValues().add(value);
// } // }
@ -155,8 +151,7 @@ public class DestinationMapNode implements DestinationNode {
if (idx >= paths.length) { if (idx >= paths.length) {
values.remove(value); values.remove(value);
pruneIfEmpty(); pruneIfEmpty();
} } else {
else {
// if (idx == paths.length - 1) { // if (idx == paths.length - 1) {
// getAnyChildNode().getValues().remove(value); // getAnyChildNode().getValues().remove(value);
// } // }
@ -181,8 +176,7 @@ public class DestinationMapNode implements DestinationNode {
if (path.equals(ANY_CHILD)) { if (path.equals(ANY_CHILD)) {
// node = node.getAnyChildNode(); // node = node.getAnyChildNode();
node = new AnyChildDestinationNode(node); node = new AnyChildDestinationNode(node);
} } else {
else {
node = node.getChild(path); node = node.getChild(path);
} }
} }
@ -191,7 +185,6 @@ public class DestinationMapNode implements DestinationNode {
answer.addAll(node.removeValues()); answer.addAll(node.removeValues());
} }
} }
public void appendDescendantValues(Set answer) { public void appendDescendantValues(Set answer) {
@ -247,11 +240,9 @@ public class DestinationMapNode implements DestinationNode {
node.appendMatchingWildcards(answer, paths, i); node.appendMatchingWildcards(answer, paths, i);
if (path.equals(ANY_CHILD)) { if (path.equals(ANY_CHILD)) {
node = new AnyChildDestinationNode(node); node = new AnyChildDestinationNode(node);
} } else {
else {
node = node.getChild(path); node = node.getChild(path);
} }
} }

View File

@ -69,7 +69,8 @@ public class PropertyExpression implements Expression {
JMS_PROPERTY_EXPRESSIONS.put("JMSDeliveryMode", new SubExpression() { JMS_PROPERTY_EXPRESSIONS.put("JMSDeliveryMode", new SubExpression() {
public Object evaluate(Message message) { public Object evaluate(Message message) {
return Integer.valueOf(message.isPersistent()?DeliveryMode.PERSISTENT:DeliveryMode.NON_PERSISTENT); return Integer.valueOf(message.isPersistent()
? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
} }
}); });
JMS_PROPERTY_EXPRESSIONS.put("JMSPriority", new SubExpression() { JMS_PROPERTY_EXPRESSIONS.put("JMSPriority", new SubExpression() {
@ -171,7 +172,8 @@ public class PropertyExpression implements Expression {
try { try {
return message.getMessage().getProperty(name); return message.getMessage().getProperty(name);
} catch (IOException ioe) { } catch (IOException ioe) {
throw JMSExceptionSupport.create("Could not get property: "+name+" reason: "+ioe.getMessage(), ioe); throw JMSExceptionSupport.create("Could not get property: " + name + " reason: "
+ ioe.getMessage(), ioe);
} }
} catch (IOException e) { } catch (IOException e) {
throw JMSExceptionSupport.create(e); throw JMSExceptionSupport.create(e);
@ -193,7 +195,6 @@ public class PropertyExpression implements Expression {
return name; return name;
} }
/** /**
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */

View File

@ -53,7 +53,8 @@ public abstract class UnaryExpression implements Expression {
}; };
} }
public static BooleanExpression createInExpression(PropertyExpression right, List elements, final boolean not) { public static BooleanExpression createInExpression(PropertyExpression right, List elements,
final boolean not) {
// Use a HashSet if there are many elements. // Use a HashSet if there are many elements.
Collection t; Collection t;
@ -125,7 +126,6 @@ public abstract class UnaryExpression implements Expression {
} }
}; };
public static BooleanExpression createNOT(BooleanExpression left) { public static BooleanExpression createNOT(BooleanExpression left) {
return new BooleanUnaryExpression(left) { return new BooleanUnaryExpression(left) {
public Object evaluate(MessageEvaluationContext message) throws JMSException { public Object evaluate(MessageEvaluationContext message) throws JMSException {
@ -175,20 +175,19 @@ public abstract class UnaryExpression implements Expression {
Class clazz = left.getClass(); Class clazz = left.getClass();
if (clazz == Integer.class) { if (clazz == Integer.class) {
return new Integer(-left.intValue()); return new Integer(-left.intValue());
} } else if (clazz == Long.class) {
else if (clazz == Long.class) {
return new Long(-left.longValue()); return new Long(-left.longValue());
} } else if (clazz == Float.class) {
else if (clazz == Float.class) {
return new Float(-left.floatValue()); return new Float(-left.floatValue());
} } else if (clazz == Double.class) {
else if (clazz == Double.class) {
return new Double(-left.doubleValue()); return new Double(-left.doubleValue());
} } else if (clazz == BigDecimal.class) {
else if (clazz == BigDecimal.class) { // We ussually get a big deciamal when we have Long.MIN_VALUE
// We ussually get a big deciamal when we have Long.MIN_VALUE constant in the // constant in the
// Selector. Long.MIN_VALUE is too big to store in a Long as a positive so we store it // Selector. Long.MIN_VALUE is too big to store in a Long as a
// as a Big decimal. But it gets Negated right away.. to here we try to covert it back // positive so we store it
// as a Big decimal. But it gets Negated right away.. to here we try
// to covert it back
// to a Long. // to a Long.
BigDecimal bd = (BigDecimal)left; BigDecimal bd = (BigDecimal)left;
bd = bd.negate(); bd = bd.negate();
@ -197,8 +196,7 @@ public abstract class UnaryExpression implements Expression {
return Long.valueOf(Long.MIN_VALUE); return Long.valueOf(Long.MIN_VALUE);
} }
return bd; return bd;
} } else {
else {
throw new RuntimeException("Don't know how to negate: " + left); throw new RuntimeException("Don't know how to negate: " + left);
} }
} }
@ -246,8 +244,8 @@ public abstract class UnaryExpression implements Expression {
} }
/** /**
* Returns the symbol that represents this binary expression. For example, addition is * Returns the symbol that represents this binary expression. For example,
* represented by "+" * addition is represented by "+"
* *
* @return * @return
*/ */

View File

@ -45,7 +45,8 @@ public final class XPathExpression implements BooleanExpression {
try { try {
m = getXPathEvaluatorConstructor(cn); m = getXPathEvaluatorConstructor(cn);
} catch (Throwable e) { } catch (Throwable e) {
log.warn("Invalid "+XPathEvaluator.class.getName()+" implementation: "+cn+", reason: "+e,e); log.warn("Invalid " + XPathEvaluator.class.getName() + " implementation: " + cn
+ ", reason: " + e, e);
cn = DEFAULT_EVALUATOR_CLASS_NAME; cn = DEFAULT_EVALUATOR_CLASS_NAME;
try { try {
m = getXPathEvaluatorConstructor(cn); m = getXPathEvaluatorConstructor(cn);
@ -58,7 +59,8 @@ public final class XPathExpression implements BooleanExpression {
} }
} }
private static Constructor getXPathEvaluatorConstructor(String cn) throws ClassNotFoundException, SecurityException, NoSuchMethodException { private static Constructor getXPathEvaluatorConstructor(String cn) throws ClassNotFoundException,
SecurityException, NoSuchMethodException {
Class c = XPathExpression.class.getClassLoader().loadClass(cn); Class c = XPathExpression.class.getClassLoader().loadClass(cn);
if (!XPathEvaluator.class.isAssignableFrom(c)) { if (!XPathEvaluator.class.isAssignableFrom(c)) {
throw new ClassCastException("" + c + " is not an instance of " + XPathEvaluator.class); throw new ClassCastException("" + c + " is not an instance of " + XPathEvaluator.class);

View File

@ -81,7 +81,8 @@ public class XalanXPathEvaluator implements XPathExpression.XPathEvaluator {
DocumentBuilder dbuilder = factory.newDocumentBuilder(); DocumentBuilder dbuilder = factory.newDocumentBuilder();
Document doc = dbuilder.parse(inputSource); Document doc = dbuilder.parse(inputSource);
// We should associated the cachedXPathAPI object with the message being evaluated // We should associated the cachedXPathAPI object with the message
// being evaluated
// since that should speedup subsequent xpath expressions. // since that should speedup subsequent xpath expressions.
CachedXPathAPI cachedXPathAPI = new CachedXPathAPI(); CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath); NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath);

View File

@ -40,18 +40,19 @@ import org.apache.activemq.command.ActiveMQTopic;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
* A factory of the ActiveMQ InitialContext which contains {@link ConnectionFactory} * A factory of the ActiveMQ InitialContext which contains
* instances as well as a child context called <i>destinations</i> which contain all of the * {@link ConnectionFactory} instances as well as a child context called
* current active destinations, in child context depending on the QoS such as * <i>destinations</i> which contain all of the current active destinations, in
* transient or durable and queue or topic. * child context depending on the QoS such as transient or durable and queue or
* topic.
* *
* @version $Revision: 1.2 $ * @version $Revision: 1.2 $
*/ */
public class ActiveMQInitialContextFactory implements InitialContextFactory { public class ActiveMQInitialContextFactory implements InitialContextFactory {
private static final String[] defaultConnectionFactoryNames = { private static final String[] defaultConnectionFactoryNames = {"ConnectionFactory",
"ConnectionFactory", "QueueConnectionFactory", "TopicConnectionFactory" "QueueConnectionFactory",
}; "TopicConnectionFactory"};
private String connectionPrefix = "connection."; private String connectionPrefix = "connection.";
private String queuePrefix = "queue."; private String queuePrefix = "queue.";
@ -71,14 +72,10 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
throw new NamingException("Invalid broker URL"); throw new NamingException("Invalid broker URL");
} }
/* if( broker==null ) { /*
try { * if( broker==null ) { try { broker = factory.getEmbeddedBroker(); }
broker = factory.getEmbeddedBroker(); * catch (JMSException e) { log.warn("Failed to get embedded
} * broker", e); } }
catch (JMSException e) {
log.warn("Failed to get embedded broker", e);
}
}
*/ */
data.put(name, factory); data.put(name, factory);
} }
@ -86,9 +83,8 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
createQueues(data, environment); createQueues(data, environment);
createTopics(data, environment); createTopics(data, environment);
/* /*
if (broker != null) { * if (broker != null) { data.put("destinations",
data.put("destinations", broker.getDestinationContext(environment)); * broker.getDestinationContext(environment)); }
}
*/ */
data.put("dynamicQueues", new LazyCreateContext() { data.put("dynamicQueues", new LazyCreateContext() {
private static final long serialVersionUID = 6503881346214855588L; private static final long serialVersionUID = 6503881346214855588L;
@ -133,7 +129,8 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
return new ReadOnlyContext(environment, data); return new ReadOnlyContext(environment, data);
} }
protected ActiveMQConnectionFactory createConnectionFactory(String name, Hashtable environment) throws URISyntaxException { protected ActiveMQConnectionFactory createConnectionFactory(String name, Hashtable environment)
throws URISyntaxException {
Hashtable temp = new Hashtable(environment); Hashtable temp = new Hashtable(environment);
String prefix = connectionPrefix + name + "."; String prefix = connectionPrefix + name + ".";
for (Iterator iter = environment.entrySet().iterator(); iter.hasNext();) { for (Iterator iter = environment.entrySet().iterator(); iter.hasNext();) {
@ -153,7 +150,8 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
String factoryNames = (String)environment.get("connectionFactoryNames"); String factoryNames = (String)environment.get("connectionFactoryNames");
if (factoryNames != null) { if (factoryNames != null) {
List list = new ArrayList(); List list = new ArrayList();
for (StringTokenizer enumeration = new StringTokenizer(factoryNames, ","); enumeration.hasMoreTokens();) { for (StringTokenizer enumeration = new StringTokenizer(factoryNames, ","); enumeration
.hasMoreTokens();) {
list.add(enumeration.nextToken().trim()); list.add(enumeration.nextToken().trim());
} }
int size = list.size(); int size = list.size();
@ -203,9 +201,11 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
} }
/** /**
* Factory method to create a new connection factory from the given environment * Factory method to create a new connection factory from the given
* environment
*/ */
protected ActiveMQConnectionFactory createConnectionFactory(Hashtable environment) throws URISyntaxException { protected ActiveMQConnectionFactory createConnectionFactory(Hashtable environment)
throws URISyntaxException {
ActiveMQConnectionFactory answer = new ActiveMQConnectionFactory(); ActiveMQConnectionFactory answer = new ActiveMQConnectionFactory();
Properties properties = new Properties(); Properties properties = new Properties();
properties.putAll(environment); properties.putAll(environment);
@ -217,7 +217,6 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
return connectionPrefix; return connectionPrefix;
} }
public void setConnectionPrefix(String connectionPrefix) { public void setConnectionPrefix(String connectionPrefix) {
this.connectionPrefix = connectionPrefix; this.connectionPrefix = connectionPrefix;
} }

View File

@ -19,6 +19,7 @@ package org.apache.activemq.kaha;
import java.io.DataInput; import java.io.DataInput;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
/** /**
* Implementation of a Marshaller for byte arrays * Implementation of a Marshaller for byte arrays
* *

View File

@ -20,6 +20,7 @@ import java.io.Externalizable;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInput; import java.io.ObjectInput;
import java.io.ObjectOutput; import java.io.ObjectOutput;
/** /**
* Used by RootContainers * Used by RootContainers
* *
@ -38,7 +39,6 @@ public class ContainerId implements Externalizable{
this.dataContainerName = dataContainerName; this.dataContainerName = dataContainerName;
} }
/** /**
* @return Returns the dataContainerPrefix. * @return Returns the dataContainerPrefix.
*/ */

View File

@ -18,16 +18,17 @@ import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
/** /**
* Represents a container of persistent objects in the store Acts as a map, but values can be retrieved in insertion * Represents a container of persistent objects in the store Acts as a map, but
* order * values can be retrieved in insertion order
* *
* @version $Revision: 1.2 $ * @version $Revision: 1.2 $
*/ */
public interface ListContainer<V> extends List<V> { public interface ListContainer<V> extends List<V> {
/** /**
* The container is created or retrieved in an unloaded state. load populates the container will all the indexes * The container is created or retrieved in an unloaded state. load
* used etc and should be called before any operations on the container * populates the container will all the indexes used etc and should be
* called before any operations on the container
*/ */
public void load(); public void load();
@ -43,7 +44,8 @@ public interface ListContainer<V> extends List<V>{
public boolean isLoaded(); public boolean isLoaded();
/** /**
* For homogenous containers can set a custom marshaller for loading values The default uses Object serialization * For homogenous containers can set a custom marshaller for loading values
* The default uses Object serialization
* *
* @param marshaller * @param marshaller
*/ */
@ -67,8 +69,8 @@ public interface ListContainer<V> extends List<V>{
public void addFirst(V o); public void addFirst(V o);
/** /**
* Appends the given element to the end of this list. (Identical in function to the <tt>add</tt> method; included * Appends the given element to the end of this list. (Identical in function
* only for consistency.) * to the <tt>add</tt> method; included only for consistency.)
* *
* @param o the element to be inserted at the end of this list. * @param o the element to be inserted at the end of this list.
*/ */
@ -91,7 +93,8 @@ public interface ListContainer<V> extends List<V>{
public V removeLast(); public V removeLast();
/** /**
* remove an objecr from the list without retrieving the old value from the store * remove an objecr from the list without retrieving the old value from the
* store
* *
* @param position * @param position
* @return true if successful * @return true if successful
@ -107,7 +110,8 @@ public interface ListContainer<V> extends List<V>{
public StoreEntry placeLast(V object); public StoreEntry placeLast(V object);
/** /**
* insert an Object in first position int the list but get a StoreEntry of its position * insert an Object in first position int the list but get a StoreEntry of
* its position
* *
* @param object * @param object
* @return the location in the Store * @return the location in the Store
@ -115,7 +119,8 @@ public interface ListContainer<V> extends List<V>{
public StoreEntry placeFirst(V object); public StoreEntry placeFirst(V object);
/** /**
* Advanced feature = must ensure the object written doesn't overwrite other objects in the container * Advanced feature = must ensure the object written doesn't overwrite other
* objects in the container
* *
* @param entry * @param entry
* @param object * @param object
@ -169,8 +174,9 @@ public interface ListContainer<V> extends List<V>{
public boolean remove(StoreEntry entry); public boolean remove(StoreEntry entry);
/** /**
* It's possible that a StoreEntry could be come stale * It's possible that a StoreEntry could be come stale this will return an
* this will return an upto date entry for the StoreEntry position * upto date entry for the StoreEntry position
*
* @param entry old entry * @param entry old entry
* @return a refreshed StoreEntry * @return a refreshed StoreEntry
*/ */

View File

@ -21,19 +21,17 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
*Represents a container of persistent objects in the store * Represents a container of persistent objects in the store Acts as a map, but
*Acts as a map, but values can be retrieved in insertion order * values can be retrieved in insertion order
* *
* @version $Revision: 1.2 $ * @version $Revision: 1.2 $
*/ */
public interface MapContainer<K, V> extends Map<K, V> { public interface MapContainer<K, V> extends Map<K, V> {
/** /**
* The container is created or retrieved in * The container is created or retrieved in an unloaded state. load
* an unloaded state. * populates the container will all the indexes used etc and should be
* load populates the container will all the indexes used etc * called before any operations on the container
* and should be called before any operations on the container
*/ */
public void load(); public void load();
@ -51,6 +49,7 @@ public interface MapContainer<K, V> extends Map<K, V>{
/** /**
* For homogenous containers can set a custom marshaller for loading keys * For homogenous containers can set a custom marshaller for loading keys
* The default uses Object serialization * The default uses Object serialization
*
* @param keyMarshaller * @param keyMarshaller
*/ */
public void setKeyMarshaller(Marshaller<K> keyMarshaller); public void setKeyMarshaller(Marshaller<K> keyMarshaller);
@ -58,10 +57,12 @@ public interface MapContainer<K, V> extends Map<K, V>{
/** /**
* For homogenous containers can set a custom marshaller for loading values * For homogenous containers can set a custom marshaller for loading values
* The default uses Object serialization * The default uses Object serialization
*
* @param valueMarshaller * @param valueMarshaller
*
*/ */
public void setValueMarshaller(Marshaller<V> valueMarshaller); public void setValueMarshaller(Marshaller<V> valueMarshaller);
/** /**
* @return the id the MapContainer was create with * @return the id the MapContainer was create with
*/ */
@ -85,12 +86,12 @@ public interface MapContainer<K, V> extends Map<K, V>{
/** /**
* Get the value associated with the key * Get the value associated with the key
*
* @param key * @param key
* @return the value associated with the key from the store * @return the value associated with the key from the store
*/ */
public V get(K key); public V get(K key);
/** /**
* @param o * @param o
* @return true if the MapContainer contains the value o * @return true if the MapContainer contains the value o
@ -99,6 +100,7 @@ public interface MapContainer<K, V> extends Map<K, V>{
/** /**
* Add add entries in the supplied Map * Add add entries in the supplied Map
*
* @param map * @param map
*/ */
public void putAll(Map<K, V> map); public void putAll(Map<K, V> map);
@ -109,29 +111,29 @@ public interface MapContainer<K, V> extends Map<K, V>{
public Set<K> keySet(); public Set<K> keySet();
/** /**
* @return a collection of all the values - the values will be lazily pulled out of the * @return a collection of all the values - the values will be lazily pulled
* store if iterated etc. * out of the store if iterated etc.
*/ */
public Collection<V> values(); public Collection<V> values();
/** /**
* @return a Set of all the Map.Entry instances - the values will be lazily pulled out of the * @return a Set of all the Map.Entry instances - the values will be lazily
* store if iterated etc. * pulled out of the store if iterated etc.
*/ */
public Set<Map.Entry<K, V>> entrySet(); public Set<Map.Entry<K, V>> entrySet();
/** /**
* Add an entry * Add an entry
*
* @param key * @param key
* @param value * @param value
* @return the old value for the key * @return the old value for the key
*/ */
public V put(K key, V value); public V put(K key, V value);
/** /**
* remove an entry associated with the key * remove an entry associated with the key
*
* @param key * @param key
* @return the old value assocaited with the key or null * @return the old value assocaited with the key or null
*/ */
@ -144,6 +146,7 @@ public interface MapContainer<K, V> extends Map<K, V>{
/** /**
* Add an entry to the Store Map * Add an entry to the Store Map
*
* @param key * @param key
* @param Value * @param Value
* @return the StoreEntry associated with the entry * @return the StoreEntry associated with the entry
@ -152,12 +155,14 @@ public interface MapContainer<K, V> extends Map<K, V>{
/** /**
* Remove an Entry from ther Map * Remove an Entry from ther Map
*
* @param entry * @param entry
*/ */
public void remove(StoreEntry entry); public void remove(StoreEntry entry);
/** /**
* Get the Key object from it's location * Get the Key object from it's location
*
* @param keyLocation * @param keyLocation
* @return the key for the entry * @return the key for the entry
*/ */
@ -165,12 +170,14 @@ public interface MapContainer<K, V> extends Map<K, V>{
/** /**
* Get the value from it's location * Get the value from it's location
*
* @param Valuelocation * @param Valuelocation
* @return the Object * @return the Object
*/ */
public V getValue(StoreEntry Valuelocation); public V getValue(StoreEntry Valuelocation);
/** Get the StoreEntry for the first value in the Map /**
* Get the StoreEntry for the first value in the Map
* *
* @return the first StoreEntry or null if the map is empty * @return the first StoreEntry or null if the map is empty
*/ */
@ -199,10 +206,10 @@ public interface MapContainer<K, V> extends Map<K, V>{
*/ */
public StoreEntry getPrevious(StoreEntry entry); public StoreEntry getPrevious(StoreEntry entry);
/** /**
* It's possible that a StoreEntry could be come stale * It's possible that a StoreEntry could be come stale this will return an
* this will return an upto date entry for the StoreEntry position * upto date entry for the StoreEntry position
*
* @param entry old entry * @param entry old entry
* @return a refreshed StoreEntry * @return a refreshed StoreEntry
*/ */
@ -210,6 +217,7 @@ public interface MapContainer<K, V> extends Map<K, V>{
/** /**
* Get the StoreEntry associated with the key * Get the StoreEntry associated with the key
*
* @param key * @param key
* @return the StoreEntry * @return the StoreEntry
*/ */

View File

@ -20,6 +20,7 @@ import java.io.DataInput;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import org.apache.activemq.command.MessageId; import org.apache.activemq.command.MessageId;
/** /**
* Implementation of a Marshaller for MessageIds * Implementation of a Marshaller for MessageIds
* *

View File

@ -16,7 +16,6 @@
*/ */
package org.apache.activemq.kaha; package org.apache.activemq.kaha;
/** /**
* Runtime exception for the Store * Runtime exception for the Store
* *
@ -25,7 +24,6 @@ package org.apache.activemq.kaha;
public class RuntimeStoreException extends RuntimeException { public class RuntimeStoreException extends RuntimeException {
private static final long serialVersionUID = 8807084681372365173L; private static final long serialVersionUID = 8807084681372365173L;
/** /**
@ -37,6 +35,7 @@ public class RuntimeStoreException extends RuntimeException{
/** /**
* Constructor * Constructor
*
* @param message * @param message
*/ */
public RuntimeStoreException(String message) { public RuntimeStoreException(String message) {
@ -45,6 +44,7 @@ public class RuntimeStoreException extends RuntimeException{
/** /**
* Constructor * Constructor
*
* @param message * @param message
* @param cause * @param cause
*/ */
@ -54,6 +54,7 @@ public class RuntimeStoreException extends RuntimeException{
/** /**
* Constructor * Constructor
*
* @param cause * @param cause
*/ */
public RuntimeStoreException(Throwable cause) { public RuntimeStoreException(Throwable cause) {

View File

@ -18,6 +18,7 @@ package org.apache.activemq.kaha;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.util.Set;
/** /**
* A Store is holds persistent containers * A Store is holds persistent containers
* *
@ -44,11 +45,11 @@ public interface Store{
*/ */
public final static Marshaller StringMarshaller = new StringMarshaller(); public final static Marshaller StringMarshaller = new StringMarshaller();
/** /**
* Command Marshaller * Command Marshaller
*/ */
public final static Marshaller CommandMarshaller = new CommandMarshaller(); public final static Marshaller CommandMarshaller = new CommandMarshaller();
/** /**
* close the store * close the store
* *
@ -98,7 +99,8 @@ public interface Store{
public boolean doesMapContainerExist(Object id, String containerName) throws IOException; public boolean doesMapContainerExist(Object id, String containerName) throws IOException;
/** /**
* Get a MapContainer with the given id - the MapContainer is created if needed * Get a MapContainer with the given id - the MapContainer is created if
* needed
* *
* @param id * @param id
* @return container for the associated id or null if it doesn't exist * @return container for the associated id or null if it doesn't exist
@ -107,7 +109,8 @@ public interface Store{
public MapContainer getMapContainer(Object id) throws IOException; public MapContainer getMapContainer(Object id) throws IOException;
/** /**
* Get a MapContainer with the given id - the MapContainer is created if needed * Get a MapContainer with the given id - the MapContainer is created if
* needed
* *
* @param id * @param id
* @param containerName * @param containerName
@ -117,7 +120,8 @@ public interface Store{
public MapContainer getMapContainer(Object id, String containerName) throws IOException; public MapContainer getMapContainer(Object id, String containerName) throws IOException;
/** /**
* Get a MapContainer with the given id - the MapContainer is created if needed * Get a MapContainer with the given id - the MapContainer is created if
* needed
* *
* @param id * @param id
* @param containerName * @param containerName
@ -125,7 +129,8 @@ public interface Store{
* @return container for the associated id or null if it doesn't exist * @return container for the associated id or null if it doesn't exist
* @throws IOException * @throws IOException
*/ */
public MapContainer getMapContainer(Object id,String containerName,boolean persistentIndex) throws IOException; public MapContainer getMapContainer(Object id, String containerName, boolean persistentIndex)
throws IOException;
/** /**
* delete a container from the default container * delete a container from the default container
@ -146,6 +151,7 @@ public interface Store{
/** /**
* Delete Map container * Delete Map container
*
* @param id * @param id
* @throws IOException * @throws IOException
*/ */
@ -206,7 +212,8 @@ public interface Store{
* @return container for the associated id or null if it doesn't exist * @return container for the associated id or null if it doesn't exist
* @throws IOException * @throws IOException
*/ */
public ListContainer getListContainer(Object id,String containerName,boolean persistentIndex) throws IOException; public ListContainer getListContainer(Object id, String containerName, boolean persistentIndex)
throws IOException;
/** /**
* delete a ListContainer from the default container * delete a ListContainer from the default container
@ -227,6 +234,7 @@ public interface Store{
/** /**
* delete a list container * delete a list container
*
* @param id * @param id
* @throws IOException * @throws IOException
*/ */
@ -258,6 +266,7 @@ public interface Store{
/** /**
* Set the default index type * Set the default index type
*
* @param type * @param type
* @see org.apache.activemq.kaha.IndexTypes * @see org.apache.activemq.kaha.IndexTypes
*/ */

View File

@ -27,9 +27,9 @@ import org.apache.activemq.kaha.impl.KahaStore;
*/ */
public class StoreFactory { public class StoreFactory {
/** /**
* open or create a Store * open or create a Store
*
* @param name * @param name
* @param mode * @param mode
* @return the opened/created store * @return the opened/created store
@ -41,6 +41,7 @@ public class StoreFactory{
/** /**
* Delete a database * Delete a database
*
* @param name of the database * @param name of the database
* @return true if successful * @return true if successful
* @throws IOException * @throws IOException

View File

@ -19,6 +19,7 @@ package org.apache.activemq.kaha;
import java.io.DataInput; import java.io.DataInput;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
/** /**
* Implementation of a Marshaller for Strings * Implementation of a Marshaller for Strings
* *

View File

@ -10,16 +10,13 @@ public interface DataManager {
String getName(); String getName();
Object readItem(Marshaller marshaller, StoreLocation item) Object readItem(Marshaller marshaller, StoreLocation item) throws IOException;
throws IOException;
StoreLocation storeDataItem(Marshaller marshaller, Object payload) StoreLocation storeDataItem(Marshaller marshaller, Object payload) throws IOException;
throws IOException;
StoreLocation storeRedoItem(Object payload) throws IOException; StoreLocation storeRedoItem(Object payload) throws IOException;
void updateItem(StoreLocation location, Marshaller marshaller, void updateItem(StoreLocation location, Marshaller marshaller, Object payload) throws IOException;
Object payload) throws IOException;
void recoverRedoItems(RedoListener listener) throws IOException; void recoverRedoItems(RedoListener listener) throws IOException;

View File

@ -49,7 +49,6 @@ class IndexRootContainer {
protected Map map = new ConcurrentHashMap(); protected Map map = new ConcurrentHashMap();
protected LinkedList list = new LinkedList(); protected LinkedList list = new LinkedList();
IndexRootContainer(IndexItem root, IndexManager im, DataManager dfm) throws IOException { IndexRootContainer(IndexItem root, IndexManager im, DataManager dfm) throws IOException {
this.root = root; this.root = root;
this.indexManager = im; this.indexManager = im;
@ -70,8 +69,6 @@ class IndexRootContainer {
return map.keySet(); return map.keySet();
} }
IndexItem addRoot(IndexManager containerIndexManager, ContainerId key) throws IOException { IndexItem addRoot(IndexManager containerIndexManager, ContainerId key) throws IOException {
if (map.containsKey(key)) { if (map.containsKey(key)) {
removeRoot(containerIndexManager, key); removeRoot(containerIndexManager, key);
@ -134,6 +131,4 @@ class IndexRootContainer {
return map.containsKey(key); return map.containsKey(key);
} }
} }

View File

@ -18,8 +18,6 @@ package org.apache.activemq.kaha.impl;
import java.io.IOException; import java.io.IOException;
/** /**
* Exception thrown if the store is in use by another application * Exception thrown if the store is in use by another application
* *

View File

@ -23,9 +23,10 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.activemq.kaha.impl.async.DataFileAppender.WriteCommand; import org.apache.activemq.kaha.impl.async.DataFileAppender.WriteCommand;
import org.apache.activemq.kaha.impl.async.DataFileAppender.WriteKey; import org.apache.activemq.kaha.impl.async.DataFileAppender.WriteKey;
import org.apache.activemq.util.ByteSequence; import org.apache.activemq.util.ByteSequence;
/** /**
* Optimized Store reader and updater. Single threaded and synchronous. Use in conjunction * Optimized Store reader and updater. Single threaded and synchronous. Use in
* with the DataFileAccessorPool of concurrent use. * conjunction with the DataFileAccessorPool of concurrent use.
* *
* @version $Revision: 1.1.1.1 $ * @version $Revision: 1.1.1.1 $
*/ */
@ -118,16 +119,16 @@ final class DataFileAccessor {
byte data[] = new byte[3]; byte data[] = new byte[3];
file.seek(location.getOffset() + AsyncDataManager.ITEM_HEAD_OFFSET_TO_SOR); file.seek(location.getOffset() + AsyncDataManager.ITEM_HEAD_OFFSET_TO_SOR);
file.readFully(data); file.readFully(data);
if( data[0] != AsyncDataManager.ITEM_HEAD_SOR[0] || if (data[0] != AsyncDataManager.ITEM_HEAD_SOR[0]
data[1] != AsyncDataManager.ITEM_HEAD_SOR[1] || || data[1] != AsyncDataManager.ITEM_HEAD_SOR[1]
data[2] != AsyncDataManager.ITEM_HEAD_SOR[2] ) { || data[2] != AsyncDataManager.ITEM_HEAD_SOR[2]) {
return false; return false;
} }
file.seek(location.getOffset() + location.getSize() - AsyncDataManager.ITEM_FOOT_SPACE); file.seek(location.getOffset() + location.getSize() - AsyncDataManager.ITEM_FOOT_SPACE);
file.readFully(data); file.readFully(data);
if( data[0] != AsyncDataManager.ITEM_HEAD_EOR[0] || if (data[0] != AsyncDataManager.ITEM_HEAD_EOR[0]
data[1] != AsyncDataManager.ITEM_HEAD_EOR[1] || || data[1] != AsyncDataManager.ITEM_HEAD_EOR[1]
data[2] != AsyncDataManager.ITEM_HEAD_EOR[2] ) { || data[2] != AsyncDataManager.ITEM_HEAD_EOR[2]) {
return false; return false;
} }
} }

View File

@ -27,8 +27,9 @@ import org.apache.activemq.util.DataByteArrayOutputStream;
import org.apache.activemq.util.LinkedNode; import org.apache.activemq.util.LinkedNode;
/** /**
* An optimized writer to do batch appends to a data file. This object is thread safe * An optimized writer to do batch appends to a data file. This object is thread
* and gains throughput as you increase the number of concurrent writes it does. * safe and gains throughput as you increase the number of concurrent writes it
* does.
* *
* @version $Revision: 1.1.1.1 $ * @version $Revision: 1.1.1.1 $
*/ */
@ -148,8 +149,10 @@ class DataFileAppender {
WriteBatch batch; WriteBatch batch;
WriteCommand write = new WriteCommand(location, data, sync); WriteCommand write = new WriteCommand(location, data, sync);
// Locate datafile and enqueue into the executor in sychronized block so that // Locate datafile and enqueue into the executor in sychronized block so
// writes get equeued onto the executor in order that they were assigned by // that
// writes get equeued onto the executor in order that they were assigned
// by
// the data manager (which is basically just appending) // the data manager (which is basically just appending)
synchronized (this) { synchronized (this) {
@ -246,13 +249,13 @@ class DataFileAppender {
} }
/** /**
* The async processing loop that writes to the data files and * The async processing loop that writes to the data files and does the
* does the force calls. * force calls.
* *
* Since the file sync() call is the slowest of all the operations, * Since the file sync() call is the slowest of all the operations, this
* this algorithm tries to 'batch' or group together several file sync() requests * algorithm tries to 'batch' or group together several file sync() requests
* into a single file sync() call. The batching is accomplished attaching the * into a single file sync() call. The batching is accomplished attaching
* same CountDownLatch instance to every force request in a group. * the same CountDownLatch instance to every force request in a group.
* *
*/ */
protected void processQueue() { protected void processQueue() {
@ -282,7 +285,6 @@ class DataFileAppender {
enqueueMutex.notify(); enqueueMutex.notify();
} }
if (o == SHUTDOWN_COMMAND) { if (o == SHUTDOWN_COMMAND) {
break; break;
} }
@ -344,7 +346,8 @@ class DataFileAppender {
// Signal any waiting threads that the write is on disk. // Signal any waiting threads that the write is on disk.
wb.latch.countDown(); wb.latch.countDown();
// Now that the data is on disk, remove the writes from the in flight // Now that the data is on disk, remove the writes from the in
// flight
// cache. // cache.
write = wb.first; write = wb.first;
while (write != null) { while (write != null) {

View File

@ -83,7 +83,6 @@ public final class DataManagerFacade implements org.apache.activemq.kaha.impl.Da
private final String name; private final String name;
private Marshaller redoMarshaller; private Marshaller redoMarshaller;
public DataManagerFacade(AsyncDataManager dataManager, String name) { public DataManagerFacade(AsyncDataManager dataManager, String name) {
this.dataManager = dataManager; this.dataManager = dataManager;
this.name = name; this.name = name;
@ -95,7 +94,6 @@ public final class DataManagerFacade implements org.apache.activemq.kaha.impl.Da
return marshaller.readPayload(dataIn); return marshaller.readPayload(dataIn);
} }
public StoreLocation storeDataItem(Marshaller marshaller, Object payload) throws IOException { public StoreLocation storeDataItem(Marshaller marshaller, Object payload) throws IOException {
final DataByteArrayOutputStream buffer = new DataByteArrayOutputStream(); final DataByteArrayOutputStream buffer = new DataByteArrayOutputStream();
marshaller.writePayload(payload, buffer); marshaller.writePayload(payload, buffer);
@ -103,7 +101,6 @@ public final class DataManagerFacade implements org.apache.activemq.kaha.impl.Da
return convertToStoreLocation(dataManager.write(data, (byte)1, false)); return convertToStoreLocation(dataManager.write(data, (byte)1, false));
} }
public void force() throws IOException { public void force() throws IOException {
dataManager.write(FORCE_COMMAND, (byte)2, true); dataManager.write(FORCE_COMMAND, (byte)2, true);
} }
@ -130,6 +127,7 @@ public final class DataManagerFacade implements org.apache.activemq.kaha.impl.Da
public void addInterestInFile(int file) throws IOException { public void addInterestInFile(int file) throws IOException {
dataManager.addInterestInFile(file); dataManager.addInterestInFile(file);
} }
public void removeInterestInFile(int file) throws IOException { public void removeInterestInFile(int file) throws IOException {
dataManager.removeInterestInFile(file); dataManager.removeInterestInFile(file);
} }
@ -137,6 +135,7 @@ public final class DataManagerFacade implements org.apache.activemq.kaha.impl.Da
public void recoverRedoItems(RedoListener listener) throws IOException { public void recoverRedoItems(RedoListener listener) throws IOException {
throw new RuntimeException("Not Implemented.."); throw new RuntimeException("Not Implemented..");
} }
public StoreLocation storeRedoItem(Object payload) throws IOException { public StoreLocation storeRedoItem(Object payload) throws IOException {
throw new RuntimeException("Not Implemented.."); throw new RuntimeException("Not Implemented..");
} }
@ -144,6 +143,7 @@ public final class DataManagerFacade implements org.apache.activemq.kaha.impl.Da
public Marshaller getRedoMarshaller() { public Marshaller getRedoMarshaller() {
return redoMarshaller; return redoMarshaller;
} }
public void setRedoMarshaller(Marshaller redoMarshaller) { public void setRedoMarshaller(Marshaller redoMarshaller) {
this.redoMarshaller = redoMarshaller; this.redoMarshaller = redoMarshaller;
} }
@ -152,5 +152,4 @@ public final class DataManagerFacade implements org.apache.activemq.kaha.impl.Da
return name; return name;
} }
} }

View File

@ -33,7 +33,6 @@ import org.apache.activemq.util.ByteSequence;
*/ */
public final class JournalFacade implements Journal { public final class JournalFacade implements Journal {
public static class RecordLocationFacade implements RecordLocation { public static class RecordLocationFacade implements RecordLocation {
private final Location location; private final Location location;
@ -80,11 +79,13 @@ public final class JournalFacade implements Journal {
return convertToRecordLocation(dataManager.getMark()); return convertToRecordLocation(dataManager.getMark());
} }
public RecordLocation getNextRecordLocation(RecordLocation location) throws InvalidRecordLocationException, IOException, IllegalStateException { public RecordLocation getNextRecordLocation(RecordLocation location)
throws InvalidRecordLocationException, IOException, IllegalStateException {
return convertToRecordLocation(dataManager.getNextLocation(convertFromRecordLocation(location))); return convertToRecordLocation(dataManager.getNextLocation(convertFromRecordLocation(location)));
} }
public Packet read(RecordLocation location) throws InvalidRecordLocationException, IOException, IllegalStateException { public Packet read(RecordLocation location) throws InvalidRecordLocationException, IOException,
IllegalStateException {
ByteSequence rc = dataManager.read(convertFromRecordLocation(location)); ByteSequence rc = dataManager.read(convertFromRecordLocation(location));
if (rc == null) if (rc == null)
return null; return null;
@ -94,7 +95,8 @@ public final class JournalFacade implements Journal {
public void setJournalEventListener(JournalEventListener listener) throws IllegalStateException { public void setJournalEventListener(JournalEventListener listener) throws IllegalStateException {
} }
public void setMark(RecordLocation location, boolean sync) throws InvalidRecordLocationException, IOException, IllegalStateException { public void setMark(RecordLocation location, boolean sync) throws InvalidRecordLocationException,
IOException, IllegalStateException {
dataManager.setMark(convertFromRecordLocation(location), sync); dataManager.setMark(convertFromRecordLocation(location), sync);
} }

View File

@ -39,7 +39,8 @@ public final class Location implements Comparable<Location> {
private byte type = NOT_SET_TYPE; private byte type = NOT_SET_TYPE;
private CountDownLatch latch; private CountDownLatch latch;
public Location(){} public Location() {
}
Location(Location item) { Location(Location item) {
this.dataFileId = item.dataFileId; this.dataFileId = item.dataFileId;
@ -76,6 +77,7 @@ public final class Location implements Comparable<Location> {
public int getOffset() { public int getOffset() {
return offset; return offset;
} }
public void setOffset(int offset) { public void setOffset(int offset) {
this.offset = offset; this.offset = offset;
} }
@ -97,7 +99,8 @@ public final class Location implements Comparable<Location> {
} }
public String toString() { public String toString() {
String result="offset = "+offset+", file = " + dataFileId + ", size = "+size + ", type = "+type; String result = "offset = " + offset + ", file = " + dataFileId + ", size = " + size + ", type = "
+ type;
return result; return result;
} }
@ -118,6 +121,7 @@ public final class Location implements Comparable<Location> {
public CountDownLatch getLatch() { public CountDownLatch getLatch() {
return latch; return latch;
} }
public void setLatch(CountDownLatch latch) { public void setLatch(CountDownLatch latch) {
this.latch = latch; this.latch = latch;
} }
@ -143,5 +147,4 @@ public final class Location implements Comparable<Location> {
return dataFileId ^ offset; return dataFileId ^ offset;
} }
} }

View File

@ -22,8 +22,8 @@ import java.nio.ByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
/** /**
* An AsyncDataFileAppender that uses NIO ByteBuffers and File chanels to more efficently * An AsyncDataFileAppender that uses NIO ByteBuffers and File chanels to more
* copy data to files. * efficently copy data to files.
* *
* @version $Revision: 1.1.1.1 $ * @version $Revision: 1.1.1.1 $
*/ */
@ -34,13 +34,13 @@ class NIODataFileAppender extends DataFileAppender {
} }
/** /**
* The async processing loop that writes to the data files and * The async processing loop that writes to the data files and does the
* does the force calls. * force calls.
* *
* Since the file sync() call is the slowest of all the operations, * Since the file sync() call is the slowest of all the operations, this
* this algorithm tries to 'batch' or group together several file sync() requests * algorithm tries to 'batch' or group together several file sync() requests
* into a single file sync() call. The batching is accomplished attaching the * into a single file sync() call. The batching is accomplished attaching
* same CountDownLatch instance to every force request in a group. * the same CountDownLatch instance to every force request in a group.
* *
*/ */
protected void processQueue() { protected void processQueue() {
@ -82,7 +82,6 @@ class NIODataFileAppender extends DataFileAppender {
enqueueMutex.notify(); enqueueMutex.notify();
} }
if (o == SHUTDOWN_COMMAND) { if (o == SHUTDOWN_COMMAND) {
break; break;
} }
@ -113,7 +112,8 @@ class NIODataFileAppender extends DataFileAppender {
header.put(write.location.getType()); header.put(write.location.getType());
header.clear(); header.clear();
transfer(header, channel); transfer(header, channel);
ByteBuffer source = ByteBuffer.wrap(write.data.getData(), write.data.getOffset(), write.data.getLength()); ByteBuffer source = ByteBuffer.wrap(write.data.getData(), write.data.getOffset(),
write.data.getLength());
transfer(source, channel); transfer(source, channel);
footer.clear(); footer.clear();
transfer(footer, channel); transfer(footer, channel);
@ -130,7 +130,8 @@ class NIODataFileAppender extends DataFileAppender {
copy(header, buffer); copy(header, buffer);
assert !header.hasRemaining(); assert !header.hasRemaining();
ByteBuffer source = ByteBuffer.wrap(write.data.getData(), write.data.getOffset(), write.data.getLength()); ByteBuffer source = ByteBuffer.wrap(write.data.getData(), write.data.getOffset(),
write.data.getLength());
copy(source, buffer); copy(source, buffer);
assert !source.hasRemaining(); assert !source.hasRemaining();
@ -157,7 +158,8 @@ class NIODataFileAppender extends DataFileAppender {
wb.latch.countDown(); wb.latch.countDown();
} }
// Now that the data is on disk, remove the writes from the in flight // Now that the data is on disk, remove the writes from the in
// flight
// cache. // cache.
write = wb.first; write = wb.first;
while (write != null) { while (write != null) {
@ -186,6 +188,7 @@ class NIODataFileAppender extends DataFileAppender {
/** /**
* Copy the bytes in header to the channel. * Copy the bytes in header to the channel.
*
* @param header - source of data * @param header - source of data
* @param channel - destination where the data will be written. * @param channel - destination where the data will be written.
* @throws IOException * @throws IOException

View File

@ -18,7 +18,6 @@ package org.apache.activemq.kaha.impl.container;
import java.util.Iterator; import java.util.Iterator;
/** /**
* An Iterator for a container entry Set * An Iterator for a container entry Set
* *
@ -28,6 +27,7 @@ public class ContainerEntrySetIterator implements Iterator{
private MapContainerImpl container; private MapContainerImpl container;
private Iterator iter; private Iterator iter;
private ContainerMapEntry currentEntry; private ContainerMapEntry currentEntry;
ContainerEntrySetIterator(MapContainerImpl container, Iterator iter) { ContainerEntrySetIterator(MapContainerImpl container, Iterator iter) {
this.container = container; this.container = container;
this.iter = iter; this.iter = iter;

View File

@ -31,12 +31,10 @@ import org.apache.activemq.kaha.impl.index.IndexLinkedList;
*/ */
public class ContainerKeySet extends ContainerCollectionSupport implements Set { public class ContainerKeySet extends ContainerCollectionSupport implements Set {
ContainerKeySet(MapContainerImpl container) { ContainerKeySet(MapContainerImpl container) {
super(container); super(container);
} }
public boolean contains(Object o) { public boolean contains(Object o) {
return container.containsKey(o); return container.containsKey(o);
} }

View File

@ -20,7 +20,6 @@ import java.util.Iterator;
import org.apache.activemq.kaha.impl.index.IndexItem; import org.apache.activemq.kaha.impl.index.IndexItem;
import org.apache.activemq.kaha.impl.index.IndexLinkedList; import org.apache.activemq.kaha.impl.index.IndexLinkedList;
/** /**
* Iterator for the set of keys for a container * Iterator for the set of keys for a container
* *

View File

@ -35,7 +35,6 @@ class ContainerMapEntry implements Map.Entry {
} }
public Object getKey() { public Object getKey() {
return key; return key;
} }
@ -48,6 +47,3 @@ class ContainerMapEntry implements Map.Entry {
return container.put(key, value); return container.put(key, value);
} }
} }

View File

@ -32,24 +32,19 @@ import org.apache.activemq.kaha.impl.index.IndexLinkedList;
*/ */
class ContainerValueCollection extends ContainerCollectionSupport implements Collection { class ContainerValueCollection extends ContainerCollectionSupport implements Collection {
ContainerValueCollection(MapContainerImpl container) { ContainerValueCollection(MapContainerImpl container) {
super(container); super(container);
} }
public boolean contains(Object o) { public boolean contains(Object o) {
return container.containsValue(o); return container.containsValue(o);
} }
public Iterator iterator() { public Iterator iterator() {
IndexLinkedList list = container.getItemList(); IndexLinkedList list = container.getItemList();
return new ContainerValueCollectionIterator(container, list, list.getRoot()); return new ContainerValueCollectionIterator(container, list, list.getRoot());
} }
public Object[] toArray() { public Object[] toArray() {
Object[] result = null; Object[] result = null;
IndexLinkedList list = container.getItemList(); IndexLinkedList list = container.getItemList();
@ -64,7 +59,6 @@ class ContainerValueCollection extends ContainerCollectionSupport implements Col
item = list.getNextEntry(item); item = list.getNextEntry(item);
} }
} }
return result; return result;
} }
@ -86,17 +80,14 @@ class ContainerValueCollection extends ContainerCollectionSupport implements Col
return result; return result;
} }
public boolean add(Object o) { public boolean add(Object o) {
throw new UnsupportedOperationException("Can't add an object here"); throw new UnsupportedOperationException("Can't add an object here");
} }
public boolean remove(Object o) { public boolean remove(Object o) {
return container.removeValue(o); return container.removeValue(o);
} }
public boolean containsAll(Collection c) { public boolean containsAll(Collection c) {
boolean result = !c.isEmpty(); boolean result = !c.isEmpty();
for (Iterator i = c.iterator(); i.hasNext();) { for (Iterator i = c.iterator(); i.hasNext();) {
@ -108,12 +99,10 @@ class ContainerValueCollection extends ContainerCollectionSupport implements Col
return result; return result;
} }
public boolean addAll(Collection c) { public boolean addAll(Collection c) {
throw new UnsupportedOperationException("Can't add everything here!"); throw new UnsupportedOperationException("Can't add everything here!");
} }
public boolean removeAll(Collection c) { public boolean removeAll(Collection c) {
boolean result = true; boolean result = true;
for (Iterator i = c.iterator(); i.hasNext();) { for (Iterator i = c.iterator(); i.hasNext();) {
@ -123,7 +112,6 @@ class ContainerValueCollection extends ContainerCollectionSupport implements Col
return result; return result;
} }
public boolean retainAll(Collection c) { public boolean retainAll(Collection c) {
List tmpList = new ArrayList(); List tmpList = new ArrayList();
for (Iterator i = c.iterator(); i.hasNext();) { for (Iterator i = c.iterator(); i.hasNext();) {
@ -138,7 +126,6 @@ class ContainerValueCollection extends ContainerCollectionSupport implements Col
return !tmpList.isEmpty(); return !tmpList.isEmpty();
} }
public void clear() { public void clear() {
container.clear(); container.clear();
} }

View File

@ -45,9 +45,8 @@ public class ListContainerImpl extends BaseContainerImpl implements ListContaine
private static final Log log = LogFactory.getLog(ListContainerImpl.class); private static final Log log = LogFactory.getLog(ListContainerImpl.class);
protected Marshaller marshaller = Store.ObjectMarshaller; protected Marshaller marshaller = Store.ObjectMarshaller;
public ListContainerImpl(ContainerId id, IndexItem root, IndexManager indexManager,
public ListContainerImpl(ContainerId id,IndexItem root,IndexManager indexManager,DataManager dataManager, DataManager dataManager, boolean persistentIndex) throws IOException {
boolean persistentIndex) throws IOException{
super(id, root, indexManager, dataManager, persistentIndex); super(id, root, indexManager, dataManager, persistentIndex);
} }
@ -436,8 +435,10 @@ public class ListContainerImpl extends BaseContainerImpl implements ListContaine
load(); load();
Object result = null; Object result = null;
IndexItem replace = indexList.isEmpty() ? null : (IndexItem)indexList.get(index); IndexItem replace = indexList.isEmpty() ? null : (IndexItem)indexList.get(index);
IndexItem prev=(indexList.isEmpty()||(index-1)<0)?null:(IndexItem)indexList.get(index-1); IndexItem prev = (indexList.isEmpty() || (index - 1) < 0) ? null : (IndexItem)indexList
IndexItem next=(indexList.isEmpty()||(index+1)>=size())?null:(IndexItem)indexList.get(index+1); .get(index - 1);
IndexItem next = (indexList.isEmpty() || (index + 1) >= size()) ? null : (IndexItem)indexList
.get(index + 1);
result = getValue(replace); result = getValue(replace);
indexList.remove(index); indexList.remove(index);
delete(replace, prev, next); delete(replace, prev, next);
@ -448,8 +449,10 @@ public class ListContainerImpl extends BaseContainerImpl implements ListContaine
protected synchronized IndexItem internalSet(int index, Object element) { protected synchronized IndexItem internalSet(int index, Object element) {
IndexItem replace = indexList.isEmpty() ? null : (IndexItem)indexList.get(index); IndexItem replace = indexList.isEmpty() ? null : (IndexItem)indexList.get(index);
IndexItem prev=(indexList.isEmpty()||(index-1)<0)?null:(IndexItem)indexList.get(index-1); IndexItem prev = (indexList.isEmpty() || (index - 1) < 0) ? null : (IndexItem)indexList
IndexItem next=(indexList.isEmpty()||(index+1)>=size())?null:(IndexItem)indexList.get(index+1); .get(index - 1);
IndexItem next = (indexList.isEmpty() || (index + 1) >= size()) ? null : (IndexItem)indexList
.get(index + 1);
indexList.remove(index); indexList.remove(index);
delete(replace, prev, next); delete(replace, prev, next);
itemRemoved(index); itemRemoved(index);
@ -640,7 +643,8 @@ public class ListContainerImpl extends BaseContainerImpl implements ListContaine
} }
/** /**
* insert an Object in first position int the list but get a StoreEntry of its position * insert an Object in first position int the list but get a StoreEntry of
* its position
* *
* @param object * @param object
* @return the location in the Store * @return the location in the Store
@ -653,7 +657,8 @@ public class ListContainerImpl extends BaseContainerImpl implements ListContaine
/** /**
* @param entry * @param entry
* @param object * @param object
* @see org.apache.activemq.kaha.ListContainer#update(org.apache.activemq.kaha.StoreEntry, java.lang.Object) * @see org.apache.activemq.kaha.ListContainer#update(org.apache.activemq.kaha.StoreEntry,
* java.lang.Object)
*/ */
public synchronized void update(StoreEntry entry, Object object) { public synchronized void update(StoreEntry entry, Object object) {
try { try {
@ -738,8 +743,9 @@ public class ListContainerImpl extends BaseContainerImpl implements ListContaine
} }
/** /**
* It's possible that a StoreEntry could be come stale * It's possible that a StoreEntry could be come stale this will return an
* this will return an upto date entry for the StoreEntry position * upto date entry for the StoreEntry position
*
* @param entry old entry * @param entry old entry
* @return a refreshed StoreEntry * @return a refreshed StoreEntry
*/ */

View File

@ -197,6 +197,7 @@ public final class MapContainerImpl extends BaseContainerImpl implements MapCont
/** /**
* Get the StoreEntry associated with the key * Get the StoreEntry associated with the key
*
* @param key * @param key
* @return the StoreEntry * @return the StoreEntry
*/ */
@ -282,7 +283,8 @@ public final class MapContainerImpl extends BaseContainerImpl implements MapCont
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.apache.activemq.kaha.MapContainer#put(java.lang.Object, java.lang.Object) * @see org.apache.activemq.kaha.MapContainer#put(java.lang.Object,
* java.lang.Object)
*/ */
public synchronized Object put(Object key, Object value) { public synchronized Object put(Object key, Object value) {
load(); load();

View File

@ -18,7 +18,6 @@ package org.apache.activemq.kaha.impl.data;
import org.apache.activemq.kaha.StoreLocation; import org.apache.activemq.kaha.StoreLocation;
/** /**
* A a wrapper for a data in the store * A a wrapper for a data in the store
* *
@ -30,7 +29,8 @@ public final class DataItem implements Item, StoreLocation{
private long offset = POSITION_NOT_SET; private long offset = POSITION_NOT_SET;
private int size; private int size;
public DataItem(){} public DataItem() {
}
DataItem(DataItem item) { DataItem(DataItem item) {
this.file = item.file; this.file = item.file;

View File

@ -32,6 +32,7 @@ import org.apache.activemq.kaha.impl.index.RedoStoreIndexItem;
import org.apache.activemq.util.IOExceptionSupport; import org.apache.activemq.util.IOExceptionSupport;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
/** /**
* Manages DataFiles * Manages DataFiles
* *
@ -91,7 +92,9 @@ public final class DataManagerImpl implements DataManager {
return result; return result;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#getName() * @see org.apache.activemq.kaha.impl.data.IDataManager#getName()
*/ */
public String getName() { public String getName() {
@ -122,35 +125,49 @@ public final class DataManagerImpl implements DataManager {
return dataFile; return dataFile;
} }
/* (non-Javadoc) /*
* @see org.apache.activemq.kaha.impl.data.IDataManager#readItem(org.apache.activemq.kaha.Marshaller, org.apache.activemq.kaha.StoreLocation) * (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#readItem(org.apache.activemq.kaha.Marshaller,
* org.apache.activemq.kaha.StoreLocation)
*/ */
public synchronized Object readItem(Marshaller marshaller, StoreLocation item) throws IOException { public synchronized Object readItem(Marshaller marshaller, StoreLocation item) throws IOException {
return getReader().readItem(marshaller, item); return getReader().readItem(marshaller, item);
} }
/* (non-Javadoc) /*
* @see org.apache.activemq.kaha.impl.data.IDataManager#storeDataItem(org.apache.activemq.kaha.Marshaller, java.lang.Object) * (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#storeDataItem(org.apache.activemq.kaha.Marshaller,
* java.lang.Object)
*/ */
public synchronized StoreLocation storeDataItem(Marshaller marshaller, Object payload) throws IOException { public synchronized StoreLocation storeDataItem(Marshaller marshaller, Object payload) throws IOException {
return getWriter().storeItem(marshaller, payload, DATA_ITEM_TYPE); return getWriter().storeItem(marshaller, payload, DATA_ITEM_TYPE);
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#storeRedoItem(java.lang.Object) * @see org.apache.activemq.kaha.impl.data.IDataManager#storeRedoItem(java.lang.Object)
*/ */
public synchronized StoreLocation storeRedoItem(Object payload) throws IOException { public synchronized StoreLocation storeRedoItem(Object payload) throws IOException {
return getWriter().storeItem(redoMarshaller, payload, REDO_ITEM_TYPE); return getWriter().storeItem(redoMarshaller, payload, REDO_ITEM_TYPE);
} }
/* (non-Javadoc) /*
* @see org.apache.activemq.kaha.impl.data.IDataManager#updateItem(org.apache.activemq.kaha.StoreLocation, org.apache.activemq.kaha.Marshaller, java.lang.Object) * (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#updateItem(org.apache.activemq.kaha.StoreLocation,
* org.apache.activemq.kaha.Marshaller, java.lang.Object)
*/ */
public synchronized void updateItem(StoreLocation location,Marshaller marshaller, Object payload) throws IOException { public synchronized void updateItem(StoreLocation location, Marshaller marshaller, Object payload)
throws IOException {
getWriter().updateItem((DataItem)location, marshaller, payload, DATA_ITEM_TYPE); getWriter().updateItem((DataItem)location, marshaller, payload, DATA_ITEM_TYPE);
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#recoverRedoItems(org.apache.activemq.kaha.impl.data.RedoListener) * @see org.apache.activemq.kaha.impl.data.IDataManager#recoverRedoItems(org.apache.activemq.kaha.impl.data.RedoListener)
*/ */
public synchronized void recoverRedoItems(RedoListener listener) throws IOException { public synchronized void recoverRedoItems(RedoListener listener) throws IOException {
@ -182,7 +199,8 @@ public final class DataManagerImpl implements DataManager {
try { try {
listener.onRedoItem(item, object); listener.onRedoItem(item, object);
// in case the listener is holding on to item references, copy it // in case the listener is holding on to item references,
// copy it
// so we don't change it behind the listener's back. // so we don't change it behind the listener's back.
item = item.copy(); item = item.copy();
@ -195,7 +213,9 @@ public final class DataManagerImpl implements DataManager {
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#close() * @see org.apache.activemq.kaha.impl.data.IDataManager#close()
*/ */
public synchronized void close() throws IOException { public synchronized void close() throws IOException {
@ -208,7 +228,9 @@ public final class DataManagerImpl implements DataManager {
fileMap.clear(); fileMap.clear();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#force() * @see org.apache.activemq.kaha.impl.data.IDataManager#force()
*/ */
public synchronized void force() throws IOException { public synchronized void force() throws IOException {
@ -218,8 +240,9 @@ public final class DataManagerImpl implements DataManager {
} }
} }
/*
/* (non-Javadoc) * (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#delete() * @see org.apache.activemq.kaha.impl.data.IDataManager#delete()
*/ */
public synchronized boolean delete() throws IOException { public synchronized boolean delete() throws IOException {
@ -232,8 +255,9 @@ public final class DataManagerImpl implements DataManager {
return result; return result;
} }
/*
/* (non-Javadoc) * (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#addInterestInFile(int) * @see org.apache.activemq.kaha.impl.data.IDataManager#addInterestInFile(int)
*/ */
public synchronized void addInterestInFile(int file) throws IOException { public synchronized void addInterestInFile(int file) throws IOException {
@ -253,7 +277,9 @@ public final class DataManagerImpl implements DataManager {
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#removeInterestInFile(int) * @see org.apache.activemq.kaha.impl.data.IDataManager#removeInterestInFile(int)
*/ */
public synchronized void removeInterestInFile(int file) throws IOException { public synchronized void removeInterestInFile(int file) throws IOException {
@ -274,7 +300,9 @@ public final class DataManagerImpl implements DataManager {
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#consolidateDataFiles() * @see org.apache.activemq.kaha.impl.data.IDataManager#consolidateDataFiles()
*/ */
public synchronized void consolidateDataFiles() throws IOException { public synchronized void consolidateDataFiles() throws IOException {
@ -300,14 +328,18 @@ public final class DataManagerImpl implements DataManager {
log.debug("discarding data file " + dataFile + (result ? "successful " : "failed")); log.debug("discarding data file " + dataFile + (result ? "successful " : "failed"));
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#getRedoMarshaller() * @see org.apache.activemq.kaha.impl.data.IDataManager#getRedoMarshaller()
*/ */
public Marshaller getRedoMarshaller() { public Marshaller getRedoMarshaller() {
return redoMarshaller; return redoMarshaller;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.IDataManager#setRedoMarshaller(org.apache.activemq.kaha.Marshaller) * @see org.apache.activemq.kaha.impl.data.IDataManager#setRedoMarshaller(org.apache.activemq.kaha.Marshaller)
*/ */
public void setRedoMarshaller(Marshaller redoMarshaller) { public void setRedoMarshaller(Marshaller redoMarshaller) {
@ -338,9 +370,11 @@ public final class DataManagerImpl implements DataManager {
} }
return reader; return reader;
} }
protected synchronized SyncDataFileReader createReader() { protected synchronized SyncDataFileReader createReader() {
return new SyncDataFileReader(this); return new SyncDataFileReader(this);
} }
public synchronized void setReader(SyncDataFileReader reader) { public synchronized void setReader(SyncDataFileReader reader) {
this.reader = reader; this.reader = reader;
} }
@ -351,9 +385,11 @@ public final class DataManagerImpl implements DataManager {
} }
return writer; return writer;
} }
private SyncDataFileWriter createWriter() { private SyncDataFileWriter createWriter() {
return new SyncDataFileWriter(this); return new SyncDataFileWriter(this);
} }
public synchronized void setWriter(SyncDataFileWriter writer) { public synchronized void setWriter(SyncDataFileWriter writer) {
this.writer = writer; this.writer = writer;
} }

View File

@ -21,6 +21,7 @@ import java.io.RandomAccessFile;
import org.apache.activemq.kaha.Marshaller; import org.apache.activemq.kaha.Marshaller;
import org.apache.activemq.kaha.StoreLocation; import org.apache.activemq.kaha.StoreLocation;
import org.apache.activemq.util.DataByteArrayInputStream; import org.apache.activemq.util.DataByteArrayInputStream;
/** /**
* Optimized Store reader * Optimized Store reader
* *
@ -41,7 +42,9 @@ public final class SyncDataFileReader {
this.dataIn = new DataByteArrayInputStream(); this.dataIn = new DataByteArrayInputStream();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.DataFileReader#readDataItemSize(org.apache.activemq.kaha.impl.data.DataItem) * @see org.apache.activemq.kaha.impl.data.DataFileReader#readDataItemSize(org.apache.activemq.kaha.impl.data.DataItem)
*/ */
public synchronized byte readDataItemSize(DataItem item) throws IOException { public synchronized byte readDataItemSize(DataItem item) throws IOException {
@ -52,8 +55,11 @@ public final class SyncDataFileReader {
return rc; return rc;
} }
/* (non-Javadoc) /*
* @see org.apache.activemq.kaha.impl.data.DataFileReader#readItem(org.apache.activemq.kaha.Marshaller, org.apache.activemq.kaha.StoreLocation) * (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.DataFileReader#readItem(org.apache.activemq.kaha.Marshaller,
* org.apache.activemq.kaha.StoreLocation)
*/ */
public synchronized Object readItem(Marshaller marshaller, StoreLocation item) throws IOException { public synchronized Object readItem(Marshaller marshaller, StoreLocation item) throws IOException {
RandomAccessFile file = dataManager.getDataFile(item).getRandomAccessFile(); RandomAccessFile file = dataManager.getDataFile(item).getRandomAccessFile();

View File

@ -21,9 +21,10 @@ import java.io.RandomAccessFile;
import org.apache.activemq.kaha.Marshaller; import org.apache.activemq.kaha.Marshaller;
import org.apache.activemq.util.DataByteArrayOutputStream; import org.apache.activemq.util.DataByteArrayOutputStream;
/** /**
* Optimized Store writer. Synchronously marshalls and writes to the data file. Simple but * Optimized Store writer. Synchronously marshalls and writes to the data file.
* may introduce a bit of contention when put under load. * Simple but may introduce a bit of contention when put under load.
* *
* @version $Revision: 1.1.1.1 $ * @version $Revision: 1.1.1.1 $
*/ */
@ -32,7 +33,6 @@ final public class SyncDataFileWriter {
private DataByteArrayOutputStream buffer; private DataByteArrayOutputStream buffer;
private DataManagerImpl dataManager; private DataManagerImpl dataManager;
/** /**
* Construct a Store writer * Construct a Store writer
* *
@ -43,10 +43,14 @@ final public class SyncDataFileWriter {
this.buffer = new DataByteArrayOutputStream(); this.buffer = new DataByteArrayOutputStream();
} }
/* (non-Javadoc) /*
* @see org.apache.activemq.kaha.impl.data.DataFileWriter#storeItem(org.apache.activemq.kaha.Marshaller, java.lang.Object, byte) * (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.DataFileWriter#storeItem(org.apache.activemq.kaha.Marshaller,
* java.lang.Object, byte)
*/ */
public synchronized DataItem storeItem(Marshaller marshaller, Object payload, byte type) throws IOException { public synchronized DataItem storeItem(Marshaller marshaller, Object payload, byte type)
throws IOException {
// Write the packet our internal buffer. // Write the packet our internal buffer.
buffer.reset(); buffer.reset();
@ -72,10 +76,14 @@ final public class SyncDataFileWriter {
return item; return item;
} }
/* (non-Javadoc) /*
* @see org.apache.activemq.kaha.impl.data.DataFileWriter#updateItem(org.apache.activemq.kaha.StoreLocation, org.apache.activemq.kaha.Marshaller, java.lang.Object, byte) * (non-Javadoc)
*
* @see org.apache.activemq.kaha.impl.data.DataFileWriter#updateItem(org.apache.activemq.kaha.StoreLocation,
* org.apache.activemq.kaha.Marshaller, java.lang.Object, byte)
*/ */
public synchronized void updateItem(DataItem item,Marshaller marshaller, Object payload, byte type) throws IOException { public synchronized void updateItem(DataItem item, Marshaller marshaller, Object payload, byte type)
throws IOException {
// Write the packet our internal buffer. // Write the packet our internal buffer.
buffer.reset(); buffer.reset();
buffer.position(DataManagerImpl.ITEM_HEAD_SIZE); buffer.position(DataManagerImpl.ITEM_HEAD_SIZE);

View File

@ -39,6 +39,7 @@ public class BadMagicException extends IOException{
/** /**
* Construct an Exception with a reason * Construct an Exception with a reason
*
* @param s * @param s
*/ */
public BadMagicException(String s) { public BadMagicException(String s) {

View File

@ -27,6 +27,7 @@ public interface Index{
/** /**
* clear the index * clear the index
*
* @throws IOException * @throws IOException
* *
*/ */
@ -57,7 +58,6 @@ public interface Index{
*/ */
public void store(Object key, StoreEntry entry) throws IOException; public void store(Object key, StoreEntry entry) throws IOException;
/** /**
* @param key * @param key
* @return the entry * @return the entry
@ -77,14 +77,14 @@ public interface Index{
/** /**
* unload indexes * unload indexes
*
* @throws IOException * @throws IOException
*/ */
public void unload() throws IOException; public void unload() throws IOException;
/** /**
* Set the marshaller for key objects * Set the marshaller for key objects
*
* @param marshaller * @param marshaller
*/ */
public void setKeyMarshaller(Marshaller marshaller); public void setKeyMarshaller(Marshaller marshaller);

View File

@ -60,13 +60,15 @@ public interface IndexLinkedList{
/** /**
* Inserts the given element at the beginning of this list. * Inserts the given element at the beginning of this list.
*
* @param item * @param item
*/ */
public void addFirst(IndexItem item); public void addFirst(IndexItem item);
/** /**
* Appends the given element to the end of this list. (Identical in function to the <tt>add</tt> method; included * Appends the given element to the end of this list. (Identical in function
* only for consistency.) * to the <tt>add</tt> method; included only for consistency.)
*
* @param item * @param item
*/ */
public void addLast(IndexItem item); public void addLast(IndexItem item);
@ -87,9 +89,11 @@ public interface IndexLinkedList{
/** /**
* Appends the specified element to the end of this list. * Appends the specified element to the end of this list.
*
* @param item * @param item
* *
* @return <tt>true</tt> (as per the general contract of <tt>Collection.add</tt>). * @return <tt>true</tt> (as per the general contract of
* <tt>Collection.add</tt>).
*/ */
public boolean add(IndexItem item); public boolean add(IndexItem item);
@ -105,13 +109,15 @@ public interface IndexLinkedList{
* @param index index of element to return. * @param index index of element to return.
* @return the element at the specified position in this list. * @return the element at the specified position in this list.
* *
* @throws IndexOutOfBoundsException if the specified index is is out of range (<tt>index &lt; 0 || index &gt;= size()</tt>). * @throws IndexOutOfBoundsException if the specified index is is out of
* range (<tt>index &lt; 0 || index &gt;= size()</tt>).
*/ */
public IndexItem get(int index); public IndexItem get(int index);
/** /**
* Inserts the specified element at the specified position in this list. Shifts the element currently at that * Inserts the specified element at the specified position in this list.
* position (if any) and any subsequent elements to the right (adds one to their indices). * Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).
* *
* @param index index at which the specified element is to be inserted. * @param index index at which the specified element is to be inserted.
* @param element element to be inserted. * @param element element to be inserted.
@ -121,8 +127,9 @@ public interface IndexLinkedList{
public void add(int index, IndexItem element); public void add(int index, IndexItem element);
/** /**
* Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts * Removes the element at the specified position in this list. Shifts any
* one from their indices). Returns the element that was removed from the list. * subsequent elements to the left (subtracts one from their indices).
* Returns the element that was removed from the list.
* *
* @param index the index of the element to removed. * @param index the index of the element to removed.
* @return the element previously at the specified position. * @return the element previously at the specified position.
@ -133,13 +140,15 @@ public interface IndexLinkedList{
// Search Operations // Search Operations
/** /**
* Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not * Returns the index in this list of the first occurrence of the specified
* contain this element. More formally, returns the lowest index i such that * element, or -1 if the List does not contain this element. More formally,
* <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>, or -1 if there is no such index. * returns the lowest index i such that
* <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>, or -1 if there
* is no such index.
* *
* @param o element to search for. * @param o element to search for.
* @return the index in this list of the first occurrence of the specified element, or -1 if the list does not * @return the index in this list of the first occurrence of the specified
* contain this element. * element, or -1 if the list does not contain this element.
*/ */
public int indexOf(StoreEntry o); public int indexOf(StoreEntry o);
@ -159,15 +168,16 @@ public interface IndexLinkedList{
*/ */
public IndexItem getPrevEntry(IndexItem entry); public IndexItem getPrevEntry(IndexItem entry);
/** /**
* remove an entry * remove an entry
*
* @param e * @param e
*/ */
public void remove(IndexItem e); public void remove(IndexItem e);
/** /**
* Ensure we have the up to date entry * Ensure we have the up to date entry
*
* @param entry * @param entry
* @return the entry * @return the entry
*/ */
@ -175,6 +185,7 @@ public interface IndexLinkedList{
/** /**
* Update the indexes of a StoreEntry * Update the indexes of a StoreEntry
*
* @param current * @param current
* @return update StoreEntry * @return update StoreEntry
*/ */

View File

@ -47,6 +47,7 @@ public class RedoStoreIndexItem implements Externalizable {
public RedoStoreIndexItem() { public RedoStoreIndexItem() {
} }
public RedoStoreIndexItem(String indexName, long offset, IndexItem item) { public RedoStoreIndexItem(String indexName, long offset, IndexItem item) {
this.indexName = indexName; this.indexName = indexName;
this.offset = offset; this.offset = offset;
@ -56,6 +57,7 @@ public class RedoStoreIndexItem implements Externalizable {
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
readExternal((DataInput)in); readExternal((DataInput)in);
} }
public void readExternal(DataInput in) throws IOException { public void readExternal(DataInput in) throws IOException {
// indexName = in.readUTF(); // indexName = in.readUTF();
offset = in.readLong(); offset = in.readLong();
@ -66,6 +68,7 @@ public class RedoStoreIndexItem implements Externalizable {
public void writeExternal(ObjectOutput out) throws IOException { public void writeExternal(ObjectOutput out) throws IOException {
writeExternal((DataOutput)out); writeExternal((DataOutput)out);
} }
public void writeExternal(DataOutput out) throws IOException { public void writeExternal(DataOutput out) throws IOException {
// out.writeUTF(indexName); // out.writeUTF(indexName);
out.writeLong(offset); out.writeLong(offset);
@ -75,6 +78,7 @@ public class RedoStoreIndexItem implements Externalizable {
public String getIndexName() { public String getIndexName() {
return indexName; return indexName;
} }
public void setIndexName(String indexName) { public void setIndexName(String indexName) {
this.indexName = indexName; this.indexName = indexName;
} }
@ -82,12 +86,15 @@ public class RedoStoreIndexItem implements Externalizable {
public IndexItem getIndexItem() { public IndexItem getIndexItem() {
return indexItem; return indexItem;
} }
public void setIndexItem(IndexItem item) { public void setIndexItem(IndexItem item) {
this.indexItem = item; this.indexItem = item;
} }
public long getOffset() { public long getOffset() {
return offset; return offset;
} }
public void setOffset(long offset) { public void setOffset(long offset) {
this.offset = offset; this.offset = offset;
} }

View File

@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import org.apache.activemq.util.DataByteArrayInputStream; import org.apache.activemq.util.DataByteArrayInputStream;
/** /**
* Optimized Store reader * Optimized Store reader
* *

View File

@ -21,6 +21,7 @@ import java.io.RandomAccessFile;
import org.apache.activemq.kaha.impl.DataManager; import org.apache.activemq.kaha.impl.DataManager;
import org.apache.activemq.util.DataByteArrayOutputStream; import org.apache.activemq.util.DataByteArrayOutputStream;
/** /**
* Optimized Store writer * Optimized Store writer
* *

Some files were not shown because too many files have changed in this diff Show More