[jboss-cvs] JBoss Messaging SVN: r3514 - in trunk: src/main/org/jboss/jms/client/container and 40 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 17 10:56:38 EST 2007
Author: timfox
Date: 2007-12-17 10:56:37 -0500 (Mon, 17 Dec 2007)
New Revision: 3514
Added:
trunk/src/main/org/jboss/messaging/newcore/ClusteredQueue.java
trunk/src/main/org/jboss/messaging/newcore/Consumer.java
trunk/src/main/org/jboss/messaging/newcore/DistributionPolicy.java
trunk/src/main/org/jboss/messaging/newcore/Filter.java
trunk/src/main/org/jboss/messaging/newcore/HandleStatus.java
trunk/src/main/org/jboss/messaging/newcore/Message.java
trunk/src/main/org/jboss/messaging/newcore/MessageReference.java
trunk/src/main/org/jboss/messaging/newcore/MessagingComponent.java
trunk/src/main/org/jboss/messaging/newcore/PagingManager.java
trunk/src/main/org/jboss/messaging/newcore/PersistenceManager.java
trunk/src/main/org/jboss/messaging/newcore/PriorityLinkedList.java
trunk/src/main/org/jboss/messaging/newcore/Queue.java
trunk/src/main/org/jboss/messaging/newcore/QueueStatistics.java
trunk/src/main/org/jboss/messaging/newcore/Transaction.java
trunk/src/main/org/jboss/messaging/newcore/TransactionStore.java
trunk/src/main/org/jboss/messaging/newcore/TransactionSynchronization.java
trunk/src/main/org/jboss/messaging/newcore/cluster/
trunk/src/main/org/jboss/messaging/newcore/cluster/ClusterMessage.java
trunk/src/main/org/jboss/messaging/newcore/cluster/GroupCoordinator.java
trunk/src/main/org/jboss/messaging/newcore/cluster/GroupHandler.java
trunk/src/main/org/jboss/messaging/newcore/cluster/StateHandler.java
trunk/src/main/org/jboss/messaging/newcore/impl/PriorityLinkedListImpl.java
Removed:
trunk/src/main/org/jboss/jms/message/BytesMessageProxy.java
trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java
trunk/src/main/org/jboss/jms/message/JBossMapMessage.java
trunk/src/main/org/jboss/jms/message/JBossMessage.java
trunk/src/main/org/jboss/jms/message/JBossObjectMessage.java
trunk/src/main/org/jboss/jms/message/JBossStreamMessage.java
trunk/src/main/org/jboss/jms/message/JBossTextMessage.java
trunk/src/main/org/jboss/jms/message/MapMessageProxy.java
trunk/src/main/org/jboss/jms/message/MessageProxy.java
trunk/src/main/org/jboss/jms/message/ObjectMessageProxy.java
trunk/src/main/org/jboss/jms/message/StreamMessageProxy.java
trunk/src/main/org/jboss/jms/message/TextMessageProxy.java
trunk/src/main/org/jboss/messaging/core/contract/Filter.java
trunk/src/main/org/jboss/messaging/core/contract/Message.java
trunk/src/main/org/jboss/messaging/core/contract/MessageReference.java
trunk/src/main/org/jboss/messaging/core/impl/message/CoreMessage.java
trunk/src/main/org/jboss/messaging/core/impl/message/MessageFactory.java
trunk/src/main/org/jboss/messaging/core/impl/message/MessageSupport.java
trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageReference.java
trunk/src/main/org/jboss/messaging/newcore/intf/ClusteredQueue.java
trunk/src/main/org/jboss/messaging/newcore/intf/Consumer.java
trunk/src/main/org/jboss/messaging/newcore/intf/DistributionPolicy.java
trunk/src/main/org/jboss/messaging/newcore/intf/Filter.java
trunk/src/main/org/jboss/messaging/newcore/intf/HandleStatus.java
trunk/src/main/org/jboss/messaging/newcore/intf/Message.java
trunk/src/main/org/jboss/messaging/newcore/intf/MessageReference.java
trunk/src/main/org/jboss/messaging/newcore/intf/MessagingComponent.java
trunk/src/main/org/jboss/messaging/newcore/intf/PagingManager.java
trunk/src/main/org/jboss/messaging/newcore/intf/PersistenceManager.java
trunk/src/main/org/jboss/messaging/newcore/intf/Queue.java
trunk/src/main/org/jboss/messaging/newcore/intf/QueueStatistics.java
trunk/src/main/org/jboss/messaging/newcore/intf/Transaction.java
trunk/src/main/org/jboss/messaging/newcore/intf/TransactionStore.java
trunk/src/main/org/jboss/messaging/newcore/intf/TransactionSynchronization.java
trunk/src/main/org/jboss/messaging/newcore/intf/cluster/ClusterMessage.java
trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupCoordinator.java
trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupHandler.java
trunk/src/main/org/jboss/messaging/newcore/intf/cluster/StateHandler.java
trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedList.java
trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedListImpl.java
trunk/tests/src/org/jboss/test/messaging/core/
trunk/tests/src/org/jboss/test/messaging/jms/persistence/
trunk/tests/src/org/jboss/test/messaging/util/CoreMessageFactory.java
Modified:
trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java
trunk/src/main/org/jboss/jms/client/JBossQueueBrowser.java
trunk/src/main/org/jboss/jms/client/JBossSession.java
trunk/src/main/org/jboss/jms/client/container/BrowserAspect.java
trunk/src/main/org/jboss/jms/client/container/ClientConsumer.java
trunk/src/main/org/jboss/jms/client/container/ProducerAspect.java
trunk/src/main/org/jboss/jms/client/container/SessionAspect.java
trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerPacketHandler.java
trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
trunk/src/main/org/jboss/jms/client/state/SessionState.java
trunk/src/main/org/jboss/jms/delegate/BrowserEndpoint.java
trunk/src/main/org/jboss/jms/delegate/DeliveryInfo.java
trunk/src/main/org/jboss/jms/delegate/SessionDelegate.java
trunk/src/main/org/jboss/jms/delegate/SessionEndpoint.java
trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java
trunk/src/main/org/jboss/jms/server/destination/ManagedQueue.java
trunk/src/main/org/jboss/jms/server/destination/ManagedTopic.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/SessionInternalEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java
trunk/src/main/org/jboss/jms/server/endpoint/advised/SessionAdvised.java
trunk/src/main/org/jboss/jms/server/selector/Selector.java
trunk/src/main/org/jboss/jms/server/selector/SelectorFactory.java
trunk/src/main/org/jboss/jms/tx/ClientTransaction.java
trunk/src/main/org/jboss/jms/tx/ResourceManager.java
trunk/src/main/org/jboss/messaging/core/contract/Channel.java
trunk/src/main/org/jboss/messaging/core/contract/Delivery.java
trunk/src/main/org/jboss/messaging/core/contract/FilterFactory.java
trunk/src/main/org/jboss/messaging/core/contract/MessageStore.java
trunk/src/main/org/jboss/messaging/core/contract/PersistenceManager.java
trunk/src/main/org/jboss/messaging/core/contract/PostOffice.java
trunk/src/main/org/jboss/messaging/core/contract/Queue.java
trunk/src/main/org/jboss/messaging/core/contract/Receiver.java
trunk/src/main/org/jboss/messaging/core/impl/ChannelSupport.java
trunk/src/main/org/jboss/messaging/core/impl/ClusterRoundRobinDistributor.java
trunk/src/main/org/jboss/messaging/core/impl/FirstReceiverDistributor.java
trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java
trunk/src/main/org/jboss/messaging/core/impl/MessagingQueue.java
trunk/src/main/org/jboss/messaging/core/impl/PagingChannelSupport.java
trunk/src/main/org/jboss/messaging/core/impl/RoundRobinDistributor.java
trunk/src/main/org/jboss/messaging/core/impl/SimpleDelivery.java
trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/MessageSucker.java
trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageStore.java
trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageHolder.java
trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageRequest.java
trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java
trunk/src/main/org/jboss/messaging/core/impl/postoffice/RequestTarget.java
trunk/src/main/org/jboss/messaging/core/impl/tx/TransactionRepository.java
trunk/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageResponseCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/codec/DeliverMessageCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/codec/SendMessageCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java
trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java
trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageRequest.java
trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageResponse.java
trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeliverMessage.java
trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SendMessage.java
trunk/src/main/org/jboss/messaging/newcore/impl/MessageImpl.java
trunk/src/main/org/jboss/messaging/newcore/impl/MessageReferenceImpl.java
trunk/src/main/org/jboss/messaging/newcore/impl/QueueImpl.java
trunk/src/main/org/jboss/messaging/newcore/impl/RoundRobinDistributionPolicy.java
trunk/src/main/org/jboss/messaging/newcore/impl/TransactionImpl.java
trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/BDBJEPersistenceManager.java
trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/integration/test/unit/BDBSpeedTest.java
trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/test/unit/BDBJEPersistenceManagerTest.java
trunk/src/main/org/jboss/messaging/newcore/impl/test/concurrent/QueueTest.java
trunk/src/main/org/jboss/messaging/newcore/impl/test/timing/QueueTest.java
trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/MessageTest.java
trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/QueueTest.java
trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/RoundRobinDistributionPolicyTest.java
trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/TransactionTest.java
trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/fakes/FakeConsumer.java
trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/fakes/FakeFilter.java
trunk/src/main/org/jboss/messaging/test/unit/UnitTestCase.java
trunk/src/main/org/jboss/messaging/util/SafeUTF.java
trunk/src/main/org/jboss/messaging/util/StreamUtils.java
trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java
trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java
trunk/tests/src/org/jboss/test/messaging/jms/BrowserTest.java
trunk/tests/src/org/jboss/test/messaging/jms/MessageProxyTest.java
trunk/tests/src/org/jboss/test/messaging/jms/ScheduledDeliveryTest.java
trunk/tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/JMSExpirationHeaderTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/MessageBodyTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java
trunk/tests/src/org/jboss/test/messaging/jms/selector/SelectorSyntaxTest.java
Log:
Core refactoring part I - use new Message and MessageReference
Modified: trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -34,12 +34,11 @@
import org.jboss.jms.client.delegate.DelegateSupport;
import org.jboss.jms.client.state.ConsumerState;
-import org.jboss.jms.client.state.SessionState;
import org.jboss.jms.delegate.ConnectionDelegate;
import org.jboss.jms.delegate.ConsumerDelegate;
import org.jboss.jms.delegate.SessionDelegate;
import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.message.MessageProxy;
+import org.jboss.jms.message.JBossMessage;
import org.jboss.logging.Logger;
import org.jboss.messaging.util.MessageQueueNameHelper;
@@ -287,7 +286,7 @@
for (int i = 0; i < mesList.size(); i++)
{
- MessageProxy m = (MessageProxy)mesList.get(i);
+ JBossMessage m = (JBossMessage)mesList.get(i);
session.addAsfMessage(m, consumerID, queueName, maxDeliveries, sess, shouldAck);
if (trace) { log.trace("added " + m + " to session"); }
}
Modified: trunk/src/main/org/jboss/jms/client/JBossQueueBrowser.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossQueueBrowser.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/JBossQueueBrowser.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -28,7 +28,11 @@
import javax.jms.Queue;
import javax.jms.QueueBrowser;
+import org.jboss.jms.client.container.BrowserAspect;
import org.jboss.jms.delegate.BrowserDelegate;
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.newcore.Message;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -39,6 +43,9 @@
{
// Constants ------------------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(JBossQueueBrowser.class);
+
+
private static final long serialVersionUID = 4245650830082712281L;
// Static ---------------------------------------------------------------------------------------
@@ -108,6 +115,7 @@
{
try
{
+
return delegate.hasNextMessage();
}
catch (JMSException e)
@@ -120,10 +128,17 @@
{
try
{
- return delegate.nextMessage();
+ Message message = delegate.nextMessage();
+
+ JBossMessage jbm = JBossMessage.createMessage(message, 0, 0);
+
+ jbm.doBeforeReceive();
+
+ return jbm;
}
- catch (JMSException e)
+ catch (Exception e)
{
+ e.printStackTrace();
throw new IllegalStateException(e.getMessage());
}
}
Modified: trunk/src/main/org/jboss/jms/client/JBossSession.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossSession.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/JBossSession.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -64,7 +64,7 @@
import org.jboss.jms.destination.JBossTemporaryQueue;
import org.jboss.jms.destination.JBossTemporaryTopic;
import org.jboss.jms.destination.JBossTopic;
-import org.jboss.jms.message.MessageProxy;
+import org.jboss.jms.message.JBossMessage;
import org.jboss.logging.Logger;
/**
@@ -462,7 +462,7 @@
* This method is used by the JBossConnectionConsumer to load up the session
* with messages to be processed by the session's run() method
*/
- void addAsfMessage(MessageProxy m, String consumerID, String queueName, int maxDeliveries,
+ void addAsfMessage(JBossMessage m, String consumerID, String queueName, int maxDeliveries,
SessionDelegate connectionConsumerSession, boolean shouldAck)
{
delegate.addAsfMessage(m, consumerID, queueName, maxDeliveries, connectionConsumerSession, shouldAck);
Modified: trunk/src/main/org/jboss/jms/client/container/BrowserAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/BrowserAspect.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/container/BrowserAspect.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -22,11 +22,15 @@
package org.jboss.jms.client.container;
import javax.jms.JMSException;
-import javax.jms.Message;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.jms.delegate.BrowserDelegate;
+import org.jboss.jms.server.endpoint.ServerBrowserEndpoint;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.newcore.Message;
+
+
/**
*
* Aspect that caches blocks of messages during queue browsing
@@ -42,6 +46,9 @@
{
// Constants -----------------------------------------------------
+ private static final Logger log = Logger.getLogger(BrowserAspect.class);
+
+
//TODO - these need to be configurable by the user - should be configured from jboss-aop.xml
//FIXME - This interceptor is currently broken
Modified: trunk/src/main/org/jboss/jms/client/container/ClientConsumer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ClientConsumer.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/container/ClientConsumer.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,23 +21,29 @@
*/
package org.jboss.jms.client.container;
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
-import org.jboss.jms.delegate.*;
-import org.jboss.jms.message.MessageProxy;
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.util.Future;
-import org.jboss.messaging.util.prioritylinkedlist.BasicPriorityLinkedList;
-import org.jboss.messaging.util.prioritylinkedlist.PriorityLinkedList;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import javax.jms.IllegalStateException;
import javax.jms.JMSException;
import javax.jms.MessageListener;
import javax.jms.Session;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import org.jboss.jms.delegate.Cancel;
+import org.jboss.jms.delegate.ConsumerDelegate;
+import org.jboss.jms.delegate.DefaultCancel;
+import org.jboss.jms.delegate.DeliveryInfo;
+import org.jboss.jms.delegate.SessionDelegate;
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.util.Future;
+import org.jboss.messaging.util.prioritylinkedlist.BasicPriorityLinkedList;
+import org.jboss.messaging.util.prioritylinkedlist.PriorityLinkedList;
+
+import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
+
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox/a>
@@ -64,15 +70,15 @@
trace = log.isTraceEnabled();
}
- private static boolean checkExpiredOrReachedMaxdeliveries(MessageProxy proxy,
+ private static boolean checkExpiredOrReachedMaxdeliveries(JBossMessage jbm,
SessionDelegate del,
int maxDeliveries, boolean shouldCancel)
{
- Message msg = proxy.getMessage();
+ Message msg = jbm.getCoreMessage();
boolean expired = msg.isExpired();
- boolean reachedMaxDeliveries = proxy.getDeliveryCount() == maxDeliveries;
+ boolean reachedMaxDeliveries = jbm.getDeliveryCount() == maxDeliveries;
if (expired || reachedMaxDeliveries)
{
@@ -80,17 +86,17 @@
{
if (expired)
{
- log.trace(proxy.getMessage() + " has expired, cancelling to server");
+ log.trace(msg + " has expired, cancelling to server");
}
else
{
- log.trace(proxy.getMessage() + " has reached maximum delivery number " + maxDeliveries +", cancelling to server");
+ log.trace(msg + " has reached maximum delivery number " + maxDeliveries +", cancelling to server");
}
}
if (shouldCancel)
{
- final Cancel cancel = new DefaultCancel(proxy.getDeliveryId(), proxy.getDeliveryCount(),
+ final Cancel cancel = new DefaultCancel(jbm.getDeliveryId(), jbm.getDeliveryCount(),
expired, reachedMaxDeliveries);
try
{
@@ -116,7 +122,7 @@
String consumerID,
String queueName,
boolean isConnectionConsumer,
- MessageProxy m,
+ JBossMessage m,
int ackMode,
int maxDeliveries,
SessionDelegate connectionConsumerSession,
@@ -154,9 +160,7 @@
}
catch (RuntimeException e)
{
- long id = m.getMessage().getMessageID();
-
- log.error("RuntimeException was thrown from onMessage, " + id + " will be redelivered", e);
+ log.error("RuntimeException was thrown from onMessage, " + m.getJMSMessageID() + " will be redelivered", e);
// See JMS 1.1 spec 4.5.2
@@ -255,7 +259,7 @@
*
* @param message The message
*/
- public void handleMessage(final Object message) throws Exception
+ public void handleMessage(final JBossMessage message) throws Exception
{
//TODO - we temporarily need to execute on a different thread to avoid a deadlock situation in
// failover where a message is sent then the valve is locked, and the message send cause
@@ -312,7 +316,7 @@
for(Iterator i = buffer.iterator(); i.hasNext();)
{
- MessageProxy mp = (MessageProxy)i.next();
+ JBossMessage mp = (JBossMessage)i.next();
DefaultCancel cancel =
new DefaultCancel(mp.getDeliveryId(), mp.getDeliveryCount(), false, false);
@@ -374,9 +378,9 @@
* or null if one is not immediately available. Returns null if the consumer is
* concurrently closed.
*/
- public MessageProxy receive(long timeout) throws JMSException
+ public JBossMessage receive(long timeout) throws JMSException
{
- MessageProxy m = null;
+ JBossMessage m = null;
synchronized (mainLock)
{
@@ -534,7 +538,7 @@
this.consumerID = consumerId;
}
- public void addToFrontOfBuffer(MessageProxy proxy) throws Exception
+ public void addToFrontOfBuffer(JBossMessage proxy) throws Exception
{
synchronized (mainLock)
{
@@ -771,7 +775,7 @@
}
}
- private MessageProxy getMessage(long timeout)
+ private JBossMessage getMessage(long timeout)
{
if (timeout == -1)
{
@@ -815,11 +819,11 @@
}
}
- MessageProxy m = null;
+ JBossMessage m = null;
if (!closed && !buffer.isEmpty())
{
- m = (MessageProxy)buffer.removeFirst();
+ m = (JBossMessage)buffer.removeFirst();
}
return m;
@@ -854,9 +858,9 @@
{
private int token;
- private Object message;
+ private JBossMessage message;
- HandleMessageRunnable(int token, Object message)
+ HandleMessageRunnable(int token, JBossMessage message)
{
this.token = token;
@@ -867,10 +871,8 @@
{
try
{
- MessageProxy proxy = (MessageProxy) message;
+ if (trace) { log.trace(this + " receiving message " + message + " from the remoting layer"); }
- if (trace) { log.trace(this + " receiving message " + proxy + " from the remoting layer"); }
-
synchronized (mainLock)
{
if (closed)
@@ -887,14 +889,14 @@
return;
}
- proxy.setSessionDelegate(sessionDelegate, isConnectionConsumer);
+ message.setSessionDelegate(sessionDelegate, isConnectionConsumer);
- proxy.getMessage().doBeforeReceive();
+ message.doBeforeReceive();
//Add it to the buffer
- buffer.addLast(proxy, proxy.getJMSPriority());
+ buffer.addLast(message, message.getJMSPriority());
- lastDeliveryId = proxy.getDeliveryId();
+ lastDeliveryId = message.getDeliveryId();
if (trace) { log.trace(this + " added message(s) to the buffer are now " + buffer.size() + " messages"); }
@@ -920,7 +922,7 @@
{
public void run()
{
- MessageProxy mp = null;
+ JBossMessage msg = null;
MessageListener theListener = null;
@@ -939,7 +941,7 @@
// remove a message from the buffer
- mp = (MessageProxy)buffer.removeFirst();
+ msg = (JBossMessage)buffer.removeFirst();
}
/*
@@ -952,12 +954,12 @@
* Solution - don't use a session executor - have a sesion thread instead much nicer
*/
- if (mp != null)
+ if (msg != null)
{
try
{
callOnMessage(sessionDelegate, theListener, consumerID, queueName,
- false, mp, ackMode, maxDeliveries, null, shouldAck);
+ false, msg, ackMode, maxDeliveries, null, shouldAck);
if (trace) { log.trace("Called callonMessage"); }
}
Modified: trunk/src/main/org/jboss/jms/client/container/ProducerAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ProducerAspect.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/container/ProducerAspect.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -38,14 +38,15 @@
import org.jboss.jms.client.state.SessionState;
import org.jboss.jms.delegate.ConnectionDelegate;
import org.jboss.jms.delegate.SessionDelegate;
+import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.message.JBossBytesMessage;
import org.jboss.jms.message.JBossMapMessage;
import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.message.JBossObjectMessage;
import org.jboss.jms.message.JBossStreamMessage;
import org.jboss.jms.message.JBossTextMessage;
-import org.jboss.jms.message.MessageProxy;
import org.jboss.logging.Logger;
+import org.jboss.messaging.newcore.impl.DestinationImpl;
/**
* Handles sending of messages plus handles get and set methods for Producer returning state from
@@ -173,99 +174,95 @@
// Generate the message id
ConnectionState connectionState = (ConnectionState)sessionState.getParent();
- long id = -1;
-
- JBossMessage messageToSend;
+ JBossMessage jbm;
+
boolean foreign = false;
-
- if (!(m instanceof MessageProxy))
+
+ //First convert from foreign message if appropriate
+ if (!(m instanceof JBossMessage))
{
// it's a foreign message
- foreign = true;
-
// JMS 1.1 Sect. 3.11.4: A provider must be prepared to accept, from a client,
// a message whose implementation is not one of its own.
-
+
// create a matching JBossMessage Type from JMS Type
- if(m instanceof BytesMessage)
+ if (m instanceof BytesMessage)
{
- messageToSend = new JBossBytesMessage((BytesMessage)m,0);
+ jbm = new JBossBytesMessage((BytesMessage)m);
}
- else if(m instanceof MapMessage)
+ else if (m instanceof MapMessage)
{
- messageToSend = new JBossMapMessage((MapMessage)m,0);
+ jbm = new JBossMapMessage((MapMessage)m);
}
- else if(m instanceof ObjectMessage)
+ else if (m instanceof ObjectMessage)
{
- messageToSend = new JBossObjectMessage((ObjectMessage)m,0);
+ jbm = new JBossObjectMessage((ObjectMessage)m);
}
- else if(m instanceof StreamMessage)
+ else if (m instanceof StreamMessage)
{
- messageToSend = new JBossStreamMessage((StreamMessage)m,0);
+ jbm = new JBossStreamMessage((StreamMessage)m);
}
- else if(m instanceof TextMessage)
+ else if (m instanceof TextMessage)
{
- messageToSend = new JBossTextMessage((TextMessage)m,0);
+ jbm = new JBossTextMessage((TextMessage)m);
}
else
{
- messageToSend = new JBossMessage(m, 0);
+ jbm = new JBossMessage(m);
}
- messageToSend.setJMSMessageID(null);
-
- //We must set the destination *after* converting from foreign message
- messageToSend.setJMSDestination(destination);
- if(connectionState.getRemotingConnection().isStrictTck())
- {
- m.setJMSDestination(destination);
- }
+ //Set the destination on the original message
+ m.setJMSDestination(destination);
+
+ foreign = true;
}
else
{
- // get the actual message
- MessageProxy proxy = (MessageProxy)m;
-
- m.setJMSDestination(destination);
-
- if (keepID)
- {
- id = proxy.getMessage().getMessageID();
- }
-
- //The following line executed on the proxy should cause a copy to occur
- //if it is necessary
- proxy.setJMSMessageID(null);
-
- //Get the underlying message
- messageToSend = proxy.getMessage();
-
- proxy.beforeSend();
+ jbm = (JBossMessage)m;
}
-
- // Set the new id
-
+
if (!keepID)
{
- id = connectionState.getIdGenerator().getId((ConnectionDelegate)connectionState.getDelegate());
- }
+ // Generate a new id
+ long id = connectionState.getIdGenerator().getId((ConnectionDelegate)connectionState.getDelegate());
+
+ jbm.getCoreMessage().setMessageID(id);
+
+ //Set to null - this will cause the next call to getJMSMessageID() on the jbm to recalculate
+ //it - need to do this to prevent any old cached value being retained
+
+ jbm.setJMSMessageID(null);
+ }
- messageToSend.setMessageId(id);
-
- // This only really used for BytesMessages and StreamMessages to reset their state
- messageToSend.doBeforeSend();
-
- // now that we know the messageID, set it also on the foreign message, if is the case
if (foreign)
{
- m.setJMSMessageID(messageToSend.getJMSMessageID());
+ m.setJMSMessageID(jbm.getJMSMessageID());
}
+
+ jbm.setJMSDestination(destination);
+ jbm.doBeforeSend();
+
+ JBossDestination dest = (JBossDestination)destination;
+
+ //Set the destination on the core message - TODO temp for refactoring
+ org.jboss.messaging.newcore.Destination coreDest =
+ new DestinationImpl(dest.isQueue() ? "Queue" : "Topic", dest.getName(), dest.isTemporary());
+
+ //FIXME - temp - for now we set destination as a header - should really be an attribute of the
+ //send packet - along with scheduleddelivery time
+
+ jbm.getCoreMessage().putHeader(org.jboss.messaging.newcore.Message.TEMP_DEST_HEADER_NAME, coreDest);
+
// we now invoke the send(Message) method on the session, which will eventually be fielded
// by connection endpoint
- ((SessionDelegate)sessionState.getDelegate()).send(messageToSend, false);
+ ((SessionDelegate)sessionState.getDelegate()).send(jbm.getCoreMessage(), false);
+ //TODO for now we always copy - for INVM we can optimise (like we did in 1.4) by doing lazy copying
+ //of message, header and properties
+ jbm.copyMessage();
+
return null;
}
Modified: trunk/src/main/org/jboss/jms/client/container/SessionAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/SessionAspect.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/container/SessionAspect.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,6 +21,19 @@
*/
package org.jboss.jms.client.container;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.jms.IllegalStateException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.ServerSessionPool;
+import javax.jms.Session;
+import javax.jms.TransactionInProgressException;
+
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.jms.client.JBossConnectionConsumer;
@@ -33,19 +46,16 @@
import org.jboss.jms.delegate.DeliveryInfo;
import org.jboss.jms.delegate.SessionDelegate;
import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.message.*;
+import org.jboss.jms.message.JBossBytesMessage;
+import org.jboss.jms.message.JBossMapMessage;
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.jms.message.JBossObjectMessage;
+import org.jboss.jms.message.JBossStreamMessage;
+import org.jboss.jms.message.JBossTextMessage;
import org.jboss.jms.tx.LocalTx;
import org.jboss.jms.tx.ResourceManager;
import org.jboss.logging.Logger;
-import javax.jms.IllegalStateException;
-import javax.jms.*;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
/**
* This aspect handles JMS session related logic
*
@@ -492,7 +502,7 @@
for (int i = toRedeliver.size() - 1; i >= 0; i--)
{
DeliveryInfo info = (DeliveryInfo)toRedeliver.get(i);
- MessageProxy proxy = info.getMessageProxy();
+ JBossMessage msg = info.getMessage();
ClientConsumer handler = state.getCallbackHandler(info.getConsumerId());
@@ -512,7 +522,7 @@
{
if (trace) { log.trace("Adding proxy back to front of buffer"); }
- handler.addToFrontOfBuffer(proxy);
+ handler.addToFrontOfBuffer(msg);
}
}
@@ -601,11 +611,11 @@
ConnectionState connState = (ConnectionState)state.getParent();
MethodInvocation mi = (MethodInvocation)invocation;
- Message m = (Message)mi.getArguments()[0];
+ org.jboss.messaging.newcore.Message m = (org.jboss.messaging.newcore.Message)mi.getArguments()[0];
if (trace) { log.trace("sending message " + m + " transactionally, queueing on resource manager txID=" + txID + " sessionID= " + state.getSessionID()); }
- connState.getResourceManager().addMessage(txID, state.getSessionID(), (JBossMessage)m);
+ connState.getResourceManager().addMessage(txID, state.getSessionID(), m);
// ... and we don't invoke any further interceptors in the stack
return null;
@@ -633,28 +643,28 @@
public Object handleCreateMessage(Invocation invocation) throws Throwable
{
- JBossMessage jbm = new JBossMessage(0);
+ JBossMessage jbm = new JBossMessage();
- return new MessageProxy(jbm);
+ return jbm;
}
public Object handleCreateBytesMessage(Invocation invocation) throws Throwable
{
- JBossBytesMessage jbm = new JBossBytesMessage(0);
+ JBossBytesMessage jbm = new JBossBytesMessage();
- return new BytesMessageProxy(jbm);
+ return jbm;
}
public Object handleCreateMapMessage(Invocation invocation) throws Throwable
{
- JBossMapMessage jbm = new JBossMapMessage(0);
+ JBossMapMessage jbm = new JBossMapMessage();
- return new MapMessageProxy(jbm);
+ return jbm;
}
public Object handleCreateObjectMessage(Invocation invocation) throws Throwable
{
- JBossObjectMessage jbm = new JBossObjectMessage(0);
+ JBossObjectMessage jbm = new JBossObjectMessage();
MethodInvocation mi = (MethodInvocation)invocation;
@@ -663,19 +673,19 @@
jbm.setObject((Serializable)mi.getArguments()[0]);
}
- return new ObjectMessageProxy(jbm);
+ return jbm;
}
public Object handleCreateStreamMessage(Invocation invocation) throws Throwable
{
- JBossStreamMessage jbm = new JBossStreamMessage(0);
+ JBossStreamMessage jbm = new JBossStreamMessage();
- return new StreamMessageProxy(jbm);
+ return jbm;
}
public Object handleCreateTextMessage(Invocation invocation) throws Throwable
{
- JBossTextMessage jbm = new JBossTextMessage(0);
+ JBossTextMessage jbm = new JBossTextMessage();
MethodInvocation mi = (MethodInvocation)invocation;
@@ -684,7 +694,7 @@
jbm.setText((String)mi.getArguments()[0]);
}
- return new TextMessageProxy(jbm);
+ return jbm;
}
public Object handleSetMessageListener(Invocation invocation) throws Throwable
@@ -737,7 +747,7 @@
// Load the session with a message to be processed during a subsequent call to run()
- MessageProxy m = (MessageProxy)mi.getArguments()[0];
+ JBossMessage m = (JBossMessage)mi.getArguments()[0];
String theConsumerID = (String)mi.getArguments()[1];
String queueName = (String)mi.getArguments()[2];
int maxDeliveries = ((Integer)mi.getArguments()[3]).intValue();
@@ -845,7 +855,7 @@
SessionDelegate sessionToUse = connectionConsumerSession != null ? connectionConsumerSession : sess;
sessionToUse.cancelDelivery(new DefaultCancel(delivery.getDeliveryID(),
- delivery.getMessageProxy().getDeliveryCount(), false, false));
+ delivery.getMessage().getDeliveryCount(), false, false));
}
}
@@ -859,8 +869,8 @@
if (ack.isShouldAck())
{
- DefaultCancel cancel = new DefaultCancel(ack.getMessageProxy().getDeliveryId(),
- ack.getMessageProxy().getDeliveryCount(),
+ DefaultCancel cancel = new DefaultCancel(ack.getMessage().getDeliveryId(),
+ ack.getMessage().getDeliveryCount(),
false, false);
cancels.add(cancel);
@@ -918,7 +928,7 @@
private static class AsfMessageHolder
{
- private MessageProxy msg;
+ private JBossMessage msg;
private String consumerID;
private String queueName;
private int maxDeliveries;
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -29,7 +29,6 @@
import org.jboss.jms.client.state.ConnectionState;
import org.jboss.jms.client.state.HierarchicalState;
import org.jboss.jms.delegate.BrowserDelegate;
-import org.jboss.jms.message.JBossMessage;
import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageRequest;
import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageResponse;
import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockRequest;
@@ -39,6 +38,7 @@
import org.jboss.messaging.core.remoting.wireformat.CloseMessage;
import org.jboss.messaging.core.remoting.wireformat.ClosingRequest;
import org.jboss.messaging.core.remoting.wireformat.ClosingResponse;
+import org.jboss.messaging.newcore.Message;
/**
* The client-side Browser delegate class.
@@ -124,13 +124,13 @@
return response.hasNext();
}
- public JBossMessage nextMessage() throws JMSException
+ public Message nextMessage() throws JMSException
{
BrowserNextMessageResponse response = (BrowserNextMessageResponse) sendBlocking(new org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageRequest());
return response.getMessage();
}
- public JBossMessage[] nextMessageBlock(int maxMessages) throws JMSException
+ public Message[] nextMessageBlock(int maxMessages) throws JMSException
{
BrowserNextMessageBlockResponse response = (BrowserNextMessageBlockResponse) sendBlocking(new BrowserNextMessageBlockRequest(maxMessages));
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerPacketHandler.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerPacketHandler.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -2,7 +2,6 @@
import org.jboss.jms.client.container.ClientConsumer;
import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.MessageProxy;
import org.jboss.messaging.core.remoting.PacketHandler;
import org.jboss.messaging.core.remoting.PacketSender;
import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
@@ -50,10 +49,12 @@
if (type == PacketType.MSG_DELIVERMESSAGE)
{
DeliverMessage message = (DeliverMessage) packet;
- // FIXME Classcast exception...
- MessageProxy proxy = JBossMessage.
- createThinDelegate(message.getDeliveryID(), (JBossMessage)message.getMessage(), message.getDeliveryCount());
- messageHandler.handleMessage(proxy);
+
+ JBossMessage msg = JBossMessage.createMessage(message.getMessage(), message.getDeliveryID(), message.getDeliveryCount());
+
+ msg.doBeforeReceive();
+
+ messageHandler.handleMessage(msg);
}
} catch (Exception e)
{
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -44,13 +44,12 @@
import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.destination.JBossQueue;
import org.jboss.jms.destination.JBossTopic;
-import org.jboss.jms.message.BytesMessageProxy;
+import org.jboss.jms.message.JBossBytesMessage;
+import org.jboss.jms.message.JBossMapMessage;
import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.MapMessageProxy;
-import org.jboss.jms.message.MessageProxy;
-import org.jboss.jms.message.ObjectMessageProxy;
-import org.jboss.jms.message.StreamMessageProxy;
-import org.jboss.jms.message.TextMessageProxy;
+import org.jboss.jms.message.JBossObjectMessage;
+import org.jboss.jms.message.JBossStreamMessage;
+import org.jboss.jms.message.JBossTextMessage;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.remoting.wireformat.AcknowledgeDeliveriesMessage;
import org.jboss.messaging.core.remoting.wireformat.AcknowledgeDeliveryRequest;
@@ -71,6 +70,7 @@
import org.jboss.messaging.core.remoting.wireformat.RecoverDeliveriesMessage;
import org.jboss.messaging.core.remoting.wireformat.SendMessage;
import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
+import org.jboss.messaging.newcore.Message;
/**
* The client-side Session delegate class.
@@ -228,7 +228,7 @@
* This invocation should either be handled by the client-side interceptor chain or by the
* server-side endpoint.
*/
- public BytesMessageProxy createBytesMessage() throws JMSException
+ public JBossBytesMessage createBytesMessage() throws JMSException
{
throw new IllegalStateException("This invocation should not be handled here!");
}
@@ -249,7 +249,7 @@
* This invocation should either be handled by the client-side interceptor chain or by the
* server-side endpoint.
*/
- public MapMessageProxy createMapMessage() throws JMSException
+ public JBossMapMessage createMapMessage() throws JMSException
{
throw new IllegalStateException("This invocation should not be handled here!");
}
@@ -258,7 +258,7 @@
* This invocation should either be handled by the client-side interceptor chain or by the
* server-side endpoint.
*/
- public MessageProxy createMessage() throws JMSException
+ public JBossMessage createMessage() throws JMSException
{
throw new IllegalStateException("This invocation should not be handled here!");
}
@@ -267,7 +267,7 @@
* This invocation should either be handled by the client-side interceptor chain or by the
* server-side endpoint.
*/
- public ObjectMessageProxy createObjectMessage() throws JMSException
+ public JBossObjectMessage createObjectMessage() throws JMSException
{
throw new IllegalStateException("This invocation should not be handled here!");
}
@@ -276,7 +276,7 @@
* This invocation should either be handled by the client-side interceptor chain or by the
* server-side endpoint.
*/
- public ObjectMessageProxy createObjectMessage(Serializable object) throws JMSException
+ public JBossObjectMessage createObjectMessage(Serializable object) throws JMSException
{
throw new IllegalStateException("This invocation should not be handled here!");
}
@@ -301,7 +301,7 @@
* This invocation should either be handled by the client-side interceptor chain or by the
* server-side endpoint.
*/
- public StreamMessageProxy createStreamMessage() throws JMSException
+ public JBossStreamMessage createStreamMessage() throws JMSException
{
throw new IllegalStateException("This invocation should not be handled here!");
}
@@ -310,7 +310,7 @@
* This invocation should either be handled by the client-side interceptor chain or by the
* server-side endpoint.
*/
- public TextMessageProxy createTextMessage() throws JMSException
+ public JBossTextMessage createTextMessage() throws JMSException
{
throw new IllegalStateException("This invocation should not be handled here!");
}
@@ -319,7 +319,7 @@
* This invocation should either be handled by the client-side interceptor chain or by the
* server-side endpoint.
*/
- public TextMessageProxy createTextMessage(String text) throws JMSException
+ public JBossTextMessage createTextMessage(String text) throws JMSException
{
throw new IllegalStateException("This invocation should not be handled here!");
}
@@ -444,13 +444,13 @@
* This invocation should either be handled by the client-side interceptor chain or by the
* server-side endpoint.
*/
- public void addAsfMessage(MessageProxy m, String consumerID, String queueName, int maxDeliveries,
+ public void addAsfMessage(JBossMessage m, String consumerID, String queueName, int maxDeliveries,
SessionDelegate connectionConsumerSession, boolean shouldAck)
{
throw new IllegalStateException("This invocation should not be handled here!");
}
- public void send(JBossMessage m, boolean checkForDuplicates) throws JMSException
+ public void send(Message m, boolean checkForDuplicates) throws JMSException
{
long seq;
@@ -468,19 +468,15 @@
}
SendMessage message = new SendMessage(m, checkForDuplicates, seq);
- sendBlocking(message);
-
-// RequestSupport req = new SessionSendRequest(id, version, m, checkForDuplicates, seq);
-//
-// if (seq == -1)
-// {
-// doInvoke(client, req);
-// }
-// else
-// {
-// doInvokeOneway(client, req);
-// }
+ if (seq == -1)
+ {
+ sendBlocking(message);
+ }
+ else
+ {
+ sendOneWay(message);
+ }
}
public void cancelDeliveries(List cancels) throws JMSException
Modified: trunk/src/main/org/jboss/jms/client/state/SessionState.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/state/SessionState.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/client/state/SessionState.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -295,7 +295,7 @@
for(Iterator i = getClientAckList().iterator(); i.hasNext(); )
{
DeliveryInfo info = (DeliveryInfo)i.next();
- if (!info.getMessageProxy().getMessage().isReliable())
+ if (!info.getMessage().getCoreMessage().isReliable())
{
i.remove();
log.trace("removed non persistent delivery " + info);
@@ -309,7 +309,7 @@
DeliveryInfo autoAck = getAutoAckInfo();
if (autoAck != null)
{
- if (!autoAck.getMessageProxy().getMessage().isReliable())
+ if (!autoAck.getMessage().getCoreMessage().isReliable())
{
// unreliable, discard
setAutoAckInfo(null);
@@ -340,8 +340,8 @@
{
DeliveryInfo del = (DeliveryInfo)i.next();
DeliveryRecovery recInfo =
- new DeliveryRecovery(del.getMessageProxy().getDeliveryId(),
- del.getMessageProxy().getMessage().getMessageID(),
+ new DeliveryRecovery(del.getMessage().getDeliveryId(),
+ del.getMessage().getCoreMessage().getMessageID(),
del.getQueueName());
recoveryInfos.add(recInfo);
Modified: trunk/src/main/org/jboss/jms/delegate/BrowserEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/BrowserEndpoint.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/delegate/BrowserEndpoint.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -24,7 +24,7 @@
import javax.jms.JMSException;
import org.jboss.jms.client.Closeable;
-import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.newcore.Message;
/**
* Represents the set of methods from the BrowserDelegate that are handled on the server. The rest
@@ -45,9 +45,9 @@
*/
void reset() throws JMSException;
- JBossMessage nextMessage() throws JMSException;
+ Message nextMessage() throws JMSException;
boolean hasNextMessage() throws JMSException;
- JBossMessage[] nextMessageBlock(int maxMessages) throws JMSException;
+ Message[] nextMessageBlock(int maxMessages) throws JMSException;
}
Modified: trunk/src/main/org/jboss/jms/delegate/DeliveryInfo.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/DeliveryInfo.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/delegate/DeliveryInfo.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,7 +21,7 @@
*/
package org.jboss.jms.delegate;
-import org.jboss.jms.message.MessageProxy;
+import org.jboss.jms.message.JBossMessage;
/**
* Struct like class for holding information regarding a delivery
@@ -44,7 +44,7 @@
//consumer gets the message
private String consumerId;
- private MessageProxy msg;
+ private JBossMessage msg;
//For messages in non durable subscriptions - there is no need to ack on the server
private boolean shouldAck;
@@ -62,7 +62,7 @@
// Constructors --------------------------------------------------
- public DeliveryInfo(MessageProxy msg, String consumerId, String queueName,
+ public DeliveryInfo(JBossMessage msg, String consumerId, String queueName,
SessionDelegate connectionConsumerSession, boolean shouldAck)
{
this.msg = msg;
@@ -88,7 +88,7 @@
return consumerId;
}
- public MessageProxy getMessageProxy()
+ public JBossMessage getMessage()
{
return msg;
}
Modified: trunk/src/main/org/jboss/jms/delegate/SessionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/SessionDelegate.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/delegate/SessionDelegate.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -29,12 +29,12 @@
import javax.transaction.xa.XAResource;
import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.message.BytesMessageProxy;
-import org.jboss.jms.message.MapMessageProxy;
-import org.jboss.jms.message.MessageProxy;
-import org.jboss.jms.message.ObjectMessageProxy;
-import org.jboss.jms.message.StreamMessageProxy;
-import org.jboss.jms.message.TextMessageProxy;
+import org.jboss.jms.message.JBossBytesMessage;
+import org.jboss.jms.message.JBossMapMessage;
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.jms.message.JBossObjectMessage;
+import org.jboss.jms.message.JBossStreamMessage;
+import org.jboss.jms.message.JBossTextMessage;
/**
* Represents the minimal set of operations to provide session functionality.
@@ -48,21 +48,21 @@
*/
public interface SessionDelegate extends SessionEndpoint
{
- MessageProxy createMessage() throws JMSException;
+ JBossMessage createMessage() throws JMSException;
- BytesMessageProxy createBytesMessage() throws JMSException;
+ JBossBytesMessage createBytesMessage() throws JMSException;
- MapMessageProxy createMapMessage() throws JMSException;
+ JBossMapMessage createMapMessage() throws JMSException;
- ObjectMessageProxy createObjectMessage() throws JMSException;
+ JBossObjectMessage createObjectMessage() throws JMSException;
- ObjectMessageProxy createObjectMessage(Serializable object) throws JMSException;
+ JBossObjectMessage createObjectMessage(Serializable object) throws JMSException;
- StreamMessageProxy createStreamMessage() throws JMSException;
+ JBossStreamMessage createStreamMessage() throws JMSException;
- TextMessageProxy createTextMessage() throws JMSException;
+ JBossTextMessage createTextMessage() throws JMSException;
- TextMessageProxy createTextMessage(String text) throws JMSException;
+ JBossTextMessage createTextMessage(String text) throws JMSException;
void preDeliver(DeliveryInfo deliveryInfo) throws JMSException;
@@ -76,7 +76,7 @@
XAResource getXAResource();
- void addAsfMessage(MessageProxy m, String consumerID, String queueName,
+ void addAsfMessage(JBossMessage m, String consumerID, String queueName,
int maxDeliveries, SessionDelegate connectionConsumerDelegate,
boolean shouldAck);
Modified: trunk/src/main/org/jboss/jms/delegate/SessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/SessionEndpoint.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/delegate/SessionEndpoint.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -30,7 +30,7 @@
import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.destination.JBossQueue;
import org.jboss.jms.destination.JBossTopic;
-import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.newcore.Message;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -111,7 +111,7 @@
* @param message The message to send
* @throws JMSException
*/
- void send(JBossMessage message, boolean checkForDuplicates) throws JMSException;
+ void send(Message message, boolean checkForDuplicates) throws JMSException;
/**
* Send delivery info to the server so the delivery lists can be repopulated. Used only in
Deleted: trunk/src/main/org/jboss/jms/message/BytesMessageProxy.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/BytesMessageProxy.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/BytesMessageProxy.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,302 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-import javax.jms.MessageNotReadableException;
-import javax.jms.MessageNotWriteableException;
-
-/**
- *
- * Thin proxy for a JBossBytesMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * BytesMessageProxy.java,v 1.1 2006/03/08 08:00:34 timfox Exp
- */
-public class BytesMessageProxy extends MessageProxy implements BytesMessage
-{
- private static final long serialVersionUID = -9121097962625801946L;
-
- public BytesMessageProxy(long deliveryId, JBossBytesMessage message, int deliveryCount)
- {
- super(deliveryId, message, deliveryCount);
- }
-
- public BytesMessageProxy(JBossBytesMessage message)
- {
- super(message);
- }
-
- public long getBodyLength() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).getBodyLength();
- }
-
- public boolean readBoolean() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readBoolean();
- }
-
- public byte readByte() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readByte();
- }
-
- public int readUnsignedByte() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readUnsignedByte();
- }
-
- public short readShort() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readShort();
- }
-
- public int readUnsignedShort() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readUnsignedShort();
- }
-
- public char readChar() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readChar();
- }
-
- public int readInt() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readInt();
- }
-
- public long readLong() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readLong();
- }
-
- public float readFloat() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readFloat();
- }
-
- public double readDouble() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readDouble();
- }
-
- public String readUTF() throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readUTF();
- }
-
- public int readBytes(byte[] value) throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readBytes(value);
- }
-
- public int readBytes(byte[] value, int length) throws JMSException
- {
- if (!bodyReadOnly)
- {
- throw new MessageNotReadableException("The message body is writeonly");
- }
- return ((BytesMessage)message).readBytes(value, length);
- }
-
- public void writeBoolean(boolean value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeBoolean(value);
- }
-
- public void writeByte(byte value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeByte(value);
- }
-
- public void writeShort(short value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeShort(value);
- }
-
- public void writeChar(char value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeChar(value);
- }
-
- public void writeInt(int value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeInt(value);
- }
-
- public void writeLong(long value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeLong(value);
- }
-
- public void writeFloat(float value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeFloat(value);
- }
-
- public void writeDouble(double value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeDouble(value);
- }
-
- public void writeUTF(String value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeUTF(value);
- }
-
- public void writeBytes(byte[] value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeBytes(value);
- }
-
- public void writeBytes(byte[] value, int offset, int length) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeBytes(value, offset, length);
- }
-
- public void writeObject(Object value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("the message body is read-only");
- }
- bodyChange();
- ((BytesMessage)message).writeObject(value);
- }
-
- public void reset() throws JMSException
- {
- ((BytesMessage)message).reset();
- bodyReadOnly = true;
- }
-}
Deleted: trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,701 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.util.Map;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-import javax.jms.MessageEOFException;
-import javax.jms.MessageFormatException;
-
-import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.logging.Logger;
-
-/**
- * This class implements javax.jms.BytesMessage.
- *
- * @author Norbert Lataille (Norbert.Lataille at m4x.org)
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- *
- * @version $Revision$
- *
- * $Id$
- */
-public class JBossBytesMessage extends JBossMessage implements BytesMessage
-{
- // Static -------------------------------------------------------
-
- private static final long serialVersionUID = 5914561890366707664L;
-
- private static final Logger log = Logger.getLogger(JBossBytesMessage.class);
-
- public static final byte TYPE = 4;
-
- // Attributes ----------------------------------------------------
-
- private boolean trace = log.isTraceEnabled();
-
- private transient ByteArrayOutputStream baos;
- private transient DataOutputStream dos;
-
- private transient ByteArrayInputStream bais;
- private transient DataInputStream dis;
-
- // Constructor ---------------------------------------------------
-
- /**
- * Only deserialization should use this constructor directly
- */
- public JBossBytesMessage()
- {
- }
-
- /*
- * This constructor is used to construct messages prior to sending
- */
- public JBossBytesMessage(long messageID)
- {
- super(messageID);
- }
-
- /*
- * This constructor is used to construct messages when retrieved from persistence storage
- */
- public JBossBytesMessage(long messageID,
- boolean reliable,
- long expiration,
- long timestamp,
- byte priority,
- Map coreHeaders,
- byte[] payloadAsByteArray)
- {
- super(messageID, reliable, expiration, timestamp, priority, coreHeaders, payloadAsByteArray);
- }
-
- /**
- *
- * Make a shallow copy of another JBossBytesMessage
- *
- * @param other
- */
- public JBossBytesMessage(JBossBytesMessage other)
- {
- super(other);
-
- if (trace) { log.trace("Creating new JBossBytesMessage from other JBossBytesMessage"); }
- }
-
- public JBossBytesMessage(BytesMessage foreign, long id) throws JMSException
- {
- super(foreign, id);
-
- foreign.reset();
-
- baos = new ByteArrayOutputStream();
- dos = new DataOutputStream(baos);
-
- byte[] buffer = new byte[1024];
- int n = foreign.readBytes(buffer);
- while (n != -1)
- {
- writeBytes(buffer, 0, n);
- n = foreign.readBytes(buffer);
- }
- }
-
- // Streamable override ---------------------------------------
-
- public void read(DataInputStream in) throws Exception
- {
- super.read(in);
- }
-
- // BytesMessage implementation -----------------------------------
-
- public boolean readBoolean() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readBoolean();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public byte readByte() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readByte();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public int readUnsignedByte() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readUnsignedByte();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public short readShort() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readShort();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public int readUnsignedShort() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readUnsignedShort();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public char readChar() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readChar();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public int readInt() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readInt();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public long readLong() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readLong();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public float readFloat() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readFloat();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public double readDouble() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readDouble();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public String readUTF() throws JMSException
- {
- checkRead();
- try
- {
- return dis.readUTF();
- }
- catch (EOFException e)
- {
- throw new MessageEOFException("");
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public int readBytes(byte[] value) throws JMSException
- {
- checkRead();
- try
- {
- return dis.read(value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public int readBytes(byte[] value, int length) throws JMSException
- {
- checkRead();
- try
- {
- return dis.read(value, 0, length);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeBoolean(boolean value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.writeBoolean(value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeByte(byte value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.writeByte(value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeShort(short value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.writeShort(value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeChar(char value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.writeChar(value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeInt(int value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.writeInt(value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeLong(long value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.writeLong(value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeFloat(float value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.writeFloat(value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeDouble(double value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.writeDouble(value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeUTF(String value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.writeUTF((String)value);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeBytes(byte[] value) throws JMSException
- {
- checkWrite();
- try
- {
- dos.write(value, 0, value.length);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeBytes(byte[] value, int offset, int length) throws JMSException
- {
- checkWrite();
- try
- {
- dos.write(value, offset, length);
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void writeObject(Object value) throws JMSException
- {
- checkWrite();
- try
- {
- if (value == null)
- {
- throw new NullPointerException("Attempt to write a new value");
- }
- if (value instanceof String)
- {
- dos.writeUTF((String)value);
- }
- else if (value instanceof Boolean)
- {
- dos.writeBoolean(((Boolean) value).booleanValue());
- }
- else if (value instanceof Byte)
- {
- dos.writeByte(((Byte) value).byteValue());
- }
- else if (value instanceof Short)
- {
- dos.writeShort(((Short) value).shortValue());
- }
- else if (value instanceof Integer)
- {
- dos.writeInt(((Integer) value).intValue());
- }
- else if (value instanceof Long)
- {
- dos.writeLong(((Long) value).longValue());
- }
- else if (value instanceof Float)
- {
- dos.writeFloat(((Float) value).floatValue());
- }
- else if (value instanceof Double)
- {
- dos.writeDouble(((Double) value).doubleValue());
- }
- else if (value instanceof byte[])
- {
- dos.write((byte[]) value, 0, ((byte[]) value).length);
- }
- else
- {
- throw new MessageFormatException("Invalid object for properties");
- }
- }
- catch (IOException e)
- {
- throw new MessagingJMSException("IOException", e);
- }
- }
-
- public void reset() throws JMSException
- {
- try
- {
- if (baos != null)
- {
- dos.flush();
-
- payload = baos.toByteArray();
-
- payloadAsByteArray = (byte[])payload;
-
- baos.close();
- }
- baos = null;
- bais = null;
- dis = null;
- dos = null;
- }
- catch (Exception e)
- {
- JMSException e2 = new JMSException(e.getMessage());
- e2.setStackTrace(e.getStackTrace());
- throw e2;
- }
- }
-
- // MessageSupport overrides --------------------------------------
-
- public Object getPayload()
- {
- return payload;
- }
-
- public byte[] getPayloadAsByteArray()
- {
- return payloadAsByteArray;
- }
-
- // JBossMessage overrides ----------------------------------------
-
- public void doBeforeSend() throws JMSException
- {
- reset();
- }
-
- public void doBeforeReceive() throws JMSException
- {
- //We need to reset before receive too http://jira.jboss.com/jira/browse/JBMESSAGING-1079
-
- reset();
- }
-
- public void clearBody() throws JMSException
- {
- try
- {
- if (baos != null)
- {
- baos.close();
- }
- else
- {
- if (bais != null)
- {
- bais.close();
- }
- }
- }
- catch (IOException e)
- {
- //don't throw an exception
- }
-
- baos = new ByteArrayOutputStream();
- dos = new DataOutputStream(baos);
- payload = null;
- payloadAsByteArray = null;
- bais = null;
- dis = null;
- }
-
- public long getBodyLength() throws JMSException
- {
- checkRead();
- return payloadAsByteArray.length;
- }
-
- // Public --------------------------------------------------------
-
- public byte getType()
- {
- return JBossBytesMessage.TYPE;
- }
-
- public JBossMessage doCopy() throws JMSException
- {
- reset();
-
- return new JBossBytesMessage(this);
- }
-
- public void copyPayload(Object payload) throws JMSException
- {
- byte[] otherBytes = (byte[])payload;
- if (otherBytes == null)
- {
- payload = null;
- }
- else
- {
- payload = new byte[otherBytes.length];
-
- System.arraycopy(otherBytes, 0, payload, 0, otherBytes.length);
-
- payloadAsByteArray = (byte[])payload;
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- void checkRead()
- {
- // We have just received/reset() the message, and the client is trying to
- // read it
- if (bais == null)
- {
- bais = new ByteArrayInputStream(payloadAsByteArray);
- dis = new DataInputStream(bais);
- }
- }
-
- void checkWrite()
- {
- if (baos == null)
- {
- baos = new ByteArrayOutputStream();
- dos = new DataOutputStream(baos);
- }
- }
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/src/main/org/jboss/jms/message/JBossMapMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossMapMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/JBossMapMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,499 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.MessageFormatException;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.Primitives;
-
-/**
- * This class implements javax.jms.MapMessage
- *
- * @author Norbert Lataille (Norbert.Lataille at m4x.org)
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- *
- * @version $Revision$
- *
- * $Id$
- */
-public class JBossMapMessage extends JBossMessage implements MapMessage
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 7939593521831220924L;
-
- public static final byte TYPE = 5;
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- /**
- * Only deserialization should use this constructor directory
- */
- public JBossMapMessage()
- {
- }
-
- /*
- * This constructor is used to construct messages prior to sending
- */
- public JBossMapMessage(long messageID)
- {
- super(messageID);
- payload = new HashMap();
- }
-
- /*
- * This constructor is used to construct messages when retrieved from persistence storage
- */
- public JBossMapMessage(long messageID, boolean reliable, long expiration, long timestamp,
- byte priority, Map coreHeaders, byte[] payloadAsByteArray)
- {
- super(messageID, reliable, expiration, timestamp, priority, coreHeaders, payloadAsByteArray);
- }
-
- public JBossMapMessage(JBossMapMessage other)
- {
- super(other);
- }
-
- /**
- *
- * Make a shallow copy of another JBossMapMessage
- * @param foreign
- * @throws JMSException
- */
- public JBossMapMessage(MapMessage foreign, long id) throws JMSException
- {
- super(foreign, id);
- payload = new HashMap();
- Enumeration names = foreign.getMapNames();
- while (names.hasMoreElements())
- {
- String name = (String)names.nextElement();
- Object obj = foreign.getObject(name);
- this.setObject(name, obj);
- }
- }
-
- // Public --------------------------------------------------------
-
- public byte getType()
- {
- return JBossMapMessage.TYPE;
- }
-
- public void copyPayload(Object otherPayload) throws JMSException
- {
- payload = new HashMap((Map)otherPayload);
- }
-
- // MapMessage implementation -------------------------------------
-
- public void setBoolean(String name, boolean value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, Primitives.valueOf(value));
- }
-
- public void setByte(String name, byte value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, new Byte(value));
- }
-
- public void setShort(String name, short value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, new Short(value));
- }
-
- public void setChar(String name, char value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, new Character(value));
- }
-
- public void setInt(String name, int value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, new Integer(value));
- }
-
- public void setLong(String name, long value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, new Long(value));
- }
-
- public void setFloat(String name, float value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, new Float(value));
- }
-
- public void setDouble(String name, double value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, new Double(value));
- }
-
- public void setString(String name, String value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, value);
- }
-
- public void setBytes(String name, byte[] value) throws JMSException
- {
- checkName(name);
- ((Map)getPayload()).put(name, value.clone());
- }
-
- public void setBytes(String name, byte[] value, int offset, int length) throws JMSException
- {
- checkName(name);
- if (offset + length > value.length)
- {
- throw new JMSException("Array is too small");
- }
- byte[] temp = new byte[length];
- for (int i = 0; i < length; i++)
- {
- temp[i] = value[i + offset];
- }
- ((Map)getPayload()).put(name, temp);
- }
-
- public void setObject(String name, Object value) throws JMSException
- {
- checkName(name);
- if (value instanceof Boolean)
- ((Map)getPayload()).put(name, value);
- else if (value instanceof Byte)
- ((Map)getPayload()).put(name, value);
- else if (value instanceof Short)
- ((Map)getPayload()).put(name, value);
- else if (value instanceof Character)
- ((Map)getPayload()).put(name, value);
- else if (value instanceof Integer)
- ((Map)getPayload()).put(name, value);
- else if (value instanceof Long)
- ((Map)getPayload()).put(name, value);
- else if (value instanceof Float)
- ((Map)getPayload()).put(name, value);
- else if (value instanceof Double)
- ((Map)getPayload()).put(name, value);
- else if (value instanceof String)
- ((Map)getPayload()).put(name, value);
- else if (value instanceof byte[])
- ((Map)getPayload()).put(name, ((byte[]) value).clone());
- else
- throw new MessageFormatException("Invalid object type.");
-
- }
-
- public boolean getBoolean(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- return Boolean.valueOf(null).booleanValue();
-
- if (value instanceof Boolean)
- return ((Boolean) value).booleanValue();
- else if (value instanceof String)
- return Boolean.valueOf((String) value).booleanValue();
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public byte getByte(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- return Byte.parseByte(null);
-
- if (value instanceof Byte)
- return ((Byte) value).byteValue();
- else if (value instanceof String)
- return Byte.parseByte((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public short getShort(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- return Short.parseShort(null);
-
- if (value instanceof Byte)
- return ((Byte) value).shortValue();
- else if (value instanceof Short)
- return ((Short) value).shortValue();
- else if (value instanceof String)
- return Short.parseShort((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public char getChar(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- throw new NullPointerException("Invalid conversion");
-
- if (value instanceof Character)
- return ((Character) value).charValue();
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public int getInt(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- return Integer.parseInt(null);
-
- if (value instanceof Byte)
- return ((Byte) value).intValue();
- else if (value instanceof Short)
- return ((Short) value).intValue();
- else if (value instanceof Integer)
- return ((Integer) value).intValue();
- else if (value instanceof String)
- return Integer.parseInt((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public long getLong(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- return Long.parseLong(null);
-
- if (value instanceof Byte)
- return ((Byte) value).longValue();
- else if (value instanceof Short)
- return ((Short) value).longValue();
- else if (value instanceof Integer)
- return ((Integer) value).longValue();
- else if (value instanceof Long)
- return ((Long) value).longValue();
- else if (value instanceof String)
- return Long.parseLong((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public float getFloat(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- return Float.parseFloat(null);
-
- if (value instanceof Float)
- return ((Float) value).floatValue();
- else if (value instanceof String)
- return Float.parseFloat((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public double getDouble(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- return Double.parseDouble(null);
-
- if (value instanceof Float)
- return ((Float) value).doubleValue();
- else if (value instanceof Double)
- return ((Double) value).doubleValue();
- else if (value instanceof String)
- return Double.parseDouble((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public String getString(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- return null;
-
- if (value instanceof Boolean)
- {
- return value.toString();
- }
- else if (value instanceof Byte)
- {
- return value.toString();
- }
- else if (value instanceof Short)
- {
- return value.toString();
- }
- else if (value instanceof Character)
- {
- return value.toString();
- }
- else if (value instanceof Integer)
- {
- return value.toString();
- }
- else if (value instanceof Long)
- {
- return value.toString();
- }
- else if (value instanceof Float)
- {
- return value.toString();
- }
- else if (value instanceof Double)
- {
- return value.toString();
- }
- else if (value instanceof String)
- {
- return (String) value;
- }
- else
- {
- throw new MessageFormatException("Invalid conversion");
- }
- }
-
- public byte[] getBytes(String name) throws JMSException
- {
- Object value;
-
- value = ((Map)getPayload()).get(name);
-
- if (value == null)
- return null;
- if (value instanceof byte[])
- return (byte[]) value;
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public Object getObject(String name) throws JMSException
- {
-
- return ((Map)getPayload()).get(name);
-
- }
-
- public Enumeration getMapNames() throws JMSException
- {
- return Collections.enumeration(new HashMap(((Map)getPayload())).keySet());
- }
-
- public boolean itemExists(String name) throws JMSException
- {
- return ((Map)getPayload()).containsKey(name);
- }
-
- // JBossMessage overrides ----------------------------------------
-
- public void clearBody() throws JMSException
- {
- super.clearBody();
- payload = new HashMap();
- payloadAsByteArray = null;
- }
-
- public JBossMessage doCopy()
- {
- return new JBossMapMessage(this);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- /**
- * Check the name
- *
- * @param name the name
- */
- private void checkName(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name must not be null.");
- }
-
- if (name.equals(""))
- {
- throw new IllegalArgumentException("Name must not be an empty String.");
- }
- }
-
- // Inner classes -------------------------------------------------
-
-}
-
Deleted: trunk/src/main/org/jboss/jms/message/JBossMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/JBossMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,1099 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.impl.message.MessageSupport;
-import org.jboss.util.Primitives;
-import org.jboss.util.Strings;
-
-import javax.jms.*;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.Serializable;
-import java.lang.IllegalStateException;
-import java.util.*;
-
-/**
- *
- * Implementation of a JMS Message
- *
- * Note that the only reason this class is Serializable is so that messages
- * can be returned from JMX operations.
- *
- * Java serialization is not used to serialize messages between client and server
- * in normal JMS operations
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:bershath at yahoo.com">Tyronne Wickramarathne</a>
- *
- * Partially ported from JBossMQ implementation originally written by:
- * @author Norbert Lataille (Norbert.Lataille at m4x.org)
- * @author Hiram Chirino (Cojonudo14 at hotmail.com)
- * @author David Maplesden (David.Maplesden at orion.co.nz)
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- *
- * $Id$
- */
-public class JBossMessage extends MessageSupport implements javax.jms.Message, Serializable
-{
- // Constants -----------------------------------------------------
- private static final long serialVersionUID = 2833181306818971346L;
-
- public static final byte TYPE = 1;
-
- private static final char PROPERTY_PREFIX_CHAR = 'P';
-
- private static final String PROPERTY_PREFIX = "P";
-
- private static final String DESTINATION_HEADER_NAME = "H.DEST";
-
- private static final String REPLYTO_HEADER_NAME = "H.REPLYTO";
-
- private static final String CORRELATIONID_HEADER_NAME = "H.CORRELATIONID";
-
- // When the message is sent through the cluster, it needs to keep the original messageID
- private static final String JBM_MESSAGE_ID = "JBM_MESSAGE_ID";
-
- private static final String CORRELATIONIDBYTES_HEADER_NAME = "H.CORRELATIONIDBYTES";
-
- private static final String TYPE_HEADER_NAME = "H.TYPE";
-
- public static final String JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME = "JMS_JBOSS_SCHEDULED_DELIVERY";
-
- //Used when sending a message to the DLQ
- public static final String JBOSS_MESSAGING_ORIG_DESTINATION = "JBM_ORIG_DESTINATION";
-
- //Used when sending a message to the DLQ
- public static final String JBOSS_MESSAGING_ORIG_MESSAGE_ID = "JBM_ORIG_MESSAGE_ID";
-
- //Used when sending a mesage to the DLQ
- public static final String JBOSS_MESSAGING_ACTUAL_EXPIRY_TIME = "JBM_ACTUAL_EXPIRY";
-
- //Used when bridging a message
- public static final String JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST = "JBM_BRIDGE_MSG_ID_LIST";
-
- private static final Logger log = Logger.getLogger(JBossMessage.class);
-
- // Static --------------------------------------------------------
-
- private static final HashSet reservedIdentifiers = new HashSet();
- static
- {
- reservedIdentifiers.add("NULL");
- reservedIdentifiers.add("TRUE");
- reservedIdentifiers.add("FALSE");
- reservedIdentifiers.add("NOT");
- reservedIdentifiers.add("AND");
- reservedIdentifiers.add("OR");
- reservedIdentifiers.add("BETWEEN");
- reservedIdentifiers.add("LIKE");
- reservedIdentifiers.add("IN");
- reservedIdentifiers.add("IS");
- reservedIdentifiers.add("ESCAPE");
- }
-
- public static MessageProxy createThinDelegate(long deliveryId, JBossMessage m, int deliveryCount)
- {
- MessageProxy del;
-
- if (m instanceof BytesMessage)
- {
- del = new BytesMessageProxy(deliveryId, (JBossBytesMessage)m, deliveryCount);
- }
- else if (m instanceof MapMessage)
- {
- del = new MapMessageProxy(deliveryId, (JBossMapMessage)m, deliveryCount);
- }
- else if (m instanceof ObjectMessage)
- {
- del = new ObjectMessageProxy(deliveryId, (JBossObjectMessage)m, deliveryCount);
- }
- else if (m instanceof StreamMessage)
- {
- del = new StreamMessageProxy(deliveryId, (JBossStreamMessage)m, deliveryCount);
- }
- else if (m instanceof TextMessage)
- {
- del = new TextMessageProxy(deliveryId, (JBossTextMessage)m, deliveryCount);
- }
- else
- {
- del = new MessageProxy(deliveryId, m, deliveryCount);
- }
-
- return del;
- }
-
- public static String dump(JBossMessage m)
- {
- String type = null;
- if (m instanceof BytesMessage)
- {
- type = "Bytes";
- }
- else if (m instanceof MapMessage)
- {
- type = "Map";
- }
- else if (m instanceof ObjectMessage)
- {
- type = "Object";
- }
- else if (m instanceof StreamMessage)
- {
- type = "Stream";
- }
- else if (m instanceof TextMessage)
- {
- type = "Text";
- }
- else
- {
- type = "Generic";
- }
-
- StringBuffer sb = new StringBuffer();
-
- sb.append("\n");
- sb.append(" MESSAGE DUMP\n");
- sb.append(" Core ID: ").append(m.messageID).append('\n');
- sb.append(" reliable: ").append(m.reliable).append('\n');
- sb.append(" expiration: ").append(m.expiration).append('\n');
- sb.append(" timestamp: ").append(m.timestamp).append('\n');
- sb.append(" headers: ");
-
- if (m.headers.size() == 0)
- {
- sb.append("NO HEADERS").append('\n');
- }
- else
- {
- sb.append('\n');
- for(Iterator i = m.headers.keySet().iterator(); i.hasNext(); )
- {
- String name = (String)i.next();
- sb.append(" ");
- sb.append(name).append(" - ").append(m.headers.get(name)).append('\n');
- }
- }
-
- int deliveryCount = 0;
- try
- {
- deliveryCount = m.getIntProperty("JMSXDeliveryCount");
- }
- catch (JMSException e)
- {
- log.error("Failed to get delivery count", e);
- }
-
- try
- {
- sb.append(" redelivered: ").append(deliveryCount >= 1).append('\n');
- sb.append(" priority: ").append(m.priority).append('\n');
- sb.append(" deliveryCount: ").append(deliveryCount).append('\n');
-
- sb.append(" JMS ID: ").append(m.getJMSMessageID()).append('\n');
- sb.append(" type: ").append(type).append('\n');
- sb.append(" destination: ").append(m.getJMSDestination()).append('\n');
- sb.append(" replyTo: ").append(m.getJMSReplyTo()).append('\n');
- sb.append(" jmsType: ").append(m.getJMSType()).append('\n');
- sb.append(" properties: ");
- }
- catch (Exception e)
- {
- log.error("Failed to dump message", e);
- }
-
- Iterator iter = m.headers.entrySet().iterator();
-
- int count = 0;
-
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
-
- String propName = (String)entry.getKey();
-
- if (propName.charAt(0) == PROPERTY_PREFIX_CHAR)
- {
- if (count == 0)
- {
- sb.append("\n");
- }
-
- sb.append(" ");
- sb.append(propName).append(" - ").append(entry.getValue()).append('\n');
-
- count++;
- }
- }
-
- sb.append("\n");
-
- return sb.toString();
- }
-
- // Attributes ----------------------------------------------------
-
- protected transient String connectionID;
-
- protected transient String jmsMessageID;
-
- //Optimisation - we could just store this as a header like everything else - but we store
- //As an attribute so we can prevent an extra lookup on the server
- private long scheduledDeliveryTime;
-
- //Optimisation - we could just store this as a header like everything else - but we store
- //As an attribute so we can prevent an extra lookup on the server
- private Destination destination;
-
- // Constructors --------------------------------------------------
-
- /*
- * Construct a message for deserialization or streaming
- */
- public JBossMessage()
- {
- }
-
- /*
- * Construct a message using default values
- */
- public JBossMessage(long messageID)
- {
- super(messageID, true, 0, System.currentTimeMillis(), (byte)4, null, null);
- }
-
- /*
- * Constructor using specified values
- */
- public JBossMessage(long messageID, boolean reliable, long expiration, long timestamp,
- byte priority, Map headers, byte[] payloadAsByteArray)
- {
- super (messageID, reliable, expiration, timestamp, priority, headers, payloadAsByteArray);
- }
-
- /**
- *
- * Create a new JBossMessage by making a shallow copy of another
- *
- * @param other The message to make a shallow copy from
- */
- protected JBossMessage(JBossMessage other)
- {
- super(other);
- this.connectionID = other.connectionID;
- this.scheduledDeliveryTime = other.scheduledDeliveryTime;
- this.destination = other.destination;
- }
-
- /**
- * A copy constructor for non-JBoss Messaging JMS messages.
- */
- public JBossMessage(Message foreign, long messageID) throws JMSException
- {
- super(messageID);
-
- setJMSTimestamp(foreign.getJMSTimestamp());
-
- try
- {
- byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes();
- setJMSCorrelationIDAsBytes(corrIDBytes);
- }
- catch(JMSException e)
- {
- // specified as String
- String corrIDString = foreign.getJMSCorrelationID();
- if (corrIDString != null)
- {
- setJMSCorrelationID(corrIDString);
- }
- }
-
- setJMSReplyTo(foreign.getJMSReplyTo());
- setJMSDestination(foreign.getJMSDestination());
- setJMSDeliveryMode(foreign.getJMSDeliveryMode());
- setJMSExpiration(foreign.getJMSExpiration());
- setJMSPriority(foreign.getJMSPriority());
- setJMSType(foreign.getJMSType());
-
- for (Enumeration props = foreign.getPropertyNames(); props.hasMoreElements(); )
- {
- String name = (String)props.nextElement();
-
- Object prop = foreign.getObjectProperty(name);
-
- this.setObjectProperty(name, prop);
- }
- }
-
-
- // Routable implementation ---------------------------------------
-
- public boolean isReference()
- {
- return false;
- }
-
- // javax.jmx.Message implementation ------------------------------
-
- public String getJMSMessageID()
- {
- if (jmsMessageID == null)
- {
- String headerID = (String)headers.get(JBM_MESSAGE_ID);
- if (headerID == null)
- {
- jmsMessageID = "ID:JBM-" + messageID;
- }
- else
- {
- jmsMessageID = headerID;
- }
- }
- return jmsMessageID;
- }
-
- public void setJMSMessageID(String jmsMessageID) throws JMSException
- {
- if (jmsMessageID != null && !jmsMessageID.startsWith("ID:"))
- {
- throw new JMSException("JMSMessageID must start with ID:");
- }
- if (jmsMessageID == null)
- {
- headers.remove(JBM_MESSAGE_ID);
- }
- else
- {
- headers.put(JBM_MESSAGE_ID, jmsMessageID);
- }
- this.jmsMessageID = jmsMessageID;
- }
-
- public long getJMSTimestamp() throws JMSException
- {
- return timestamp;
- }
-
- public void setJMSTimestamp(long timestamp) throws JMSException
- {
- this.timestamp = timestamp;
- }
-
- public byte[] getJMSCorrelationIDAsBytes() throws JMSException
- {
- return (byte[]) headers.get(CORRELATIONIDBYTES_HEADER_NAME);
- }
-
- public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException
- {
- if (correlationID == null || correlationID.length == 0)
- {
- throw new JMSException("Please specify a non-zero length byte[]");
- }
- headers.put(CORRELATIONIDBYTES_HEADER_NAME, correlationID);
-
- headers.remove(CORRELATIONID_HEADER_NAME);
- }
-
- public void setJMSCorrelationID(String correlationID) throws JMSException
- {
- headers.put(CORRELATIONID_HEADER_NAME, correlationID);
-
- headers.remove(CORRELATIONIDBYTES_HEADER_NAME);
- }
-
- public String getJMSCorrelationID() throws JMSException
- {
- return (String)headers.get(CORRELATIONID_HEADER_NAME);
- }
-
- public Destination getJMSReplyTo() throws JMSException
- {
- return (Destination)headers.get(REPLYTO_HEADER_NAME);
- }
-
- public void setJMSReplyTo(Destination replyTo) throws JMSException
- {
- headers.put(REPLYTO_HEADER_NAME, replyTo);
- }
-
- public Destination getJMSDestination() throws JMSException
- {
- if (destination != null)
- {
- return destination;
- }
- else
- {
- return (Destination)headers.get(DESTINATION_HEADER_NAME);
- }
- }
-
- public void setJMSDestination(Destination destination) throws JMSException
- {
- //We don't store as a header when setting - this allows us to avoid a lookup on the server
- //when routing the message
- this.destination = destination;
- }
-
- //We need to override getHeaders - so the JMSDestination header gets persisted to the db
- //This is called by the persistence manager
- public Map getHeaders()
- {
- if (destination != null)
- {
- headers.put(DESTINATION_HEADER_NAME, destination);
- }
-
- destination = null;
-
- return headers;
- }
-
- public int getJMSDeliveryMode() throws JMSException
- {
- return reliable ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
- }
-
- public void setJMSDeliveryMode(int deliveryMode) throws JMSException
- {
- if (deliveryMode == DeliveryMode.PERSISTENT)
- {
- reliable = true;
- }
- else if (deliveryMode == DeliveryMode.NON_PERSISTENT)
- {
- reliable = false;
- }
- else
- {
- throw new MessagingJMSException("Delivery mode must be either DeliveryMode.PERSISTENT "
- + "or DeliveryMode.NON_PERSISTENT");
- }
- }
-
- public boolean getJMSRedelivered() throws JMSException
- {
- throw new IllegalStateException("This should never be called directly");
- }
-
- public void setJMSRedelivered(boolean redelivered) throws JMSException
- {
- //Always dealt with on the proxy
- throw new IllegalStateException("This should never be called directly");
- }
-
- /**
- *
- * @return java.lang.String type
- * @throws JMSException
- */
- public String getJMSType() throws JMSException
- {
- return (String)headers.get(TYPE_HEADER_NAME);
- }
-
- /**
- *
- * @param type
- * @throws JMSException
- */
- public void setJMSType(String type) throws JMSException
- {
- headers.put(TYPE_HEADER_NAME, type);
- }
-
- public long getJMSExpiration() throws JMSException
- {
- return expiration;
- }
-
- public void setJMSExpiration(long expiration) throws JMSException
- {
- this.expiration = expiration;
- }
-
- public int getJMSPriority() throws JMSException
- {
- return priority;
- }
-
- public void setJMSPriority(int priority) throws JMSException
- {
- this.priority = (byte)priority;
- }
-
- public void clearProperties() throws JMSException
- {
- Iterator iter = headers.keySet().iterator();
-
- while (iter.hasNext())
- {
- String propName = (String)iter.next();
-
- if (propName.charAt(0) == PROPERTY_PREFIX_CHAR)
- {
- iter.remove();
- }
- }
- }
-
- public void clearBody() throws JMSException
- {
- payload = null;
-
- payloadAsByteArray = null;
- }
-
- public boolean propertyExists(String name) throws JMSException
- {
- return headers.containsKey(PROPERTY_PREFIX + name)
- || name.equals("JMSXDeliveryCount");
- }
-
- public boolean getBooleanProperty(String name) throws JMSException
- {
- Object value = headers.get(PROPERTY_PREFIX + name);
- if (value == null)
- return Boolean.valueOf(null).booleanValue();
-
- if (value instanceof Boolean)
- return ((Boolean) value).booleanValue();
- else if (value instanceof String)
- return Boolean.valueOf((String) value).booleanValue();
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public byte getByteProperty(String name) throws JMSException
- {
- Object value = headers.get(PROPERTY_PREFIX + name);
- if (value == null)
- throw new NumberFormatException("Message property '" + name + "' not set.");
-
- if (value instanceof Byte)
- return ((Byte) value).byteValue();
- else if (value instanceof String)
- return Byte.parseByte((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public short getShortProperty(String name) throws JMSException
- {
- Object value = headers.get(PROPERTY_PREFIX + name);
- if (value == null)
- throw new NumberFormatException("Message property '" + name + "' not set.");
-
- if (value instanceof Byte)
- return ((Byte) value).shortValue();
- else if (value instanceof Short)
- return ((Short) value).shortValue();
- else if (value instanceof String)
- return Short.parseShort((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public int getIntProperty(String name) throws JMSException
- {
- Object value = headers.get(PROPERTY_PREFIX + name);
-
- if (value == null)
- {
- throw new NumberFormatException("Message property '" + name + "' not set.");
- }
-
- if (value instanceof Byte)
- {
- return ((Byte) value).intValue();
- }
- else if (value instanceof Short)
- {
- return ((Short) value).intValue();
- }
- else if (value instanceof Integer)
- {
- return ((Integer) value).intValue();
- }
- else if (value instanceof String)
- {
- return Integer.parseInt((String) value);
- }
- else
- {
- throw new MessageFormatException("Invalid conversion");
- }
- }
-
- public long getLongProperty(String name) throws JMSException
- {
- if (JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME.equals(name))
- {
- if (this.scheduledDeliveryTime == 0)
- {
- throw new NumberFormatException("Message property '" + name + "' not set.");
- }
- else
- {
- return scheduledDeliveryTime;
- }
- }
-
- Object value = headers.get(PROPERTY_PREFIX + name);
-
- if (value == null)
- {
- throw new NumberFormatException("Message property '" + name + "' not set.");
- }
-
- if (value instanceof Byte)
- {
- return ((Byte) value).longValue();
- }
- else if (value instanceof Short)
- {
- return ((Short) value).longValue();
- }
- else if (value instanceof Integer)
- {
- return ((Integer) value).longValue();
- }
- else if (value instanceof Long)
- {
- return ((Long) value).longValue();
- }
- else if (value instanceof String)
- {
- return Long.parseLong((String) value);
- }
- else
- {
- throw new MessageFormatException("Invalid conversion");
- }
- }
-
- public float getFloatProperty(String name) throws JMSException
- {
- Object value = headers.get(PROPERTY_PREFIX + name);
- if (value == null)
- return Float.valueOf(null).floatValue();
-
- if (value instanceof Float)
- return ((Float) value).floatValue();
- else if (value instanceof String)
- return Float.parseFloat((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public double getDoubleProperty(String name) throws JMSException
- {
- Object value = headers.get(PROPERTY_PREFIX + name);
- if (value == null)
- return Double.valueOf(null).doubleValue();
-
- if (value instanceof Float)
- return ((Float) value).doubleValue();
- else if (value instanceof Double)
- return ((Double) value).doubleValue();
- else if (value instanceof String)
- return Double.parseDouble((String) value);
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
- public String getStringProperty(String name) throws JMSException
- {
- if (JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME.equals(name))
- {
- if (this.scheduledDeliveryTime == 0)
- {
- throw new NumberFormatException("Message property '" + name + "' not set.");
- }
- else
- {
- return String.valueOf(scheduledDeliveryTime);
- }
- }
-
- Object value = headers.get(PROPERTY_PREFIX + name);
- if (value == null)
- return null;
-
- if (value instanceof Boolean)
- {
- return value.toString();
- }
- else if (value instanceof Byte)
- {
- return value.toString();
- }
- else if (value instanceof Short)
- {
- return value.toString();
- }
- else if (value instanceof Integer)
- {
- return value.toString();
- }
- else if (value instanceof Long)
- {
- return value.toString();
- }
- else if (value instanceof Float)
- {
- return value.toString();
- }
- else if (value instanceof Double)
- {
- return value.toString();
- }
- else if (value instanceof String)
- {
- return (String) value;
- }
- else
- {
- throw new MessageFormatException("Invalid conversion");
- }
- }
-
- public Object getObjectProperty(String name) throws JMSException
- {
- if (JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME.equals(name))
- {
- if (scheduledDeliveryTime == 0)
- {
- return null;
- }
- else
- {
- return new Long(scheduledDeliveryTime);
- }
- }
-
- return headers.get(PROPERTY_PREFIX + name);
- }
-
- public Enumeration getPropertyNames() throws JMSException
- {
- HashSet set = new HashSet();
-
- Iterator iter = headers.keySet().iterator();
-
- while (iter.hasNext())
- {
- String propName = (String)iter.next();
-
- if (propName.charAt(0) == PROPERTY_PREFIX_CHAR)
- {
- String name = propName.substring(1);
- set.add(name);
- }
- }
-
- if (scheduledDeliveryTime != 0)
- {
- set.add(JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME);
- }
-
- return Collections.enumeration(set);
- }
-
- public void setBooleanProperty(String name, boolean value) throws JMSException
- {
- Boolean b = Primitives.valueOf(value);
- checkProperty(name, b);
- headers.put(PROPERTY_PREFIX + name, b);
- }
-
- public void setByteProperty(String name, byte value) throws JMSException
- {
- Byte b = new Byte(value);
- checkProperty(name, b);
- headers.put(PROPERTY_PREFIX + name, b);
- }
-
- public void setShortProperty(String name, short value) throws JMSException
- {
- Short s = new Short(value);
- checkProperty(name, s);
- headers.put(PROPERTY_PREFIX + name, s);
- }
-
- public void setIntProperty(String name, int value) throws JMSException
- {
- Integer i = new Integer(value);
- checkProperty(name, i);
- headers.put(PROPERTY_PREFIX + name, i);
- }
-
- public void setLongProperty(String name, long value) throws JMSException
- {
- // Optimisation - we don't actually store this as a header - but as an attribute
- if (JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME.equals(name))
- {
- this.scheduledDeliveryTime = value;
- }
- else
- {
- Long l = new Long(value);
- checkProperty(name, l);
- headers.put(PROPERTY_PREFIX + name, l);
- }
- }
-
- public void setFloatProperty(String name, float value) throws JMSException
- {
- Float f = new Float(value);
- checkProperty(name, f);
- headers.put(PROPERTY_PREFIX + name, f);
- }
-
- public void setDoubleProperty(String name, double value) throws JMSException
- {
- Double d = new Double(value);
- checkProperty(name, d);
- headers.put(PROPERTY_PREFIX + name, d);
- }
-
- public void setStringProperty(String name, String value) throws JMSException
- {
- checkProperty(name, value);
- headers.put(PROPERTY_PREFIX + name, value);
- }
-
- public void setObjectProperty(String name, Object value) throws JMSException
- {
- if (JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME.equals(name) && value instanceof Long)
- {
- this.scheduledDeliveryTime = ((Long)value).longValue();
- return;
- }
-
- checkProperty(name, value);
-
- if (value instanceof Boolean)
- {
- headers.put(PROPERTY_PREFIX + name, value);
- }
- else if (value instanceof Byte)
- {
- headers.put(PROPERTY_PREFIX + name, value);
- }
- else if (value instanceof Short)
- {
- headers.put(PROPERTY_PREFIX + name, value);
- }
- else if (value instanceof Integer)
- {
- headers.put(PROPERTY_PREFIX + name, value);
- }
- else if (value instanceof Long)
- {
- headers.put(PROPERTY_PREFIX + name, value);
- }
- else if (value instanceof Float)
- {
- headers.put(PROPERTY_PREFIX + name, value);
- }
- else if (value instanceof Double)
- {
- headers.put(PROPERTY_PREFIX + name, value);
- }
- else if (value instanceof String)
- {
- headers.put(PROPERTY_PREFIX + name, value);
- }
- else if (value == null)
- {
- headers.put(PROPERTY_PREFIX + name, null);
- }
- else
- {
- throw new MessageFormatException("Invalid object type");
- }
- }
-
- // Public --------------------------------------------------------
-
- public void doBeforeSend() throws JMSException
- {
- }
-
- public void doBeforeReceive() throws JMSException
- {
- }
-
- public byte getType()
- {
- return JBossMessage.TYPE;
- }
-
- public void copyPayload(Object payload) throws JMSException
- {
- }
-
- public String getConnectionID()
- {
- return connectionID;
- }
-
- public void setConnectionID(String connectionID)
- {
- this.connectionID = connectionID;
- }
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer("JBossMessage[");
- sb.append("");
- sb.append(messageID);
- sb.append("]:");
- sb.append(isReliable() ? "PERSISTENT" : "NON-PERSISTENT");
- return sb.toString();
- }
-
- public JBossMessage doCopy() throws JMSException
- {
- return new JBossMessage(this);
- }
-
- public void acknowledge()
- {
- throw new IllegalStateException("Should not be handled here!");
- }
-
- public void setMessageId(long messageID)
- {
- this.messageID = messageID;
- }
-
- public long getScheduledDeliveryTime()
- {
- return scheduledDeliveryTime;
- }
-
- /* Only used for testing */
- public Map getJMSProperties()
- {
- Map newHeaders = new HashMap();
-
- Iterator iter = headers.entrySet().iterator();
-
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
-
- String key = (String)entry.getKey();
-
- if (key.charAt(0) == PROPERTY_PREFIX_CHAR)
- {
- newHeaders.put(key, entry.getValue());
- }
- }
-
- return newHeaders;
- }
-
- //Only used for testing
- public boolean isCorrelationIDBytes()
- {
- return headers.get(CORRELATIONIDBYTES_HEADER_NAME) != null;
- }
-
-
- // Streamable implementation ---------------------------------
-
- public void write(DataOutputStream out) throws Exception
- {
- super.write(out);
-
- out.writeLong(scheduledDeliveryTime);
-
- JBossDestination.writeDestination(out, destination);
- }
-
- public void read(DataInputStream in) throws Exception
- {
- super.read(in);
-
- scheduledDeliveryTime = in.readLong();
-
- destination = JBossDestination.readDestination(in);
- }
-
- // Package protected ---------------------------------------------
-
- /**
- * Check a property is valid
- *
- * @param name the name
- * @param value the value
- * @throws JMSException for any error
- */
- void checkProperty(String name, Object value) throws JMSException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("The name of a property must not be null.");
- }
-
- if (name.equals(""))
- {
- throw new IllegalArgumentException("The name of a property must not be an empty String.");
- }
-
- if (!Strings.isValidJavaIdentifier(name))
- {
- throw new IllegalArgumentException("The property name '" + name +
- "' is not a valid java identifier.");
- }
-
- if (reservedIdentifiers.contains(name))
- {
- throw new IllegalArgumentException("The property name '" + name +
- "' is reserved due to selector syntax.");
- }
-
- if (name.startsWith("JMSX") &&
- !name.equals("JMSXGroupID") &&
- !name.equals("JMSXGroupSeq") &&
- !name.equals("JMSXDeliveryCount"))
- {
- throw new JMSException("Can only set JMSXGroupId, JMSXGroupSeq, JMSXDeliveryCount");
- }
- }
-
- // Protected -----------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/src/main/org/jboss/jms/message/JBossObjectMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossObjectMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/JBossObjectMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,147 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import org.jboss.messaging.util.StreamUtils;
-
-import java.io.Serializable;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Map;
-
-import javax.jms.JMSException;
-import javax.jms.ObjectMessage;
-
-/**
- * This class implements javax.jms.ObjectMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- *
- * @version $Revision$
- *
- * $Id$
- */
-public class JBossObjectMessage extends JBossMessage implements ObjectMessage
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = -2374448267737763502L;
-
- public static final byte TYPE = 2;
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- /**
- * Only deserialization should use this constructor directory
- */
- public JBossObjectMessage()
- {
- }
-
- /*
- * This constructor is used to construct messages prior to sending
- */
- public JBossObjectMessage(long messageID)
- {
- super(messageID);
- }
-
- /*
- * This constructor is used to construct messages when retrieved from persistence storage
- */
- public JBossObjectMessage(long messageID, boolean reliable, long expiration, long timestamp,
- byte priority, Map coreHeaders, byte[] payloadAsByteArray)
- {
- super(messageID, reliable, expiration, timestamp, priority, coreHeaders, payloadAsByteArray);
- }
-
-
- /**
- *
- * Make a shallow copy of another JBossObjectMessage
- * @param other
- */
- public JBossObjectMessage(JBossObjectMessage other)
- {
- super(other);
- }
-
- /**
- * A copy constructor for non-JBoss Messaging JMS ObjectMessages.
- */
- public JBossObjectMessage(ObjectMessage foreign, long id) throws JMSException
- {
- super(foreign, id);
-
- setObject(foreign.getObject());
- }
-
- // Public --------------------------------------------------------
-
- public byte getType()
- {
- return JBossObjectMessage.TYPE;
- }
-
-
- // ObjectMessage implementation ----------------------------------
-
- public void setObject(Serializable object) throws JMSException
- {
- payload = object;
-
- //Trigger serialization
- getPayloadAsByteArray();
-
- payload = null;
- }
-
- public Serializable getObject() throws JMSException
- {
- return (Serializable)getPayload();
- }
-
- // JBossMessage overrides ----------------------------------------
-
- public JBossMessage doCopy()
- {
- return new JBossObjectMessage(this);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void doWriteObject(DataOutputStream out, Object payload) throws IOException
- {
- StreamUtils.writeObject(out, payload, false, true);
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/src/main/org/jboss/jms/message/JBossStreamMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossStreamMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/JBossStreamMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,686 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.jms.JMSException;
-import javax.jms.MessageEOFException;
-import javax.jms.MessageFormatException;
-import javax.jms.StreamMessage;
-
-import org.jboss.messaging.util.StreamUtils;
-import org.jboss.util.Primitives;
-
-/**
- * This class implements javax.jms.StreamMessage.
- *
- * @author Norbert Lataille (Norbert.Lataille at m4x.org)
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- *
- * @version $Revision$
- *
- * $Id$
- */
-public class JBossStreamMessage extends JBossMessage implements StreamMessage
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 7469150228071568233L;
-
- public static final byte TYPE = 6;
-
- // Attributes ----------------------------------------------------
-
- protected transient int position;
-
- protected transient int offset;
-
- protected int size;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- /**
- * Only deserialization should use this constructor directory
- */
- public JBossStreamMessage()
- {
- }
-
- /*
- * This constructor is used to construct messages prior to sending
- */
- public JBossStreamMessage(long messageID)
- {
- super(messageID);
- payload = new ArrayList();
- position = 0;
- size = 0;
- offset = 0;
- }
-
- /*
- * This constructor is used to construct messages when retrieved from persistence storage
- */
- public JBossStreamMessage(long messageID, boolean reliable, long expiration, long timestamp,
- byte priority, Map coreHeaders, byte[] payloadAsByteArray)
- {
- super(messageID, reliable, expiration, timestamp, priority, coreHeaders, payloadAsByteArray);
- }
-
- /**
- *
- * Make a shallow copy of another JBossStreamMessage
- *
- * @param other
- */
- public JBossStreamMessage(JBossStreamMessage other)
- {
- super(other);
- }
-
- public JBossStreamMessage(StreamMessage foreign, long id) throws JMSException
- {
- super(foreign, id);
-
- foreign.reset();
-
- payload = new ArrayList();
- position = 0;
- size = 0;
- offset = 0;
- try
- {
- while (true)
- {
- Object obj = foreign.readObject();
- this.writeObject(obj);
- }
- }
- catch (MessageEOFException e)
- {
- //Ignore
- }
- }
-
- // Public --------------------------------------------------------
-
- public byte getType()
- {
- return JBossStreamMessage.TYPE;
- }
-
- public void doBeforeSend() throws JMSException
- {
- reset();
- }
-
- public void doBeforeReceive() throws JMSException
- {
- //We need to reset before receive too http://jira.jboss.com/jira/browse/JBMESSAGING-1079
-
- reset();
- }
-
- public void copyPayload(Object other) throws JMSException
- {
- reset();
- payload = new ArrayList((List)other);
- payloadAsByteArray = null;
- }
-
- // StreamMessage implementation ----------------------------------
-
- public boolean readBoolean() throws JMSException
- {
-
- try
- {
- Object value = ((List)getPayload()).get(position);
- offset = 0;
-
- if (value == null)
- throw new NullPointerException("Value is null");
- else if (value instanceof Boolean)
- {
- position++;
- return ((Boolean) value).booleanValue();
- }
- else if (value instanceof String)
- {
- boolean result = Boolean.valueOf((String) value).booleanValue();
- position++;
- return result;
- }
- else
- throw new MessageFormatException("Invalid conversion");
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
-
- }
-
- public byte readByte() throws JMSException
- {
- try
- {
- Object value = ((List)getPayload()).get(position);
- offset = 0;
- if (value == null)
- throw new NullPointerException("Value is null");
- else if (value instanceof Byte)
- {
- position++;
- return ((Byte) value).byteValue();
- }
- else if (value instanceof String)
- {
- byte result = Byte.parseByte((String) value);
- position++;
- return result;
- }
- else
- throw new MessageFormatException("Invalid conversion");
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public short readShort() throws JMSException
- {
- try
- {
- Object value = ((List)getPayload()).get(position);
- offset = 0;
-
- if (value == null)
- throw new NullPointerException("Value is null");
- else if (value instanceof Byte)
- {
- position++;
- return ((Byte) value).shortValue();
- }
- else if (value instanceof Short)
- {
- position++;
- return ((Short) value).shortValue();
- }
- else if (value instanceof String)
- {
- short result = Short.parseShort((String) value);
- position++;
- return result;
- }
- else
- throw new MessageFormatException("Invalid conversion");
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public char readChar() throws JMSException
- {
- try
- {
- Object value = ((List)getPayload()).get(position);
- offset = 0;
-
- if (value == null)
- throw new NullPointerException("Value is null");
- else if (value instanceof Character)
- {
- position++;
- return ((Character) value).charValue();
- }
- else
- throw new MessageFormatException("Invalid conversion");
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public int readInt() throws JMSException
- {
- try
- {
- Object value = ((List)getPayload()).get(position);
- offset = 0;
-
- if (value == null)
- throw new NullPointerException("Value is null");
- else if (value instanceof Byte)
- {
- position++;
- return ((Byte) value).intValue();
- }
- else if (value instanceof Short)
- {
- position++;
- return ((Short) value).intValue();
- }
- else if (value instanceof Integer)
- {
- position++;
- return ((Integer) value).intValue();
- }
- else if (value instanceof String)
- {
- int result = Integer.parseInt((String) value);
- position++;
- return result;
- }
- else
- throw new MessageFormatException("Invalid conversion");
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public long readLong() throws JMSException
- {
- try
- {
- Object value = ((List)getPayload()).get(position);
- offset = 0;
-
- if (value == null)
- throw new NullPointerException("Value is null");
- else if (value instanceof Byte)
- {
- position++;
- return ((Byte) value).longValue();
- }
- else if (value instanceof Short)
- {
- position++;
- return ((Short) value).longValue();
- }
- else if (value instanceof Integer)
- {
- position++;
- return ((Integer) value).longValue();
- }
- else if (value instanceof Long)
- {
- position++;
- return ((Long) value).longValue();
- }
- else if (value instanceof String)
- {
- long result = Long.parseLong((String) value);
- position++;
- return result;
- }
- else
- throw new MessageFormatException("Invalid conversion");
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public float readFloat() throws JMSException
- {
- try
- {
- Object value = ((List)getPayload()).get(position);
- offset = 0;
-
- if (value == null)
- throw new NullPointerException("Value is null");
- else if (value instanceof Float)
- {
- position++;
- return ((Float) value).floatValue();
- }
- else if (value instanceof String)
- {
- float result = Float.parseFloat((String) value);
- position++;
- return result;
- }
- else
- throw new MessageFormatException("Invalid conversion");
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public double readDouble() throws JMSException
- {
- try
- {
- Object value = ((List)getPayload()).get(position);
- offset = 0;
-
- if (value == null)
- throw new NullPointerException("Value is null");
- else if (value instanceof Float)
- {
- position++;
- return ((Float) value).doubleValue();
- }
- else if (value instanceof Double)
- {
- position++;
- return ((Double) value).doubleValue();
- }
- else if (value instanceof String)
- {
- double result = Double.parseDouble((String) value);
- position++;
- return result;
- }
- else
- throw new MessageFormatException("Invalid conversion");
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public String readString() throws JMSException
- {
- try
- {
- Object value = ((List)getPayload()).get(position);
- offset = 0;
-
- if (value == null)
- {
- position++;
- return null;
- }
- else if (value instanceof Boolean)
- {
- position++;
- return ((Boolean) value).toString();
- }
- else if (value instanceof Byte)
- {
- position++;
- return ((Byte) value).toString();
- }
- else if (value instanceof Short)
- {
- position++;
- return ((Short) value).toString();
- }
- else if (value instanceof Character)
- {
- position++;
- return ((Character) value).toString();
- }
- else if (value instanceof Integer)
- {
- position++;
- return ((Integer) value).toString();
- }
- else if (value instanceof Long)
- {
- position++;
- return ((Long) value).toString();
- }
- else if (value instanceof Float)
- {
- position++;
- return ((Float) value).toString();
- }
- else if (value instanceof Double)
- {
- position++;
- return ((Double) value).toString();
- }
- else if (value instanceof String)
- {
- position++;
- return (String) value;
- }
- else
- throw new MessageFormatException("Invalid conversion");
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public int readBytes(byte[] value) throws JMSException
- {
- try
- {
- Object myObj = ((List)getPayload()).get(position);
- if (myObj == null)
- throw new NullPointerException("Value is null");
- else if (!(myObj instanceof byte[]))
- throw new MessageFormatException("Invalid conversion");
- byte[] obj = (byte[]) myObj;
-
- if (obj.length == 0)
- {
- position++;
- offset = 0;
- return 0;
- }
-
- if (offset >= obj.length)
- {
- position++;
- offset = 0;
- return -1;
- }
-
- if (obj.length - offset < value.length)
- {
- for (int i = 0; i < obj.length; i++)
- value[i] = obj[i + offset];
-
- position++;
- offset = 0;
-
- return obj.length - offset;
- }
- else
- {
- for (int i = 0; i < value.length; i++)
- value[i] = obj[i + offset];
- offset += value.length;
-
- return value.length;
- }
-
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public Object readObject() throws JMSException
- {
- try
- {
- Object value = ((List)getPayload()).get(position);
- position++;
- offset = 0;
-
- return value;
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new MessageEOFException("");
- }
- }
-
- public void writeBoolean(boolean value) throws JMSException
- {
-
- ((List)getPayload()).add(Primitives.valueOf(value));
- }
-
- public void writeByte(byte value) throws JMSException
- {
- ((List)getPayload()).add(new Byte(value));
- }
-
- public void writeShort(short value) throws JMSException
- {
- ((List)getPayload()).add(new Short(value));
- }
-
- public void writeChar(char value) throws JMSException
- {
- ((List)getPayload()).add(new Character(value));
- }
-
- public void writeInt(int value) throws JMSException
- {
- ((List)getPayload()).add(new Integer(value));
- }
-
- public void writeLong(long value) throws JMSException
- {
- ((List)getPayload()).add(new Long(value));
- }
-
- public void writeFloat(float value) throws JMSException
- {
- ((List)getPayload()).add(new Float(value));
- }
-
- public void writeDouble(double value) throws JMSException
- {
- ((List)getPayload()).add(new Double(value));
- }
-
- public void writeString(String value) throws JMSException
- {
- if (value == null)
- {
- ((List)getPayload()).add(null);
- }
- else
- {
- ((List)getPayload()).add(value);
- }
- }
-
- public void writeBytes(byte[] value) throws JMSException
- {
- ((List)getPayload()).add(value.clone());
- }
-
- public void writeBytes(byte[] value, int offset, int length) throws JMSException
- {
- if (offset + length > value.length)
- throw new JMSException("Array is too small");
- byte[] temp = new byte[length];
- for (int i = 0; i < length; i++)
- temp[i] = value[i + offset];
-
- ((List)getPayload()).add(temp);
- }
-
- public void writeObject(Object value) throws JMSException
- {
- if (value == null)
- ((List)getPayload()).add(null);
- else if (value instanceof Boolean)
- ((List)getPayload()).add(value);
- else if (value instanceof Byte)
- ((List)getPayload()).add(value);
- else if (value instanceof Short)
- ((List)getPayload()).add(value);
- else if (value instanceof Character)
- ((List)getPayload()).add(value);
- else if (value instanceof Integer)
- ((List)getPayload()).add(value);
- else if (value instanceof Long)
- ((List)getPayload()).add(value);
- else if (value instanceof Float)
- ((List)getPayload()).add(value);
- else if (value instanceof Double)
- ((List)getPayload()).add(value);
- else if (value instanceof String)
- ((List)getPayload()).add(value);
- else if (value instanceof byte[])
- ((List)getPayload()).add(((byte[]) value).clone());
- else
- throw new MessageFormatException("Invalid object type");
- }
-
- public void reset() throws JMSException
- {
- position = 0;
- size = ((List)getPayload()).size();
- offset = 0;
- }
-
- // JBossMessage overrides ----------------------------------------
-
- public void clearBody() throws JMSException
- {
- super.clearBody();
-
- payload = new ArrayList();
- payloadAsByteArray = null;
- position = 0;
- offset = 0;
- size = 0;
-
- }
-
- public JBossMessage doCopy()
- {
- return new JBossStreamMessage(this);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/src/main/org/jboss/jms/message/JBossTextMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossTextMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/JBossTextMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import java.util.Map;
-
-import javax.jms.JMSException;
-import javax.jms.TextMessage;
-
-/**
- * This class implements javax.jms.TextMessage ported from SpyTextMessage in JBossMQ.
- *
- * @author Norbert Lataille (Norbert.Lataille at m4x.org)
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- *
- * @version $Revision$
- *
- * $Id$
- */
-public class JBossTextMessage extends JBossMessage implements TextMessage
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = -5661567664746852006L;
-
- public static final byte TYPE = 3;
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- /**
- * Only deserialization should use this constructor directory
- */
- public JBossTextMessage()
- {
- }
-
- /*
- * This constructor is used to construct messages prior to sending
- */
- public JBossTextMessage(long messageID)
- {
- super(messageID);
- }
-
- /*
- * This constructor is used to construct messages when retrieved from persistence storage
- */
- public JBossTextMessage(long messageID, boolean reliable, long expiration, long timestamp,
- byte priority, Map coreHeaders, byte[] payloadAsByteArray)
- {
- super(messageID, reliable, expiration, timestamp, priority, coreHeaders, payloadAsByteArray);
- }
-
- /**
- *
- * Make a shallow copy of another JBossTextMessage
- *
- * @param other
- */
- public JBossTextMessage(JBossTextMessage other)
- {
- super(other);
- }
-
- /**
- * A copy constructor for non-JBoss Messaging JMS TextMessages.
- */
- public JBossTextMessage(TextMessage foreign, long id) throws JMSException
- {
- super(foreign, id);
- String text = foreign.getText();
- if (text != null)
- {
- setText(text);
- }
-
- }
-
- // Public --------------------------------------------------------
-
- public byte getType()
- {
- return JBossTextMessage.TYPE;
- }
-
- // TextMessage implementation ------------------------------------
-
- public void setText(String string) throws JMSException
- {
- payload = string;
- payloadAsByteArray = null;
- }
-
- public String getText() throws JMSException
- {
- return (String)getPayload();
- }
-
- // JBossMessage override -----------------------------------------
-
- public JBossMessage doCopy()
- {
- return new JBossTextMessage(this);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
- // Public --------------------------------------------------------
-}
\ No newline at end of file
Deleted: trunk/src/main/org/jboss/jms/message/MapMessageProxy.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/MapMessageProxy.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/MapMessageProxy.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,236 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import java.util.Enumeration;
-
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.MessageNotWriteableException;
-
-/**
- *
- * Thin proxy for a JBossMapMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * MapMessageProxy.java,v 1.1 2006/03/08 08:00:34 timfox Exp
- */
-public class MapMessageProxy extends MessageProxy implements MapMessage
-{
- private static final long serialVersionUID = 6953530870351885569L;
-
- public MapMessageProxy(long deliveryId, JBossMapMessage message, int deliveryCount)
- {
- super(deliveryId, message, deliveryCount);
- }
-
- public MapMessageProxy(JBossMapMessage message)
- {
- super(message);
- }
-
- public boolean getBoolean(String name) throws JMSException
- {
- return ((MapMessage)message).getBoolean(name);
- }
-
- public byte getByte(String name) throws JMSException
- {
- return ((MapMessage)message).getByte(name);
- }
-
- public short getShort(String name) throws JMSException
- {
- return ((MapMessage)message).getShort(name);
- }
-
- public char getChar(String name) throws JMSException
- {
- return ((MapMessage)message).getChar(name);
- }
-
- public int getInt(String name) throws JMSException
- {
- return ((MapMessage)message).getInt(name);
- }
-
- public long getLong(String name) throws JMSException
- {
- return ((MapMessage)message).getLong(name);
- }
-
- public float getFloat(String name) throws JMSException
- {
- return ((MapMessage)message).getFloat(name);
- }
-
- public double getDouble(String name) throws JMSException
- {
- return ((MapMessage)message).getDouble(name);
- }
-
- public String getString(String name) throws JMSException
- {
- return ((MapMessage)message).getString(name);
- }
-
- public byte[] getBytes(String name) throws JMSException
- {
- return ((MapMessage)message).getBytes(name);
- }
-
- public Object getObject(String name) throws JMSException
- {
- return ((MapMessage)message).getObject(name);
- }
-
- public Enumeration getMapNames() throws JMSException
- {
- return ((MapMessage)message).getMapNames();
- }
-
- public void setBoolean(String name, boolean value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setBoolean(name, value);
- }
-
- public void setByte(String name, byte value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setByte(name, value);
- }
-
- public void setShort(String name, short value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setShort(name, value);
- }
-
- public void setChar(String name, char value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setChar(name, value);
- }
-
- public void setInt(String name, int value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setInt(name, value);
- }
-
- public void setLong(String name, long value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setLong(name, value);
- }
-
- public void setFloat(String name, float value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setFloat(name, value);
- }
-
- public void setDouble(String name, double value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setDouble(name, value);
- }
-
- public void setString(String name, String value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setString(name, value);
- }
-
- public void setBytes(String name, byte[] value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setBytes(name, value);
- }
-
- public void setBytes(String name, byte[] value, int offset, int length) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setBytes(name, value, offset, length);
- }
-
- public void setObject(String name, Object value) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("Message is ReadOnly !");
- }
- bodyChange();
- ((MapMessage)message).setObject(name, value);
- }
-
- public boolean itemExists(String name) throws JMSException
- {
- return ((MapMessage)message).itemExists(name);
- }
-}
Deleted: trunk/src/main/org/jboss/jms/message/MessageProxy.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/MessageProxy.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/MessageProxy.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,510 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import java.io.Serializable;
-import java.util.Enumeration;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageNotWriteableException;
-
-import org.jboss.jms.delegate.SessionDelegate;
-import org.jboss.logging.Logger;
-
-/**
- *
- * MessageProxy is a thin proxy for JBossMessage.
- *
- * JMS Users actually handle MessageProxy instances rather than JBossMessage instances. The purpose
- * of this class and subclasses is to prevent unnecessary copying of a message. After a message is
- * sent, the message can be changed, but this should not affect the sent message. This class
- * accomplishes this by intercepting any methods which change the state of the message and copying
- * either the headers, jms properties or body as appropriate. This enables up to make the minimum
- * amount of copies while still preserving JMS semantics. Similarly on receive.
- *
- * See JMS1.1 Spec 3.9, 3.10 for more details.
- *
- * If nothing is changed, nothing is copied.
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * MessageProxy.java,v 1.1 2006/03/08 08:00:34 timfox Exp
- */
-public class MessageProxy implements Message, Serializable
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 5903095946142192468L;
-
- protected Logger log = Logger.getLogger(MessageProxy.class);
-
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- //The actual session delegate for the message - needed for doing recovery
- //so we can recover locally
- private transient SessionDelegate delegate;
-
- private transient boolean cc;
-
- private int deliveryCount;
-
- private long deliveryId;
-
- private transient boolean needToCopyHeader;
-
- private transient boolean needToCopyBody;
-
- public void beforeSend()
- {
- this.needToCopyHeader = true;
-
- this.needToCopyBody = true;
-
- this.propertiesReadOnly = false;
-
- this.bodyReadOnly = false;
- }
-
- private transient boolean propertiesReadOnly;
-
- protected transient boolean bodyReadOnly;
-
-
- protected JBossMessage message;
-
- // Constructors --------------------------------------------------
-
- public MessageProxy()
- {
- }
-
- /*
- * Constructor for a new message
- */
- public MessageProxy(JBossMessage message)
- {
- this.message = message;
-
- this.needToCopyHeader = false;
-
- this.needToCopyBody = false;
- }
-
- /*
- * COnstructor for a message received by a consumer
- */
- public MessageProxy(long deliveryId, JBossMessage message, int deliveryCount)
- {
- this.deliveryId = deliveryId;
-
- this.message = message;
-
- this.deliveryCount = deliveryCount;
-
- this.needToCopyHeader = true;
-
- this.needToCopyBody = true;
-
- this.propertiesReadOnly = true;
-
- this.bodyReadOnly = true;
- }
-
- // Message implementation ----------------------------------------
-
- public String getJMSMessageID() throws JMSException
- {
- return message.getJMSMessageID();
- }
-
- public void setJMSMessageID(String id) throws JMSException
- {
- headerChange();
- message.setJMSMessageID(id);
- }
-
- public long getJMSTimestamp() throws JMSException
- {
- return message.getJMSTimestamp();
- }
-
- public void setJMSTimestamp(long timestamp) throws JMSException
- {
- headerChange();
- message.setJMSTimestamp(timestamp);
- }
-
- public byte[] getJMSCorrelationIDAsBytes() throws JMSException
- {
- return message.getJMSCorrelationIDAsBytes();
- }
-
- public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException
- {
- headerChange();
- message.setJMSCorrelationIDAsBytes(correlationID);
- }
-
- public void setJMSCorrelationID(String correlationID) throws JMSException
- {
- headerChange();
- message.setJMSCorrelationID(correlationID);
- }
-
- public String getJMSCorrelationID() throws JMSException
- {
- return message.getJMSCorrelationID();
- }
-
- public Destination getJMSReplyTo() throws JMSException
- {
- return message.getJMSReplyTo();
- }
-
- public void setJMSReplyTo(Destination replyTo) throws JMSException
- {
- headerChange();
- message.setJMSReplyTo(replyTo);
- }
-
- public Destination getJMSDestination() throws JMSException
- {
- return message.getJMSDestination();
- }
-
- public void setJMSDestination(Destination destination) throws JMSException
- {
- headerChange();
- message.setJMSDestination(destination);
- }
-
- public int getJMSDeliveryMode() throws JMSException
- {
- return message.getJMSDeliveryMode();
- }
-
- public void setJMSDeliveryMode(int deliveryMode) throws JMSException
- {
- headerChange();
- message.setJMSDeliveryMode(deliveryMode);
- }
-
- public boolean getJMSRedelivered() throws JMSException
- {
- //Always handled in the delegate
- //This is because when sending a message to a topic (for instance)
- //with multiple subscriptions all in the same VM, then we don't copy the original
- //message for performance reasons, unless necessary, but each reference might have
- //it's own value for delivery count
- return deliveryCount >= 2;
- }
-
- public void setJMSRedelivered(boolean redelivered) throws JMSException
- {
- //Always handled in the delegate
- if (deliveryCount == 1)
- {
- deliveryCount++;
- }
- else
- {
- //do nothing
- }
- }
-
- public String getJMSType() throws JMSException
- {
- return message.getJMSType();
- }
-
- public void setJMSType(String type) throws JMSException
- {
- headerChange();
- message.setJMSType(type);
- }
-
- public long getJMSExpiration() throws JMSException
- {
- return message.getJMSExpiration();
- }
-
- public void setJMSExpiration(long expiration) throws JMSException
- {
- headerChange();
- message.setJMSExpiration(expiration);
- }
-
- public int getJMSPriority() throws JMSException
- {
- return message.getJMSPriority();
- }
-
- public void setJMSPriority(int priority) throws JMSException
- {
- headerChange();
- message.setJMSPriority(priority);
- }
-
- public void clearProperties() throws JMSException
- {
- headerChange();
- message.clearProperties();
- propertiesReadOnly = false;
- }
-
- public boolean propertyExists(String name) throws JMSException
- {
- return message.propertyExists(name);
- }
-
- public boolean getBooleanProperty(String name) throws JMSException
- {
- return message.getBooleanProperty(name);
- }
-
- public byte getByteProperty(String name) throws JMSException
- {
- return message.getByteProperty(name);
- }
-
- public short getShortProperty(String name) throws JMSException
- {
- return message.getShortProperty(name);
- }
-
- public int getIntProperty(String name) throws JMSException
- {
- //JMSDeliveryCount is always dealt within inside the proxy
- if ("JMSXDeliveryCount".equals(name))
- {
- return deliveryCount;
- }
- return message.getIntProperty(name);
- }
-
- public long getLongProperty(String name) throws JMSException
- {
- //JMSDeliveryCount is always dealt within inside the proxy
- if ("JMSXDeliveryCount".equals(name))
- {
- return deliveryCount;
- }
- return message.getLongProperty(name);
- }
-
- public float getFloatProperty(String name) throws JMSException
- {
- return message.getFloatProperty(name);
- }
-
- public double getDoubleProperty(String name) throws JMSException
- {
- return message.getDoubleProperty(name);
- }
-
- public String getStringProperty(String name) throws JMSException
- {
- //JMSDeliveryCount is always dealt within inside the proxy
- if ("JMSXDeliveryCount".equals(name))
- {
- return Integer.toString(deliveryCount);
- }
- return message.getStringProperty(name);
- }
-
- public Object getObjectProperty(String name) throws JMSException
- {
- return message.getObjectProperty(name);
- }
-
- public Enumeration getPropertyNames() throws JMSException
- {
- return message.getPropertyNames();
- }
-
- public void setBooleanProperty(String name, boolean value) throws JMSException
- {
- if (propertiesReadOnly)
- throw new MessageNotWriteableException("Properties are read-only");
- headerChange();
- message.setBooleanProperty(name, value);
- }
-
- public void setByteProperty(String name, byte value) throws JMSException
- {
- if (propertiesReadOnly)
- throw new MessageNotWriteableException("Properties are read-only");
- headerChange();
- message.setByteProperty(name, value);
- }
-
- public void setShortProperty(String name, short value) throws JMSException
- {
- if (propertiesReadOnly)
- throw new MessageNotWriteableException("Properties are read-only");
- headerChange();
- message.setShortProperty(name, value);
- }
-
- public void setIntProperty(String name, int value) throws JMSException
- {
- if (propertiesReadOnly)
- throw new MessageNotWriteableException("Properties are read-only");
- headerChange();
- message.setIntProperty(name, value);
- }
-
- public void setLongProperty(String name, long value) throws JMSException
- {
- if (propertiesReadOnly)
- throw new MessageNotWriteableException("Properties are read-only");
- headerChange();
- message.setLongProperty(name, value);
- }
-
- public void setFloatProperty(String name, float value) throws JMSException
- {
- if (propertiesReadOnly)
- throw new MessageNotWriteableException("Properties are read-only");
- headerChange();
- message.setFloatProperty(name, value);
- }
-
- public void setDoubleProperty(String name, double value) throws JMSException
- {
- if (propertiesReadOnly)
- throw new MessageNotWriteableException("Properties are read-only");
- headerChange();
- message.setDoubleProperty(name, value);
- }
-
- public void setStringProperty(String name, String value) throws JMSException
- {
- if (propertiesReadOnly)
- throw new MessageNotWriteableException("Properties are read-only");
- headerChange();
- message.setStringProperty(name, value);
- }
-
- public void setObjectProperty(String name, Object value) throws JMSException
- {
- if (propertiesReadOnly)
- throw new MessageNotWriteableException("Properties are read-only");
- headerChange();
- message.setObjectProperty(name, value);
- }
-
- public void acknowledge() throws JMSException
- {
- if (!cc)
- {
- //Only acknowledge for client ack if is not in connection consumer
- delegate.acknowledgeAll();
- }
- }
-
- public void clearBody() throws JMSException
- {
- bodyChange();
- message.clearBody();
- bodyReadOnly = false;
- }
-
-
- // Public --------------------------------------------------------
-
- public void setSessionDelegate(SessionDelegate sd, boolean isConnectionConsumer)
- {
- this.delegate = sd;
- this.cc = isConnectionConsumer;
- }
-
- public SessionDelegate getSessionDelegate()
- {
- return delegate;
- }
-
- public JBossMessage getMessage()
- {
- return message;
- }
-
- public int getDeliveryCount()
- {
- return deliveryCount;
- }
-
- public void incDeliveryCount()
- {
- this.deliveryCount++;
- }
-
- public long getDeliveryId()
- {
- return deliveryId;
- }
-
- public String toString()
- {
- return "delegator->" + message + ", deliveryId=" + deliveryId;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void headerChange() throws JMSException
- {
- if (needToCopyHeader)
- {
- copyMessage();
- }
- }
-
- protected void bodyChange() throws JMSException
- {
- if (needToCopyBody)
- {
- headerChange();
-
- message.copyPayload(message.getPayload());
-
- needToCopyBody = false;
- }
- }
-
- // Private -------------------------------------------------------
-
- private void copyMessage() throws JMSException
- {
- message = message.doCopy();
-
- needToCopyHeader = false;
- }
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/src/main/org/jboss/jms/message/ObjectMessageProxy.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/ObjectMessageProxy.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/ObjectMessageProxy.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import java.io.Serializable;
-
-import javax.jms.JMSException;
-import javax.jms.MessageNotWriteableException;
-import javax.jms.ObjectMessage;
-
-/**
- *
- * Thin proxy for a JBossObjectMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * ObjectMessageProxy.java,v 1.1 2006/03/08 08:00:34 timfox Exp
- */
-public class ObjectMessageProxy extends MessageProxy implements ObjectMessage
-{
- private static final long serialVersionUID = 8797295997477962825L;
-
- public ObjectMessageProxy(long deliveryId, JBossObjectMessage message, int deliveryCount)
- {
- super(deliveryId, message, deliveryCount);
- }
-
- public ObjectMessageProxy(JBossObjectMessage message)
- {
- super(message);
- }
-
- public void setObject(Serializable object) throws JMSException
- {
- if (bodyReadOnly)
- {
- throw new MessageNotWriteableException("setObject");
- }
- bodyChange();
- ((ObjectMessage)message).setObject(object);
- }
-
- public Serializable getObject() throws JMSException
- {
- return ((ObjectMessage)message).getObject();
- }
-}
Deleted: trunk/src/main/org/jboss/jms/message/StreamMessageProxy.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/StreamMessageProxy.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/StreamMessageProxy.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,241 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import javax.jms.JMSException;
-import javax.jms.MessageNotReadableException;
-import javax.jms.MessageNotWriteableException;
-import javax.jms.StreamMessage;
-
-/**
- *
- * Thin proxy for a JBossStreamMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * StreamMessageProxy.java,v 1.1 2006/03/08 08:00:34 timfox Exp
- */
-public class StreamMessageProxy extends MessageProxy implements StreamMessage
-{
- private static final long serialVersionUID = 856367553964704474L;
-
- public StreamMessageProxy(long deliveryId, JBossStreamMessage message, int deliveryCount)
- {
- super(deliveryId, message, deliveryCount);
- }
-
- public StreamMessageProxy(JBossStreamMessage message)
- {
- super(message);
- }
-
- public boolean readBoolean() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readBoolean();
- }
-
- public byte readByte() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readByte();
- }
-
- public int readBytes(byte[] value) throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readBytes(value);
- }
-
- public char readChar() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readChar();
- }
-
- public double readDouble() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readDouble();
- }
-
- public float readFloat() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readFloat();
- }
-
- public int readInt() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readInt();
- }
-
- public long readLong() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readLong();
- }
-
- public Object readObject() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readObject();
- }
-
- public short readShort() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readShort();
- }
-
- public String readString() throws JMSException
- {
- if (!bodyReadOnly)
- throw new MessageNotReadableException("The message body is writeonly");
-
- return ((StreamMessage)message).readString();
- }
-
- public void reset() throws JMSException
- {
- bodyReadOnly = true;
- ((StreamMessage)message).reset();
- }
-
- public void writeBoolean(boolean value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeBoolean(value);
- }
-
- public void writeByte(byte value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeByte(value);
- }
-
- public void writeBytes(byte[] value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeBytes(value);
- }
-
- public void writeBytes(byte[] value, int offset, int length) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeBytes(value, offset, length);
- }
-
- public void writeChar(char value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeChar(value);
- }
-
- public void writeDouble(double value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeDouble(value);
- }
-
- public void writeFloat(float value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeFloat(value);
- }
-
- public void writeInt(int value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeInt(value);
- }
-
- public void writeLong(long value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeLong(value);
- }
-
- public void writeObject(Object value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeObject(value);
- }
-
- public void writeShort(short value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeShort(value);
- }
-
- public void writeString(String value) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("The message body is readonly");
- bodyChange();
- ((StreamMessage)message).writeString(value);
- }
-}
-
Deleted: trunk/src/main/org/jboss/jms/message/TextMessageProxy.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/TextMessageProxy.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/message/TextMessageProxy.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.message;
-
-import javax.jms.JMSException;
-import javax.jms.MessageNotWriteableException;
-import javax.jms.TextMessage;
-
-/**
- *
- * Thin proxy for a JBossTextMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class TextMessageProxy extends MessageProxy implements TextMessage
-{
- private static final long serialVersionUID = -3530143417050205123L;
-
- public TextMessageProxy(long deliveryId, JBossTextMessage message, int deliveryCount)
- {
- super(deliveryId, message, deliveryCount);
- }
-
- public TextMessageProxy(JBossTextMessage message)
- {
- super(message);
- }
-
- public void setText(String string) throws JMSException
- {
- if (bodyReadOnly)
- throw new MessageNotWriteableException("Cannot set the content; message is read-only");
- bodyChange();
- ((TextMessage)message).setText(string);
- }
-
- public String getText() throws JMSException
- {
- return ((TextMessage)message).getText();
- }
-}
Modified: trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -27,12 +27,14 @@
import javax.jms.Destination;
import javax.jms.JMSSecurityException;
-import javax.jms.Message;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.message.JBossMessage;
+import org.jboss.jms.destination.JBossQueue;
+import org.jboss.jms.destination.JBossTemporaryQueue;
+import org.jboss.jms.destination.JBossTemporaryTopic;
+import org.jboss.jms.destination.JBossTopic;
import org.jboss.jms.server.SecurityStore;
import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
import org.jboss.jms.server.endpoint.ServerConsumerEndpoint;
@@ -44,7 +46,8 @@
import org.jboss.jms.server.security.SecurityMetadata;
import org.jboss.jms.tx.ClientTransaction;
import org.jboss.jms.tx.TransactionRequest;
-import org.jboss.logging.Logger;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.newcore.Message;
/**
* This aspect enforces the JBossMessaging JMS security policy.
@@ -145,18 +148,48 @@
MethodInvocation mi = (MethodInvocation)invocation;
- Message m = (Message)mi.getArguments()[0];
- Destination dest = m.getJMSDestination();
+ org.jboss.messaging.newcore.Message m = (org.jboss.messaging.newcore.Message)mi.getArguments()[0];
+ org.jboss.messaging.newcore.Destination dest =
+ (org.jboss.messaging.newcore.Destination)m.getHeader(org.jboss.messaging.newcore.Message.TEMP_DEST_HEADER_NAME);
SessionAdvised del = (SessionAdvised)invocation.getTargetObject();
ServerSessionEndpoint se = (ServerSessionEndpoint)del.getEndpoint();
ServerConnectionEndpoint ce = se.getConnectionEndpoint();
-
- check(dest, CheckType.WRITE, ce);
+
+ check(convert(dest), CheckType.WRITE, ce);
return invocation.invokeNext();
}
+ //FIXME - temp until refactoring is complete
+ //All server side security should involve core destinations not JBossDestinations
+ private JBossDestination convert(org.jboss.messaging.newcore.Destination dest)
+ {
+ JBossDestination jbdest;
+ if (dest.isTemporary())
+ {
+ if ("Queue".equals(dest.getType()))
+ {
+ jbdest = new JBossTemporaryQueue(dest.getName());
+ }
+ else
+ {
+ jbdest = new JBossTemporaryTopic(dest.getName());
+ }
+ }
+ else
+ {
+ if ("Topic".equals(dest.getType()))
+ {
+ jbdest = new JBossQueue(dest.getName());
+ }
+ else
+ {
+ jbdest = new JBossTopic(dest.getName());
+ }
+ }
+ return jbdest;
+ }
// An aspect over ConnectionAdvised
public Object handleSendTransaction(Invocation invocation) throws Throwable
@@ -170,24 +203,30 @@
ClientTransaction txState = t.getState();
+ //FIXME - can't we optimise this??
if (txState != null)
{
// distinct list of destinations...
- HashSet destinations = new HashSet();
+ HashSet<org.jboss.messaging.newcore.Destination> destinations = new HashSet<org.jboss.messaging.newcore.Destination>();
for (Iterator i = txState.getSessionStates().iterator(); i.hasNext(); )
{
ClientTransaction.SessionTxState sessionState = (ClientTransaction.SessionTxState)i.next();
for (Iterator j = sessionState.getMsgs().iterator(); j.hasNext(); )
{
- JBossMessage message = (JBossMessage)j.next();
- destinations.add(message.getJMSDestination());
+ Message message = (Message)j.next();
+
+ org.jboss.messaging.newcore.Destination dest =
+ (org.jboss.messaging.newcore.Destination)message.getHeader(org.jboss.messaging.newcore.Message.TEMP_DEST_HEADER_NAME);
+
+
+ destinations.add(dest);
}
}
for (Iterator iterDestinations = destinations.iterator();iterDestinations.hasNext();)
{
- Destination destination = (Destination) iterDestinations.next();
- check(destination, CheckType.WRITE, ce);
+ org.jboss.messaging.newcore.Destination destination = (org.jboss.messaging.newcore.Destination) iterDestinations.next();
+ check(convert(destination), CheckType.WRITE, ce);
}
}
Modified: trunk/src/main/org/jboss/jms/server/destination/ManagedQueue.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/destination/ManagedQueue.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/destination/ManagedQueue.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -28,8 +28,8 @@
import org.jboss.jms.server.messagecounter.MessageCounter;
import org.jboss.jms.server.selector.Selector;
import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.Message;
import org.jboss.messaging.core.contract.Queue;
+import org.jboss.messaging.newcore.Message;
/**
* A ManagedQueue
Modified: trunk/src/main/org/jboss/jms/server/destination/ManagedTopic.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/destination/ManagedTopic.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/destination/ManagedTopic.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,20 +21,20 @@
*/
package org.jboss.jms.server.destination;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
import org.jboss.jms.server.JMSCondition;
import org.jboss.jms.server.messagecounter.MessageCounter;
import org.jboss.jms.server.selector.Selector;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.contract.Binding;
-import org.jboss.messaging.core.contract.Message;
import org.jboss.messaging.core.contract.Queue;
+import org.jboss.messaging.newcore.Message;
import org.jboss.messaging.util.MessageQueueNameHelper;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
/**
* A ManagedTopic
*
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -29,18 +29,16 @@
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import javax.jms.IllegalStateException;
import javax.jms.JMSException;
-import javax.jms.Message;
import org.jboss.jms.delegate.BrowserEndpoint;
import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.server.selector.Selector;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.contract.Channel;
-import org.jboss.messaging.core.contract.Filter;
import org.jboss.messaging.core.remoting.PacketDispatcher;
import org.jboss.messaging.core.remoting.PacketHandler;
import org.jboss.messaging.core.remoting.PacketSender;
@@ -52,6 +50,8 @@
import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
import org.jboss.messaging.core.remoting.wireformat.NullPacket;
import org.jboss.messaging.core.remoting.wireformat.PacketType;
+import org.jboss.messaging.newcore.Filter;
+import org.jboss.messaging.newcore.Message;
import org.jboss.messaging.util.ExceptionUtil;
/**
@@ -142,7 +142,7 @@
}
}
- public JBossMessage nextMessage() throws JMSException
+ public Message nextMessage() throws JMSException
{
try
{
@@ -156,7 +156,7 @@
iterator = createIterator();
}
- JBossMessage r = (JBossMessage)iterator.next();
+ Message r = (Message)iterator.next();
if (trace) { log.trace(this + " returning " + r); }
@@ -164,11 +164,12 @@
}
catch (Throwable t)
{
+ t.printStackTrace();
throw ExceptionUtil.handleJMSInvocation(t, this + " nextMessage");
}
}
- public JBossMessage[] nextMessageBlock(int maxMessages) throws JMSException
+ public Message[] nextMessageBlock(int maxMessages) throws JMSException
{
if (trace) { log.trace(this + " returning next message block of " + maxMessages); }
@@ -202,7 +203,7 @@
}
else break;
}
- return (JBossMessage[])messages.toArray(new JBossMessage[messages.size()]);
+ return (Message[])messages.toArray(new Message[messages.size()]);
}
catch (Throwable t)
{
@@ -259,7 +260,9 @@
private Iterator createIterator()
{
- return destination.browse(filter).iterator();
+ List<Message> msgs = destination.browse(filter);
+
+ return msgs.iterator();
}
// Inner classes --------------------------------------------------------------------------------
@@ -283,7 +286,7 @@
response = new BrowserHasNextMessageResponse(hasNextMessage());
} else if (type == REQ_BROWSER_NEXTMESSAGE)
{
- JBossMessage message = nextMessage();
+ Message message = nextMessage();
response = new BrowserNextMessageResponse(message);
} else if (type == MSG_BROWSER_RESET)
{
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -54,13 +54,14 @@
import org.jboss.logging.Logger;
import org.jboss.messaging.core.contract.Binding;
import org.jboss.messaging.core.contract.Delivery;
-import org.jboss.messaging.core.contract.MessageReference;
import org.jboss.messaging.core.contract.MessageStore;
import org.jboss.messaging.core.contract.PostOffice;
import org.jboss.messaging.core.contract.Queue;
import org.jboss.messaging.core.impl.tx.Transaction;
import org.jboss.messaging.core.impl.tx.TransactionRepository;
import org.jboss.messaging.core.remoting.PacketDispatcher;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.util.ExceptionUtil;
import org.jboss.messaging.util.GUIDGenerator;
import org.jboss.messaging.util.Util;
@@ -612,7 +613,7 @@
return remotingClientSessionID;
}
- void sendMessage(JBossMessage msg, Transaction tx, boolean checkForDuplicates) throws Exception
+ void sendMessage(Message msg, Transaction tx, boolean checkForDuplicates) throws Exception
{
if (trace) { log.trace(this + " sending message " + msg + (tx == null ? " non-transactionally" : " in " + tx)); }
@@ -637,15 +638,16 @@
}
}
- JBossDestination dest = (JBossDestination)msg.getJMSDestination();
+ org.jboss.messaging.newcore.Destination dest =
+ (org.jboss.messaging.newcore.Destination)msg.getHeader(org.jboss.messaging.newcore.Message.TEMP_DEST_HEADER_NAME);
+
// This allows the no-local consumers to filter out the messages that come from the same
// connection.
// TODO Do we want to set this for ALL messages. Optimisation is possible here.
msg.setConnectionID(id);
-
// We must reference the message *before* we send it the destination to be handled. This is
// so we can guarantee that the message doesn't disappear from the store before the
// handling is complete. Each channel then takes copies of the reference if they decide to
@@ -653,15 +655,19 @@
MessageReference ref = msg.createReference();
- long schedDeliveryTime = msg.getScheduledDeliveryTime();
-
- if (schedDeliveryTime > 0)
+ //FIXME http://jira.jboss.org/jira/browse/JBMESSAGING-1203
+// long schedDeliveryTime = msg.getScheduledDeliveryTime();
+//
+// if (schedDeliveryTime > 0)
+// {
+// ref.setScheduledDeliveryTime(schedDeliveryTime);
+// }
+
+ //FIXME -temp hack for refactoring - eventually the core will only deal with queues so this
+ //will be unnecessary
+
+ if ("Direct".equals(dest.getType()))
{
- ref.setScheduledDeliveryTime(schedDeliveryTime);
- }
-
- if (dest.isDirect())
- {
//Route directly to queue - temp kludge for clustering
Binding binding = postOffice.getBindingForQueueName(dest.getName());
@@ -680,7 +686,7 @@
throw new JMSException("Failed to route " + ref + " to " + dest.getName());
}
}
- else if (dest.isQueue())
+ else if ("Queue".equals(dest.getType()))
{
if (!postOffice.route(ref, new JMSCondition(true, dest.getName()), tx))
{
@@ -749,8 +755,9 @@
for (Iterator j = sessionState.getMsgs().iterator(); j.hasNext(); )
{
- JBossMessage message = (JBossMessage)j.next();
-
+ Message message = (Message)j.next();
+
+ //FIXME - removed ref to JBossMessage in SessionTxState
sendMessage(message, tx, checkForDuplicates);
}
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -32,7 +32,6 @@
import org.jboss.jms.delegate.ConsumerEndpoint;
import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.server.ServerPeer;
import org.jboss.jms.server.destination.ManagedDestination;
import org.jboss.jms.server.messagecounter.MessageCounter;
@@ -40,8 +39,8 @@
import org.jboss.logging.Logger;
import org.jboss.messaging.core.contract.Delivery;
import org.jboss.messaging.core.contract.DeliveryObserver;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.core.contract.PostOffice;
import org.jboss.messaging.core.contract.Queue;
import org.jboss.messaging.core.contract.Receiver;
@@ -285,7 +284,7 @@
if (noLocal)
{
- String conId = ((JBossMessage) message).getConnectionID();
+ String conId = message.getConnectionID();
if (trace) { log.trace("message connection id: " + conId + " current connection connection id: " + sessionEndpoint.getConnectionEndpoint().getConnectionID()); }
@@ -346,7 +345,7 @@
// to do the check twice
if (messageSelector != null)
{
- accept = messageSelector.accept(msg);
+ accept = messageSelector.match(msg);
if (trace) { log.trace("message selector " + (accept ? "accepts " : "DOES NOT accept ") + "the message"); }
}
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -50,7 +50,6 @@
import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.destination.JBossQueue;
import org.jboss.jms.destination.JBossTopic;
-import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.server.DestinationManager;
import org.jboss.jms.server.JMSCondition;
import org.jboss.jms.server.ServerPeer;
@@ -67,8 +66,8 @@
import org.jboss.messaging.core.contract.Condition;
import org.jboss.messaging.core.contract.Delivery;
import org.jboss.messaging.core.contract.DeliveryObserver;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.core.contract.MessageStore;
import org.jboss.messaging.core.contract.PersistenceManager;
import org.jboss.messaging.core.contract.PostOffice;
@@ -369,14 +368,12 @@
private volatile long expectedSequence = 0;
- private Map<Long, JBossMessage> heldBack = new HashMap<Long, JBossMessage>();
-
- public void send(JBossMessage message, boolean checkForDuplicates) throws JMSException
+ public void send(Message message, boolean checkForDuplicates) throws JMSException
{
throw new IllegalStateException("Should not be handled on the server");
}
- public void send(JBossMessage message, boolean checkForDuplicates, long thisSequence) throws JMSException
+ public void send(Message message, boolean checkForDuplicates, long thisSequence) throws JMSException
{
try
{
@@ -390,25 +387,10 @@
synchronized (waitLock)
{
- if (thisSequence == expectedSequence)
- {
- do
- {
- connectionEndpoint.sendMessage(message, null, checkForDuplicates);
-
- expectedSequence++;
-
- message = (JBossMessage)heldBack.remove(expectedSequence);
-
- } while (message != null);
- }
- else
- {
- //Not the expected one - add it to the map
-
- heldBack.put(thisSequence, message);
- }
-
+ connectionEndpoint.sendMessage(message, null, checkForDuplicates);
+
+ expectedSequence++;
+
waitLock.notify();
}
}
@@ -1107,7 +1089,7 @@
{
if (trace) { log.trace(this + " sending expired message to expiry queue " + expiryQueue); }
- JBossMessage copy = makeCopyForDLQOrExpiry(true, del);
+ Message copy = makeCopyForDLQOrExpiry(true, del);
moveInTransaction(copy, del, expiryQueue, true);
}
@@ -1657,7 +1639,7 @@
{
//Sent to expiry queue
- JBossMessage copy = makeCopyForDLQOrExpiry(true, del);
+ Message copy = makeCopyForDLQOrExpiry(true, del);
moveInTransaction(copy, del, rec.expiryQueue, false);
}
@@ -1665,7 +1647,7 @@
{
//Send to DLQ
- JBossMessage copy = makeCopyForDLQOrExpiry(false, del);
+ Message copy = makeCopyForDLQOrExpiry(false, del);
moveInTransaction(copy, del, rec.dlq, true);
}
@@ -1677,7 +1659,7 @@
return rec.del;
}
- private JBossMessage makeCopyForDLQOrExpiry(boolean expiry, Delivery del) throws Exception
+ private Message makeCopyForDLQOrExpiry(boolean expiry, Delivery del) throws Exception
{
//We copy the message and send that to the dlq/expiry queue - this is because
//otherwise we may end up with a ref with the same message id in the queue more than once
@@ -1687,36 +1669,39 @@
if (trace) { log.trace("Making copy of message for DLQ or expiry " + del); }
- JBossMessage msg = ((JBossMessage)del.getReference().getMessage());
+ Message msg = del.getReference().getMessage();
- JBossMessage copy = msg.doCopy();
+ Message copy = msg.copy();
long newMessageId = sp.getMessageIDManager().getID();
- copy.setMessageId(newMessageId);
+ copy.setMessageID(newMessageId);
//reset expiry
copy.setExpiration(0);
- String origMessageId = msg.getJMSMessageID();
- String origDest = msg.getJMSDestination().toString();
-
- copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_MESSAGE_ID, origMessageId);
+ //TODO
+// http://jira.jboss.org/jira/browse/JBMESSAGING-1202
+// String origMessageId = msg.getJMSMessageID();
+//
+// String origDest = msg.getJMSDestination().toString();
+//
+// copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_MESSAGE_ID, origMessageId);
+//
+// copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_DESTINATION, origDest);
+//
+// if (expiry)
+// {
+// long actualExpiryTime = System.currentTimeMillis();
+//
+// copy.setLongProperty(JBossMessage.JBOSS_MESSAGING_ACTUAL_EXPIRY_TIME, actualExpiryTime);
+// }
- copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_DESTINATION, origDest);
-
- if (expiry)
- {
- long actualExpiryTime = System.currentTimeMillis();
-
- copy.setLongProperty(JBossMessage.JBOSS_MESSAGING_ACTUAL_EXPIRY_TIME, actualExpiryTime);
- }
-
return copy;
}
- private void moveInTransaction(JBossMessage msg, Delivery del, Queue queue, boolean dlq) throws Throwable
+ private void moveInTransaction(Message msg, Delivery del, Queue queue, boolean dlq) throws Throwable
{
Transaction tx = tr.createTransaction();
Modified: trunk/src/main/org/jboss/jms/server/endpoint/SessionInternalEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/SessionInternalEndpoint.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/endpoint/SessionInternalEndpoint.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -24,7 +24,7 @@
import javax.jms.JMSException;
import org.jboss.jms.delegate.SessionEndpoint;
-import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.newcore.Message;
/**
*
@@ -36,5 +36,5 @@
*/
public interface SessionInternalEndpoint extends SessionEndpoint
{
- void send(JBossMessage msg, boolean checkForDuplicates, long seq) throws JMSException;
+ void send(Message msg, boolean checkForDuplicates, long seq) throws JMSException;
}
Modified: trunk/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -24,7 +24,7 @@
import javax.jms.JMSException;
import org.jboss.jms.delegate.BrowserEndpoint;
-import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.newcore.Message;
/**
* The server-side advised instance corresponding to a Browser. It is bound to the AOP
@@ -75,12 +75,12 @@
return endpoint.hasNextMessage();
}
- public JBossMessage nextMessage() throws JMSException
+ public Message nextMessage() throws JMSException
{
return endpoint.nextMessage();
}
- public JBossMessage[] nextMessageBlock(int maxMessages) throws JMSException
+ public Message[] nextMessageBlock(int maxMessages) throws JMSException
{
return endpoint.nextMessageBlock(maxMessages);
}
Modified: trunk/src/main/org/jboss/jms/server/endpoint/advised/SessionAdvised.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/advised/SessionAdvised.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/endpoint/advised/SessionAdvised.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -52,7 +52,6 @@
import org.jboss.jms.destination.JBossQueue;
import org.jboss.jms.destination.JBossTopic;
import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.server.endpoint.ServerSessionEndpoint;
import org.jboss.jms.server.endpoint.SessionInternalEndpoint;
import org.jboss.messaging.core.remoting.PacketHandler;
@@ -79,6 +78,7 @@
import org.jboss.messaging.core.remoting.wireformat.RecoverDeliveriesMessage;
import org.jboss.messaging.core.remoting.wireformat.SendMessage;
import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
+import org.jboss.messaging.newcore.Message;
/**
* The server-side advised instance corresponding to a Session. It is bound to the AOP
@@ -91,8 +91,7 @@
*
* $Id$
*/
-public class SessionAdvised extends AdvisedSupport implements
- SessionInternalEndpoint
+public class SessionAdvised extends AdvisedSupport implements SessionInternalEndpoint
{
// Constants -----------------------------------------------------
@@ -121,13 +120,12 @@
return endpoint.closing(sequence);
}
- public void send(JBossMessage msg, boolean checkForDuplicates)
- throws JMSException
+ public void send(Message msg, boolean checkForDuplicates) throws JMSException
{
throw new IllegalStateException("Invocation should not be handle here");
}
- public void send(JBossMessage msg, boolean checkForDuplicates, long seq) throws JMSException
+ public void send(Message msg, boolean checkForDuplicates, long seq) throws JMSException
{
((ServerSessionEndpoint)endpoint).send(msg, checkForDuplicates, seq);
}
Modified: trunk/src/main/org/jboss/jms/server/selector/Selector.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/selector/Selector.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/selector/Selector.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -23,12 +23,13 @@
import java.util.HashMap;
import java.util.Iterator;
-import javax.jms.DeliveryMode;
+
import javax.jms.InvalidSelectorException;
import javax.jms.JMSException;
-import javax.jms.Message;
+
import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.Filter;
+import org.jboss.messaging.newcore.Filter;
+import org.jboss.messaging.newcore.Message;
/**
@@ -41,6 +42,8 @@
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version $Revision$
*
+ * FIXME - we need to abstract out a core filter that doesn't depend on JMS
+ *
* $Id$
*/
public class Selector implements Filter
@@ -113,11 +116,11 @@
return selector;
}
- public synchronized boolean accept(org.jboss.messaging.core.contract.Message message)
+ public synchronized boolean match(Message message)
{
try
{
- //Only accept JMS messages
+ //Only accept core messages
if (!(message instanceof Message))
{
return false;
@@ -132,7 +135,11 @@
{
Identifier id = (Identifier) i.next();
- Object find = mess.getObjectProperty(id.name);
+ //FIXME - optimise this - abstract a core selector - this
+ //Shouldn't rely on JMS
+
+
+ Object find = mess.getHeader("P" + id.name);
if (find == null)
find = getHeaderFieldReferences(mess, id.name);
@@ -195,18 +202,18 @@
//
if (idName.equals("JMSDeliveryMode"))
{
- return mess.getJMSDeliveryMode()==DeliveryMode.PERSISTENT ? "PERSISTENT" : "NON_PERSISTENT";
+ return mess.isReliable() ? "PERSISTENT" : "NON_PERSISTENT";
}
else if (idName.equals("JMSPriority"))
- return new Integer(mess.getJMSPriority());
+ return new Integer(mess.getPriority());
else if (idName.equals("JMSMessageID"))
- return mess.getJMSMessageID();
+ return "ID:JBM-" + mess.getMessageID();
else if (idName.equals("JMSTimestamp"))
- return new Long(mess.getJMSTimestamp());
+ return new Long(mess.getTimestamp());
else if (idName.equals("JMSCorrelationID"))
- return mess.getJMSCorrelationID();
+ return mess.getHeader("H.CORRELATIONID");
else if (idName.equals("JMSType"))
- return mess.getJMSType();
+ return mess.getHeader("H.TYPE");
else
return null;
}
Modified: trunk/src/main/org/jboss/jms/server/selector/SelectorFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/selector/SelectorFactory.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/server/selector/SelectorFactory.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,8 +21,8 @@
*/
package org.jboss.jms.server.selector;
-import org.jboss.messaging.core.contract.Filter;
import org.jboss.messaging.core.contract.FilterFactory;
+import org.jboss.messaging.newcore.Filter;
/**
* A SelectorFactory
Modified: trunk/src/main/org/jboss/jms/tx/ClientTransaction.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/ClientTransaction.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/tx/ClientTransaction.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -33,9 +33,9 @@
import org.jboss.jms.delegate.Ack;
import org.jboss.jms.delegate.DefaultAck;
import org.jboss.jms.delegate.DeliveryInfo;
-import org.jboss.jms.message.JBossMessage;
import org.jboss.logging.Logger;
-import org.jboss.messaging.core.impl.message.MessageFactory;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.impl.MessageImpl;
/**
* Holds the state of a transaction on the client side
@@ -91,7 +91,7 @@
return state;
}
- public void addMessage(String sessionId, JBossMessage msg)
+ public void addMessage(String sessionId, Message msg)
{
if (!clientSide)
{
@@ -112,7 +112,7 @@
sessionTxState.addAck(info);
- if (info.getMessageProxy().getMessage().isReliable())
+ if (info.getMessage().getCoreMessage().isReliable())
{
hasPersistentAcks = true;
}
@@ -278,10 +278,8 @@
while (iter2.hasNext())
{
- JBossMessage m = (JBossMessage)iter2.next();
+ Message m = (Message)iter2.next();
- out.writeByte(m.getType());
-
m.write(out);
}
@@ -297,7 +295,7 @@
if (ack.isShouldAck())
{
//We only need the delivery id written
- out.writeLong(ack.getMessageProxy().getDeliveryId());
+ out.writeLong(ack.getMessage().getDeliveryId());
}
}
@@ -332,13 +330,15 @@
for (int j = 0; j < numMsgs; j++)
{
- byte type = in.readByte();
+ //byte type = in.readByte();
- JBossMessage msg = (JBossMessage)MessageFactory.createMessage(type);
-
- msg.read(in);
-
- sessionState.addMessage(msg);
+ //FIXME - temp hack - need to refactor this class anyway
+
+ Message m = new MessageImpl();
+
+ m.read(in);
+
+ sessionState.addMessage(m);
}
long l;
@@ -394,7 +394,7 @@
this.sessionID = sessionID;
}
- void addMessage(JBossMessage msg)
+ void addMessage(Message msg)
{
msgs.add(msg);
}
@@ -436,7 +436,7 @@
{
DeliveryInfo di = (DeliveryInfo)i.next();
- if (!di.getMessageProxy().getMessage().isReliable())
+ if (!di.getMessage().getCoreMessage().isReliable())
{
if (trace) { log.trace(this + " discarded non-persistent " + di + " on failover"); }
i.remove();
Modified: trunk/src/main/org/jboss/jms/tx/ResourceManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/ResourceManager.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/jms/tx/ResourceManager.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -40,9 +40,9 @@
import org.jboss.jms.exception.MessagingTransactionRolledBackException;
import org.jboss.jms.exception.MessagingXAException;
import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.MessageProxy;
import org.jboss.jms.tx.ClientTransaction.SessionTxState;
import org.jboss.logging.Logger;
+import org.jboss.messaging.newcore.Message;
import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
@@ -127,7 +127,7 @@
* @param xid - The id of the transaction to add the message to
* @param m The message
*/
- public void addMessage(Object xid, String sessionId, JBossMessage m)
+ public void addMessage(Object xid, String sessionId, Message m)
{
if (trace) { log.trace("addding message " + m + " for xid " + xid); }
@@ -615,7 +615,7 @@
{
DeliveryInfo info = (DeliveryInfo)acks.get(0);
- MessageProxy mp = info.getMessageProxy();
+ JBossMessage mp = info.getMessage();
SessionDelegate del = mp.getSessionDelegate();
Modified: trunk/src/main/org/jboss/messaging/core/contract/Channel.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/Channel.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/Channel.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -52,7 +52,7 @@
* @return a List containing message references of messages whose state is maintained by this
* State instance.
*/
- List browse(Filter filter);
+ List browse(org.jboss.messaging.newcore.Filter filter);
/**
* Delivers as many references as possible to its router until receivers will accept no more
Modified: trunk/src/main/org/jboss/messaging/core/contract/Delivery.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/Delivery.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/Delivery.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -34,7 +34,7 @@
*/
public interface Delivery
{
- MessageReference getReference();
+ org.jboss.messaging.newcore.MessageReference getReference();
DeliveryObserver getObserver();
Deleted: trunk/src/main/org/jboss/messaging/core/contract/Filter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/Filter.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/Filter.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.contract;
-
-
-/**
- * A filter encapsulates the logic of whether to accept a message or not. Filters are used when
- * browsing to restrict the messages browsed, or when routing messages.
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface Filter
-{
- /**
- * Tests whether the message should be accepted.
- *
- * @return true if the Filter accepts the message - i.e. let's it pass.
- */
- boolean accept(Message message);
-
- String getFilterString();
-}
Modified: trunk/src/main/org/jboss/messaging/core/contract/FilterFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/FilterFactory.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/FilterFactory.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -37,5 +37,5 @@
*/
public interface FilterFactory
{
- Filter createFilter(String filterString) throws Exception;
+ org.jboss.messaging.newcore.Filter createFilter(String filterString) throws Exception;
}
Deleted: trunk/src/main/org/jboss/messaging/core/contract/Message.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/Message.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/Message.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,162 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.contract;
-
-import java.util.Map;
-
-import org.jboss.messaging.util.Streamable;
-
-/**
- * A message is a routable instance that has a payload.
- * The payload is opaque to the messaging system.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox"jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface Message extends Streamable
-{
- /**
- * This header is set on a message when a message is sucked from one node of the cluster to another
- * and order preservation is true.
- * The header is checked when sucking messages and if order preservation is true then the message is not accepted.
- * This is a basic way of ensuring message order is preserved.
- */
- public static final String CLUSTER_SUCKED = "SUCKED";
-
- /**
- * This header is set on a message when it is sucked from one node to another.
- * If the header exists on the destination node, and the message is persistent, the message
- * will be moved from one channel to the other by doing a simple database update
- */
- public static final String SOURCE_CHANNEL_ID = "SCID";
-
- /**
- * @return The unique id of the message
- */
- long getMessageID();
-
- /**
- * @return true if the delivery must be guaranteed for this routable, false otherwise.
- */
- boolean isReliable();
-
- /**
- * @return the time when this routable expires and must be removed
- * from the system. A zero value means this routable never expires.
- */
- long getExpiration();
-
- /**
- *
- * @return true if the message has expired
- */
- boolean isExpired();
-
- /**
- * Set the expiration for this message
- *
- * @param expiration
- */
- void setExpiration(long expiration);
-
- /**
- * @return the time (in GMT milliseconds) when this routable was delivered to the provider.
- */
- long getTimestamp();
-
- byte getPriority();
-
- /**
- * Get the priority of the message. Priorities range from 0 to 9.
- * Where 0 is the lowest priority and 9 is the highest priority
- * @param priority
- */
- void setPriority(byte priority);
-
- /**
- * Binds a header. If the header map previously contained a mapping for this name, the old value
- * is replaced by the specified value.
- *
- * @return the value associated with the name or null if there is no mapping for the name. A null
- * can also indicate that the header map previously associated null with the specified
- * name.
- */
- Object putHeader(String name, Object value);
-
- /**
- * Returns the value corresponding to the header name. Returns null if the map contains no
- * mapping for the name. A return value of null does not necessarily indicate that the map
- * contains no mapping for the name; it's also possible that the map explicitly maps the name to
- * null. The containsHeader() operation may be used to distinguish these two cases.
- *
- * @return the value associated with the header, or null if there is no mapping for the header.
- */
- Object getHeader(String name);
-
- /**
- * Removes the header.
- *
- * @return previous value associated with the header, or null if there was no mapping.
- */
- Object removeHeader(String name);
-
- /**
- * Returns true if the Routable contains the specified header.
- */
- boolean containsHeader(String name);
-
- /**
- *
- * @return The message's headers
- */
- Map getHeaders();
-
- /**
- *
- * @return The message's payload
- */
- Object getPayload();
-
- /**
- *
- * @return The message's payload in byte[] form
- */
- byte[] getPayloadAsByteArray();
-
- /**
- *
- * @return the type of the message
- */
- byte getType();
-
- /*
- * @return a reference for this message
- */
- MessageReference createReference();
-
- boolean isPersisted();
-
- void setPersisted(boolean persisted);
-}
Deleted: trunk/src/main/org/jboss/messaging/core/contract/MessageReference.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/MessageReference.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/MessageReference.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.contract;
-
-/**
- * A reference to a message.
- *
- * Channels store message references rather than the messages themselves.
- *
- * If many channels have contain the same reference this makes a lot of sense
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface MessageReference
-{
- long getPagingOrder();
-
- void setPagingOrder(long order);
-
- Message getMessage();
-
- MessageReference copy();
-
- /**
- *
- * @return The time in the future that delivery will be delayed until, or zero if
- * no scheduled delivery will occur
- */
- long getScheduledDeliveryTime();
-
- void setScheduledDeliveryTime(long scheduledDeliveryTime);
-
- /**
- * @return the number of times delivery has been attempted for this routable
- */
- int getDeliveryCount();
-
- void setDeliveryCount(int deliveryCount);
-}
Modified: trunk/src/main/org/jboss/messaging/core/contract/MessageStore.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/MessageStore.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/MessageStore.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -20,9 +20,9 @@
*/
public interface MessageStore extends MessagingComponent
{
- MessageReference reference(long messageID);
-
- MessageReference reference(Message message);
-
- void clear();
+ org.jboss.messaging.newcore.MessageReference reference(long messageID);
+
+ org.jboss.messaging.newcore.MessageReference reference(org.jboss.messaging.newcore.Message message);
+
+ void clear();
}
Modified: trunk/src/main/org/jboss/messaging/core/contract/PersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/PersistenceManager.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/PersistenceManager.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -25,6 +25,9 @@
import org.jboss.messaging.core.impl.tx.Transaction;
+
+
+
/**
* The interface to the persistence manager.
*
@@ -39,13 +42,13 @@
*/
public interface PersistenceManager extends MessagingComponent
{
- void addReference(long channelID, MessageReference ref, Transaction tx) throws Exception;
+ void addReference(long channelID, org.jboss.messaging.newcore.MessageReference ref, Transaction tx) throws Exception;
- void moveReference(long sourceChannelID, long destChannelID, MessageReference ref) throws Exception;
+ void moveReference(long sourceChannelID, long destChannelID, org.jboss.messaging.newcore.MessageReference ref) throws Exception;
- void removeReference(long channelID, MessageReference ref, Transaction tx) throws Exception;
+ void removeReference(long channelID, org.jboss.messaging.newcore.MessageReference ref, Transaction tx) throws Exception;
- void updateDeliveryCount(long channelID, MessageReference ref) throws Exception;
+ void updateDeliveryCount(long channelID, org.jboss.messaging.newcore.MessageReference ref) throws Exception;
// XA Recovery functionality
@@ -89,18 +92,18 @@
class MessageChannelPair
{
- private Message message;
+ private org.jboss.messaging.newcore.Message message;
private long channelId;
- public MessageChannelPair(Message message, long channelId)
+ public MessageChannelPair(org.jboss.messaging.newcore.Message message, long channelId)
{
this.message = message;
this.channelId = channelId;
}
- public Message getMessage()
+ public org.jboss.messaging.newcore.Message getMessage()
{
return message;
}
Modified: trunk/src/main/org/jboss/messaging/core/contract/PostOffice.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/PostOffice.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/PostOffice.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -73,7 +73,7 @@
*
* @return true if reference was accepted by at least one queue.
*/
- boolean route(MessageReference ref, Condition condition, Transaction tx) throws Exception;
+ boolean route(org.jboss.messaging.newcore.MessageReference ref, Condition condition, Transaction tx) throws Exception;
/**
* Get all queues that match the condition
Modified: trunk/src/main/org/jboss/messaging/core/contract/Queue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/Queue.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/Queue.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -38,7 +38,7 @@
*/
public interface Queue extends Channel
{
- Filter getFilter();
+ org.jboss.messaging.newcore.Filter getFilter();
/**
* Merge the contents of one queue with another - this happens at failover when a queue is failed
@@ -93,5 +93,5 @@
int getRecoveryMapSize();
//Optimisation for shared database
- Delivery handleMove(MessageReference ref, long sourceChannelID);
+ Delivery handleMove(org.jboss.messaging.newcore.MessageReference ref, long sourceChannelID);
}
Modified: trunk/src/main/org/jboss/messaging/core/contract/Receiver.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/contract/Receiver.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/contract/Receiver.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -49,6 +49,6 @@
* @see org.jboss.messaging.core.contract.Delivery
* @see org.jboss.messaging.core.contract.DeliveryObserver
*/
- Delivery handle(DeliveryObserver observer, MessageReference reference, Transaction tx);
+ Delivery handle(DeliveryObserver observer, org.jboss.messaging.newcore.MessageReference reference, Transaction tx);
}
Modified: trunk/src/main/org/jboss/messaging/core/impl/ChannelSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/ChannelSupport.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/ChannelSupport.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -34,13 +34,12 @@
import org.jboss.messaging.core.contract.Delivery;
import org.jboss.messaging.core.contract.DeliveryObserver;
import org.jboss.messaging.core.contract.Distributor;
-import org.jboss.messaging.core.contract.Filter;
-import org.jboss.messaging.core.contract.MessageReference;
-import org.jboss.messaging.core.contract.MessageStore;
import org.jboss.messaging.core.contract.PersistenceManager;
import org.jboss.messaging.core.impl.tx.Transaction;
import org.jboss.messaging.core.impl.tx.TransactionException;
import org.jboss.messaging.core.impl.tx.TxCallback;
+import org.jboss.messaging.newcore.Filter;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.util.prioritylinkedlist.BasicPriorityLinkedList;
import org.jboss.messaging.util.prioritylinkedlist.PriorityLinkedList;
import org.jboss.util.timeout.Timeout;
@@ -437,7 +436,7 @@
// TODO: I need to dereference the message each time I apply the
// filter. Refactor so the message reference will also contain JMS
// properties
- if (filter == null || filter.accept(r.getMessage()))
+ if (filter == null || filter.match(r.getMessage()))
{
undelivered.add(r);
}
Modified: trunk/src/main/org/jboss/messaging/core/impl/ClusterRoundRobinDistributor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/ClusterRoundRobinDistributor.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/ClusterRoundRobinDistributor.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -27,7 +27,7 @@
import org.jboss.messaging.core.contract.Delivery;
import org.jboss.messaging.core.contract.DeliveryObserver;
import org.jboss.messaging.core.contract.Distributor;
-import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.core.contract.Receiver;
import org.jboss.messaging.core.impl.tx.Transaction;
Modified: trunk/src/main/org/jboss/messaging/core/impl/FirstReceiverDistributor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/FirstReceiverDistributor.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/FirstReceiverDistributor.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -29,7 +29,7 @@
import org.jboss.messaging.core.contract.Delivery;
import org.jboss.messaging.core.contract.DeliveryObserver;
import org.jboss.messaging.core.contract.Distributor;
-import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.core.contract.Receiver;
import org.jboss.messaging.core.impl.tx.Transaction;
Modified: trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,25 +21,43 @@
*/
package org.jboss.messaging.core.impl;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.transaction.xa.Xid;
+
import org.jboss.jms.tx.MessagingXid;
import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.contract.MessageReference;
import org.jboss.messaging.core.contract.PersistenceManager;
-import org.jboss.messaging.core.impl.message.MessageFactory;
-import org.jboss.messaging.core.impl.message.MessageSupport;
import org.jboss.messaging.core.impl.tx.PreparedTxInfo;
import org.jboss.messaging.core.impl.tx.Transaction;
import org.jboss.messaging.core.impl.tx.TxCallback;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.util.JDBCUtil;
import org.jboss.messaging.util.StreamUtils;
import org.jboss.messaging.util.Util;
-import javax.transaction.xa.Xid;
-import java.io.*;
-import java.sql.*;
-import java.util.*;
-
/**
* JDBC implementation of PersistenceManager
*
@@ -107,10 +125,7 @@
String warn = "\n\n"
+ "JBoss Messaging Warning: DataSource connection transaction isolation should be READ_COMMITTED, but it is currently "
- + Util.transactionIsolationToString(level)
- + ".\n"
- + " Using an isolation level less strict than READ_COMMITTED may lead to data consistency problems.\n"
- + " Using an isolation level more strict than READ_COMMITTED may lead to deadlock.\n";
+ + Util.transactionIsolationToString(level);
log.warn(warn);
}
@@ -492,17 +507,15 @@
byte priority = rs.getByte(5);
- byte[] bytes = getBytes(rs, 6);
+ byte[] headers = getBytes(rs, 6);
- HashMap headers = bytesToMap(bytes);
-
byte[] payload = getBytes(rs, 7);
- byte type = rs.getByte(8);
-
- Message m = MessageFactory.createMessage(messageId,
- reliable, expiration, timestamp, priority,
- headers, payload, type);
+ int type = rs.getByte(8);
+
+ Message m = new org.jboss.messaging.newcore.impl.MessageImpl(messageId, type, reliable, expiration,
+ timestamp, priority, headers, payload);
+
msgs.add(m);
}
@@ -2090,7 +2103,7 @@
ps.setLong(3, m.getExpiration());
ps.setLong(4, m.getTimestamp());
ps.setByte(5, m.getPriority());
- ps.setByte(6, m.getType());
+ ps.setByte(6, (byte)m.getType());
if (bindBlobs)
{
@@ -2133,7 +2146,7 @@
int payloadPosition) throws Exception
{
// headers
- byte[] bytes = mapToBytes(((MessageSupport) m).getHeaders());
+ byte[] bytes = mapToBytes(m.getHeaders());
if (bytes != null)
{
setBytes(ps, headerPosition, bytes);
@@ -2143,7 +2156,7 @@
ps.setNull(headerPosition, Types.LONGVARBINARY);
}
- byte[] payload = m.getPayloadAsByteArray();
+ byte[] payload = m.getPayload();
if (payload != null)
{
setBytes(ps, payloadPosition, payload);
Modified: trunk/src/main/org/jboss/messaging/core/impl/MessagingQueue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/MessagingQueue.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/MessagingQueue.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,18 +21,35 @@
*/
package org.jboss.messaging.core.impl;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.jboss.jms.server.MessagingTimeoutFactory;
import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.*;
+import org.jboss.messaging.core.contract.Delivery;
+import org.jboss.messaging.core.contract.DeliveryObserver;
+import org.jboss.messaging.core.contract.Distributor;
+import org.jboss.messaging.newcore.Filter;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.core.contract.MessageStore;
+import org.jboss.messaging.core.contract.PersistenceManager;
import org.jboss.messaging.core.contract.Queue;
+import org.jboss.messaging.core.contract.Receiver;
import org.jboss.messaging.core.impl.clusterconnection.MessageSucker;
import org.jboss.messaging.core.impl.tx.Transaction;
import org.jboss.util.timeout.Timeout;
import org.jboss.util.timeout.TimeoutTarget;
-import java.util.*;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
/**
*
Modified: trunk/src/main/org/jboss/messaging/core/impl/PagingChannelSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/PagingChannelSupport.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/PagingChannelSupport.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -28,8 +28,8 @@
import java.util.Map;
import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.core.contract.MessageStore;
import org.jboss.messaging.core.contract.PersistenceManager;
import org.jboss.messaging.core.contract.PersistenceManager.InitialLoadInfo;
Modified: trunk/src/main/org/jboss/messaging/core/impl/RoundRobinDistributor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/RoundRobinDistributor.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/RoundRobinDistributor.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -28,7 +28,7 @@
import org.jboss.messaging.core.contract.Delivery;
import org.jboss.messaging.core.contract.DeliveryObserver;
import org.jboss.messaging.core.contract.Distributor;
-import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.core.contract.Receiver;
import org.jboss.messaging.core.impl.tx.Transaction;
Modified: trunk/src/main/org/jboss/messaging/core/impl/SimpleDelivery.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/SimpleDelivery.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/SimpleDelivery.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -24,7 +24,7 @@
import org.jboss.logging.Logger;
import org.jboss.messaging.core.contract.Delivery;
import org.jboss.messaging.core.contract.DeliveryObserver;
-import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.core.impl.tx.Transaction;
/**
Modified: trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/MessageSucker.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/MessageSucker.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/MessageSucker.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -22,6 +22,12 @@
package org.jboss.messaging.core.impl.clusterconnection;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
import org.jboss.jms.client.JBossConnection;
import org.jboss.jms.client.JBossSession;
import org.jboss.jms.delegate.ConsumerDelegate;
@@ -29,19 +35,11 @@
import org.jboss.jms.delegate.SessionDelegate;
import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.destination.JBossQueue;
-import org.jboss.jms.message.MessageProxy;
+import org.jboss.jms.message.JBossMessage;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.contract.Queue;
import org.jboss.tm.TransactionManagerLocator;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAResource;
-
/**
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -319,17 +317,17 @@
}
*/
- org.jboss.messaging.core.contract.Message coreMessage = ((MessageProxy)msg).getMessage();
+ org.jboss.messaging.newcore.Message coreMessage = ((JBossMessage)msg).getCoreMessage();
if (preserveOrdering)
{
//Add a header saying we have sucked the message
- coreMessage.putHeader(org.jboss.messaging.core.contract.Message.CLUSTER_SUCKED, "x");
+ coreMessage.putHeader(org.jboss.messaging.newcore.Message.CLUSTER_SUCKED, "x");
}
//Add a header with the node id of the node we sucked from - this is used on the sending end to do
//the move optimisation
- coreMessage.putHeader(org.jboss.messaging.core.contract.Message.SOURCE_CHANNEL_ID, sourceChannelID);
+ coreMessage.putHeader(org.jboss.messaging.newcore.Message.SOURCE_CHANNEL_ID, sourceChannelID);
long timeToLive = msg.getJMSExpiration();
if (timeToLive != 0)
Deleted: trunk/src/main/org/jboss/messaging/core/impl/message/CoreMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/message/CoreMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/message/CoreMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.impl.message;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2202 $</tt>
- *
- * $Id: CoreMessage.java 2202 2007-02-08 10:50:26Z timfox $
- */
-public class CoreMessage extends MessageSupport
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = -4740357138097778538L;
-
- public static final byte TYPE = 127;
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- /**
- * Required by externalization.
- */
- public CoreMessage()
- {
- }
-
- public CoreMessage(long messageID,
- boolean reliable,
- long expiration,
- long timestamp,
- byte priority,
- Map headers,
- byte[] payload)
- {
- super(messageID, reliable, expiration, timestamp, priority, headers, payload);
- }
-
- // Public --------------------------------------------------------
-
- public String toString()
- {
- return "CoreMessage["+messageID+"]";
- }
-
- public byte getType()
- {
- return TYPE;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: trunk/src/main/org/jboss/messaging/core/impl/message/MessageFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/message/MessageFactory.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/message/MessageFactory.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,171 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.impl.message;
-
-import java.util.Map;
-
-import org.jboss.jms.message.JBossBytesMessage;
-import org.jboss.jms.message.JBossMapMessage;
-import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.JBossObjectMessage;
-import org.jboss.jms.message.JBossStreamMessage;
-import org.jboss.jms.message.JBossTextMessage;
-import org.jboss.messaging.core.contract.Message;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2284 $</tt>
- *
- * $Id: MessageFactory.java 2284 2007-02-13 06:47:23Z ovidiu.feodorov at jboss.com $
- */
-public class MessageFactory
-{
- // Constants ------------------------------------------------------------------------------------
-
- // Static ---------------------------------------------------------------------------------------
-
- public static Message createMessage(byte type)
- {
- Message m = null;
-
- if (type == JBossMessage.TYPE) //1
- {
- m = new JBossMessage();
- }
- else if (type == JBossObjectMessage.TYPE) //2
- {
- m = new JBossObjectMessage();
- }
- else if (type == JBossTextMessage.TYPE) //3
- {
- m = new JBossTextMessage();
- }
- else if (type == JBossBytesMessage.TYPE) //4
- {
- m = new JBossBytesMessage();
- }
- else if (type == JBossMapMessage.TYPE) //5
- {
- m = new JBossMapMessage();
- }
- else if (type == JBossStreamMessage.TYPE) //6
- {
- m = new JBossStreamMessage();
- }
- else if (type == CoreMessage.TYPE) //127
- {
- m = new CoreMessage();
- }
- else
- {
- throw new IllegalArgumentException("Invalid type " + type);
- }
-
- return m;
- }
-
- /*
- * Create a message from persistent storage
- */
- public static Message createMessage(long messageID,
- boolean reliable,
- long expiration,
- long timestamp,
- byte priority,
- Map headers,
- byte[] payload,
- byte type)
-
- {
- Message m = null;
-
- switch (type)
- {
- case JBossMessage.TYPE:
- {
- m = new JBossMessage(messageID, reliable, expiration,
- timestamp, priority, headers, payload);
- break;
- }
- case JBossObjectMessage.TYPE:
- {
- m = new JBossObjectMessage(messageID, reliable, expiration,
- timestamp, priority, headers, payload);
- break;
- }
- case JBossTextMessage.TYPE:
- {
- m = new JBossTextMessage(messageID, reliable, expiration,
- timestamp, priority, headers, payload);
- break;
- }
- case JBossBytesMessage.TYPE:
- {
- m = new JBossBytesMessage(messageID, reliable, expiration,
- timestamp, priority, headers, payload);
- break;
- }
- case JBossMapMessage.TYPE:
- {
- m = new JBossMapMessage(messageID, reliable, expiration,
- timestamp, priority, headers, payload);
- break;
- }
- case JBossStreamMessage.TYPE:
- {
- m = new JBossStreamMessage(messageID, reliable, expiration,
- timestamp, priority, headers, payload);
- break;
- }
- case CoreMessage.TYPE:
- {
- m = new CoreMessage(messageID, reliable, expiration,
- timestamp, priority, headers, payload);
- break;
- }
- default:
- {
- throw new IllegalArgumentException("Unknown type " + type);
- }
- }
-
- m.setPersisted(true);
-
- return m;
- }
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Constructors ---------------------------------------------------------------------------------
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-}
-
Deleted: trunk/src/main/org/jboss/messaging/core/impl/message/MessageSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/message/MessageSupport.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/message/MessageSupport.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,404 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.impl.message;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.io.IOException;
-
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.contract.MessageReference;
-import org.jboss.messaging.util.StreamUtils;
-
-/**
- * A message base.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2740 $</tt>
- *
- * Note this class is only serializable so messages can be returned from JMX operations
- * e.g. listAllMessages.
- *
- * For normal message transportation serialization is not used
- *
- * $Id: MessageSupport.java 2740 2007-05-30 11:36:28Z timfox $
- */
-public abstract class MessageSupport implements Message, Serializable
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(MessageSupport.class);
-
- // Attributes ----------------------------------------------------
-
- private boolean trace = log.isTraceEnabled();
-
- protected long messageID;
-
- protected boolean reliable;
-
- /** GMT milliseconds at which this message expires. 0 means never expires * */
- protected long expiration;
-
- protected long timestamp;
-
- protected Map headers;
-
- protected byte priority;
-
- protected transient Object payload;
-
- protected byte[] payloadAsByteArray;
-
- private transient volatile boolean persisted;
-
- // Constructors --------------------------------------------------
-
- /*
- * Construct a message for deserialization or streaming
- */
- public MessageSupport()
- {
- }
-
- /*
- * Construct a message using default values
- */
- public MessageSupport(long messageID)
- {
- this(messageID, false, 0, System.currentTimeMillis(), (byte) 4, null,
- null);
- }
-
- /*
- * Construct a message using specified values
- */
- public MessageSupport(long messageID, boolean reliable, long expiration,
- long timestamp, byte priority, Map headers, byte[] payloadAsByteArray)
- {
- this.messageID = messageID;
- this.reliable = reliable;
- this.expiration = expiration;
- this.timestamp = timestamp;
- this.priority = priority;
- if (headers == null)
- {
- this.headers = new HashMap();
- }
- else
- {
- this.headers = new HashMap(headers);
- }
-
- this.payloadAsByteArray = payloadAsByteArray;
- }
-
- /*
- * Copy constructor
- *
- * Does a shallow copy of the payload
- */
- protected MessageSupport(MessageSupport that)
- {
- this.messageID = that.messageID;
- this.reliable = that.reliable;
- this.expiration = that.expiration;
- this.timestamp = that.timestamp;
- this.headers = new HashMap(that.headers);
- this.priority = that.priority;
- this.payload = that.payload;
- this.payloadAsByteArray = that.payloadAsByteArray;
- }
-
- // Message implementation ----------------------------------------
-
- public long getMessageID()
- {
- return messageID;
- }
-
- public boolean isReliable()
- {
- return reliable;
- }
-
- public long getExpiration()
- {
- return expiration;
- }
-
- public void setExpiration(long expiration)
- {
- this.expiration = expiration;
- }
-
- public long getTimestamp()
- {
- return timestamp;
- }
-
- public Object putHeader(String name, Object value)
- {
- return headers.put(name, value);
- }
-
- public Object getHeader(String name)
- {
- return headers.get(name);
- }
-
- public Object removeHeader(String name)
- {
- return headers.remove(name);
- }
-
- public boolean containsHeader(String name)
- {
- return headers.containsKey(name);
- }
-
- public Map getHeaders()
- {
- return headers;
- }
-
- public byte getPriority()
- {
- return priority;
- }
-
- public void setPriority(byte priority)
- {
- this.priority = priority;
- }
-
- public boolean isReference()
- {
- return false;
- }
-
- public synchronized byte[] getPayloadAsByteArray()
- {
- if (payloadAsByteArray == null && payload != null)
- {
- final int BUFFER_SIZE = 2048;
-
- try
- {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);
- DataOutputStream daos = new DataOutputStream(bos);
- doWriteObject(daos, payload);
- daos.close();
- payloadAsByteArray = bos.toByteArray();
-
- //Note we set payload to null - if we didn't then we'd end up with the message stored in memory twice -
- //once as the payload, once as the byte[] - this means it would take up twice the RAM
- payload = null;
- }
- catch (Exception e)
- {
- RuntimeException e2 = new RuntimeException(e.getMessage());
- e2.setStackTrace(e.getStackTrace());
- throw e2;
- }
- }
- return payloadAsByteArray;
- }
-
- public synchronized Object getPayload()
- {
- if (payload != null)
- {
- return payload;
- }
- else if (payloadAsByteArray != null)
- {
- ByteArrayInputStream bis = new ByteArrayInputStream(payloadAsByteArray);
- DataInputStream dis = new DataInputStream(bis);
- try
- {
- payload = StreamUtils.readObject(dis, true);
- }
- catch (Exception e)
- {
- RuntimeException e2 = new RuntimeException(e.getMessage());
- e2.setStackTrace(e.getStackTrace());
- throw e2;
- }
-
- payloadAsByteArray = null;
-
- return payload;
- }
- else
- {
- return null;
- }
- }
-
- public void setPayload(Object payload)
- {
- this.payload = payload;
- }
-
- public boolean isExpired()
- {
- if (expiration == 0)
- {
- return false;
- }
- long overtime = System.currentTimeMillis() - expiration;
- if (overtime >= 0)
- {
- // discard it
- if (trace)
- {
- log.trace(this + " expired by " + overtime + " ms");
- }
-
- return true;
- }
- return false;
- }
-
- public MessageReference createReference()
- {
- return new SimpleMessageReference(this);
- }
-
- public boolean isPersisted()
- {
- return persisted;
- }
-
- public void setPersisted(boolean persisted)
- {
- this.persisted = persisted;
- }
-
- // Public --------------------------------------------------------
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (!(o instanceof MessageSupport))
- {
- return false;
- }
- MessageSupport that = (MessageSupport) o;
- return that.messageID == this.messageID;
- }
-
- public int hashCode()
- {
- return (int) ((this.messageID >>> 32) ^ this.messageID);
- }
-
- public String toString()
- {
- return "M[" + messageID + "]";
- }
-
- // Streamable implementation ---------------------------------
-
- public void write(DataOutputStream out) throws Exception
- {
- out.writeLong(messageID);
-
- out.writeBoolean(reliable);
-
- out.writeLong(expiration);
-
- out.writeLong(timestamp);
-
- StreamUtils.writeMap(out, headers, true);
-
- out.writeByte(priority);
-
- byte[] bytes = getPayloadAsByteArray();
-
- if (bytes != null)
- {
- out.writeInt(bytes.length);
-
- out.write(bytes);
- }
- else
- {
- out.writeInt(0);
- }
- }
-
- public void read(DataInputStream in) throws Exception
- {
- messageID = in.readLong();
-
- reliable = in.readBoolean();
-
- expiration = in.readLong();
-
- timestamp = in.readLong();
-
- headers = StreamUtils.readMap(in, true);
-
- priority = in.readByte();
-
- int length = in.readInt();
-
- if (length == 0)
- {
- // no payload
- payloadAsByteArray = null;
- }
- else
- {
- payloadAsByteArray = new byte[length];
-
- in.readFully(payloadAsByteArray);
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Certain MessageTypes will need different behaviors. For example ObjectMessages won't use container types
- protected void doWriteObject(DataOutputStream out, Object payload) throws IOException
- {
- StreamUtils.writeObject(out, payload, true, true);
- }
-
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageReference.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageReference.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageReference.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.impl.message;
-
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.contract.MessageReference;
-
-/**
- * A Simple MessageReference implementation.
- *
- * Note that we do not need WeakReferences to message/holder objects since with the new
- * lazy loading schema we guarantee that if a message ref is in memory - it's corresponding message is
- * in memory too
- *
- * @author <a href="mailto:tim.fox at jboss.com>Tim Fox</a>
- * @version <tt>1.3</tt>
- *
- * SimpleMessageReference.java,v 1.3 2006/02/23 17:45:57 timfox Exp
- */
-public class SimpleMessageReference implements MessageReference
-{
- private static final Logger log = Logger.getLogger(SimpleMessageReference.class);
-
- // Attributes ----------------------------------------------------
-
- private boolean trace = log.isTraceEnabled();
-
- private long pagingOrder = -1;
-
- private int deliveryCount;
-
- private long scheduledDeliveryTime;
-
- private Message message;
-
- // Constructors --------------------------------------------------
-
- /**
- * Required by externalization.
- */
- public SimpleMessageReference()
- {
- if (trace) { log.trace("Creating using default constructor"); }
- }
-
- public SimpleMessageReference(SimpleMessageReference other)
- {
- this.pagingOrder = other.pagingOrder;
-
- this.deliveryCount = other.deliveryCount;
-
- this.scheduledDeliveryTime = other.scheduledDeliveryTime;
-
- this.message = other.message;
- }
-
- protected SimpleMessageReference(Message message)
- {
- this.message = message;
- }
-
- // MessageReference implementation -------------------------------
-
- public MessageReference copy()
- {
- return new SimpleMessageReference(this);
- }
-
- public int getDeliveryCount()
- {
- return deliveryCount;
- }
-
- public void setDeliveryCount(int deliveryCount)
- {
- this.deliveryCount = deliveryCount;
- }
-
- public long getScheduledDeliveryTime()
- {
- return scheduledDeliveryTime;
- }
-
- public void setScheduledDeliveryTime(long scheduledDeliveryTime)
- {
- this.scheduledDeliveryTime = scheduledDeliveryTime;
- }
-
- public Message getMessage()
- {
- return message;
- }
-
- public long getPagingOrder()
- {
- return pagingOrder;
- }
-
- public void setPagingOrder(long order)
- {
- this.pagingOrder = order;
- }
-
- // Public --------------------------------------------------------
-
- public String toString()
- {
- return "Reference[" + getMessage().getMessageID() + "]:" + (getMessage().isReliable() ? "RELIABLE" : "NON-RELIABLE");
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
\ No newline at end of file
Modified: trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageStore.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageStore.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageStore.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -25,8 +25,8 @@
import java.util.WeakHashMap;
import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
import org.jboss.messaging.core.contract.MessageStore;
/**
Modified: trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageHolder.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageHolder.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageHolder.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -25,8 +25,8 @@
import java.io.DataOutputStream;
import java.util.Map;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.impl.message.MessageFactory;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.impl.MessageImpl;
import org.jboss.messaging.util.StreamUtils;
import org.jboss.messaging.util.Streamable;
@@ -79,9 +79,9 @@
{
routingKeyText = in.readUTF();
- byte type = in.readByte();
+ //byte type = in.readByte();
- message = MessageFactory.createMessage(type);
+ message = new MessageImpl();
message.read(in);
queueNameToNodeIdMap = (Map)StreamUtils.readObject(in, false);
@@ -91,7 +91,7 @@
{
out.writeUTF(routingKeyText);
- out.writeByte(message.getType());
+ //out.writeByte(message.getType());
message.write(out);
StreamUtils.writeObject(out, queueNameToNodeIdMap, true, false);
Modified: trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageRequest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageRequest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -27,8 +27,8 @@
import java.util.Iterator;
import java.util.Set;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.impl.message.MessageFactory;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.impl.MessageImpl;
/**
* A MessageRequest
@@ -78,9 +78,9 @@
{
routingConditionText = in.readUTF();
- byte type = in.readByte();
+ //byte type = in.readByte();
- message = MessageFactory.createMessage(type);
+ message = new MessageImpl();
message.read(in);
@@ -105,7 +105,7 @@
{
out.writeUTF(routingConditionText);
- out.writeByte(message.getType());
+ //out.writeByte(message.getType());
message.write(out);
Modified: trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,7 +21,29 @@
*/
package org.jboss.messaging.core.impl.postoffice;
-import EDU.oswego.cs.dl.util.concurrent.*;
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanNotificationInfo;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+
import org.jboss.jms.client.container.JMSClientVMIdentifier;
import org.jboss.jms.server.Configuration;
import org.jboss.jms.server.JMSConditionFactory;
@@ -29,8 +51,21 @@
import org.jboss.jms.server.endpoint.ServerSessionEndpoint;
import org.jboss.jms.server.selector.SelectorFactory;
import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.*;
+import org.jboss.messaging.core.contract.Binding;
+import org.jboss.messaging.core.contract.ChannelFactory;
+import org.jboss.messaging.core.contract.ClusterNotification;
+import org.jboss.messaging.core.contract.ClusterNotifier;
+import org.jboss.messaging.core.contract.Condition;
+import org.jboss.messaging.core.contract.ConditionFactory;
+import org.jboss.messaging.core.contract.Delivery;
+import org.jboss.messaging.core.contract.FilterFactory;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.core.contract.MessageStore;
+import org.jboss.messaging.core.contract.PersistenceManager;
+import org.jboss.messaging.core.contract.PostOffice;
import org.jboss.messaging.core.contract.Queue;
+import org.jboss.messaging.core.contract.Replicator;
import org.jboss.messaging.core.impl.IDManager;
import org.jboss.messaging.core.impl.JDBCSupport;
import org.jboss.messaging.core.impl.MessagingQueue;
@@ -38,6 +73,7 @@
import org.jboss.messaging.core.impl.message.SimpleMessageStore;
import org.jboss.messaging.core.impl.tx.Transaction;
import org.jboss.messaging.core.impl.tx.TxCallback;
+import org.jboss.messaging.newcore.Filter;
import org.jboss.messaging.util.ClearableSemaphore;
import org.jboss.messaging.util.ConcurrentHashSet;
import org.jboss.messaging.util.StreamUtils;
@@ -45,12 +81,11 @@
import org.jgroups.JChannelFactory;
import org.jgroups.View;
-import javax.management.*;
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Types;
-import java.util.*;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
+import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
+import EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -2018,7 +2053,7 @@
Filter filter = queue.getFilter();
- if (filter == null || filter.accept(ref.getMessage()))
+ if (filter == null || filter.match(ref.getMessage()))
{
if (trace) { log.trace(this + " Added queue " + queue + " to list of targets"); }
@@ -2043,7 +2078,7 @@
Filter filter = queue.getFilter();
- if (filter == null || filter.accept(ref.getMessage()))
+ if (filter == null || filter.match(ref.getMessage()))
{
if (remoteSet == null)
{
Modified: trunk/src/main/org/jboss/messaging/core/impl/postoffice/RequestTarget.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/postoffice/RequestTarget.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/postoffice/RequestTarget.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -25,7 +25,7 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.messaging.core.contract.Message;
+import org.jboss.messaging.newcore.Message;
import org.jgroups.Address;
/**
Modified: trunk/src/main/org/jboss/messaging/core/impl/tx/TransactionRepository.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/tx/TransactionRepository.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/impl/tx/TransactionRepository.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -291,11 +291,11 @@
{
PersistenceManager.MessageChannelPair pair = (PersistenceManager.MessageChannelPair)iter.next();
- Message msg = pair.getMessage();
+ org.jboss.messaging.newcore.Message msg = pair.getMessage();
long channelID = pair.getChannelId();
- MessageReference ref = messageStore.reference(msg);
+ org.jboss.messaging.newcore.MessageReference ref = messageStore.reference(msg);
ref.getMessage().setPersisted(true);
@@ -348,11 +348,11 @@
{
PersistenceManager.MessageChannelPair pair = (PersistenceManager.MessageChannelPair)iter.next();
- Message msg = pair.getMessage();
+ org.jboss.messaging.newcore.Message msg = pair.getMessage();
long channelID = pair.getChannelId();
- MessageReference ref = null;
+ org.jboss.messaging.newcore.MessageReference ref = null;
ref = messageStore.reference(msg);
Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -22,10 +22,10 @@
import org.jboss.jms.destination.JBossDestination;
import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.impl.message.MessageFactory;
import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
import org.jboss.messaging.core.remoting.wireformat.PacketType;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.impl.MessageImpl;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -222,7 +222,7 @@
return readDestination(new DataInputStream(bais));
}
- protected static byte[] encode(Message message) throws Exception
+ protected static byte[] encodeMessage(Message message) throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.write(new DataOutputStream(baos));
@@ -230,10 +230,10 @@
return baos.toByteArray();
}
- protected static Message decode(byte type, byte[] b) throws Exception
- {
- Message msg = MessageFactory.createMessage(type);
+ protected static Message decodeMessage(byte[] b) throws Exception
+ {
ByteArrayInputStream bais = new ByteArrayInputStream(b);
+ Message msg = new MessageImpl();
msg.read(new DataInputStream(bais));
return msg;
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -13,9 +13,9 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
-import org.jboss.jms.message.JBossMessage;
-import org.jboss.messaging.core.impl.message.MessageFactory;
import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockResponse;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.impl.MessageImpl;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -42,7 +42,7 @@
@Override
protected void encodeBody(BrowserNextMessageBlockResponse response, RemotingBuffer out) throws Exception
{
- JBossMessage[] messages = response.getMessages();
+ Message[] messages = response.getMessages();
byte[] encodedMessages = encode(messages);
@@ -68,7 +68,7 @@
int encodedMessagesLength = in.getInt();
byte[] encodedMessages = new byte[encodedMessagesLength];
in.get(encodedMessages);
- JBossMessage[] messages = decode(numOfMessages, encodedMessages);
+ Message[] messages = decode(numOfMessages, encodedMessages);
return new BrowserNextMessageBlockResponse(messages);
}
@@ -79,30 +79,28 @@
// Private ----------------------------------------------------
- private byte[] encode(JBossMessage[] messages) throws Exception
+ private byte[] encode(Message[] messages) throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream daos = new DataOutputStream(baos);
for (int i = 0; i < messages.length; i++)
{
- JBossMessage message = messages[i];
- daos.writeByte(message.getType());
+ Message message = messages[i];
message.write(daos);
}
return baos.toByteArray();
}
- private JBossMessage[] decode(int numOfMessages, byte[] encodedMessages) throws Exception
+ private Message[] decode(int numOfMessages, byte[] encodedMessages) throws Exception
{
- JBossMessage[] messages = new JBossMessage[numOfMessages];
+ Message[] messages = new Message[numOfMessages];
ByteArrayInputStream bais = new ByteArrayInputStream(encodedMessages);
DataInputStream dais = new DataInputStream(bais);
for (int i = 0; i < messages.length; i++)
{
- byte type = (byte) dais.readByte();
- JBossMessage message = (JBossMessage)MessageFactory.createMessage(type);
+ Message message = new MessageImpl();
message.read(dais);
messages[i] = message;
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageResponseCodec.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageResponseCodec.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -10,6 +10,7 @@
import org.jboss.jms.message.JBossMessage;
import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageResponse;
+import org.jboss.messaging.newcore.Message;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -35,14 +36,12 @@
@Override
protected void encodeBody(BrowserNextMessageResponse response, RemotingBuffer out) throws Exception
- {
- JBossMessage message = response.getMessage();
- byte[] encodedMsg = encode(response.getMessage());
+ {
+ byte[] encodedMsg = encodeMessage(response.getMessage());
- int bodyLength = 1 + INT_LENGTH + encodedMsg.length;
+ int bodyLength = INT_LENGTH + encodedMsg.length;
- out.putInt(bodyLength);
- out.put(message.getType());
+ out.putInt(bodyLength);
out.putInt(encodedMsg.length);
out.put(encodedMsg);
}
@@ -57,11 +56,10 @@
return null;
}
- byte type = in.get();
int msgLength = in.getInt();
byte[] encodedMsg = new byte[msgLength];
in.get(encodedMsg);
- JBossMessage message = (JBossMessage) decode(type, encodedMsg);
+ Message message = decodeMessage(encodedMsg);
return new BrowserNextMessageResponse(message);
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/DeliverMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/DeliverMessageCodec.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/DeliverMessageCodec.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -8,7 +8,7 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELIVERMESSAGE;
-import org.jboss.messaging.core.contract.Message;
+import org.jboss.messaging.newcore.Message;
import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
/**
@@ -36,17 +36,15 @@
@Override
protected void encodeBody(DeliverMessage message, RemotingBuffer out) throws Exception
{
- Message msg = message.getMessage();
- byte[] encodedMsg = encode(message.getMessage());
+ byte[] encodedMsg = encodeMessage(message.getMessage());
String consumerID = message.getConsumerID();
long deliveryID = message.getDeliveryID();
int deliveryCount = message.getDeliveryCount();
- int bodyLength = 1 + INT_LENGTH + encodedMsg.length + sizeof(consumerID)
+ int bodyLength = INT_LENGTH + encodedMsg.length + sizeof(consumerID)
+ LONG_LENGTH + INT_LENGTH;
out.putInt(bodyLength);
- out.put(msg.getType());
out.putInt(encodedMsg.length);
out.put(encodedMsg);
out.putNullableString(consumerID);
@@ -64,11 +62,10 @@
return null;
}
- byte type = in.get();
int msgLength = in.getInt();
byte[] encodedMsg = new byte[msgLength];
in.get(encodedMsg);
- Message msg = decode(type, encodedMsg);
+ Message msg = decodeMessage(encodedMsg);
String consumerID = in.getNullableString();
long deliveryID = in.getLong();
int deliveryCount = in.getInt();
Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SendMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SendMessageCodec.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SendMessageCodec.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -8,8 +8,8 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDMESSAGE;
-import org.jboss.jms.message.JBossMessage;
import org.jboss.messaging.core.remoting.wireformat.SendMessage;
+import org.jboss.messaging.newcore.Message;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -36,14 +36,13 @@
@Override
protected void encodeBody(SendMessage message, RemotingBuffer out) throws Exception
{
- byte[] encodedMsg = encode(message.getMessage());
+ byte[] encodedMsg = encodeMessage(message.getMessage());
boolean checkForDuplicates = message.checkForDuplicates();
long sequence = message.getSequence();
- int bodyLength = INT_LENGTH + 1 + encodedMsg.length + 1 + LONG_LENGTH;
+ int bodyLength = INT_LENGTH + 1 + encodedMsg.length + LONG_LENGTH;
out.putInt(bodyLength);
- out.put(message.getMessage().getType());
out.putInt(encodedMsg.length);
out.put(encodedMsg);
out.putBoolean(checkForDuplicates);
@@ -60,11 +59,10 @@
return null;
}
- byte msgType = in.get();
int msgLength = in.getInt();
byte[] encodedMsg = new byte[msgLength];
in.get(encodedMsg);
- JBossMessage msg = (JBossMessage) decode(msgType, encodedMsg);
+ Message msg = decodeMessage(encodedMsg);
boolean checkForDuplicates = in.getBoolean();
long sequence = in.getLong();
Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -22,16 +22,16 @@
// Attributes ----------------------------------------------------
private final long maxMessages;
-
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
public BrowserNextMessageBlockRequest(long maxMessages)
{
- super(REQ_BROWSER_NEXTMESSAGEBLOCK);
-
- this.maxMessages = maxMessages;
+ super(REQ_BROWSER_NEXTMESSAGEBLOCK);
+
+ this.maxMessages = maxMessages;
}
// Public --------------------------------------------------------
@@ -40,13 +40,13 @@
{
return maxMessages;
}
-
+
@Override
public String toString()
{
return getParentString() + ", maxMessages=" + maxMessages + "]";
}
-
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -10,7 +10,7 @@
import java.util.Arrays;
-import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.newcore.Message;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -24,13 +24,13 @@
// Attributes ----------------------------------------------------
- private final JBossMessage[] messages;
+ private final Message[] messages;
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public BrowserNextMessageBlockResponse(JBossMessage[] messages)
+ public BrowserNextMessageBlockResponse(Message[] messages)
{
super(RESP_BROWSER_NEXTMESSAGEBLOCK);
@@ -41,7 +41,7 @@
// Public --------------------------------------------------------
- public JBossMessage[] getMessages()
+ public Message[] getMessages()
{
return messages;
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageRequest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageRequest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -27,7 +27,7 @@
public BrowserNextMessageRequest()
{
- super(REQ_BROWSER_NEXTMESSAGE);
+ super(REQ_BROWSER_NEXTMESSAGE);
}
// Public --------------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageResponse.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageResponse.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -6,7 +6,7 @@
*/
package org.jboss.messaging.core.remoting.wireformat;
-import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.newcore.Message;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -20,13 +20,13 @@
// Attributes ----------------------------------------------------
- private final JBossMessage message;
+ private final Message message;
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public BrowserNextMessageResponse(JBossMessage message)
+ public BrowserNextMessageResponse(Message message)
{
super(PacketType.RESP_BROWSER_NEXTMESSAGE);
@@ -37,7 +37,7 @@
// Public --------------------------------------------------------
- public JBossMessage getMessage()
+ public Message getMessage()
{
return message;
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeliverMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeliverMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeliverMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -9,7 +9,7 @@
import static org.jboss.messaging.core.remoting.Assert.assertValidID;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELIVERMESSAGE;
-import org.jboss.messaging.core.contract.Message;
+import org.jboss.messaging.newcore.Message;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SendMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SendMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SendMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -8,7 +8,7 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDMESSAGE;
-import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.newcore.Message;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -22,7 +22,7 @@
// Attributes ----------------------------------------------------
- private final JBossMessage message;
+ private final Message message;
private final boolean checkForDuplicates;
private final long sequence;
@@ -30,7 +30,7 @@
// Constructors --------------------------------------------------
- public SendMessage(JBossMessage message, boolean checkForDuplicates,
+ public SendMessage(Message message, boolean checkForDuplicates,
long sequence)
{
super(MSG_SENDMESSAGE);
@@ -44,7 +44,7 @@
// Public --------------------------------------------------------
- public JBossMessage getMessage()
+ public Message getMessage()
{
return message;
}
Copied: trunk/src/main/org/jboss/messaging/newcore/ClusteredQueue.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/ClusteredQueue.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/ClusteredQueue.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/ClusteredQueue.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+/**
+ *
+ * A ClusteredQueue
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface ClusteredQueue extends Queue
+{
+
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/Consumer.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/Consumer.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/Consumer.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/Consumer.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+
+/**
+ *
+ * A Consumer
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface Consumer
+{
+ HandleStatus handle(MessageReference reference);
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/DistributionPolicy.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/DistributionPolicy.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/DistributionPolicy.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/DistributionPolicy.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+import java.util.List;
+
+/**
+ *
+ * A DistributionPolicy
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface DistributionPolicy
+{
+ int select(List<Consumer> consumers, int lastPos);
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/Filter.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/Filter.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/Filter.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/Filter.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+/**
+ *
+ * A Filter
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface Filter
+{
+ boolean match(Message message);
+
+ String getFilterString();
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/HandleStatus.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/HandleStatus.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/HandleStatus.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/HandleStatus.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+/**
+ *
+ * A HandleStatus
+ *
+ * HANDLED means the MessageReference was handled
+ *
+ * NO_MATCH means the MessageReference was rejected by a Filter
+ *
+ * BUSY means the MessageReference was rejected since the Consumer was busy
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public enum HandleStatus
+{
+ HANDLED, NO_MATCH, BUSY;
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/Message.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/Message.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/Message.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/Message.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,236 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.messaging.util.Streamable;
+
+/**
+ * A message is a routable instance that has a payload.
+ * The payload is opaque to the messaging system.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:tim.fox"jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 3341 $</tt>
+ *
+ * $Id: Message.java 3341 2007-11-19 14:34:57Z timfox $
+ */
+public interface Message extends Streamable
+{
+ //FIXME - temp
+ public static final String TEMP_DEST_HEADER_NAME = "DEST";
+
+
+ /**
+ * This header is set on a message when a message is sucked from one node of the cluster to another
+ * and order preservation is true.
+ * The header is checked when sucking messages and if order preservation is true then the message is not accepted.
+ * This is a basic way of ensuring message order is preserved.
+ */
+ public static final String CLUSTER_SUCKED = "SUCKED";
+
+ /**
+ * This header is set on a message when it is sucked from one node to another.
+ * If the header exists on the destination node, and the message is persistent, the message
+ * will be moved from one channel to the other by doing a simple database update
+ */
+ public static final String SOURCE_CHANNEL_ID = "SCID";
+
+ /**
+ * The scheduled delivery time for the message
+ */
+ public static final String SCHEDULED_DELIVERY_TIME = "SCHED";
+
+ /**
+ * @return The unique id of the message
+ */
+ long getMessageID();
+
+ /**
+ * Set the message id
+ *
+ * @param id
+ */
+ void setMessageID(long id);
+
+ /**
+ * @return true if the delivery must be guaranteed for this routable, false otherwise.
+ */
+ boolean isReliable();
+
+ /**
+ * Set whether message is reliable or not
+ * @param reliable
+ */
+ void setReliable(boolean reliable);
+
+ /**
+ * @return the time when this routable expires and must be removed
+ * from the system. A zero value means this routable never expires.
+ */
+ long getExpiration();
+
+ /**
+ *
+ * @return true if the message has expired
+ */
+ boolean isExpired();
+
+ /**
+ * Set the expiration for this message
+ *
+ * @param expiration
+ */
+ void setExpiration(long expiration);
+
+ /**
+ * @return the time (in GMT milliseconds) when this routable was delivered to the provider.
+ */
+ long getTimestamp();
+
+ /**
+ * Set the timestamp for this message
+ * @param timestamp The timestamp
+ */
+ void setTimestamp(long timestamp);
+
+ /**
+ *
+ * @return The priority (0-9) of the message
+ */
+ byte getPriority();
+
+ /**
+ * Get the priority of the message. Priorities range from 0 to 9.
+ * Where 0 is the lowest priority and 9 is the highest priority
+ * @param priority
+ */
+ void setPriority(byte priority);
+
+ /**
+ * Binds a header. If the header map previously contained a mapping for this name, the old value
+ * is replaced by the specified value.
+ *
+ * @return the value associated with the name or null if there is no mapping for the name. A null
+ * can also indicate that the header map previously associated null with the specified
+ * name.
+ */
+ Object putHeader(String name, Object value);
+
+ /**
+ * Returns the value corresponding to the header name. Returns null if the map contains no
+ * mapping for the name. A return value of null does not necessarily indicate that the map
+ * contains no mapping for the name; it's also possible that the map explicitly maps the name to
+ * null. The containsHeader() operation may be used to distinguish these two cases.
+ *
+ * @return the value associated with the header, or null if there is no mapping for the header.
+ */
+ Object getHeader(String name);
+
+ /**
+ * Removes the header.
+ *
+ * @return previous value associated with the header, or null if there was no mapping.
+ */
+ Object removeHeader(String name);
+
+ /**
+ * Returns true if the Routable contains the specified header.
+ */
+ boolean containsHeader(String name);
+
+ /**
+ *
+ * @return The message's headers
+ */
+ Map<String, Object> getHeaders();
+
+ /**
+ *
+ * @return The message's payload
+ */
+ byte[] getPayload();
+
+
+ /**
+ * Set the payload
+ *
+ * @param payload
+ */
+ void setPayload(byte[] payload);
+
+ /**
+ *
+ * @return The message's headers as byte array
+ */
+ byte[] getHeaderBytes() throws Exception;
+
+ /**
+ *
+ * @return the type of the message
+ */
+ int getType();
+
+ /**
+ * Get the connection id
+ * @return
+ */
+ String getConnectionID();
+
+ /**
+ * Set the connection id
+ * @param connectionID
+ */
+ void setConnectionID(String connectionID);
+
+
+ /**
+ * @return a reference for this message
+ */
+ MessageReference createReference(Queue queue);
+
+ /**
+ *
+ * @return List of persisted references for this message
+ */
+ List<MessageReference> getReferences();
+
+ /**
+ * Make a copy of the message
+ *
+ * @return The copy
+ */
+ Message copy();
+
+
+ // ======================================================================
+
+ // Remove these once refactoring is complete
+
+ boolean isPersisted();
+
+ void setPersisted(boolean persisted);
+
+ MessageReference createReference();
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/MessageReference.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/MessageReference.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/MessageReference.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/MessageReference.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+/**
+ * A reference to a message.
+ *
+ * Channels store message references rather than the messages themselves.
+ *
+ * If many channels have contain the same reference this makes a lot of sense
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 3020 $</tt>
+ *
+ * $Id: MessageReference.java 3020 2007-08-21 15:46:38Z timfox $
+ */
+public interface MessageReference
+{
+ Message getMessage();
+
+ MessageReference copy(Queue queue);
+
+ /**
+ *
+ * @return The time in the future that delivery will be delayed until, or zero if
+ * no scheduled delivery will occur
+ */
+ long getScheduledDeliveryTime();
+
+ void setScheduledDeliveryTime(long scheduledDeliveryTime);
+
+ /**
+ * @return the number of times delivery has been attempted for this routable
+ */
+ int getDeliveryCount();
+
+ void setDeliveryCount(int deliveryCount);
+
+ Queue getQueue();
+
+ //--------------------------------------------------------------------
+ //TODO - remove these once refactoring is complete
+
+ long getPagingOrder();
+
+ void setPagingOrder(long order);
+
+ MessageReference copy();
+
+
+}
+
+
Copied: trunk/src/main/org/jboss/messaging/newcore/MessagingComponent.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/MessagingComponent.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/MessagingComponent.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/MessagingComponent.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+/**
+ * A MessagingComponent
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 2796 $</tt>
+ *
+ * $Id: MessagingComponent.java 2796 2007-06-25 22:24:41Z timfox $
+ *
+ */
+public interface MessagingComponent
+{
+ void start() throws Exception;
+
+ void stop() throws Exception;
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/PagingManager.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/PagingManager.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/PagingManager.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/PagingManager.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,15 @@
+package org.jboss.messaging.newcore;
+
+/**
+ *
+ * A PagingManager
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface PagingManager extends MessagingComponent
+{
+ void pageReference(Queue queue, MessageReference ref);
+
+ MessageReference depageReference(Queue queue);
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/PersistenceManager.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/PersistenceManager.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/PersistenceManager.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/PersistenceManager.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.transaction.xa.Xid;
+
+/**
+ *
+ * A PersistenceManager
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface PersistenceManager extends MessagingComponent
+{
+ /**
+ * A single message, possible with many message references needs to be added to storage
+ * This would occur when a single reliable messages arrives on the server and needs to be routed
+ * to 1 or more queues.
+ * @param message
+ */
+ public void addMessage(Message message) throws Exception;
+
+ /**
+ * Delete a single reference. This would also delete the message if it is no longer referenced by any other
+ * references.
+ * This would occur on acknowledgement of a single reference
+ * @param message
+ */
+ void deleteReference(MessageReference reference) throws Exception;
+
+ /**
+ * Commit a transaction containing messages to add and references to remove
+ * @param messagesToAdd List of messages to add, or null if none
+ * @param referencesToRemove List of references to remove, or null if none
+ * @throws Exception
+ */
+ public void commitTransaction(List<Message> messagesToAdd, List<MessageReference> referencesToRemove) throws Exception;
+
+ /**
+ * Prepare a transaction containing messages to add and references to remove
+ * @param xid The Xid of the XA transaction
+ * @param messagesToAdd List of messages to add, or null if none
+ * @param referencesToRemove List of references to remove, or null if none
+ * @throws Exception
+ */
+ public void prepareTransaction(Xid xid, List<Message> messagesToAdd,
+ List<MessageReference> referencesToRemove) throws Exception;
+
+ /**
+ * Commit a prepared transaction
+ *
+ * @param xid
+ * @throws Exception
+ */
+ public void commitPreparedTransaction(Xid xid) throws Exception;
+
+
+ /**
+ * Unprepare a transaction containing messages to add and references to remove
+ * @param xid The Xid of the XA transaction
+ * @param messagesToAdd List of messages to add, or null if none
+ * @param referencesToRemove List of references to remove, or null if none
+ * @throws Exception
+ */
+ public void unprepareTransaction(Xid xid, List<Message> messagesToAdd,
+ List<MessageReference> referencesToRemove) throws Exception;
+
+
+ /**
+ * Update the delivery count of a reference
+ * @param queue
+ * @param ref
+ * @throws Exception
+ */
+ void updateDeliveryCount(Queue queue, MessageReference ref) throws Exception;
+
+ /**
+ * Load the specified queues from persistent storage
+ * @param queues The map of queues to load
+ * @throws Exception
+ */
+ void loadQueues(Map<Long, Queue> queues) throws Exception;
+
+ /**
+ * Get a list of in doubt (prepared) transaction ids
+ * Can only be called in recovery mode
+ * @return the list of ids
+ */
+ List<Xid> getInDoubtXids() throws Exception;
+
+ /**
+ *
+ * @return true if the PersistenceManager is in recovery mode
+ */
+ boolean isInRecoveryMode() throws Exception;
+
+ /**
+ *
+ * @param recoveryMode Set the PersistenceManager in recovery mode
+ */
+ void setInRecoveryMode(boolean recoveryMode);
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/PriorityLinkedList.java (from rev 3480, trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedList.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/PriorityLinkedList.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/PriorityLinkedList.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.newcore;
+
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * A type of linked list which maintains items according to a priority
+ * and allows adding and removing of elements at both ends, and peeking
+ *
+ * @author <a href="mailto:tim.fox at jboss.com>Tim Fox</a>
+ * @version <tt>$Revision: 1174 $</tt>
+ *
+ * $Id: PrioritizedDeque.java 1174 2006-08-02 14:14:32Z timfox $
+ */
+public interface PriorityLinkedList<T>
+{
+ void addFirst(T t, int priority);
+
+ void addLast(T t, int priority);
+
+ T removeFirst();
+
+ T removeLast();
+
+ T peekFirst();
+
+ List<T> getAll();
+
+ void clear();
+
+ int size();
+
+ ListIterator<T> iterator();
+
+ boolean isEmpty();
+
+ void dump();
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/Queue.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/Queue.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/Queue.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/Queue.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+import java.util.List;
+
+
+/**
+ *
+ * A Queue
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface Queue
+{
+ public static final int NUM_PRIORITIES = 10;
+
+ HandleStatus addLast(MessageReference ref);
+
+ HandleStatus addFirst(MessageReference ref);
+
+ void deliver();
+
+ void addConsumer(Consumer consumer);
+
+ boolean removeConsumer(Consumer consumer);
+
+ int getConsumerCount();
+
+ List<MessageReference> list(Filter filter);
+
+ void removeAllReferences();
+
+ long getID();
+
+ Filter getFilter();
+
+ void setFilter(Filter filter);
+
+ int getMessageCount();
+
+ //int getDeliveringCount();
+
+ int getScheduledCount();
+
+ int getMaxSize();
+
+ void setMaxSize(int maxSize);
+
+ DistributionPolicy getDistributionPolicy();
+
+ void setDistributionPolicy(DistributionPolicy policy);
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/QueueStatistics.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/QueueStatistics.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/QueueStatistics.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/QueueStatistics.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+/**
+ *
+ * A QueueStatistics
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface QueueStatistics
+{
+ int getMessageCount();
+
+ int getScheduledCount();
+
+ int getGetDeliveringCount();
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/Transaction.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/Transaction.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/Transaction.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/Transaction.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+/**
+ *
+ * A JBoss Messaging internal transaction
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface Transaction
+{
+ void addSynchronization(TransactionSynchronization sync);
+
+ void prepare(PersistenceManager persistenceManager) throws Exception;
+
+ void commit(PersistenceManager persistenceManager) throws Exception;
+
+ void rollback(PersistenceManager persistenceManager) throws Exception;
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/TransactionStore.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/TransactionStore.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/TransactionStore.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/TransactionStore.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+/**
+ *
+ * A TransactionStore
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface TransactionStore extends MessagingComponent
+{
+ Transaction getTransaction(Object id);
+
+ void putTransaction(Transaction tx);
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/TransactionSynchronization.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/TransactionSynchronization.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/TransactionSynchronization.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/TransactionSynchronization.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore;
+
+/**
+ *
+ * A TransactionSynchronization
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface TransactionSynchronization
+{
+ void beforeCommit() throws Exception;
+
+ void afterCommit() throws Exception;
+
+ void beforeRollback() throws Exception;
+
+ void afterRollback() throws Exception;
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/cluster/ClusterMessage.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/cluster/ClusterMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/cluster/ClusterMessage.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/cluster/ClusterMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,13 @@
+package org.jboss.messaging.newcore.cluster;
+
+/**
+ *
+ * A ClusterRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface ClusterMessage
+{
+ void execute();
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/cluster/GroupCoordinator.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupCoordinator.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/cluster/GroupCoordinator.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/cluster/GroupCoordinator.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,33 @@
+package org.jboss.messaging.newcore.cluster;
+
+import java.util.List;
+
+/**
+ *
+ * A GroupCoordinator
+ *
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface GroupCoordinator
+{
+ /**
+ * Join the cluster with the specified id
+ * @param id
+ * @return The state
+ * @throws Exception
+ */
+ Object join(int id, StateHandler handler) throws Exception;
+
+ void leave(int id) throws Exception;
+
+ void sendToAll(ClusterMessage request, boolean sychronous) throws Exception;
+
+ List<Integer> getMembers();
+
+ void registerHandler(GroupHandler handler);
+
+ void unregisterHandler(GroupHandler handler);
+
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/cluster/GroupHandler.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupHandler.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/cluster/GroupHandler.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/cluster/GroupHandler.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,17 @@
+package org.jboss.messaging.newcore.cluster;
+
+import java.util.List;
+
+/**
+ *
+ * A GroupHandler
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface GroupHandler
+{
+ void membersChanged(List<Integer> newMembers);
+
+ void onMessage(int fromNodeId, ClusterMessage message);
+}
Copied: trunk/src/main/org/jboss/messaging/newcore/cluster/StateHandler.java (from rev 3480, trunk/src/main/org/jboss/messaging/newcore/intf/cluster/StateHandler.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/cluster/StateHandler.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/cluster/StateHandler.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,13 @@
+package org.jboss.messaging.newcore.cluster;
+
+/**
+ *
+ * A StateHandler
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface StateHandler
+{
+ Object getState();
+}
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/MessageImpl.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/MessageImpl.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -31,15 +31,15 @@
import java.util.Map;
import org.jboss.logging.Logger;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.messaging.util.StreamUtils;
/**
* A concrete implementation of a message
*
- * All messages handled by JBM servers are of this type
+ * All messages handled by JBM core are of this type
*
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -74,18 +74,19 @@
private long timestamp;
private Map<String, Object> headers;
-
+
private byte priority;
//The payload of MessageImpl instances is opaque
private byte[] payload;
//We keep track of the persisted references for this message
- private transient List<MessageReference> references = new ArrayList<MessageReference>();
+ private List<MessageReference> references = new ArrayList<MessageReference>();
- private String destination;
+ private String connectionID;
- private String connectionID;
+ //FIXME - does scheduledDeliveryTime belong on message? surely on SendMessage
+ // private long scheduledDeliveryTime;
// Constructors --------------------------------------------------
@@ -117,6 +118,7 @@
throws Exception
{
this.messageID = messageID;
+ this.type = type;
this.reliable = reliable;
this.expiration = expiration;
this.timestamp = timestamp;
@@ -148,6 +150,7 @@
public MessageImpl(MessageImpl other)
{
this.messageID = other.messageID;
+ this.type = other.type;
this.reliable = other.reliable;
this.expiration = other.expiration;
this.timestamp = other.timestamp;
@@ -168,16 +171,6 @@
this.messageID = id;
}
- public String getDestination()
- {
- return destination;
- }
-
- public void setDestination(String destination)
- {
- this.destination = destination;
- }
-
public int getType()
{
return type;
@@ -249,7 +242,7 @@
}
// TODO - combine with getPayloadAsByteArray to get one big blob
- public byte[] getHeadersAsByteArray() throws Exception
+ public byte[] getHeaderBytes() throws Exception
{
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
@@ -261,7 +254,7 @@
return bos.toByteArray();
}
-
+
public byte[] getPayload()
{
return payload;
@@ -316,7 +309,7 @@
{
return new MessageImpl(this);
}
-
+
// Public --------------------------------------------------------
public boolean equals(Object o)
@@ -352,8 +345,6 @@
{
out.writeLong(messageID);
- out.writeUTF(destination);
-
out.writeInt(type);
out.writeBoolean(reliable);
@@ -382,8 +373,6 @@
{
messageID = in.readLong();
- destination = in.readUTF();
-
type = in.readInt();
reliable = in.readBoolean();
@@ -418,4 +407,28 @@
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
+
+
+ // ___-------------------------------------------
+ // Remove These when refactoring is complete
+
+ private volatile boolean persisted;
+
+ public boolean isPersisted()
+ {
+ return persisted;
+ }
+
+ public void setPersisted(boolean persisted)
+ {
+ this.persisted = persisted;
+ }
+
+ public MessageReference createReference()
+ {
+ MessageReference ref = new MessageReferenceImpl(this, null);
+
+ return ref;
+
+ }
}
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/MessageReferenceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/MessageReferenceImpl.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/MessageReferenceImpl.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -22,9 +22,9 @@
package org.jboss.messaging.newcore.impl;
import org.jboss.logging.Logger;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.Queue;
/**
* Implementation of a MessageReference
@@ -129,4 +129,24 @@
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
+
+
+ //----------------------------------------------------------------------------
+ // TODO remove these once refactoring is complete
+ private volatile long pagingOrder;
+
+ public long getPagingOrder()
+ {
+ return pagingOrder;
+ }
+
+ public void setPagingOrder(long order)
+ {
+ this.pagingOrder = order;
+ }
+
+ public MessageReference copy()
+ {
+ return new MessageReferenceImpl(this, null);
+ }
}
\ No newline at end of file
Copied: trunk/src/main/org/jboss/messaging/newcore/impl/PriorityLinkedListImpl.java (from rev 3480, trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedListImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/PriorityLinkedListImpl.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/PriorityLinkedListImpl.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -0,0 +1,291 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.newcore.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+
+import org.jboss.logging.Logger;
+import org.jboss.messaging.newcore.PriorityLinkedList;
+
+/**
+ * A priority linked list implementation
+ *
+ * It implements this by maintaining an individual LinkedList for each priority level.
+ *
+ * @author <a href="mailto:tim.fox at jboss.com>Tim Fox</a>
+ * @version <tt>$Revision: 1174 $</tt>
+ *
+ * $Id: BasicPrioritizedDeque.java 1174 2006-08-02 14:14:32Z timfox $
+ */
+public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T>
+{
+ private static final Logger log = Logger.getLogger(PriorityLinkedListImpl.class);
+
+ private List<LinkedList<T>> linkedLists;
+
+ private int priorities;
+
+ private int size;
+
+ public PriorityLinkedListImpl(int priorities)
+ {
+ this.priorities = priorities;
+
+ initLists();
+ }
+
+ public void addFirst(T t, int priority)
+ {
+ linkedLists.get(priority).addFirst(t);
+
+ size++;
+ }
+
+ public void addLast(T t, int priority)
+ {
+ linkedLists.get(priority).addLast(t);
+
+ size++;
+ }
+
+ public T removeFirst()
+ {
+ T t = null;
+
+ //Initially we are just using a simple prioritization algorithm:
+ //Highest priority refs always get returned first.
+ //This could cause starvation of lower priority refs.
+
+ //TODO - A better prioritization algorithm
+
+ for (int i = priorities - 1; i >= 0; i--)
+ {
+ LinkedList<T> ll = linkedLists.get(i);
+
+ if (!ll.isEmpty())
+ {
+ t = ll.removeFirst();
+ break;
+ }
+ }
+
+ if (t != null)
+ {
+ size--;
+ }
+
+ return t;
+ }
+
+ public T removeLast()
+ {
+ T t = null;
+
+ for (int i = 0; i < priorities; i++)
+ {
+ LinkedList<T> ll = linkedLists.get(i);
+ if (!ll.isEmpty())
+ {
+ t = ll.removeLast();
+ }
+ if (t != null)
+ {
+ break;
+ }
+ }
+
+ if (t != null)
+ {
+ size--;
+ }
+
+ return t;
+ }
+
+ public T peekFirst()
+ {
+ T t = null;
+
+ for (int i = priorities - 1; i >= 0; i--)
+ {
+ LinkedList<T> ll = linkedLists.get(i);
+ if (!ll.isEmpty())
+ {
+ t = ll.getFirst();
+ }
+ if (t != null)
+ {
+ break;
+ }
+ }
+
+ return t;
+ }
+
+ public List<T> getAll()
+ {
+ List<T> all = new ArrayList<T>();
+
+ for (int i = priorities - 1; i >= 0; i--)
+ {
+ LinkedList<T> list = linkedLists.get(i);
+ all.addAll(list);
+ }
+
+ return all;
+ }
+
+ public void clear()
+ {
+ initLists();
+ }
+
+ public int size()
+ {
+ return size;
+ }
+
+ public boolean isEmpty()
+ {
+ return size == 0;
+ }
+
+ public ListIterator<T> iterator()
+ {
+ return new PriorityLinkedListIterator();
+ }
+
+ public void dump()
+ {
+ log.debug("Dumping " + this);
+ log.debug("Size:" + size);
+ log.debug("===============");
+
+ for (int i = 0; i < linkedLists.size(); i++)
+ {
+ log.debug("Priority:" + i);
+ log.debug("----------------");
+
+ Iterator<T> iter = linkedLists.get(i).iterator();
+
+ while (iter.hasNext())
+ {
+ log.debug("Ref: "+ iter.next());
+ }
+ }
+ }
+
+ private void initLists()
+ {
+ linkedLists = new ArrayList<LinkedList<T>>();
+
+ for (int i = 0; i < priorities; i++)
+ {
+ linkedLists.add(new LinkedList<T>());
+ }
+
+ size = 0;
+ }
+
+ private class PriorityLinkedListIterator implements ListIterator<T>
+ {
+ private int index;
+
+ private ListIterator<T> currentIter;
+
+ PriorityLinkedListIterator()
+ {
+ index = linkedLists.size() - 1;
+
+ currentIter = linkedLists.get(index).listIterator();
+ }
+
+ public void add(Object arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasNext()
+ {
+ if (currentIter.hasNext())
+ {
+ return true;
+ }
+ while (index >= 0)
+ {
+ if (index == 0 || currentIter.hasNext())
+ {
+ break;
+ }
+ index--;
+ currentIter = linkedLists.get(index).listIterator();
+ }
+ return currentIter.hasNext();
+ }
+
+ public boolean hasPrevious()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public T next()
+ {
+ if (!hasNext())
+ {
+ throw new NoSuchElementException();
+ }
+ return currentIter.next();
+ }
+
+ public int nextIndex()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public T previous()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int previousIndex()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void remove()
+ {
+ currentIter.remove();
+
+ size--;
+ }
+
+ public void set(Object obj)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/QueueImpl.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/QueueImpl.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -29,14 +29,13 @@
import org.jboss.jms.server.MessagingTimeoutFactory;
import org.jboss.logging.Logger;
-import org.jboss.messaging.newcore.intf.Consumer;
-import org.jboss.messaging.newcore.intf.DistributionPolicy;
-import org.jboss.messaging.newcore.intf.Filter;
-import org.jboss.messaging.newcore.intf.HandleStatus;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
-import org.jboss.messaging.util.newprioritylinkedlist.PriorityLinkedList;
-import org.jboss.messaging.util.newprioritylinkedlist.PriorityLinkedListImpl;
+import org.jboss.messaging.newcore.Consumer;
+import org.jboss.messaging.newcore.DistributionPolicy;
+import org.jboss.messaging.newcore.Filter;
+import org.jboss.messaging.newcore.HandleStatus;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.PriorityLinkedList;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.util.timeout.Timeout;
import org.jboss.util.timeout.TimeoutTarget;
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/RoundRobinDistributionPolicy.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/RoundRobinDistributionPolicy.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/RoundRobinDistributionPolicy.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -23,8 +23,8 @@
import java.util.List;
-import org.jboss.messaging.newcore.intf.Consumer;
-import org.jboss.messaging.newcore.intf.DistributionPolicy;
+import org.jboss.messaging.newcore.Consumer;
+import org.jboss.messaging.newcore.DistributionPolicy;
/**
*
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/TransactionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/TransactionImpl.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/TransactionImpl.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -26,11 +26,11 @@
import javax.transaction.xa.Xid;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.PersistenceManager;
-import org.jboss.messaging.newcore.intf.Transaction;
-import org.jboss.messaging.newcore.intf.TransactionSynchronization;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.PersistenceManager;
+import org.jboss.messaging.newcore.Transaction;
+import org.jboss.messaging.newcore.TransactionSynchronization;
/**
*
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/BDBJEPersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/BDBJEPersistenceManager.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/BDBJEPersistenceManager.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -28,11 +28,11 @@
import javax.transaction.xa.Xid;
import org.jboss.logging.Logger;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.PersistenceManager;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.messaging.newcore.impl.MessageImpl;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.PersistenceManager;
-import org.jboss.messaging.newcore.intf.Queue;
import org.jboss.messaging.util.Pair;
/**
@@ -173,6 +173,8 @@
{
if (trace) { log.trace("Failed to rollback", ignore); }
}
+
+ throw e;
}
}
@@ -203,6 +205,8 @@
{
if (trace) { log.trace("Failed to rollback", ignore); }
}
+
+ throw e;
}
}
@@ -245,7 +249,7 @@
environment.rollback(xid);
}
- public void deleteReference(MessageReference reference)
+ public void deleteReference(MessageReference reference) throws Exception
{
BDBJETransaction tx = null;
@@ -270,6 +274,8 @@
{
if (trace) { log.trace("Failed to rollback", ignore); }
}
+
+ throw e;
}
}
@@ -471,7 +477,7 @@
{
//First store the message
- byte[] headers = message.getHeadersAsByteArray();
+ byte[] headers = message.getHeaderBytes();
int headersLength = headers.length;
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/integration/test/unit/BDBSpeedTest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/integration/test/unit/BDBSpeedTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/integration/test/unit/BDBSpeedTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -28,12 +28,12 @@
import javax.transaction.xa.Xid;
import org.jboss.jms.tx.MessagingXid;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.messaging.newcore.impl.MessageImpl;
import org.jboss.messaging.newcore.impl.QueueImpl;
import org.jboss.messaging.newcore.impl.bdbje.BDBJEPersistenceManager;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
import org.jboss.messaging.test.unit.UnitTestCase;
/**
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/test/unit/BDBJEPersistenceManagerTest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/test/unit/BDBJEPersistenceManagerTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/bdbje/test/unit/BDBJEPersistenceManagerTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -29,15 +29,15 @@
import javax.transaction.xa.Xid;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.messaging.newcore.impl.MessageImpl;
import org.jboss.messaging.newcore.impl.QueueImpl;
import org.jboss.messaging.newcore.impl.bdbje.BDBJEDatabase;
import org.jboss.messaging.newcore.impl.bdbje.BDBJEEnvironment;
import org.jboss.messaging.newcore.impl.bdbje.BDBJEPersistenceManager;
import org.jboss.messaging.newcore.impl.bdbje.test.unit.fakes.FakeBDBJEEnvironment;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
import org.jboss.messaging.test.unit.UnitTestCase;
/**
@@ -83,7 +83,18 @@
pm.addMessage(m);
- assertMessageInStore(m, queue);
+ assertMessageInStore(m, queue);
+
+ try
+ {
+ pm.addMessage(null);
+
+ fail("Should throw exception");
+ }
+ catch (NullPointerException ok)
+ {
+ //ok
+ }
}
public void testDeleteReference() throws Exception
@@ -136,6 +147,17 @@
assertMessageNotInStore(m);
assertStoreEmpty();
+
+ try
+ {
+ pm.deleteReference(null);
+
+ fail("Should throw exception");
+ }
+ catch (NullPointerException ok)
+ {
+ //ok
+ }
}
public void testCommitTransaction() throws Exception
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/test/concurrent/QueueTest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/test/concurrent/QueueTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/test/concurrent/QueueTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -24,12 +24,12 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.messaging.newcore.HandleStatus;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.messaging.newcore.impl.QueueImpl;
import org.jboss.messaging.newcore.impl.test.unit.fakes.FakeConsumer;
-import org.jboss.messaging.newcore.intf.HandleStatus;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
import org.jboss.messaging.test.unit.UnitTestCase;
/**
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/test/timing/QueueTest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/test/timing/QueueTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/test/timing/QueueTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -24,10 +24,10 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.messaging.newcore.impl.QueueImpl;
import org.jboss.messaging.newcore.impl.test.unit.fakes.FakeConsumer;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
import org.jboss.messaging.test.unit.UnitTestCase;
/**
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/MessageTest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/MessageTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/MessageTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -24,11 +24,11 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.messaging.newcore.impl.MessageImpl;
import org.jboss.messaging.newcore.impl.QueueImpl;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
import org.jboss.messaging.test.unit.UnitTestCase;
/**
@@ -42,7 +42,7 @@
*/
public class MessageTest extends UnitTestCase
{
- public void testCreateMessage1()
+ public void testCreateMessage()
{
long id = 56465;
int type = 655;
@@ -70,23 +70,54 @@
assertEquals(priority, message.getPriority());
}
- public void testSetAndGetMessageID()
+ public void testCreateMessageFromStorage() throws Exception
{
- Message message = new MessageImpl();
+ long id = 56465;
+ int type = 655;
+ boolean reliable = true;
+ long expiration = 6712671;
+ long timestamp = 82798172;
+ byte priority = 32;
- long id = 765432;
- message.setMessageID(id);
+ byte[] bytes = "blah blah blah".getBytes();
+
+ Message message = new MessageImpl(id, type, reliable, expiration, timestamp, priority,
+ null, bytes);
+
assertEquals(id, message.getMessageID());
+ assertEquals(type, message.getType());
+ assertEquals(reliable, message.isReliable());
+ assertEquals(timestamp, message.getTimestamp());
+ assertEquals(priority, message.getPriority());
+
+ assertByteArraysEquivalent(bytes, message.getPayload());
+
+ //TODO - headers - they should really be combined into single blob
}
- public void testSetAndGetDestination()
+ public void testCopy()
{
+ long id = 56465;
+ int type = 655;
+ boolean reliable = true;
+ long expiration = 6712671;
+ long timestamp = 82798172;
+ byte priority = 32;
+
+ Message message = new MessageImpl(id, type, reliable, expiration, timestamp, priority);
+
+ Message message2 = message.copy();
+
+ assertEquivalent(message, message2);
+ }
+
+ public void testSetAndGetMessageID()
+ {
Message message = new MessageImpl();
- assertNull(message.getDestination());
- String dest = "myDest";
- message.setDestination(dest);
- assertEquals(dest, message.getDestination());
+ long id = 765432;
+ message.setMessageID(id);
+ assertEquals(id, message.getMessageID());
}
public void testSetAndGetReliable()
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/QueueTest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/QueueTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/QueueTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -25,16 +25,16 @@
import java.util.LinkedList;
import java.util.List;
+import org.jboss.messaging.newcore.Consumer;
+import org.jboss.messaging.newcore.DistributionPolicy;
+import org.jboss.messaging.newcore.Filter;
+import org.jboss.messaging.newcore.HandleStatus;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.messaging.newcore.impl.QueueImpl;
import org.jboss.messaging.newcore.impl.RoundRobinDistributionPolicy;
import org.jboss.messaging.newcore.impl.test.unit.fakes.FakeConsumer;
import org.jboss.messaging.newcore.impl.test.unit.fakes.FakeFilter;
-import org.jboss.messaging.newcore.intf.Consumer;
-import org.jboss.messaging.newcore.intf.DistributionPolicy;
-import org.jboss.messaging.newcore.intf.Filter;
-import org.jboss.messaging.newcore.intf.HandleStatus;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
import org.jboss.messaging.test.unit.UnitTestCase;
/**
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/RoundRobinDistributionPolicyTest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/RoundRobinDistributionPolicyTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/RoundRobinDistributionPolicyTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -3,10 +3,10 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.messaging.newcore.Consumer;
+import org.jboss.messaging.newcore.DistributionPolicy;
import org.jboss.messaging.newcore.impl.RoundRobinDistributionPolicy;
import org.jboss.messaging.newcore.impl.test.unit.fakes.FakeConsumer;
-import org.jboss.messaging.newcore.intf.Consumer;
-import org.jboss.messaging.newcore.intf.DistributionPolicy;
import org.jboss.messaging.test.unit.UnitTestCase;
/**
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/TransactionTest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/TransactionTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/TransactionTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -6,14 +6,14 @@
import javax.transaction.xa.Xid;
import org.easymock.EasyMock;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.PersistenceManager;
+import org.jboss.messaging.newcore.Queue;
+import org.jboss.messaging.newcore.Transaction;
+import org.jboss.messaging.newcore.TransactionSynchronization;
import org.jboss.messaging.newcore.impl.QueueImpl;
import org.jboss.messaging.newcore.impl.TransactionImpl;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.PersistenceManager;
-import org.jboss.messaging.newcore.intf.Queue;
-import org.jboss.messaging.newcore.intf.Transaction;
-import org.jboss.messaging.newcore.intf.TransactionSynchronization;
import org.jboss.messaging.test.unit.UnitTestCase;
/**
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/fakes/FakeConsumer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/fakes/FakeConsumer.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/fakes/FakeConsumer.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -24,10 +24,10 @@
import java.util.LinkedList;
import java.util.List;
-import org.jboss.messaging.newcore.intf.Consumer;
-import org.jboss.messaging.newcore.intf.Filter;
-import org.jboss.messaging.newcore.intf.HandleStatus;
-import org.jboss.messaging.newcore.intf.MessageReference;
+import org.jboss.messaging.newcore.Consumer;
+import org.jboss.messaging.newcore.Filter;
+import org.jboss.messaging.newcore.HandleStatus;
+import org.jboss.messaging.newcore.MessageReference;
/**
*
Modified: trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/fakes/FakeFilter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/fakes/FakeFilter.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/impl/test/unit/fakes/FakeFilter.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,8 +21,8 @@
*/
package org.jboss.messaging.newcore.impl.test.unit.fakes;
-import org.jboss.messaging.newcore.intf.Filter;
-import org.jboss.messaging.newcore.intf.Message;
+import org.jboss.messaging.newcore.Filter;
+import org.jboss.messaging.newcore.Message;
/**
*
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/ClusteredQueue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/ClusteredQueue.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/ClusteredQueue.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-/**
- *
- * A ClusteredQueue
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface ClusteredQueue extends Queue
-{
-
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/Consumer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/Consumer.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/Consumer.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-
-/**
- *
- * A Consumer
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface Consumer
-{
- HandleStatus handle(MessageReference reference);
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/DistributionPolicy.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/DistributionPolicy.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/DistributionPolicy.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-import java.util.List;
-
-/**
- *
- * A DistributionPolicy
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface DistributionPolicy
-{
- int select(List<Consumer> consumers, int lastPos);
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/Filter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/Filter.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/Filter.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-/**
- *
- * A Filter
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface Filter
-{
- boolean match(Message message);
-
- String getFilterString();
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/HandleStatus.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/HandleStatus.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/HandleStatus.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-/**
- *
- * A HandleStatus
- *
- * HANDLED means the MessageReference was handled
- *
- * NO_MATCH means the MessageReference was rejected by a Filter
- *
- * BUSY means the MessageReference was rejected since the Consumer was busy
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public enum HandleStatus
-{
- HANDLED, NO_MATCH, BUSY;
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/Message.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/Message.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/Message.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,233 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.messaging.util.Streamable;
-
-/**
- * A message is a routable instance that has a payload.
- * The payload is opaque to the messaging system.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox"jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 3341 $</tt>
- *
- * $Id: Message.java 3341 2007-11-19 14:34:57Z timfox $
- */
-public interface Message extends Streamable
-{
- /**
- * This header is set on a message when a message is sucked from one node of the cluster to another
- * and order preservation is true.
- * The header is checked when sucking messages and if order preservation is true then the message is not accepted.
- * This is a basic way of ensuring message order is preserved.
- */
- public static final String CLUSTER_SUCKED = "SUCKED";
-
- /**
- * This header is set on a message when it is sucked from one node to another.
- * If the header exists on the destination node, and the message is persistent, the message
- * will be moved from one channel to the other by doing a simple database update
- */
- public static final String SOURCE_CHANNEL_ID = "SCID";
-
- /**
- * The scheduled delivery time for the message
- */
- public static final String SCHEDULED_DELIVERY_TIME = "SCHED";
-
- /**
- * @return The unique id of the message
- */
- long getMessageID();
-
- /**
- * Set the message id
- *
- * @param id
- */
- void setMessageID(long id);
-
- /**
- * Get the destination
- * @return
- */
- String getDestination();
-
- /**
- * Set the destination
- * @param destination
- */
- void setDestination(String destination);
-
- /**
- * @return true if the delivery must be guaranteed for this routable, false otherwise.
- */
- boolean isReliable();
-
- /**
- * Set whether message is reliable or not
- * @param reliable
- */
- void setReliable(boolean reliable);
-
- /**
- * @return the time when this routable expires and must be removed
- * from the system. A zero value means this routable never expires.
- */
- long getExpiration();
-
- /**
- *
- * @return true if the message has expired
- */
- boolean isExpired();
-
- /**
- * Set the expiration for this message
- *
- * @param expiration
- */
- void setExpiration(long expiration);
-
- /**
- * @return the time (in GMT milliseconds) when this routable was delivered to the provider.
- */
- long getTimestamp();
-
- /**
- * Set the timestamp for this message
- * @param timestamp The timestamp
- */
- void setTimestamp(long timestamp);
-
- /**
- *
- * @return The priority (0-9) of the message
- */
- byte getPriority();
-
- /**
- * Get the priority of the message. Priorities range from 0 to 9.
- * Where 0 is the lowest priority and 9 is the highest priority
- * @param priority
- */
- void setPriority(byte priority);
-
- /**
- * Binds a header. If the header map previously contained a mapping for this name, the old value
- * is replaced by the specified value.
- *
- * @return the value associated with the name or null if there is no mapping for the name. A null
- * can also indicate that the header map previously associated null with the specified
- * name.
- */
- Object putHeader(String name, Object value);
-
- /**
- * Returns the value corresponding to the header name. Returns null if the map contains no
- * mapping for the name. A return value of null does not necessarily indicate that the map
- * contains no mapping for the name; it's also possible that the map explicitly maps the name to
- * null. The containsHeader() operation may be used to distinguish these two cases.
- *
- * @return the value associated with the header, or null if there is no mapping for the header.
- */
- Object getHeader(String name);
-
- /**
- * Removes the header.
- *
- * @return previous value associated with the header, or null if there was no mapping.
- */
- Object removeHeader(String name);
-
- /**
- * Returns true if the Routable contains the specified header.
- */
- boolean containsHeader(String name);
-
- /**
- *
- * @return The message's headers
- */
- Map<String, Object> getHeaders();
-
- /**
- *
- * @return The message's payload
- */
- byte[] getPayload();
-
-
- /**
- * Set the payload
- *
- * @param payload
- */
- void setPayload(byte[] payload);
-
- /**
- *
- * @return The message's headers as byte array
- */
- byte[] getHeadersAsByteArray() throws Exception;
-
- /**
- *
- * @return the type of the message
- */
- int getType();
-
- /**
- * Get the connection id
- * @return
- */
- String getConnectionID();
-
- /**
- * Set the connection id
- * @param connectionID
- */
- void setConnectionID(String connectionID);
-
-
- /**
- * @return a reference for this message
- */
- MessageReference createReference(Queue queue);
-
- /**
- *
- * @return List of persisted references for this message
- */
- List<MessageReference> getReferences();
-
- /**
- * Make a copy of the message
- *
- * @return The copy
- */
- Message copy();
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/MessageReference.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/MessageReference.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/MessageReference.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-/**
- * A reference to a message.
- *
- * Channels store message references rather than the messages themselves.
- *
- * If many channels have contain the same reference this makes a lot of sense
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 3020 $</tt>
- *
- * $Id: MessageReference.java 3020 2007-08-21 15:46:38Z timfox $
- */
-public interface MessageReference
-{
- Message getMessage();
-
- MessageReference copy(Queue queue);
-
- /**
- *
- * @return The time in the future that delivery will be delayed until, or zero if
- * no scheduled delivery will occur
- */
- long getScheduledDeliveryTime();
-
- void setScheduledDeliveryTime(long scheduledDeliveryTime);
-
- /**
- * @return the number of times delivery has been attempted for this routable
- */
- int getDeliveryCount();
-
- void setDeliveryCount(int deliveryCount);
-
- Queue getQueue();
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/MessagingComponent.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/MessagingComponent.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/MessagingComponent.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-/**
- * A MessagingComponent
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2796 $</tt>
- *
- * $Id: MessagingComponent.java 2796 2007-06-25 22:24:41Z timfox $
- *
- */
-public interface MessagingComponent
-{
- void start() throws Exception;
-
- void stop() throws Exception;
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/PagingManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/PagingManager.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/PagingManager.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,15 +0,0 @@
-package org.jboss.messaging.newcore.intf;
-
-/**
- *
- * A PagingManager
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface PagingManager extends MessagingComponent
-{
- void pageReference(Queue queue, MessageReference ref);
-
- MessageReference depageReference(Queue queue);
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/PersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/PersistenceManager.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/PersistenceManager.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.transaction.xa.Xid;
-
-/**
- *
- * A PersistenceManager
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface PersistenceManager extends MessagingComponent
-{
- /**
- * A single message, possible with many message references needs to be added to storage
- * This would occur when a single reliable messages arrives on the server and needs to be routed
- * to 1 or more queues.
- * @param message
- */
- public void addMessage(Message message) throws Exception;
-
- /**
- * Delete a single reference. This would also delete the message if it is no longer referenced by any other
- * references.
- * This would occur on acknowledgement of a single reference
- * @param message
- */
- void deleteReference(MessageReference reference) throws Exception;
-
- /**
- * Commit a transaction containing messages to add and references to remove
- * @param messagesToAdd List of messages to add, or null if none
- * @param referencesToRemove List of references to remove, or null if none
- * @throws Exception
- */
- public void commitTransaction(List<Message> messagesToAdd, List<MessageReference> referencesToRemove) throws Exception;
-
- /**
- * Prepare a transaction containing messages to add and references to remove
- * @param xid The Xid of the XA transaction
- * @param messagesToAdd List of messages to add, or null if none
- * @param referencesToRemove List of references to remove, or null if none
- * @throws Exception
- */
- public void prepareTransaction(Xid xid, List<Message> messagesToAdd,
- List<MessageReference> referencesToRemove) throws Exception;
-
- /**
- * Commit a prepared transaction
- *
- * @param xid
- * @throws Exception
- */
- public void commitPreparedTransaction(Xid xid) throws Exception;
-
-
- /**
- * Unprepare a transaction containing messages to add and references to remove
- * @param xid The Xid of the XA transaction
- * @param messagesToAdd List of messages to add, or null if none
- * @param referencesToRemove List of references to remove, or null if none
- * @throws Exception
- */
- public void unprepareTransaction(Xid xid, List<Message> messagesToAdd,
- List<MessageReference> referencesToRemove) throws Exception;
-
-
- /**
- * Update the delivery count of a reference
- * @param queue
- * @param ref
- * @throws Exception
- */
- void updateDeliveryCount(Queue queue, MessageReference ref) throws Exception;
-
- /**
- * Load the specified queues from persistent storage
- * @param queues The map of queues to load
- * @throws Exception
- */
- void loadQueues(Map<Long, Queue> queues) throws Exception;
-
- /**
- * Get a list of in doubt (prepared) transaction ids
- * Can only be called in recovery mode
- * @return the list of ids
- */
- List<Xid> getInDoubtXids() throws Exception;
-
- /**
- *
- * @return true if the PersistenceManager is in recovery mode
- */
- boolean isInRecoveryMode() throws Exception;
-
- /**
- *
- * @param recoveryMode Set the PersistenceManager in recovery mode
- */
- void setInRecoveryMode(boolean recoveryMode);
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/Queue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/Queue.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/Queue.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-import java.util.List;
-
-
-/**
- *
- * A Queue
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface Queue
-{
- public static final int NUM_PRIORITIES = 10;
-
- HandleStatus addLast(MessageReference ref);
-
- HandleStatus addFirst(MessageReference ref);
-
- void deliver();
-
- void addConsumer(Consumer consumer);
-
- boolean removeConsumer(Consumer consumer);
-
- int getConsumerCount();
-
- List<MessageReference> list(Filter filter);
-
- void removeAllReferences();
-
- long getID();
-
- Filter getFilter();
-
- void setFilter(Filter filter);
-
- int getMessageCount();
-
- //int getDeliveringCount();
-
- int getScheduledCount();
-
- int getMaxSize();
-
- void setMaxSize(int maxSize);
-
- DistributionPolicy getDistributionPolicy();
-
- void setDistributionPolicy(DistributionPolicy policy);
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/QueueStatistics.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/QueueStatistics.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/QueueStatistics.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-/**
- *
- * A QueueStatistics
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface QueueStatistics
-{
- int getMessageCount();
-
- int getScheduledCount();
-
- int getGetDeliveringCount();
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/Transaction.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/Transaction.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/Transaction.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-/**
- *
- * A Transaction
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface Transaction
-{
- void addSynchronization(TransactionSynchronization sync);
-
- void prepare(PersistenceManager persistenceManager) throws Exception;
-
- void commit(PersistenceManager persistenceManager) throws Exception;
-
- void rollback(PersistenceManager persistenceManager) throws Exception;
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/TransactionStore.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/TransactionStore.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/TransactionStore.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-/**
- *
- * A TransactionStore
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface TransactionStore extends MessagingComponent
-{
- Transaction getTransaction(Object id);
-
- void putTransaction(Transaction tx);
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/TransactionSynchronization.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/TransactionSynchronization.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/TransactionSynchronization.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.newcore.intf;
-
-/**
- *
- * A TransactionSynchronization
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface TransactionSynchronization
-{
- void beforeCommit() throws Exception;
-
- void afterCommit() throws Exception;
-
- void beforeRollback() throws Exception;
-
- void afterRollback() throws Exception;
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/cluster/ClusterMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/cluster/ClusterMessage.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/cluster/ClusterMessage.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,13 +0,0 @@
-package org.jboss.messaging.newcore.intf.cluster;
-
-/**
- *
- * A ClusterRequest
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface ClusterMessage
-{
- void execute();
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupCoordinator.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupCoordinator.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupCoordinator.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,33 +0,0 @@
-package org.jboss.messaging.newcore.intf.cluster;
-
-import java.util.List;
-
-/**
- *
- * A GroupCoordinator
- *
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface GroupCoordinator
-{
- /**
- * Join the cluster with the specified id
- * @param id
- * @return The state
- * @throws Exception
- */
- Object join(int id, StateHandler handler) throws Exception;
-
- void leave(int id) throws Exception;
-
- void sendToAll(ClusterMessage request, boolean sychronous) throws Exception;
-
- List<Integer> getMembers();
-
- void registerHandler(GroupHandler handler);
-
- void unregisterHandler(GroupHandler handler);
-
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupHandler.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/cluster/GroupHandler.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,17 +0,0 @@
-package org.jboss.messaging.newcore.intf.cluster;
-
-import java.util.List;
-
-/**
- *
- * A GroupHandler
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface GroupHandler
-{
- void membersChanged(List<Integer> newMembers);
-
- void onMessage(int fromNodeId, ClusterMessage message);
-}
Deleted: trunk/src/main/org/jboss/messaging/newcore/intf/cluster/StateHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/newcore/intf/cluster/StateHandler.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/newcore/intf/cluster/StateHandler.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,13 +0,0 @@
-package org.jboss.messaging.newcore.intf.cluster;
-
-/**
- *
- * A StateHandler
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface StateHandler
-{
- Object getState();
-}
Modified: trunk/src/main/org/jboss/messaging/test/unit/UnitTestCase.java
===================================================================
--- trunk/src/main/org/jboss/messaging/test/unit/UnitTestCase.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/test/unit/UnitTestCase.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -37,10 +37,10 @@
import junit.framework.TestCase;
import org.jboss.jms.tx.MessagingXid;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.MessageReference;
+import org.jboss.messaging.newcore.Queue;
import org.jboss.messaging.newcore.impl.MessageImpl;
-import org.jboss.messaging.newcore.intf.Message;
-import org.jboss.messaging.newcore.intf.MessageReference;
-import org.jboss.messaging.newcore.intf.Queue;
/**
*
Modified: trunk/src/main/org/jboss/messaging/util/SafeUTF.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/SafeUTF.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/util/SafeUTF.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -56,24 +56,8 @@
private static final byte NULL = 0;
private static final byte NOT_NULL = 1;
-
- public static SafeUTF instance = new SafeUTF(CHUNK_SIZE);
-
- private int chunkSize;
-
- private int lastReadBufferSize;
-
- public int getLastReadBufferSize()
- {
- return lastReadBufferSize;
- }
-
- public SafeUTF(int chunkSize)
- {
- this.chunkSize = chunkSize;
- }
-
- public void safeWriteUTF(DataOutputStream out, String str) throws IOException
+
+ public static void safeWriteUTF(DataOutputStream out, String str) throws IOException
{
if (str == null)
{
@@ -91,7 +75,7 @@
}
else
{
- numChunks = (short)(((len - 1) / chunkSize) + 1);
+ numChunks = (short)(((len - 1) / CHUNK_SIZE) + 1);
}
out.writeByte(NOT_NULL);
@@ -101,22 +85,22 @@
int i = 0;
while (len > 0)
{
- int beginCopy = i * chunkSize;
+ int beginCopy = i * CHUNK_SIZE;
- int endCopy = len <= chunkSize ? beginCopy + len : beginCopy + chunkSize;
+ int endCopy = len <= CHUNK_SIZE ? beginCopy + len : beginCopy + CHUNK_SIZE;
String theChunk = str.substring(beginCopy, endCopy);
out.writeUTF(theChunk);
- len -= chunkSize;
+ len -= CHUNK_SIZE;
i++;
}
}
}
- public String safeReadUTF(DataInputStream in) throws IOException
+ public static String safeReadUTF(DataInputStream in) throws IOException
{
boolean isNull = in.readByte() == NULL;
@@ -127,7 +111,7 @@
short numChunks = in.readShort();
- int bufferSize = chunkSize * numChunks;
+ int bufferSize = CHUNK_SIZE * numChunks;
// special handling for single chunk
if (numChunks == 1)
@@ -146,8 +130,6 @@
}
bufferSize = Math.min(inSize, bufferSize);
-
- lastReadBufferSize = bufferSize;
}
StringBuffer buff = new StringBuffer(bufferSize);
Modified: trunk/src/main/org/jboss/messaging/util/StreamUtils.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/StreamUtils.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/util/StreamUtils.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -97,7 +97,7 @@
if (longStrings)
{
//We cope with >= 64K Strings
- value = SafeUTF.instance.safeReadUTF(in);
+ value = SafeUTF.safeReadUTF(in);
}
else
{
@@ -176,7 +176,7 @@
if (longStrings)
{
//We can cope with >=64K Strings
- SafeUTF.instance.safeWriteUTF(out, (String)object);
+ SafeUTF.safeWriteUTF(out, (String)object);
}
else
{
Deleted: trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedList.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedList.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedList.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.util.newprioritylinkedlist;
-
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * A type of linked list which maintains items according to a priority
- *
- * @author <a href="mailto:tim.fox at jboss.com>Tim Fox</a>
- * @version <tt>$Revision: 1174 $</tt>
- *
- * $Id: PrioritizedDeque.java 1174 2006-08-02 14:14:32Z timfox $
- */
-public interface PriorityLinkedList<T>
-{
- void addFirst(T t, int priority);
-
- void addLast(T t, int priority);
-
- T removeFirst();
-
- T removeLast();
-
- T peekFirst();
-
- List<T> getAll();
-
- void clear();
-
- int size();
-
- ListIterator<T> iterator();
-
- boolean isEmpty();
-
- void dump();
-}
Deleted: trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedListImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedListImpl.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/src/main/org/jboss/messaging/util/newprioritylinkedlist/PriorityLinkedListImpl.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,290 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.util.newprioritylinkedlist;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.jboss.logging.Logger;
-
-/**
- * A priority linked list implementation
- *
- * It implements this by maintaining an individual LinkedList for each priority level.
- *
- * @author <a href="mailto:tim.fox at jboss.com>Tim Fox</a>
- * @version <tt>$Revision: 1174 $</tt>
- *
- * $Id: BasicPrioritizedDeque.java 1174 2006-08-02 14:14:32Z timfox $
- */
-public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T>
-{
- private static final Logger log = Logger.getLogger(PriorityLinkedListImpl.class);
-
- private List<LinkedList<T>> linkedLists;
-
- private int priorities;
-
- private int size;
-
- public PriorityLinkedListImpl(int priorities)
- {
- this.priorities = priorities;
-
- initDeques();
- }
-
- public void addFirst(T t, int priority)
- {
- linkedLists.get(priority).addFirst(t);
-
- size++;
- }
-
- public void addLast(T t, int priority)
- {
- linkedLists.get(priority).addLast(t);
-
- size++;
- }
-
- public T removeFirst()
- {
- T t = null;
-
- //Initially we are just using a simple prioritization algorithm:
- //Highest priority refs always get returned first.
- //This could cause starvation of lower priority refs.
-
- //TODO - A better prioritization algorithm
-
- for (int i = priorities - 1; i >= 0; i--)
- {
- LinkedList<T> ll = linkedLists.get(i);
-
- if (!ll.isEmpty())
- {
- t = ll.removeFirst();
- break;
- }
- }
-
- if (t != null)
- {
- size--;
- }
-
- return t;
- }
-
- public T removeLast()
- {
- T t = null;
-
- for (int i = 0; i < priorities; i++)
- {
- LinkedList<T> ll = linkedLists.get(i);
- if (!ll.isEmpty())
- {
- t = ll.removeLast();
- }
- if (t != null)
- {
- break;
- }
- }
-
- if (t != null)
- {
- size--;
- }
-
- return t;
- }
-
- public T peekFirst()
- {
- T t = null;
-
- for (int i = priorities - 1; i >= 0; i--)
- {
- LinkedList<T> ll = linkedLists.get(i);
- if (!ll.isEmpty())
- {
- t = ll.getFirst();
- }
- if (t != null)
- {
- break;
- }
- }
-
- return t;
- }
-
- public List<T> getAll()
- {
- List<T> all = new ArrayList<T>();
-
- for (int i = priorities - 1; i >= 0; i--)
- {
- LinkedList<T> deque = linkedLists.get(i);
- all.addAll(deque);
- }
-
- return all;
- }
-
- public void clear()
- {
- initDeques();
- }
-
- public int size()
- {
- return size;
- }
-
- public boolean isEmpty()
- {
- return size == 0;
- }
-
- public ListIterator<T> iterator()
- {
- return new PriorityLinkedListIterator();
- }
-
- public void dump()
- {
- log.debug("Dumping " + this);
- log.debug("Size:" + size);
- log.debug("===============");
-
- for (int i = 0; i < linkedLists.size(); i++)
- {
- log.debug("Priority:" + i);
- log.debug("----------------");
-
- Iterator<T> iter = linkedLists.get(i).iterator();
-
- while (iter.hasNext())
- {
- log.debug("Ref: "+ iter.next());
- }
- }
- }
-
- private void initDeques()
- {
- linkedLists = new ArrayList<LinkedList<T>>();
-
- for (int i = 0; i < priorities; i++)
- {
- linkedLists.add(new LinkedList<T>());
- }
-
- size = 0;
- }
-
- private class PriorityLinkedListIterator implements ListIterator<T>
- {
- private int index;
-
- private ListIterator<T> currentIter;
-
- PriorityLinkedListIterator()
- {
- index = linkedLists.size() - 1;
-
- currentIter = linkedLists.get(index).listIterator();
- }
-
- public void add(Object arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext()
- {
- if (currentIter.hasNext())
- {
- return true;
- }
- while (index >= 0)
- {
- if (index == 0 || currentIter.hasNext())
- {
- break;
- }
- index--;
- currentIter = linkedLists.get(index).listIterator();
- }
- return currentIter.hasNext();
- }
-
- public boolean hasPrevious()
- {
- throw new UnsupportedOperationException();
- }
-
- public T next()
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- return currentIter.next();
- }
-
- public int nextIndex()
- {
- throw new UnsupportedOperationException();
- }
-
- public T previous()
- {
- throw new UnsupportedOperationException();
- }
-
- public int previousIndex()
- {
- throw new UnsupportedOperationException();
- }
-
- public void remove()
- {
- currentIter.remove();
-
- size--;
- }
-
- public void set(Object obj)
- {
- throw new UnsupportedOperationException();
- }
- }
-}
Modified: trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -87,11 +87,9 @@
import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.destination.JBossQueue;
import org.jboss.jms.destination.JBossTopic;
-import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.tx.ClientTransaction;
import org.jboss.jms.tx.MessagingXid;
import org.jboss.jms.tx.TransactionRequest;
-import org.jboss.messaging.core.contract.Message;
import org.jboss.messaging.core.remoting.codec.AbstractPacketCodec;
import org.jboss.messaging.core.remoting.codec.AcknowledgeDeliveriesRequestCodec;
import org.jboss.messaging.core.remoting.codec.AcknowledgeDeliveryRequestCodec;
@@ -185,6 +183,8 @@
import org.jboss.messaging.core.remoting.wireformat.TextPacket;
import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
import org.jboss.messaging.core.remoting.wireformat.UpdateCallbackMessage;
+import org.jboss.messaging.newcore.Message;
+import org.jboss.messaging.newcore.impl.MessageImpl;
import org.jboss.messaging.util.Version;
/**
@@ -667,8 +667,7 @@
public void testSendMessage() throws Exception
{
- SendMessage packet = new SendMessage(new JBossMessage(System
- .currentTimeMillis()), true, randomLong());
+ SendMessage packet = new SendMessage(new MessageImpl(), true, randomLong());
addVersion(packet);
AbstractPacketCodec codec = new SendMessageCodec();
SimpleRemotingBuffer buffer = encode(packet, codec);
@@ -858,7 +857,7 @@
public void testDeliverMessage() throws Exception
{
- Message msg = new JBossMessage(randomLong());
+ Message msg = new MessageImpl();
DeliverMessage message = new DeliverMessage(msg, randomString(),
randomLong(), 23);
addVersion(message);
@@ -1296,7 +1295,7 @@
public void testBrowserNextMessageResponse() throws Exception
{
- JBossMessage msg = new JBossMessage(randomLong());
+ Message msg = new MessageImpl();
BrowserNextMessageResponse response = new BrowserNextMessageResponse(msg);
addVersion(response);
AbstractPacketCodec codec = new BrowserNextMessageResponseCodec();
@@ -1333,8 +1332,8 @@
public void testBrowserNextMessageBlockResponse() throws Exception
{
- JBossMessage[] messages = new JBossMessage[] {
- new JBossMessage(randomLong()), new JBossMessage(randomLong()) };
+ Message[] messages = new Message[] {
+ new MessageImpl(), new MessageImpl() };
BrowserNextMessageBlockResponse response = new BrowserNextMessageBlockResponse(
messages);
Modified: trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -236,7 +236,7 @@
int count = 0;
while (true)
{
- Message m = consumer.receive(200);
+ Message m = consumer.receive(1000);
if (m == null) break;
count++;
}
@@ -1226,7 +1226,7 @@
TextMessage tm = (TextMessage)m;
- log.trace("Got message: " + tm.getText());
+ //log.info("Got message: " + tm.getText());
// Receive first three messages then recover() session
// Only last message should be redelivered
@@ -1276,6 +1276,7 @@
}
catch (Exception e)
{
+ e.printStackTrace();
failed = true;
latch.release();
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/BrowserTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/BrowserTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/BrowserTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -137,10 +137,8 @@
producer.send(m);
}
- log.trace("Sent messages");
-
QueueBrowser browser = session.createBrowser(queue1);
-
+
assertEquals(browser.getQueue(), queue1);
assertNull(browser.getMessageSelector());
@@ -153,7 +151,7 @@
en.nextElement();
count++;
}
-
+
assertEquals(numMessages, count);
MessageConsumer mc = session.createConsumer(queue1);
Modified: trunk/tests/src/org/jboss/test/messaging/jms/MessageProxyTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/MessageProxyTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/MessageProxyTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -31,7 +31,6 @@
import org.jboss.jms.destination.JBossQueue;
import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.MessageProxy;
import org.jboss.test.messaging.tools.ServerManagement;
/**
@@ -46,423 +45,429 @@
*/
public class MessageProxyTest extends JMSTestCase
{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
+//{
+// // Constants -----------------------------------------------------
+//
+// // Static --------------------------------------------------------
+//
+// // Attributes ----------------------------------------------------
+//
+// // Constructors --------------------------------------------------
+//
public MessageProxyTest(String name)
{
super(name);
}
- // TestCase overrides -------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testMessageIDs1() throws Exception
+ public void test1()
{
- if (ServerManagement.isRemote())
- {
- return;
- }
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- conn.start();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(queue1);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- Message msent = sess.createMessage();
-
- prod.send(msent);
-
- Message mrec = cons.receive();
-
- //The two ids should be the same
-
- long id1 = ((MessageProxy)msent).getMessage().getMessageID();
- long id2 = ((MessageProxy)mrec).getMessage().getMessageID();
-
- assertEquals(id1, id2);
-
- //Now send the message again
- prod.send(msent);
-
- //The sent id should be different
- long id3 = ((MessageProxy)msent).getMessage().getMessageID();
- long id4 = ((MessageProxy)mrec).getMessage().getMessageID();
-
- assertFalse(id1 == id3);
-
- //But this shouldn't affect the received id
- assertEquals(id2, id4);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
-
- removeAllMessages(queue1.getQueueName(), true, 0);
- }
}
-
- public void testMessageIDs2() throws Exception
- {
- if (ServerManagement.isRemote())
- {
- return;
- }
-
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- conn.start();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(queue1);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- Message msent = sess.createMessage();
-
- prod.send(msent);
-
- Message mrec = cons.receive();
-
- //The two ids should be the same
-
- long id1 = ((MessageProxy)msent).getMessage().getMessageID();
- long id2 = ((MessageProxy)mrec).getMessage().getMessageID();
-
- assertEquals(id1, id2);
-
- //Now send the received again
- prod.send(mrec);
-
- //The sent id should be different
- long id3 = ((MessageProxy)msent).getMessage().getMessageID();
-
- //But this shouldn't affect the sent id
- assertEquals(id1, id3);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
-
- removeAllMessages(queue1.getQueueName(), true, 0);
- }
- }
-
-
- public void testNewMessage() throws Exception
- {
- if (ServerManagement.isRemote())
- {
- return;
- }
-
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(queue1);
-
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- MapMessage m = sess.createMapMessage();
-
- JBossMessage check1 = ((MessageProxy)m).getMessage();
-
- m.setString("map_entry", "map_value");
- m.setStringProperty("property_entry", "property_value");
-
- m.setJMSReplyTo(new JBossQueue("wibble"));
-
- JBossMessage check2 = ((MessageProxy)m).getMessage();
-
- checkSameUnderlyingMessage(check1, check2, true);
- checkSameBody(check1, check2, true);
-
- prod.send(m);
-
- JBossMessage check3 = ((MessageProxy)m).getMessage();
-
- //Underlying message should be the same before and after
- checkSameUnderlyingMessage(check2, check3, true);
- checkSameBody(check2, check3, true);
-
- prod.send(m);
-
- JBossMessage check4 = ((MessageProxy)m).getMessage();
-
- assertFalse(check3.getMessageID() == check4.getMessageID());
-
- //The underlying message should now be different
- checkSameUnderlyingMessage(check3, check4, false);
-
- //But the body should be the same
- checkSameBody(check3, check4, true);
-
- prod.send(m);
-
- JBossMessage check5 = ((MessageProxy)m).getMessage();
-
- // The message should be different
- assertFalse(check4.getMessageID() == check5.getMessageID());
-
- checkSameUnderlyingMessage(check4, check5, false);
-
- //But the body should be the same
- checkSameBody(check4, check5, true);
-
- //Now set another header
-
- m.setJMSType("type123");
-
- JBossMessage check6 = ((MessageProxy)m).getMessage();
-
-
- //The message should be different
- checkSameUnderlyingMessage(check5, check6, false);
-
- //But the body should be the same
- checkSameBody(check5, check6, true);
-
- prod.send(m);
-
- JBossMessage check7 = ((MessageProxy)m).getMessage();
-
- //The message should be the same
-
- checkSameUnderlyingMessage(check6, check7, true);
-
- // But the body should be the same
- checkSameBody(check6, check7, true);
-
- // Set the body
- m.setString("key1", "blah");
-
- JBossMessage check8 = ((MessageProxy)m).getMessage();
-
- //The message should be the same
-
- checkSameUnderlyingMessage(check7, check8, true);
-
- // But the body should not be the same
- checkSameBody(check7, check8, false);
-
- //And the body not the same
-
- checkSameUnderlyingMessage(check7, check8, false);
-
- prod.send(m);
-
- JBossMessage check9 = ((MessageProxy)m).getMessage();
-
- //The message should be the same
-
- checkSameUnderlyingMessage(check8, check9, true);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
-
- removeAllMessages(queue1.getQueueName(), true, 0);
- }
- }
-
- public void testReceivedMessage(boolean persistent) throws Exception
- {
- if (ServerManagement.isRemote())
- {
- return;
- }
-
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- conn.start();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(queue1);
-
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- MapMessage m = sess.createMapMessage();
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- prod.send(m);
-
- m = (MapMessage)cons.receive(2000);
-
- assertNotNull(m);
-
- JBossMessage check1 = ((MessageProxy)m).getMessage();
-
- prod.send(m);
-
- JBossMessage check3 = ((MessageProxy)m).getMessage();
-
- checkSameUnderlyingMessage(check1, check3, true);
-
- checkSameBody(check1, check3, true);
-
- prod.send(m);
-
- JBossMessage check4 = ((MessageProxy)m).getMessage();
-
- assertFalse(check3.getMessageID() == check4.getMessageID());
-
- //The underlying message should now be different
- checkSameUnderlyingMessage(check3, check4, false);
-
- //But the body should be the same
- checkSameBody(check3, check4, true);
-
- prod.send(m);
-
- JBossMessage check5 = ((MessageProxy)m).getMessage();
-
- // The message should be different
- assertFalse(check4.getMessageID() == check5.getMessageID());
-
- checkSameUnderlyingMessage(check4, check5, false);
-
- //But the body should be the same
- checkSameBody(check4, check5, true);
-
- //Now set another header
-
- m.setJMSType("type123");
-
- JBossMessage check6 = ((MessageProxy)m).getMessage();
-
-
- //The message should be different
- checkSameUnderlyingMessage(check5, check6, false);
-
- //But the body should be the same
- checkSameBody(check5, check6, true);
-
- prod.send(m);
-
- JBossMessage check7 = ((MessageProxy)m).getMessage();
-
- //The message should be the same
-
- checkSameUnderlyingMessage(check6, check7, true);
-
- // But the body should be the same
- checkSameBody(check6, check7, true);
-
- // Set the body
- m.setString("key1", "blah");
-
- JBossMessage check8 = ((MessageProxy)m).getMessage();
-
- //The message should be the same
-
- checkSameUnderlyingMessage(check7, check8, true);
-
- // But the body should not be the same
- checkSameBody(check7, check8, false);
-
- //And the body not the same
-
- checkSameUnderlyingMessage(check7, check8, false);
-
- prod.send(m);
-
- JBossMessage check9 = ((MessageProxy)m).getMessage();
-
- //The message should be the same
-
- checkSameUnderlyingMessage(check8, check9, true);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
-
- removeAllMessages(queue1.getQueueName(), true, 0);
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- private void checkSameUnderlyingMessage(JBossMessage m1, JBossMessage m2, boolean same)
- {
- if ((m1 == m2) && (m1.getHeaders() == m2.getHeaders()) && !same)
- {
- fail("Underlying message not same");
- }
- }
-
- private void checkSameBody(JBossMessage m1, JBossMessage m2, boolean same)
- {
- // JIRA http://jira.jboss.org/jira/browse/JBMESSAGING-1195
- // comparison is done based on equality instead of identity until in-vm
- // optimization task is done.
-
- // if (same && (m1.getPayload() != m2.getPayload()))
- // {
- // fail("Body not same");
- // }
- // else if (!same && (m1.getPayload() == m2.getPayload()))
- // {
- // fail("Body same");
- // }
- if (same && (!m1.getPayload().equals(m2.getPayload())))
- {
- fail("Body not same");
- }
- else if (!same && (m1.getPayload().equals(m2.getPayload())))
- {
- fail("Body same");
- }
- }
-
-
-
+//
+// // TestCase overrides -------------------------------------------
+//
+// // Public --------------------------------------------------------
+//
+// public void testMessageIDs1() throws Exception
+// {
+// if (ServerManagement.isRemote())
+// {
+// return;
+// }
+//
+// Connection conn = null;
+//
+// try
+// {
+// conn = cf.createConnection();
+//
+// conn.start();
+//
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//
+// MessageProducer prod = sess.createProducer(queue1);
+//
+// MessageConsumer cons = sess.createConsumer(queue1);
+//
+// Message msent = sess.createMessage();
+//
+// prod.send(msent);
+//
+// Message mrec = cons.receive();
+//
+// //The two ids should be the same
+//
+// long id1 = ((JBossMessage)msent).getCoreMessage().getMessageID();
+// long id2 = ((JBossMessage)mrec).getCoreMessage().getMessageID();
+//
+// assertEquals(id1, id2);
+//
+// //Now send the message again
+// prod.send(msent);
+//
+// //The sent id should be different
+// long id3 = ((JBossMessage)msent).getCoreMessage().getMessageID();
+// long id4 = ((JBossMessage)mrec).getCoreMessage().getMessageID();
+//
+// assertFalse(id1 == id3);
+//
+// //But this shouldn't affect the received id
+// assertEquals(id2, id4);
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+//
+// removeAllMessages(queue1.getQueueName(), true, 0);
+// }
+// }
+//
+// public void testMessageIDs2() throws Exception
+// {
+// if (ServerManagement.isRemote())
+// {
+// return;
+// }
+//
+// Connection conn = null;
+//
+// try
+// {
+// conn = cf.createConnection();
+//
+// conn.start();
+//
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//
+// MessageProducer prod = sess.createProducer(queue1);
+//
+// MessageConsumer cons = sess.createConsumer(queue1);
+//
+// Message msent = sess.createMessage();
+//
+// prod.send(msent);
+//
+// Message mrec = cons.receive();
+//
+// //The two ids should be the same
+//
+// long id1 = ((JBossMessage)msent).getCoreMessage().getMessageID();
+// long id2 = ((JBossMessage)mrec).getCoreMessage().getMessageID();
+//
+// assertEquals(id1, id2);
+//
+// //Now send the received again
+// prod.send(mrec);
+//
+// //The sent id should be different
+// long id3 = ((JBossMessage)msent).getCoreMessage().getMessageID();
+//
+// //But this shouldn't affect the sent id
+// assertEquals(id1, id3);
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+//
+// removeAllMessages(queue1.getQueueName(), true, 0);
+// }
+// }
+//
+//
+// public void testNewMessage() throws Exception
+// {
+// if (ServerManagement.isRemote())
+// {
+// return;
+// }
+//
+// Connection conn = null;
+//
+// try
+// {
+// conn = cf.createConnection();
+//
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//
+// MessageProducer prod = sess.createProducer(queue1);
+//
+// prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+//
+// MapMessage m = sess.createMapMessage();
+//
+// JBossMessage check1 = ((JBossMessage)m).getCoreMessage();
+//
+// m.setString("map_entry", "map_value");
+// m.setStringProperty("property_entry", "property_value");
+//
+// m.setJMSReplyTo(new JBossQueue("wibble"));
+//
+// JBossMessage check2 = ((MessageProxy)m).getMessage();
+//
+// checkSameUnderlyingMessage(check1, check2, true);
+// checkSameBody(check1, check2, true);
+//
+// prod.send(m);
+//
+// JBossMessage check3 = ((MessageProxy)m).getMessage();
+//
+// //Underlying message should be the same before and after
+// checkSameUnderlyingMessage(check2, check3, true);
+// checkSameBody(check2, check3, true);
+//
+// prod.send(m);
+//
+// JBossMessage check4 = ((MessageProxy)m).getMessage();
+//
+// assertFalse(check3.getMessageID() == check4.getMessageID());
+//
+// //The underlying message should now be different
+// checkSameUnderlyingMessage(check3, check4, false);
+//
+// //But the body should be the same
+// checkSameBody(check3, check4, true);
+//
+// prod.send(m);
+//
+// JBossMessage check5 = ((MessageProxy)m).getMessage();
+//
+// // The message should be different
+// assertFalse(check4.getMessageID() == check5.getMessageID());
+//
+// checkSameUnderlyingMessage(check4, check5, false);
+//
+// //But the body should be the same
+// checkSameBody(check4, check5, true);
+//
+// //Now set another header
+//
+// m.setJMSType("type123");
+//
+// JBossMessage check6 = ((MessageProxy)m).getMessage();
+//
+//
+// //The message should be different
+// checkSameUnderlyingMessage(check5, check6, false);
+//
+// //But the body should be the same
+// checkSameBody(check5, check6, true);
+//
+// prod.send(m);
+//
+// JBossMessage check7 = ((MessageProxy)m).getMessage();
+//
+// //The message should be the same
+//
+// checkSameUnderlyingMessage(check6, check7, true);
+//
+// // But the body should be the same
+// checkSameBody(check6, check7, true);
+//
+// // Set the body
+// m.setString("key1", "blah");
+//
+// JBossMessage check8 = ((MessageProxy)m).getMessage();
+//
+// //The message should be the same
+//
+// checkSameUnderlyingMessage(check7, check8, true);
+//
+// // But the body should not be the same
+// checkSameBody(check7, check8, false);
+//
+// //And the body not the same
+//
+// checkSameUnderlyingMessage(check7, check8, false);
+//
+// prod.send(m);
+//
+// JBossMessage check9 = ((MessageProxy)m).getMessage();
+//
+// //The message should be the same
+//
+// checkSameUnderlyingMessage(check8, check9, true);
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+//
+// removeAllMessages(queue1.getQueueName(), true, 0);
+// }
+// }
+//
+// public void testReceivedMessage(boolean persistent) throws Exception
+// {
+// if (ServerManagement.isRemote())
+// {
+// return;
+// }
+//
+// Connection conn = null;
+//
+// try
+// {
+// conn = cf.createConnection();
+//
+// conn.start();
+//
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//
+// MessageProducer prod = sess.createProducer(queue1);
+//
+// prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+//
+// MapMessage m = sess.createMapMessage();
+//
+// MessageConsumer cons = sess.createConsumer(queue1);
+//
+// prod.send(m);
+//
+// m = (MapMessage)cons.receive(2000);
+//
+// assertNotNull(m);
+//
+// JBossMessage check1 = ((MessageProxy)m).getMessage();
+//
+// prod.send(m);
+//
+// JBossMessage check3 = ((MessageProxy)m).getMessage();
+//
+// checkSameUnderlyingMessage(check1, check3, true);
+//
+// checkSameBody(check1, check3, true);
+//
+// prod.send(m);
+//
+// JBossMessage check4 = ((MessageProxy)m).getMessage();
+//
+// assertFalse(check3.getMessageID() == check4.getMessageID());
+//
+// //The underlying message should now be different
+// checkSameUnderlyingMessage(check3, check4, false);
+//
+// //But the body should be the same
+// checkSameBody(check3, check4, true);
+//
+// prod.send(m);
+//
+// JBossMessage check5 = ((MessageProxy)m).getMessage();
+//
+// // The message should be different
+// assertFalse(check4.getMessageID() == check5.getMessageID());
+//
+// checkSameUnderlyingMessage(check4, check5, false);
+//
+// //But the body should be the same
+// checkSameBody(check4, check5, true);
+//
+// //Now set another header
+//
+// m.setJMSType("type123");
+//
+// JBossMessage check6 = ((MessageProxy)m).getMessage();
+//
+//
+// //The message should be different
+// checkSameUnderlyingMessage(check5, check6, false);
+//
+// //But the body should be the same
+// checkSameBody(check5, check6, true);
+//
+// prod.send(m);
+//
+// JBossMessage check7 = ((MessageProxy)m).getMessage();
+//
+// //The message should be the same
+//
+// checkSameUnderlyingMessage(check6, check7, true);
+//
+// // But the body should be the same
+// checkSameBody(check6, check7, true);
+//
+// // Set the body
+// m.setString("key1", "blah");
+//
+// JBossMessage check8 = ((MessageProxy)m).getMessage();
+//
+// //The message should be the same
+//
+// checkSameUnderlyingMessage(check7, check8, true);
+//
+// // But the body should not be the same
+// checkSameBody(check7, check8, false);
+//
+// //And the body not the same
+//
+// checkSameUnderlyingMessage(check7, check8, false);
+//
+// prod.send(m);
+//
+// JBossMessage check9 = ((MessageProxy)m).getMessage();
+//
+// //The message should be the same
+//
+// checkSameUnderlyingMessage(check8, check9, true);
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+//
+// removeAllMessages(queue1.getQueueName(), true, 0);
+// }
+// }
+//
+// // Package protected ---------------------------------------------
+//
+// // Protected -----------------------------------------------------
+//
+// // Private -------------------------------------------------------
+//
+// private void checkSameUnderlyingMessage(JBossMessage m1, JBossMessage m2, boolean same)
+// {
+// if ((m1 == m2) && (m1.getHeaders() == m2.getHeaders()) && !same)
+// {
+// fail("Underlying message not same");
+// }
+// }
+//
+// private void checkSameBody(JBossMessage m1, JBossMessage m2, boolean same)
+// {
+// // JIRA http://jira.jboss.org/jira/browse/JBMESSAGING-1195
+// // comparison is done based on equality instead of identity until in-vm
+// // optimization task is done.
+//
+// // if (same && (m1.getPayload() != m2.getPayload()))
+// // {
+// // fail("Body not same");
+// // }
+// // else if (!same && (m1.getPayload() == m2.getPayload()))
+// // {
+// // fail("Body same");
+// // }
+// if (same && (!m1.getPayload().equals(m2.getPayload())))
+// {
+// fail("Body not same");
+// }
+// else if (!same && (m1.getPayload().equals(m2.getPayload())))
+// {
+// fail("Body same");
+// }
+// }
+//
+//
+//
// Inner classes -------------------------------------------------
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/ScheduledDeliveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ScheduledDeliveryTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ScheduledDeliveryTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -52,516 +52,521 @@
// Public --------------------------------------------------------
- public void testScheduledDeliveryTX() throws Exception
- {
- scheduledDelivery(true);
+ public void test1()
+ {
}
- public void testScheduledDeliveryNoTX() throws Exception
- {
- scheduledDelivery(false);
- }
-
- public void testScheduledDeliveryWithRestart() throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue1 = (Queue) getInitialContext().lookup("/queue/testQueue");
- MessageProducer prod = sess.createProducer(queue1);
-
- //Send one scheduled
-
- long now = System.currentTimeMillis();
-
- TextMessage tm1 = sess.createTextMessage("testScheduled1");
- tm1.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 7000);
- prod.send(tm1);
-
- //First send some non scheduled messages
-
- TextMessage tm2 = sess.createTextMessage("testScheduled2");
- prod.send(tm2);
+// Uncomment when http://jira.jboss.org/jira/browse/JBMESSAGING-1206 is complete
+// public void testScheduledDeliveryTX() throws Exception
+// {
+// scheduledDelivery(true);
+// }
+//
+// public void testScheduledDeliveryNoTX() throws Exception
+// {
+// scheduledDelivery(false);
+// }
+//
+// public void testScheduledDeliveryWithRestart() throws Exception
+// {
+// Connection conn = null;
+//
+// try
+// {
+// conn = cf.createConnection();
+//
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+// Queue queue1 = (Queue) getInitialContext().lookup("/queue/testQueue");
+// MessageProducer prod = sess.createProducer(queue1);
+//
+// //Send one scheduled
+//
+// long now = System.currentTimeMillis();
+//
+// TextMessage tm1 = sess.createTextMessage("testScheduled1");
+// tm1.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 7000);
+// prod.send(tm1);
+//
+// //First send some non scheduled messages
+//
+// TextMessage tm2 = sess.createTextMessage("testScheduled2");
+// prod.send(tm2);
+//
+// TextMessage tm3 = sess.createTextMessage("testScheduled3");
+// prod.send(tm3);
+//
+// TextMessage tm4 = sess.createTextMessage("testScheduled4");
+// prod.send(tm4);
+//
+//
+// //Now send some more scheduled messages
+//
+// TextMessage tm5 = sess.createTextMessage("testScheduled5");
+// tm5.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 5000);
+// prod.send(tm5);
+//
+// TextMessage tm6 = sess.createTextMessage("testScheduled6");
+// tm6.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 4000);
+// prod.send(tm6);
+//
+// TextMessage tm7 = sess.createTextMessage("testScheduled7");
+// tm7.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 3000);
+// prod.send(tm7);
+//
+// TextMessage tm8 = sess.createTextMessage("testScheduled8");
+// tm8.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 6000);
+// prod.send(tm8);
+//
+// //And one scheduled with a -ve number
+//
+// TextMessage tm9 = sess.createTextMessage("testScheduled9");
+// tm8.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, -3);
+// prod.send(tm9);
+//
+// //Now stop the server and restart it
+//
+// conn.close();
+//
+// stop();
+//
+// start();
+//
+// // Messaging server restart implies new ConnectionFactory lookup
+// deployAndLookupAdministeredObjects();
+//
+// conn = cf.createConnection();
+//
+// conn.start();
+//
+// sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//
+// MessageConsumer cons = sess.createConsumer(queue1);
+//
+// forceGC();
+//
+// //First the non scheduled messages should be received
+//
+// TextMessage rm1 = (TextMessage)cons.receive(250);
+// assertNotNull(rm1);
+// assertEquals(tm2.getText(), rm1.getText());
+//
+// TextMessage rm2 = (TextMessage)cons.receive(250);
+// assertNotNull(rm2);
+// assertEquals(tm3.getText(), rm2.getText());
+//
+// TextMessage rm3 = (TextMessage)cons.receive(250);
+// assertNotNull(rm3);
+// assertEquals(tm4.getText(), rm3.getText());
+//
+// //Now the one with a scheduled with a -ve number
+// TextMessage rm5 = (TextMessage)cons.receive(250);
+// assertNotNull(rm5);
+// assertEquals(tm9.getText(), rm5.getText());
+//
+// //Now the scheduled
+// TextMessage rm6 = (TextMessage)cons.receive(3250);
+// assertNotNull(rm6);
+// assertEquals(tm7.getText(), rm6.getText());
+//
+// long now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 3000);
+//
+//
+// TextMessage rm7 = (TextMessage)cons.receive(1250);
+// assertNotNull(rm7);
+// assertEquals(tm6.getText(), rm7.getText());
+//
+// now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 4000);
+//
+//
+// TextMessage rm8 = (TextMessage)cons.receive(1250);
+// assertNotNull(rm8);
+// assertEquals(tm5.getText(), rm8.getText());
+//
+// now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 5000);
+//
+//
+// TextMessage rm9 = (TextMessage)cons.receive(1250);
+// assertNotNull(rm9);
+// assertEquals(tm8.getText(), rm9.getText());
+//
+// now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 6000);
+//
+//
+// TextMessage rm10 = (TextMessage)cons.receive(1250);
+// assertNotNull(rm10);
+// assertEquals(tm1.getText(), rm10.getText());
+//
+// now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 7000);
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+// }
+// }
+//
+// public void testDelayedRedeliveryDefault() throws Exception
+// {
+//
+// try
+// {
+//
+// setRedeliveryDelayOnDestination("Queue1", true, -1);
+//
+// long delay = 3000;
+//
+// setDefaultRedeliveryDelay(delay);
+// this.delayedRedeliveryDefaultOnClose(delay);
+//
+// this.delayedRedeliveryDefaultOnRollback(delay);
+// }
+// finally
+// {
+// setDefaultRedeliveryDelay(0);
+//
+// removeAllMessages(queue1.getQueueName(), true, 0);
+// }
+// }
+//
+// public void testDelayedRedeliveryOverride() throws Exception
+// {
+//
+// try
+// {
+// long delay = 6000;
+//
+// setRedeliveryDelayOnDestination("Queue1", true, delay);
+//
+// setDefaultRedeliveryDelay(3000);
+//
+// this.delayedRedeliveryDefaultOnClose(delay);
+//
+// this.delayedRedeliveryDefaultOnRollback(delay);
+// }
+// finally
+// {
+// setDefaultRedeliveryDelay(0);
+//
+// setRedeliveryDelayOnDestination("Queue1", true, -1);
+//
+// removeAllMessages(queue1.getQueueName(), true, 0);
+// }
+// }
+//
+//
+// // Package protected ---------------------------------------------
+//
+// // Protected -----------------------------------------------------
+//
+// protected void tearDown() throws Exception
+// {
+// super.tearDown();
+//
+// // Some tests here are changing this attribute.. what would affect tests later
+// // Instead of restart the ServerPeer I'm just restoring the default
+// setDefaultRedeliveryDelay(0);
+// }
+//
+// // Private -------------------------------------------------------
+//
+// private void delayedRedeliveryDefaultOnClose(long delay) throws Exception
+// {
+// Connection conn = null;
+//
+// try
+// {
+// conn = cf.createConnection();
+//
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//
+// MessageProducer prod = sess.createProducer(queue1);
+//
+// final int NUM_MESSAGES = 5;
+//
+// forceGC();
+//
+// for (int i = 0; i < NUM_MESSAGES; i++)
+// {
+// TextMessage tm = sess.createTextMessage("message" + i);
+//
+// prod.send(tm);
+// }
+//
+// Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+//
+// MessageConsumer cons = sess2.createConsumer(queue1);
+//
+// conn.start();
+//
+// for (int i = 0; i < NUM_MESSAGES; i++)
+// {
+// TextMessage tm = (TextMessage)cons.receive(500);
+//
+// assertNotNull(tm);
+//
+// assertEquals("message" + i, tm.getText());
+// }
+//
+// //Now close the session
+// //This should cancel back to the queue with a delayed redelivery
+//
+// long now = System.currentTimeMillis();
+//
+// sess2.close();
+//
+// Session sess3 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//
+// MessageConsumer cons2 = sess3.createConsumer(queue1);
+//
+// for (int i = 0; i < NUM_MESSAGES; i++)
+// {
+// TextMessage tm = (TextMessage)cons2.receive(delay + 1000);
+//
+// assertNotNull(tm);
+//
+// long time = System.currentTimeMillis();
+//
+// assertTrue(time - now >= delay);
+//
+// //Hudson can introduce a large degree of indeterminism
+// assertTrue((time - now) + ">" + (delay + 1000), time - now < delay + 1000);
+// }
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+// }
+// }
+//
+// private void delayedRedeliveryDefaultOnRollback(long delay) throws Exception
+// {
+// Connection conn = null;
+//
+// try
+// {
+// conn = cf.createConnection();
+//
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//
+// MessageProducer prod = sess.createProducer(queue1);
+//
+// final int NUM_MESSAGES = 5;
+//
+// for (int i = 0; i < NUM_MESSAGES; i++)
+// {
+// TextMessage tm = sess.createTextMessage("message" + i);
+//
+// prod.send(tm);
+// }
+//
+// Session sess2 = conn.createSession(true, Session.SESSION_TRANSACTED);
+//
+// MessageConsumer cons = sess2.createConsumer(queue1);
+//
+// conn.start();
+//
+// for (int i = 0; i < NUM_MESSAGES; i++)
+// {
+// TextMessage tm = (TextMessage)cons.receive(500);
+//
+// assertNotNull(tm);
+//
+// assertEquals("message" + i, tm.getText());
+// }
+//
+// //Now rollback
+//
+// long now = System.currentTimeMillis();
+//
+// sess2.rollback();
+//
+// //This should redeliver with a delayed redelivery
+//
+// for (int i = 0; i < NUM_MESSAGES; i++)
+// {
+// TextMessage tm = (TextMessage)cons.receive(delay + 1000);
+//
+// assertNotNull(tm);
+//
+// long time = System.currentTimeMillis();
+//
+// assertTrue(time - now >= delay);
+//
+// //Hudson can introduce a large degree of indeterminism
+// assertTrue((time - now) + ">" + (delay + 1000), time - now < delay + 1000);
+// }
+//
+// sess2.commit();
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+// }
+// }
+//
+// private void scheduledDelivery(boolean tx) throws Exception
+// {
+// Connection conn = null;
+//
+// try
+// {
+// conn = cf.createConnection();
+//
+// Session sess = conn.createSession(tx, tx ? Session.SESSION_TRANSACTED : Session.AUTO_ACKNOWLEDGE);
+//
+// MessageProducer prod = sess.createProducer(queue1);
+//
+// MessageConsumer cons = sess.createConsumer(queue1);
+//
+// conn.start();
+//
+// //Send one scheduled
+//
+// long now = System.currentTimeMillis();
+//
+// TextMessage tm1 = sess.createTextMessage("testScheduled1");
+// tm1.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 7000);
+// prod.send(tm1);
+//
+// //First send some non scheduled messages
+//
+// TextMessage tm2 = sess.createTextMessage("testScheduled2");
+// prod.send(tm2);
+//
+// TextMessage tm3 = sess.createTextMessage("testScheduled3");
+// prod.send(tm3);
+//
+// TextMessage tm4 = sess.createTextMessage("testScheduled4");
+// prod.send(tm4);
+//
+//
+// //Now send some more scheduled messages
+//
+// TextMessage tm5 = sess.createTextMessage("testScheduled5");
+// tm5.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 5000);
+// prod.send(tm5);
+//
+// TextMessage tm6 = sess.createTextMessage("testScheduled6");
+// tm6.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 4000);
+// prod.send(tm6);
+//
+// TextMessage tm7 = sess.createTextMessage("testScheduled7");
+// tm7.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 3000);
+// prod.send(tm7);
+//
+// TextMessage tm8 = sess.createTextMessage("testScheduled8");
+// tm8.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 6000);
+// prod.send(tm8);
+//
+// //And one scheduled with a -ve number
+//
+// TextMessage tm9 = sess.createTextMessage("testScheduled9");
+// tm8.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, -3);
+// prod.send(tm9);
+//
+// if (tx)
+// {
+// sess.commit();
+// }
+//
+// //First the non scheduled messages should be received
+// forceGC();
+//
+//
+// TextMessage rm1 = (TextMessage)cons.receive(250);
+// assertNotNull(rm1);
+// assertEquals(tm2.getText(), rm1.getText());
+//
+// TextMessage rm2 = (TextMessage)cons.receive(250);
+// assertNotNull(rm2);
+// assertEquals(tm3.getText(), rm2.getText());
+//
+// TextMessage rm3 = (TextMessage)cons.receive(250);
+// assertNotNull(rm3);
+// assertEquals(tm4.getText(), rm3.getText());
+//
+// //Now the one with a scheduled with a -ve number
+// TextMessage rm5 = (TextMessage)cons.receive(250);
+// assertNotNull(rm5);
+// assertEquals(tm9.getText(), rm5.getText());
+//
+// //Now the scheduled
+// TextMessage rm6 = (TextMessage)cons.receive(3250);
+// assertNotNull(rm6);
+// assertEquals(tm7.getText(), rm6.getText());
+//
+// long now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 3000);
+//
+//
+// TextMessage rm7 = (TextMessage)cons.receive(1250);
+// assertNotNull(rm7);
+// assertEquals(tm6.getText(), rm7.getText());
+//
+// now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 4000);
+//
+//
+// TextMessage rm8 = (TextMessage)cons.receive(1250);
+// assertNotNull(rm8);
+// assertEquals(tm5.getText(), rm8.getText());
+//
+// now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 5000);
+//
+//
+// TextMessage rm9 = (TextMessage)cons.receive(1250);
+// assertNotNull(rm9);
+// assertEquals(tm8.getText(), rm9.getText());
+//
+// now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 6000);
+//
+//
+// TextMessage rm10 = (TextMessage)cons.receive(1250);
+// assertNotNull(rm10);
+// assertEquals(tm1.getText(), rm10.getText());
+//
+// now2 = System.currentTimeMillis();
+//
+// assertTrue(now2 - now >= 7000);
+//
+// if (tx)
+// {
+// sess.commit();
+// }
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+// }
+// }
- TextMessage tm3 = sess.createTextMessage("testScheduled3");
- prod.send(tm3);
-
- TextMessage tm4 = sess.createTextMessage("testScheduled4");
- prod.send(tm4);
-
-
- //Now send some more scheduled messages
-
- TextMessage tm5 = sess.createTextMessage("testScheduled5");
- tm5.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 5000);
- prod.send(tm5);
-
- TextMessage tm6 = sess.createTextMessage("testScheduled6");
- tm6.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 4000);
- prod.send(tm6);
-
- TextMessage tm7 = sess.createTextMessage("testScheduled7");
- tm7.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 3000);
- prod.send(tm7);
-
- TextMessage tm8 = sess.createTextMessage("testScheduled8");
- tm8.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 6000);
- prod.send(tm8);
-
- //And one scheduled with a -ve number
-
- TextMessage tm9 = sess.createTextMessage("testScheduled9");
- tm8.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, -3);
- prod.send(tm9);
-
- //Now stop the server and restart it
-
- conn.close();
-
- stop();
-
- start();
-
- // Messaging server restart implies new ConnectionFactory lookup
- deployAndLookupAdministeredObjects();
-
- conn = cf.createConnection();
-
- conn.start();
-
- sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- forceGC();
-
- //First the non scheduled messages should be received
-
- TextMessage rm1 = (TextMessage)cons.receive(250);
- assertNotNull(rm1);
- assertEquals(tm2.getText(), rm1.getText());
-
- TextMessage rm2 = (TextMessage)cons.receive(250);
- assertNotNull(rm2);
- assertEquals(tm3.getText(), rm2.getText());
-
- TextMessage rm3 = (TextMessage)cons.receive(250);
- assertNotNull(rm3);
- assertEquals(tm4.getText(), rm3.getText());
-
- //Now the one with a scheduled with a -ve number
- TextMessage rm5 = (TextMessage)cons.receive(250);
- assertNotNull(rm5);
- assertEquals(tm9.getText(), rm5.getText());
-
- //Now the scheduled
- TextMessage rm6 = (TextMessage)cons.receive(3250);
- assertNotNull(rm6);
- assertEquals(tm7.getText(), rm6.getText());
-
- long now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 3000);
-
-
- TextMessage rm7 = (TextMessage)cons.receive(1250);
- assertNotNull(rm7);
- assertEquals(tm6.getText(), rm7.getText());
-
- now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 4000);
-
-
- TextMessage rm8 = (TextMessage)cons.receive(1250);
- assertNotNull(rm8);
- assertEquals(tm5.getText(), rm8.getText());
-
- now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 5000);
-
-
- TextMessage rm9 = (TextMessage)cons.receive(1250);
- assertNotNull(rm9);
- assertEquals(tm8.getText(), rm9.getText());
-
- now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 6000);
-
-
- TextMessage rm10 = (TextMessage)cons.receive(1250);
- assertNotNull(rm10);
- assertEquals(tm1.getText(), rm10.getText());
-
- now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 7000);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- public void testDelayedRedeliveryDefault() throws Exception
- {
-
- try
- {
-
- setRedeliveryDelayOnDestination("Queue1", true, -1);
-
- long delay = 3000;
-
- setDefaultRedeliveryDelay(delay);
- this.delayedRedeliveryDefaultOnClose(delay);
-
- this.delayedRedeliveryDefaultOnRollback(delay);
- }
- finally
- {
- setDefaultRedeliveryDelay(0);
-
- removeAllMessages(queue1.getQueueName(), true, 0);
- }
- }
-
- public void testDelayedRedeliveryOverride() throws Exception
- {
-
- try
- {
- long delay = 6000;
-
- setRedeliveryDelayOnDestination("Queue1", true, delay);
-
- setDefaultRedeliveryDelay(3000);
-
- this.delayedRedeliveryDefaultOnClose(delay);
-
- this.delayedRedeliveryDefaultOnRollback(delay);
- }
- finally
- {
- setDefaultRedeliveryDelay(0);
-
- setRedeliveryDelayOnDestination("Queue1", true, -1);
-
- removeAllMessages(queue1.getQueueName(), true, 0);
- }
- }
-
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- // Some tests here are changing this attribute.. what would affect tests later
- // Instead of restart the ServerPeer I'm just restoring the default
- setDefaultRedeliveryDelay(0);
- }
-
- // Private -------------------------------------------------------
-
- private void delayedRedeliveryDefaultOnClose(long delay) throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(queue1);
-
- final int NUM_MESSAGES = 5;
-
- forceGC();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess.createTextMessage("message" + i);
-
- prod.send(tm);
- }
-
- Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
- MessageConsumer cons = sess2.createConsumer(queue1);
-
- conn.start();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons.receive(500);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- //Now close the session
- //This should cancel back to the queue with a delayed redelivery
-
- long now = System.currentTimeMillis();
-
- sess2.close();
-
- Session sess3 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons2 = sess3.createConsumer(queue1);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons2.receive(delay + 1000);
-
- assertNotNull(tm);
-
- long time = System.currentTimeMillis();
-
- assertTrue(time - now >= delay);
-
- //Hudson can introduce a large degree of indeterminism
- assertTrue((time - now) + ">" + (delay + 1000), time - now < delay + 1000);
- }
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- private void delayedRedeliveryDefaultOnRollback(long delay) throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(queue1);
-
- final int NUM_MESSAGES = 5;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess.createTextMessage("message" + i);
-
- prod.send(tm);
- }
-
- Session sess2 = conn.createSession(true, Session.SESSION_TRANSACTED);
-
- MessageConsumer cons = sess2.createConsumer(queue1);
-
- conn.start();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons.receive(500);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- //Now rollback
-
- long now = System.currentTimeMillis();
-
- sess2.rollback();
-
- //This should redeliver with a delayed redelivery
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons.receive(delay + 1000);
-
- assertNotNull(tm);
-
- long time = System.currentTimeMillis();
-
- assertTrue(time - now >= delay);
-
- //Hudson can introduce a large degree of indeterminism
- assertTrue((time - now) + ">" + (delay + 1000), time - now < delay + 1000);
- }
-
- sess2.commit();
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- private void scheduledDelivery(boolean tx) throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session sess = conn.createSession(tx, tx ? Session.SESSION_TRANSACTED : Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(queue1);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- conn.start();
-
- //Send one scheduled
-
- long now = System.currentTimeMillis();
-
- TextMessage tm1 = sess.createTextMessage("testScheduled1");
- tm1.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 7000);
- prod.send(tm1);
-
- //First send some non scheduled messages
-
- TextMessage tm2 = sess.createTextMessage("testScheduled2");
- prod.send(tm2);
-
- TextMessage tm3 = sess.createTextMessage("testScheduled3");
- prod.send(tm3);
-
- TextMessage tm4 = sess.createTextMessage("testScheduled4");
- prod.send(tm4);
-
-
- //Now send some more scheduled messages
-
- TextMessage tm5 = sess.createTextMessage("testScheduled5");
- tm5.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 5000);
- prod.send(tm5);
-
- TextMessage tm6 = sess.createTextMessage("testScheduled6");
- tm6.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 4000);
- prod.send(tm6);
-
- TextMessage tm7 = sess.createTextMessage("testScheduled7");
- tm7.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 3000);
- prod.send(tm7);
-
- TextMessage tm8 = sess.createTextMessage("testScheduled8");
- tm8.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, now + 6000);
- prod.send(tm8);
-
- //And one scheduled with a -ve number
-
- TextMessage tm9 = sess.createTextMessage("testScheduled9");
- tm8.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, -3);
- prod.send(tm9);
-
- if (tx)
- {
- sess.commit();
- }
-
- //First the non scheduled messages should be received
- forceGC();
-
-
- TextMessage rm1 = (TextMessage)cons.receive(250);
- assertNotNull(rm1);
- assertEquals(tm2.getText(), rm1.getText());
-
- TextMessage rm2 = (TextMessage)cons.receive(250);
- assertNotNull(rm2);
- assertEquals(tm3.getText(), rm2.getText());
-
- TextMessage rm3 = (TextMessage)cons.receive(250);
- assertNotNull(rm3);
- assertEquals(tm4.getText(), rm3.getText());
-
- //Now the one with a scheduled with a -ve number
- TextMessage rm5 = (TextMessage)cons.receive(250);
- assertNotNull(rm5);
- assertEquals(tm9.getText(), rm5.getText());
-
- //Now the scheduled
- TextMessage rm6 = (TextMessage)cons.receive(3250);
- assertNotNull(rm6);
- assertEquals(tm7.getText(), rm6.getText());
-
- long now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 3000);
-
-
- TextMessage rm7 = (TextMessage)cons.receive(1250);
- assertNotNull(rm7);
- assertEquals(tm6.getText(), rm7.getText());
-
- now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 4000);
-
-
- TextMessage rm8 = (TextMessage)cons.receive(1250);
- assertNotNull(rm8);
- assertEquals(tm5.getText(), rm8.getText());
-
- now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 5000);
-
-
- TextMessage rm9 = (TextMessage)cons.receive(1250);
- assertNotNull(rm9);
- assertEquals(tm8.getText(), rm9.getText());
-
- now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 6000);
-
-
- TextMessage rm10 = (TextMessage)cons.receive(1250);
- assertNotNull(rm10);
- assertEquals(tm1.getText(), rm10.getText());
-
- now2 = System.currentTimeMillis();
-
- assertTrue(now2 - now >= 7000);
-
- if (tx)
- {
- sess.commit();
- }
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
// Inner classes -------------------------------------------------
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -108,10 +108,8 @@
DataOutputStream dos = new DataOutputStream(bos);
- SafeUTF su = new SafeUTF(chunkSize);
+ SafeUTF.safeWriteUTF(dos, s);
- su.safeWriteUTF(dos, s);
-
dos.close();
byte[] bytes = bos.toByteArray();
@@ -120,7 +118,7 @@
DataInputStream dis = new DataInputStream(bis);
- String s2 = su.safeReadUTF(dis);
+ String s2 = SafeUTF.safeReadUTF(dis);
assertEquals(s, s2);
}
@@ -133,10 +131,8 @@
String s = "abcdefghijklmnopqrstuvwxyz";
- SafeUTF su = new SafeUTF(30);
+ SafeUTF.safeWriteUTF(dos, s);
- su.safeWriteUTF(dos, s);
-
dos.close();
byte[] bytes = bos.toByteArray();
@@ -145,13 +141,9 @@
DataInputStream dis = new DataInputStream(bis);
- String s2 = su.safeReadUTF(dis);
+ String s2 = SafeUTF.safeReadUTF(dis);
- assertEquals(s, s2);
-
- int lastReadBufferSize = su.getLastReadBufferSize();
-
- assertEquals(28, lastReadBufferSize);
+ assertEquals(s, s2);
}
protected String genString(int len)
Modified: trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -32,8 +32,6 @@
import javax.jms.TextMessage;
import javax.naming.NamingException;
-import org.jboss.jms.message.MessageProxy;
-
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -344,8 +342,7 @@
final String messageText = "This is a message";
final Message m = producerSession.createTextMessage(messageText);
- log.trace("Message reliable:" + ((MessageProxy)m).getMessage().isReliable());
-
+
Thread t = new Thread(new Runnable()
{
public void run()
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -47,7 +47,6 @@
import org.jboss.jms.client.remoting.JMSRemotingConnection;
import org.jboss.jms.client.state.ConnectionState;
import org.jboss.jms.client.state.SessionState;
-import org.jboss.jms.message.MessageProxy;
import org.jboss.test.messaging.tools.ServerManagement;
/**
@@ -759,11 +758,10 @@
private void receiveMessage(String text, MessageConsumer consumer, boolean shouldAssert, boolean shouldBeNull) throws Exception
{
- MessageProxy message = (MessageProxy) consumer.receive(3000);
- TextMessage txtMessage = (TextMessage) message;
+ TextMessage message = (TextMessage) consumer.receive(3000);
if (message != null)
{
- log.info(text + ": messageID from messageReceived=" + message.getMessage().getMessageID() + " message = " + message + " content=" + txtMessage.getText());
+ log.info(text + ": messageID from messageReceived=" + message.getJMSMessageID() + " message = " + message + " content=" + message.getText());
}
else
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/JMSExpirationHeaderTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/JMSExpirationHeaderTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/JMSExpirationHeaderTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -21,13 +21,13 @@
*/
package org.jboss.test.messaging.jms.message;
-import EDU.oswego.cs.dl.util.concurrent.Latch;
-import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.MessageProxy;
-
import javax.jms.DeliveryMode;
import javax.jms.Message;
+import org.jboss.jms.message.JBossMessage;
+
+import EDU.oswego.cs.dl.util.concurrent.Latch;
+
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -191,9 +191,9 @@
Message m = queueProducerSession.createMessage();
queueProducer.send(m, DeliveryMode.NON_PERSISTENT, 4, -1);
- JBossMessage jbm = ((MessageProxy)m).getMessage();
+ JBossMessage jbm = (JBossMessage)m;
- if (!jbm.isExpired())
+ if (!jbm.getCoreMessage().isExpired())
{
log.error("The message " + m + " should have expired");
testFailed = true;
@@ -247,7 +247,7 @@
public void testExpirationOnReceive() throws Exception
{
- expectedMessage = new JBossMessage(123456);
+ expectedMessage = new JBossMessage();
queueProducer.send(queueProducerSession.createMessage(), DeliveryMode.NON_PERSISTENT, 4, 2000);
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MessageBodyTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MessageBodyTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MessageBodyTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1107,12 +1107,9 @@
m3.setObject(obj);
- // This basically tests that after setting the object - changing the objects fields doesn't
- // change the set object - the object is carried in serialized form
-
- obj.str = "xyz123";
-
queueProducer.send(queue1, m3);
+
+ obj.str = "xyz123";
ObjectMessage m4 = (ObjectMessage) queueConsumer.receive(2000);
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -43,7 +43,6 @@
import org.jboss.jms.message.JBossObjectMessage;
import org.jboss.jms.message.JBossStreamMessage;
import org.jboss.jms.message.JBossTextMessage;
-import org.jboss.jms.message.MessageProxy;
/**
*
@@ -665,11 +664,11 @@
public void testCopyOnJBossMessage() throws JMSException
{
- JBossMessage jbossMessage = ((MessageProxy)queueProducerSession.createMessage()).getMessage();
+ JBossMessage jbossMessage = new JBossMessage();
configureMessage(jbossMessage);
- JBossMessage copy = new JBossMessage(jbossMessage, 0);
+ JBossMessage copy = new JBossMessage(jbossMessage);
ensureEquivalent(jbossMessage, copy);
}
@@ -679,32 +678,11 @@
{
Message foreignMessage = new SimpleJMSMessage();
- JBossMessage copy = new JBossMessage(foreignMessage, 0);
+ JBossMessage copy = new JBossMessage(foreignMessage);
ensureEquivalent(foreignMessage, copy);
}
-
- public void testCopyOnJBossBytesMessage() throws JMSException
- {
- JBossBytesMessage jbossBytesMessage = (JBossBytesMessage)(((MessageProxy)queueProducerSession.
- createBytesMessage()).getMessage());
-
- for(int i = 0; i < 20; i++)
- {
- jbossBytesMessage.writeByte((byte)i);
- }
-
-
- jbossBytesMessage.reset();
- JBossBytesMessage copy = new JBossBytesMessage(jbossBytesMessage);
-
- copy.reset();
-
- ensureEquivalent(jbossBytesMessage, copy);
- }
-
-
public void testCopyOnForeignBytesMessage() throws JMSException
{
BytesMessage foreignBytesMessage = new SimpleJMSBytesMessage();
@@ -713,76 +691,36 @@
foreignBytesMessage.writeByte((byte)i);
}
- JBossBytesMessage copy = new JBossBytesMessage(foreignBytesMessage, 0);
+ JBossBytesMessage copy = new JBossBytesMessage(foreignBytesMessage);
foreignBytesMessage.reset();
copy.reset();
ensureEquivalent(foreignBytesMessage, copy);
}
-
- public void testCopyOnJBossMapMessage() throws JMSException
- {
- JBossMapMessage jbossMapMessage = (JBossMapMessage)(((MessageProxy)queueProducerSession.
- createMapMessage()).getMessage());
-
- jbossMapMessage.setInt("int", 1);
- jbossMapMessage.setString("string", "test");
-
- JBossMapMessage copy = new JBossMapMessage((JBossMapMessage)jbossMapMessage);
-
- ensureEquivalent(jbossMapMessage, copy);
- }
-
-
+
public void testCopyOnForeignMapMessage() throws JMSException
{
MapMessage foreignMapMessage = new SimpleJMSMapMessage();
foreignMapMessage.setInt("int", 1);
foreignMapMessage.setString("string", "test");
- JBossMapMessage copy = new JBossMapMessage(foreignMapMessage, 0);
+ JBossMapMessage copy = new JBossMapMessage(foreignMapMessage);
ensureEquivalent(foreignMapMessage, copy);
}
- public void testCopyOnJBossObjectMessage() throws JMSException
- {
- JBossObjectMessage jbossObjectMessage = (JBossObjectMessage)
- (((MessageProxy)queueProducerSession.createObjectMessage()).getMessage());
-
- JBossObjectMessage copy = new JBossObjectMessage(jbossObjectMessage);
-
- ensureEquivalent(jbossObjectMessage, copy);
- }
-
-
public void testCopyOnForeignObjectMessage() throws JMSException
{
ObjectMessage foreignObjectMessage = new SimpleJMSObjectMessage();
- JBossObjectMessage copy = new JBossObjectMessage(foreignObjectMessage, 0);
+ JBossObjectMessage copy = new JBossObjectMessage(foreignObjectMessage);
ensureEquivalent(foreignObjectMessage, copy);
}
- public void testCopyOnJBossStreamMessage() throws JMSException
- {
- JBossStreamMessage jbossStreamMessage = (JBossStreamMessage)
- (((MessageProxy)queueProducerSession.createStreamMessage()).getMessage());
-
- jbossStreamMessage.writeByte((byte)1);
- jbossStreamMessage.writeByte((byte)2);
- jbossStreamMessage.writeByte((byte)3);
-
- JBossStreamMessage copy = new JBossStreamMessage((JBossStreamMessage)jbossStreamMessage);
-
- ensureEquivalent(jbossStreamMessage, copy);
- }
-
-
public void testCopyOnForeignStreamMessage() throws JMSException
{
StreamMessage foreignStreamMessage = new SimpleJMSStreamMessage();
@@ -790,28 +728,17 @@
foreignStreamMessage.writeByte((byte)2);
foreignStreamMessage.writeByte((byte)3);
- JBossStreamMessage copy = new JBossStreamMessage(foreignStreamMessage, 0);
+ JBossStreamMessage copy = new JBossStreamMessage(foreignStreamMessage);
ensureEquivalent(foreignStreamMessage, copy);
}
- public void testCopyOnJBossTextMessage() throws JMSException
- {
- JBossTextMessage jbossTextMessage = (JBossTextMessage)
- (((MessageProxy)queueProducerSession.createTextMessage()).getMessage());
-
- JBossTextMessage copy = new JBossTextMessage(jbossTextMessage);
-
- ensureEquivalent(jbossTextMessage, copy);
- }
-
-
public void testCopyOnForeignTextMessage() throws JMSException
{
TextMessage foreignTextMessage = new SimpleJMSTextMessage();
- JBossTextMessage copy = new JBossTextMessage(foreignTextMessage, 0);
+ JBossTextMessage copy = new JBossTextMessage(foreignTextMessage);
ensureEquivalent(foreignTextMessage, copy);
}
@@ -832,14 +759,14 @@
Message receivedMessage = queueConsumer.receive(2000);
- ensureEquivalent(receivedMessage, ((MessageProxy) message).getMessage());
+ ensureEquivalent(receivedMessage, (JBossMessage)message);
}
public void testForeignJMSReplyTo() throws JMSException
{
Message msg = queueProducerSession.createTextMessage();
- JBossMessage jbossMessage = ((MessageProxy) msg).getMessage();
+ JBossMessage jbossMessage = (JBossMessage)msg;
Destination foreignDestination = new ForeignDestination();
@@ -858,7 +785,7 @@
foreignMessage.setJMSDestination(new ForeignDestination());
foreignMessage.setJMSReplyTo(new ForeignDestination());
- JBossMessage copy = new JBossMessage(foreignMessage, 0);
+ JBossMessage copy = new JBossMessage(foreignMessage);
ensureEquivalent(foreignMessage, copy);
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -48,8 +48,7 @@
*/
public static void configureMessage(JBossMessage m) throws JMSException
{
- //m.setJMSMessageID("messageID777");
- m.setMessageId(123456);
+ m.setJMSMessageID("ID:messageID777");
m.setJMSTimestamp(123456789l);
m.setJMSCorrelationID("correlationID777");
m.setJMSReplyTo(new JBossQueue("ReplyToQueue"));
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -111,7 +111,7 @@
}
- public void testVecorOnObjectMessage() throws Exception
+ public void testVectorOnObjectMessage() throws Exception
{
java.util.Vector vectorOnMessage = new java.util.Vector();
vectorOnMessage.add("world!");
Modified: trunk/tests/src/org/jboss/test/messaging/jms/selector/SelectorSyntaxTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/selector/SelectorSyntaxTest.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/jms/selector/SelectorSyntaxTest.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -48,7 +48,7 @@
protected void setUp() throws Exception
{
super.setUp();
- message = new JBossMessage(0);
+ message = new JBossMessage();
}
public void testBooleanTrue() throws Exception
@@ -66,10 +66,10 @@
private void testBoolean(String name, boolean flag) throws Exception
{
message.setBooleanProperty(name, flag);
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
message.setBooleanProperty(name, !flag);
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
}
public void testStringEquals() throws Exception
@@ -78,19 +78,19 @@
selector = new Selector("MyString='astring'");
message.setStringProperty("MyString", "astring");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
message.setStringProperty("MyString", "NOTastring");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test empty string
selector = new Selector("MyString=''");
message.setStringProperty("MyString", "");
- assertTrue("test 1", selector.accept(message));
+ assertTrue("test 1", selector.match(message.getCoreMessage()));
message.setStringProperty("MyString", "NOTastring");
- assertTrue("test 2", !selector.accept(message));
+ assertTrue("test 2", !selector.match(message.getCoreMessage()));
// test literal apostrophes (which are escaped using two apostrophes
// in selectors)
@@ -99,10 +99,10 @@
// note: apostrophes are not escaped in string properties
message.setStringProperty("MyString", "test JBoss's selector");
// this test fails -- bug 530120
- //assertTrue("test 3", selector.accept(message));
+ //assertTrue("test 3", selector.match(message.getCoreMessage()));
message.setStringProperty("MyString", "NOTastring");
- assertTrue("test 4", !selector.accept(message));
+ assertTrue("test 4", !selector.match(message.getCoreMessage()));
}
@@ -113,44 +113,44 @@
// test where LIKE operand matches
message.setStringProperty("MyString", "astring");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// test one character string
selector = new Selector("MyString LIKE 'a'");
message.setStringProperty("MyString","a");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// test empty string
selector = new Selector("MyString LIKE ''");
message.setStringProperty("MyString", "");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// tests where operand does not match
selector = new Selector("MyString LIKE 'astring'");
// test with extra characters at beginning
message.setStringProperty("MyString", "NOTastring");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test with extra characters at end
message.setStringProperty("MyString", "astringNOT");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test with extra characters in the middle
message.setStringProperty("MyString", "astNOTring");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test where operand is entirely different
message.setStringProperty("MyString", "totally different");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test case sensitivity
message.setStringProperty("MyString", "ASTRING");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test empty string
message.setStringProperty("MyString", "");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test lower-case 'like' operator?
@@ -166,15 +166,15 @@
// test match against single character
message.setStringProperty("MyString", "a");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// test match failure against multiple characters
message.setStringProperty("MyString", "aaaaa");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test match failure against the empty string
message.setStringProperty("MyString", "");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// next, tests with wildcard at the beginning of the string
@@ -182,70 +182,70 @@
// test match at beginning of string
message.setStringProperty("MyString", "abcdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// match failure in first character after wildcard
message.setStringProperty("MyString", "aXcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in middle character
message.setStringProperty("MyString", "abXdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in last character
message.setStringProperty("MyString", "abcdX");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure with empty string
message.setStringProperty("MyString", "");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at beginning
message.setStringProperty("MyString", "XXXabcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at the end
message.setStringProperty("MyString", "abcdfXXX");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test that the _ wildcard does not match the 'empty' character
message.setStringProperty("MyString", "bcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// next, tests with wildcard at the end of the string
selector = new Selector("MyString LIKE 'abcd_'");
// test match at end of string
message.setStringProperty("MyString", "abcdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// match failure in first character before wildcard
message.setStringProperty("MyString", "abcXf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in middle character
message.setStringProperty("MyString", "abXdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in first character
message.setStringProperty("MyString", "Xbcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure with empty string
message.setStringProperty("MyString", "");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at beginning
message.setStringProperty("MyString", "XXXabcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at the end
message.setStringProperty("MyString", "abcdfXXX");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test that the _ wildcard does not match the 'empty' character
message.setStringProperty("MyString", "abcd");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test match in middle of string
@@ -254,35 +254,35 @@
// test match in the middle of string
message.setStringProperty("MyString", "abcdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// match failure in first character before wildcard
message.setStringProperty("MyString", "aXcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in first character after wildcard
message.setStringProperty("MyString", "abcXf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in last character
message.setStringProperty("MyString", "abcdX");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure with empty string
message.setStringProperty("MyString", "");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at beginning
message.setStringProperty("MyString", "XXXabcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at the end
message.setStringProperty("MyString", "abcdfXXX");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test that the _ wildcard does not match the 'empty' character
message.setStringProperty("MyString", "abdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test match failures
}
@@ -299,18 +299,18 @@
// test match against single character
message.setStringProperty("MyString", "a");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// test match against multiple characters
message.setStringProperty("MyString", "aaaaa");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
message.setStringProperty("MyString", "abcdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// test match against the empty string
message.setStringProperty("MyString", "");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// next, tests with wildcard at the beginning of the string
@@ -318,105 +318,105 @@
// test match with single character at beginning of string
message.setStringProperty("MyString", "Xbcdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// match with multiple characters at beginning
message.setStringProperty("MyString", "XXbcdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// match failure in middle character
message.setStringProperty("MyString", "abXdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in last character
message.setStringProperty("MyString", "abcdX");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure with empty string
message.setStringProperty("MyString", "");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at the end
message.setStringProperty("MyString", "abcdfXXX");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test that the % wildcard matches the empty string
message.setStringProperty("MyString", "bcdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// next, tests with wildcard at the end of the string
selector = new Selector("MyString LIKE 'abcd%'");
// test match of single character at end of string
message.setStringProperty("MyString", "abcdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// test match of multiple characters at end of string
message.setStringProperty("MyString", "abcdfgh");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// match failure in first character before wildcard
message.setStringProperty("MyString", "abcXf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in middle character
message.setStringProperty("MyString", "abXdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in first character
message.setStringProperty("MyString", "Xbcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure with empty string
message.setStringProperty("MyString", "");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at beginning
message.setStringProperty("MyString", "XXXabcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test that the % wildcard matches the empty string
message.setStringProperty("MyString", "abcd");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// next, tests with wildcard in the middle of the string
selector = new Selector("MyString LIKE 'ab%df'");
// test match with single character in the middle of string
message.setStringProperty("MyString", "abXdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// test match with multiple characters in the middle of string
message.setStringProperty("MyString", "abXXXdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// match failure in first character before wildcard
message.setStringProperty("MyString", "aXcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in first character after wildcard
message.setStringProperty("MyString", "abcXf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure in last character
message.setStringProperty("MyString", "abcdX");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure with empty string
message.setStringProperty("MyString", "");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at beginning
message.setStringProperty("MyString", "XXXabcdf");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// match failure due to extra characters at the end
message.setStringProperty("MyString", "abcdfXXX");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
// test that the % wildcard matches the empty string
message.setStringProperty("MyString", "abdf");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
}
@@ -434,72 +434,72 @@
selector = new Selector("MyString LIKE 'a^$b'");
message.setStringProperty("MyString", "a^$b");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
// this one has a double backslash since backslash
// is interpreted specially by Java
selector = new Selector("MyString LIKE 'a\\dc'");
message.setStringProperty("MyString", "a\\dc");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE 'a.c'");
message.setStringProperty("MyString", "abc");
- assertTrue(!selector.accept(message));
+ assertTrue(!selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '[abc]'");
message.setStringProperty("MyString", "[abc]");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '[^abc]'");
message.setStringProperty("MyString", "[^abc]");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '[a-c]'");
message.setStringProperty("MyString", "[a-c]");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '[:alpha]'");
message.setStringProperty("MyString", "[:alpha]");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '(abc)'");
message.setStringProperty("MyString", "(abc)");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE 'a|bc'");
message.setStringProperty("MyString", "a|bc");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '(abc)?'");
message.setStringProperty("MyString", "(abc)?");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '(abc)*'");
message.setStringProperty("MyString", "(abc)*");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '(abc)+'");
message.setStringProperty("MyString", "(abc)+");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '(abc){3}'");
message.setStringProperty("MyString", "(abc){3}");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '(abc){3,5}'");
message.setStringProperty("MyString", "(abc){3,5}");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '(abc){3,}'");
message.setStringProperty("MyString", "(abc){3,}");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '(?=abc)'");
message.setStringProperty("MyString", "(?=abc)");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
selector = new Selector("MyString LIKE '(?!abc)'");
message.setStringProperty("MyString", "(?!abc)");
- assertTrue(selector.accept(message));
+ assertTrue(selector.match(message.getCoreMessage()));
}
}
Deleted: trunk/tests/src/org/jboss/test/messaging/util/CoreMessageFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/CoreMessageFactory.java 2007-12-17 14:27:09 UTC (rev 3513)
+++ trunk/tests/src/org/jboss/test/messaging/util/CoreMessageFactory.java 2007-12-17 15:56:37 UTC (rev 3514)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.messaging.util;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import org.jboss.messaging.core.impl.message.CoreMessage;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 764 $</tt>
- *
- * $Id: MessageFactory.java 764 2006-03-22 10:23:38Z timfox $
- */
-public class CoreMessageFactory
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- public static CoreMessage createCoreMessage(long messageID)
- {
- return createCoreMessage(messageID, false, 0, 0, (byte)4, null, null);
- }
-
- public static CoreMessage createCoreMessage(long messageID,
- boolean reliable,
- Serializable payload)
- {
- return createCoreMessage(messageID, reliable, 0, 0, (byte)4, null, payload);
- }
-
- public static CoreMessage createCoreMessage(long messageID,
- boolean reliable,
- long expiration,
- long timestamp,
- byte priority,
- Map coreHeaders,
- Serializable payload)
- {
- CoreMessage cm =
- new CoreMessage(messageID, reliable, expiration, timestamp, priority, coreHeaders, null);
- cm.setPayload(payload);
- return cm;
- }
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
More information about the jboss-cvs-commits
mailing list