From commits-return-10898-apmail-activemq-commits-archive=activemq.apache.org@activemq.apache.org Sat May 30 00:08:04 2009 Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 66727 invoked from network); 30 May 2009 00:08:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 May 2009 00:08:04 -0000 Received: (qmail 23390 invoked by uid 500); 30 May 2009 00:08:17 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 23338 invoked by uid 500); 30 May 2009 00:08:17 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 23329 invoked by uid 99); 30 May 2009 00:08:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 May 2009 00:08:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 May 2009 00:08:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 146A12388902; Sat, 30 May 2009 00:07:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r780145 - in /activemq/sandbox/activemq-flow: ./ activemq-broker/src/main/java/org/apache/activemq/broker/ activemq-broker/src/main/java/org/apache/activemq/broker/db/ activemq-broker/src/main/java/org/apache/activemq/broker/store/ activemq... Date: Sat, 30 May 2009 00:07:47 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090530000748.146A12388902@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: chirino Date: Sat May 30 00:07:45 2009 New Revision: 780145 URL: http://svn.apache.org/viewvc?rev=780145&view=rev Log: Added the protobuf dependency. Moved the Store package out to the store module. Added: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/BrokerDatabase.java - copied, changed from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoreListener.java - copied, changed from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoreListener.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoredElement.java - copied, changed from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoredElement.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/SaveableQueueElement.java - copied, changed from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/SaveableQueueElement.java activemq/sandbox/activemq-flow/activemq-protobuf/ - copied from r780142, activemq/activemq-protobuf/trunk/ activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/ activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/ activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/ activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/ activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/ activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/QueueDescriptor.java - copied unchanged from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/QueueDescriptor.java activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/Store.java - copied unchanged from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/Store.java activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/StoreFactory.java - copied unchanged from r780081, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/StoreFactory.java activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/memory/ - copied from r780081, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/memory/ activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java - copied, changed from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/Service.java activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayOutputStream.java activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequence.java activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequenceData.java activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/FactoryFinder.java Removed: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/QueueDescriptor.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoreListener.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoredElement.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/SaveableQueueElement.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/Store.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/StoreFactory.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/memory/ Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerMessageDelivery.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerQueueStore.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageBroker.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDelivery.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDeliveryWrapper.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/Router.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/CursoredQueue.java activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/QueueStore.java activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueuePerfTest.java activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/flow/MockQueue.java activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf-test/pom.xml activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf/pom.xml activemq/sandbox/activemq-flow/activemq-protobuf/pom.xml activemq/sandbox/activemq-flow/pom.xml Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerMessageDelivery.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerMessageDelivery.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerMessageDelivery.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerMessageDelivery.java Sat May 30 00:07:45 2009 @@ -21,10 +21,10 @@ import java.util.Collection; import java.util.HashMap; -import org.apache.activemq.broker.store.BrokerDatabase; +import org.apache.activemq.broker.db.BrokerDatabase; +import org.apache.activemq.broker.db.SaveableQueueElement; +import org.apache.activemq.broker.db.BrokerDatabase.OperationContext; import org.apache.activemq.broker.store.QueueDescriptor; -import org.apache.activemq.broker.store.SaveableQueueElement; -import org.apache.activemq.broker.store.BrokerDatabase.OperationContext; import org.apache.activemq.broker.store.Store.MessageRecord; import org.apache.activemq.flow.ISourceController; Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerQueueStore.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerQueueStore.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerQueueStore.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerQueueStore.java Sat May 30 00:07:45 2009 @@ -22,10 +22,10 @@ import java.util.HashMap; import java.util.Iterator; -import org.apache.activemq.broker.store.BrokerDatabase; +import org.apache.activemq.broker.db.BrokerDatabase; +import org.apache.activemq.broker.db.RestoreListener; +import org.apache.activemq.broker.db.SaveableQueueElement; import org.apache.activemq.broker.store.QueueDescriptor; -import org.apache.activemq.broker.store.RestoreListener; -import org.apache.activemq.broker.store.SaveableQueueElement; import org.apache.activemq.broker.store.Store.QueueQueryResult; import org.apache.activemq.dispatch.IDispatcher; import org.apache.activemq.flow.ISourceController; @@ -401,7 +401,7 @@ } public final void restoreQueueElements(QueueDescriptor queue, boolean recordsOnly, long firstSequence, long maxSequence, int maxCount, - org.apache.activemq.broker.store.RestoreListener listener) { + org.apache.activemq.broker.db.RestoreListener listener) { database.restoreMessages(queue, recordsOnly, firstSequence, maxSequence, maxCount, listener); } Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageBroker.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageBroker.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageBroker.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageBroker.java Sat May 30 00:07:45 2009 @@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.Connection; -import org.apache.activemq.broker.store.BrokerDatabase; +import org.apache.activemq.broker.db.BrokerDatabase; import org.apache.activemq.broker.store.Store; import org.apache.activemq.dispatch.IDispatcher; import org.apache.activemq.protobuf.AsciiBuffer; Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDelivery.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDelivery.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDelivery.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDelivery.java Sat May 30 00:07:45 2009 @@ -16,8 +16,8 @@ */ package org.apache.activemq.broker; +import org.apache.activemq.broker.db.SaveableQueueElement; import org.apache.activemq.broker.store.QueueDescriptor; -import org.apache.activemq.broker.store.SaveableQueueElement; import org.apache.activemq.broker.store.Store; import org.apache.activemq.flow.ISourceController; import org.apache.activemq.protobuf.AsciiBuffer; Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDeliveryWrapper.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDeliveryWrapper.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDeliveryWrapper.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/MessageDeliveryWrapper.java Sat May 30 00:07:45 2009 @@ -16,8 +16,8 @@ */ package org.apache.activemq.broker; +import org.apache.activemq.broker.db.SaveableQueueElement; import org.apache.activemq.broker.store.QueueDescriptor; -import org.apache.activemq.broker.store.SaveableQueueElement; import org.apache.activemq.broker.store.Store.MessageRecord; import org.apache.activemq.flow.ISourceController; import org.apache.activemq.protobuf.AsciiBuffer; Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/Router.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/Router.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/Router.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/Router.java Sat May 30 00:07:45 2009 @@ -27,7 +27,7 @@ import org.apache.activemq.broker.MessageDelivery; import org.apache.activemq.broker.QueueDomain; import org.apache.activemq.broker.TopicDomain; -import org.apache.activemq.broker.store.BrokerDatabase; +import org.apache.activemq.broker.db.BrokerDatabase; import org.apache.activemq.flow.ISourceController; import org.apache.activemq.protobuf.AsciiBuffer; Copied: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/BrokerDatabase.java (from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java) URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/BrokerDatabase.java?p2=activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/BrokerDatabase.java&p1=activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java&r1=780141&r2=780145&rev=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/BrokerDatabase.java Sat May 30 00:07:45 2009 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.broker.store; +package org.apache.activemq.broker.db; import java.io.IOException; import java.util.ArrayList; @@ -31,6 +31,8 @@ import org.apache.activemq.broker.MessageDelivery; import org.apache.activemq.broker.protocol.ProtocolHandler; import org.apache.activemq.broker.protocol.ProtocolHandlerFactory; +import org.apache.activemq.broker.store.QueueDescriptor; +import org.apache.activemq.broker.store.Store; import org.apache.activemq.broker.store.Store.Callback; import org.apache.activemq.broker.store.Store.FatalStoreException; import org.apache.activemq.broker.store.Store.KeyNotFoundException; @@ -38,6 +40,7 @@ import org.apache.activemq.broker.store.Store.QueueQueryResult; import org.apache.activemq.broker.store.Store.QueueRecord; import org.apache.activemq.broker.store.Store.Session; +import org.apache.activemq.broker.store.Store.VoidCallback; import org.apache.activemq.dispatch.IDispatcher; import org.apache.activemq.flow.AbstractLimitedFlowResource; import org.apache.activemq.flow.Flow; @@ -861,7 +864,7 @@ if (!records.hasNext()) { rm.nextSequence = -1; } else { - rm.nextSequence = records.next().queueKey; + rm.nextSequence = records.next().getQueueKey(); } } catch (KeyNotFoundException e) { rm.nextSequence = -1; @@ -871,14 +874,14 @@ if (!recordsOnly) { try { - rm.mRecord = session.messageGetRecord(rm.qRecord.messageKey); - rm.handler = protocolHandlers.get(rm.mRecord.encoding.toString()); + rm.mRecord = session.messageGetRecord(rm.qRecord.getMessageKey()); + rm.handler = protocolHandlers.get(rm.mRecord.getEncoding().toString()); if (rm.handler == null) { try { - rm.handler = ProtocolHandlerFactory.createProtocolHandler(rm.mRecord.encoding.toString()); - protocolHandlers.put(rm.mRecord.encoding.toString(), rm.handler); + rm.handler = ProtocolHandlerFactory.createProtocolHandler(rm.mRecord.getEncoding().toString()); + protocolHandlers.put(rm.mRecord.getEncoding().toString(), rm.handler); } catch (Throwable thrown) { - throw new RuntimeException("Unknown message format" + rm.mRecord.encoding.toString(), thrown); + throw new RuntimeException("Unknown message format" + rm.mRecord.getEncoding().toString(), thrown); } } msgs.add(rm); Copied: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoreListener.java (from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoreListener.java) URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoreListener.java?p2=activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoreListener.java&p1=activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoreListener.java&r1=780141&r2=780145&rev=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoreListener.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoreListener.java Sat May 30 00:07:45 2009 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.broker.store; +package org.apache.activemq.broker.db; import java.util.Collection; Copied: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoredElement.java (from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoredElement.java) URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoredElement.java?p2=activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoredElement.java&p1=activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoredElement.java&r1=780141&r2=780145&rev=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/RestoredElement.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/RestoredElement.java Sat May 30 00:07:45 2009 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.broker.store; +package org.apache.activemq.broker.db; /** * A holder for queue elements loaded from the store. Copied: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/SaveableQueueElement.java (from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/SaveableQueueElement.java) URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/SaveableQueueElement.java?p2=activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/SaveableQueueElement.java&p1=activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/SaveableQueueElement.java&r1=780141&r2=780145&rev=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/SaveableQueueElement.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/db/SaveableQueueElement.java Sat May 30 00:07:45 2009 @@ -14,7 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.broker.store; +package org.apache.activemq.broker.db; + +import org.apache.activemq.broker.store.QueueDescriptor; public interface SaveableQueueElement { Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/CursoredQueue.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/CursoredQueue.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/CursoredQueue.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/CursoredQueue.java Sat May 30 00:07:45 2009 @@ -24,10 +24,10 @@ import java.util.LinkedList; import java.util.Map.Entry; +import org.apache.activemq.broker.db.RestoreListener; +import org.apache.activemq.broker.db.RestoredElement; +import org.apache.activemq.broker.db.SaveableQueueElement; import org.apache.activemq.broker.store.QueueDescriptor; -import org.apache.activemq.broker.store.RestoreListener; -import org.apache.activemq.broker.store.RestoredElement; -import org.apache.activemq.broker.store.SaveableQueueElement; import org.apache.activemq.flow.Flow; import org.apache.activemq.flow.FlowController; import org.apache.activemq.flow.IFlowController; Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/QueueStore.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/QueueStore.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/QueueStore.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/queue/QueueStore.java Sat May 30 00:07:45 2009 @@ -17,10 +17,10 @@ package org.apache.activemq.queue; +import org.apache.activemq.broker.db.RestoreListener; +import org.apache.activemq.broker.db.SaveableQueueElement; +import org.apache.activemq.broker.db.BrokerDatabase.OperationContext; import org.apache.activemq.broker.store.QueueDescriptor; -import org.apache.activemq.broker.store.RestoreListener; -import org.apache.activemq.broker.store.SaveableQueueElement; -import org.apache.activemq.broker.store.BrokerDatabase.OperationContext; import org.apache.activemq.flow.ISourceController; public interface QueueStore { Modified: activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueuePerfTest.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueuePerfTest.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueuePerfTest.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueuePerfTest.java Sat May 30 00:07:45 2009 @@ -24,8 +24,8 @@ import javax.jms.JMSException; +import org.apache.activemq.broker.db.BrokerDatabase; import org.apache.activemq.broker.openwire.OpenWireMessageDelivery; -import org.apache.activemq.broker.store.BrokerDatabase; import org.apache.activemq.broker.store.Store; import org.apache.activemq.broker.store.StoreFactory; import org.apache.activemq.command.ActiveMQDestination; Modified: activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java Sat May 30 00:07:45 2009 @@ -19,7 +19,7 @@ import java.io.File; import java.util.ArrayList; -import org.apache.activemq.broker.store.BrokerDatabase; +import org.apache.activemq.broker.db.BrokerDatabase; import org.apache.activemq.broker.store.Store; import org.apache.activemq.broker.store.StoreFactory; import org.apache.activemq.dispatch.IDispatcher; Modified: activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/flow/MockQueue.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/flow/MockQueue.java?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/flow/MockQueue.java (original) +++ activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/flow/MockQueue.java Sat May 30 00:07:45 2009 @@ -5,9 +5,9 @@ import java.util.HashMap; +import org.apache.activemq.broker.db.RestoreListener; +import org.apache.activemq.broker.db.SaveableQueueElement; import org.apache.activemq.broker.store.QueueDescriptor; -import org.apache.activemq.broker.store.RestoreListener; -import org.apache.activemq.broker.store.SaveableQueueElement; import org.apache.activemq.flow.Commands.Destination; import org.apache.activemq.flow.MockBroker.DeliveryTarget; import org.apache.activemq.queue.IQueue; Modified: activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf-test/pom.xml URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf-test/pom.xml?rev=780145&r1=780142&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf-test/pom.xml (original) +++ activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf-test/pom.xml Sat May 30 00:07:45 2009 @@ -21,12 +21,12 @@ org.apache.activemq.protobuf activemq-protobuf-pom - 1.0-SNAPSHOT + 1.1-SNAPSHOT org.apache.activemq.protobuf activemq-protobuf-test - 1.0-SNAPSHOT + 1.1-SNAPSHOT jar ActiveMQ Protocol Buffers Tests @@ -41,7 +41,7 @@ org.apache.activemq.protobuf activemq-protobuf - 1.0-SNAPSHOT + 1.1-SNAPSHOT Modified: activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf/pom.xml URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf/pom.xml?rev=780145&r1=780142&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf/pom.xml (original) +++ activemq/sandbox/activemq-flow/activemq-protobuf/activemq-protobuf/pom.xml Sat May 30 00:07:45 2009 @@ -21,12 +21,12 @@ org.apache.activemq.protobuf activemq-protobuf-pom - 1.0-SNAPSHOT + 1.1-SNAPSHOT org.apache.activemq.protobuf activemq-protobuf - 1.0-SNAPSHOT + 1.1-SNAPSHOT maven-plugin ActiveMQ Protocol Buffers Implementation and Compiler @@ -37,6 +37,12 @@ + org.apache.activemq + activemq-util + 6.0-SNAPSHOT + true + + org.apache.maven maven-plugin-api 2.0 Modified: activemq/sandbox/activemq-flow/activemq-protobuf/pom.xml URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-protobuf/pom.xml?rev=780145&r1=780142&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-protobuf/pom.xml (original) +++ activemq/sandbox/activemq-flow/activemq-protobuf/pom.xml Sat May 30 00:07:45 2009 @@ -27,7 +27,7 @@ org.apache.activemq.protobuf activemq-protobuf-pom - 1.0-SNAPSHOT + 1.1-SNAPSHOT pom ActiveMQ Protocol Buffers POM Copied: activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java (from r780141, activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java) URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java?p2=activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java&p1=activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java&r1=780141&r2=780145&rev=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java (original) +++ activemq/sandbox/activemq-flow/activemq-store/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java Sat May 30 00:07:45 2009 @@ -16,9 +16,9 @@ */ package org.apache.activemq.broker.store.memory; +import java.io.File; import java.util.ArrayList; import java.util.Collection; -import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -26,19 +26,16 @@ import java.util.TreeMap; import java.util.concurrent.atomic.AtomicLong; -import java.io.File; - import org.apache.activemq.broker.store.QueueDescriptor; import org.apache.activemq.broker.store.Store; import org.apache.activemq.protobuf.AsciiBuffer; import org.apache.activemq.protobuf.Buffer; -import org.apache.activemq.queue.QueueStore; import org.apache.activemq.util.ByteArrayOutputStream; import org.apache.activemq.util.ByteSequence; import org.apache.activemq.util.Comparators; /** - * An in memory implementation of the {@link QueueStore} interface. It does not + * An in memory implementation of the {@link Store} interface. It does not * properly roll back operations if an error occurs in the middle of a * transaction and it does not persist changes across restarts. */ Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/Service.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/Service.java?rev=780145&view=auto ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/Service.java (added) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/Service.java Sat May 30 00:07:45 2009 @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq; + + +/** + * The core lifecyle interface for ActiveMQ components. + * + * If there was a standard way to do so, it'd be good to register this + * interface with Spring so it treats the start/stop methods as those of + * {@link org.springframework.beans.factory.InitializingBean} + * and {@link org.springframework.beans.factory.DisposableBean} + * + * @version $Revision: 1.1 $ + */ +public interface Service { + + void start() throws Exception; + + void stop() throws Exception; + +} Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java?rev=780145&view=auto ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java (added) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java Sat May 30 00:07:45 2009 @@ -0,0 +1,100 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.util; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Very similar to the java.io.ByteArrayInputStream but this version is not + * thread safe. + */ +public class ByteArrayInputStream extends InputStream { + + byte buffer[]; + int limit; + int pos; + int mark; + + public ByteArrayInputStream(byte data[]) { + this(data, 0, data.length); + } + + public ByteArrayInputStream(ByteSequence sequence) { + this(sequence.getData(), sequence.getOffset(), sequence.getLength()); + } + + public ByteArrayInputStream(byte data[], int offset, int size) { + this.buffer = data; + this.mark = offset; + this.pos = offset; + this.limit = offset + size; + } + + public int read() throws IOException { + if (pos < limit) { + return buffer[pos++] & 0xff; + } else { + return -1; + } + } + + public int read(byte[] b) throws IOException { + return read(b, 0, b.length); + } + + public int read(byte b[], int off, int len) { + if (pos < limit) { + len = Math.min(len, limit - pos); + if (len > 0) { + System.arraycopy(buffer, pos, b, off, len); + pos += len; + } + return len; + } else { + return -1; + } + } + + public long skip(long len) throws IOException { + if (pos < limit) { + len = Math.min(len, limit - pos); + if (len > 0) { + pos += len; + } + return len; + } else { + return -1; + } + } + + public int available() { + return limit - pos; + } + + public boolean markSupported() { + return true; + } + + public void mark(int markpos) { + mark = pos; + } + + public void reset() { + pos = mark; + } +} Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayOutputStream.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayOutputStream.java?rev=780145&view=auto ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayOutputStream.java (added) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayOutputStream.java Sat May 30 00:07:45 2009 @@ -0,0 +1,82 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.util; + +import java.io.OutputStream; + + +/** + * Very similar to the java.io.ByteArrayOutputStream but this version + * is not thread safe and the resulting data is returned in a ByteSequence + * to avoid an extra byte[] allocation. + */ +public class ByteArrayOutputStream extends OutputStream { + + byte buffer[]; + int size; + + public ByteArrayOutputStream() { + this(1028); + } + public ByteArrayOutputStream(int capacity) { + buffer = new byte[capacity]; + } + + public void write(int b) { + int newsize = size + 1; + checkCapacity(newsize); + buffer[size] = (byte) b; + size = newsize; + } + + public void write(byte b[], int off, int len) { + int newsize = size + len; + checkCapacity(newsize); + System.arraycopy(b, off, buffer, size, len); + size = newsize; + } + + /** + * Ensures the the buffer has at least the minimumCapacity specified. + * @param i + */ + private void checkCapacity(int minimumCapacity) { + if (minimumCapacity > buffer.length) { + byte b[] = new byte[Math.max(buffer.length << 1, minimumCapacity)]; + System.arraycopy(buffer, 0, b, 0, size); + buffer = b; + } + } + + public void reset() { + size = 0; + } + + public ByteSequence toByteSequence() { + return new ByteSequence(buffer, 0, size); + } + + public byte[] toByteArray() { + byte rc[] = new byte[size]; + System.arraycopy(buffer, 0, rc, 0, size); + return rc; + } + + public int size() { + return size; + } +} Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequence.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequence.java?rev=780145&view=auto ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequence.java (added) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequence.java Sat May 30 00:07:45 2009 @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.activemq.util; + +public class ByteSequence { + + public byte[] data; + public int offset; + public int length; + + public ByteSequence(byte data[]) { + this.data = data; + this.offset = 0; + this.length = data.length; + } + + public ByteSequence(byte data[], int offset, int length) { + this.data = data; + this.offset = offset; + this.length = length; + } + + public byte[] getData() { + return data; + } + + public int getLength() { + return length; + } + + public int getOffset() { + return offset; + } + + public void setData(byte[] data) { + this.data = data; + } + + public void setLength(int length) { + this.length = length; + } + + public void setOffset(int offset) { + this.offset = offset; + } + + public void compact() { + if (length != data.length) { + byte t[] = new byte[length]; + System.arraycopy(data, offset, t, 0, length); + data = t; + offset = 0; + } + } + +} Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequenceData.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequenceData.java?rev=780145&view=auto ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequenceData.java (added) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequenceData.java Sat May 30 00:07:45 2009 @@ -0,0 +1,271 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.util; + +import java.io.IOException; + +/** + * Used to write and read primitives to and from a ByteSequence. + */ +public final class ByteSequenceData { + + private ByteSequenceData() { + } + + public static byte[] toByteArray(ByteSequence packet) { + if (packet.offset == 0 && packet.length == packet.data.length) { + return packet.data; + } + + byte rc[] = new byte[packet.length]; + System.arraycopy(packet.data, packet.offset, rc, 0, packet.length); + return rc; + } + + private static void spaceNeeded(ByteSequence packet, int i) { + assert packet.offset + i <= packet.length; + } + + public static int remaining(ByteSequence packet) { + return packet.length - packet.offset; + } + + public static int read(ByteSequence packet) { + return packet.data[packet.offset++] & 0xff; + } + + public static void readFully(ByteSequence packet, byte[] b) throws IOException { + readFully(packet, b, 0, b.length); + } + + public static void readFully(ByteSequence packet, byte[] b, int off, int len) throws IOException { + spaceNeeded(packet, len); + System.arraycopy(packet.data, packet.offset, b, off, len); + packet.offset += len; + } + + public static int skipBytes(ByteSequence packet, int n) throws IOException { + int rc = Math.min(n, remaining(packet)); + packet.offset += rc; + return rc; + } + + public static boolean readBoolean(ByteSequence packet) throws IOException { + spaceNeeded(packet, 1); + return read(packet) != 0; + } + + public static byte readByte(ByteSequence packet) throws IOException { + spaceNeeded(packet, 1); + return (byte)read(packet); + } + + public static int readUnsignedByte(ByteSequence packet) throws IOException { + spaceNeeded(packet, 1); + return read(packet); + } + + public static short readShortBig(ByteSequence packet) throws IOException { + spaceNeeded(packet, 2); + return (short)((read(packet) << 8) + (read(packet) << 0)); + } + + public static short readShortLittle(ByteSequence packet) throws IOException { + spaceNeeded(packet, 2); + return (short)((read(packet) << 0) + (read(packet) << 8)); + } + + public static int readUnsignedShortBig(ByteSequence packet) throws IOException { + spaceNeeded(packet, 2); + return (read(packet) << 8) + (read(packet) << 0); + } + + public static int readUnsignedShortLittle(ByteSequence packet) throws IOException { + spaceNeeded(packet, 2); + return (read(packet) << 0) + (read(packet) << 8); + } + + public static char readCharBig(ByteSequence packet) throws IOException { + spaceNeeded(packet, 2); + return (char)((read(packet) << 8) + (read(packet) << 0)); + } + + public static char readCharLittle(ByteSequence packet) throws IOException { + spaceNeeded(packet, 2); + return (char)((read(packet) << 0) + (read(packet) << 8)); + } + + public static int readIntBig(ByteSequence packet) throws IOException { + spaceNeeded(packet, 4); + return (read(packet) << 24) + (read(packet) << 16) + (read(packet) << 8) + (read(packet) << 0); + } + + public static int readIntLittle(ByteSequence packet) throws IOException { + spaceNeeded(packet, 4); + return (read(packet) << 0) + (read(packet) << 8) + (read(packet) << 16) + (read(packet) << 24); + } + + public static long readLongBig(ByteSequence packet) throws IOException { + spaceNeeded(packet, 8); + return ((long)read(packet) << 56) + ((long)read(packet) << 48) + ((long)read(packet) << 40) + ((long)read(packet) << 32) + ((long)read(packet) << 24) + + ((read(packet)) << 16) + ((read(packet)) << 8) + ((read(packet)) << 0); + } + + public static long readLongLittle(ByteSequence packet) throws IOException { + spaceNeeded(packet, 8); + return (read(packet) << 0) + (read(packet) << 8) + (read(packet) << 16) + ((long)read(packet) << 24) + ((long)read(packet) << 32) + ((long)read(packet) << 40) + + ((long)read(packet) << 48) + ((long)read(packet) << 56); + } + + public static double readDoubleBig(ByteSequence packet) throws IOException { + return Double.longBitsToDouble(readLongBig(packet)); + } + + public static double readDoubleLittle(ByteSequence packet) throws IOException { + return Double.longBitsToDouble(readLongLittle(packet)); + } + + public static float readFloatBig(ByteSequence packet) throws IOException { + return Float.intBitsToFloat(readIntBig(packet)); + } + + public static float readFloatLittle(ByteSequence packet) throws IOException { + return Float.intBitsToFloat(readIntLittle(packet)); + } + + public static void write(ByteSequence packet, int b) throws IOException { + spaceNeeded(packet, 1); + packet.data[packet.offset++] = (byte)b; + } + + public static void write(ByteSequence packet, byte[] b) throws IOException { + write(packet, b, 0, b.length); + } + + public static void write(ByteSequence packet, byte[] b, int off, int len) throws IOException { + spaceNeeded(packet, len); + System.arraycopy(b, off, packet.data, packet.offset, len); + packet.offset += len; + } + + public static void writeBoolean(ByteSequence packet, boolean v) throws IOException { + spaceNeeded(packet, 1); + write(packet, v ? 1 : 0); + } + + public static void writeByte(ByteSequence packet, int v) throws IOException { + spaceNeeded(packet, 1); + write(packet, v); + } + + public static void writeShortBig(ByteSequence packet, int v) throws IOException { + spaceNeeded(packet, 2); + write(packet, (v >>> 8) & 0xFF); + write(packet, (v >>> 0) & 0xFF); + } + + public static void writeShortLittle(ByteSequence packet, int v) throws IOException { + spaceNeeded(packet, 2); + write(packet, (v >>> 0) & 0xFF); + write(packet, (v >>> 8) & 0xFF); + } + + public static void writeCharBig(ByteSequence packet, int v) throws IOException { + spaceNeeded(packet, 2); + write(packet, (v >>> 8) & 0xFF); + write(packet, (v >>> 0) & 0xFF); + } + + public static void writeCharLittle(ByteSequence packet, int v) throws IOException { + spaceNeeded(packet, 2); + write(packet, (v >>> 0) & 0xFF); + write(packet, (v >>> 8) & 0xFF); + } + + public static void writeIntBig(ByteSequence packet, int v) throws IOException { + spaceNeeded(packet, 4); + write(packet, (v >>> 24) & 0xFF); + write(packet, (v >>> 16) & 0xFF); + write(packet, (v >>> 8) & 0xFF); + write(packet, (v >>> 0) & 0xFF); + } + + public static void writeIntLittle(ByteSequence packet, int v) throws IOException { + spaceNeeded(packet, 4); + write(packet, (v >>> 0) & 0xFF); + write(packet, (v >>> 8) & 0xFF); + write(packet, (v >>> 16) & 0xFF); + write(packet, (v >>> 24) & 0xFF); + } + + public static void writeLongBig(ByteSequence packet, long v) throws IOException { + spaceNeeded(packet, 8); + write(packet, (int)(v >>> 56) & 0xFF); + write(packet, (int)(v >>> 48) & 0xFF); + write(packet, (int)(v >>> 40) & 0xFF); + write(packet, (int)(v >>> 32) & 0xFF); + write(packet, (int)(v >>> 24) & 0xFF); + write(packet, (int)(v >>> 16) & 0xFF); + write(packet, (int)(v >>> 8) & 0xFF); + write(packet, (int)(v >>> 0) & 0xFF); + } + + public static void writeLongLittle(ByteSequence packet, long v) throws IOException { + spaceNeeded(packet, 8); + write(packet, (int)(v >>> 0) & 0xFF); + write(packet, (int)(v >>> 8) & 0xFF); + write(packet, (int)(v >>> 16) & 0xFF); + write(packet, (int)(v >>> 24) & 0xFF); + write(packet, (int)(v >>> 32) & 0xFF); + write(packet, (int)(v >>> 40) & 0xFF); + write(packet, (int)(v >>> 48) & 0xFF); + write(packet, (int)(v >>> 56) & 0xFF); + } + + public static void writeDoubleBig(ByteSequence packet, double v) throws IOException { + writeLongBig(packet, Double.doubleToLongBits(v)); + } + + public static void writeDoubleLittle(ByteSequence packet, double v) throws IOException { + writeLongLittle(packet, Double.doubleToLongBits(v)); + } + + public static void writeFloatBig(ByteSequence packet, float v) throws IOException { + writeIntBig(packet, Float.floatToIntBits(v)); + } + + public static void writeFloatLittle(ByteSequence packet, float v) throws IOException { + writeIntLittle(packet, Float.floatToIntBits(v)); + } + + public static void writeRawDoubleBig(ByteSequence packet, double v) throws IOException { + writeLongBig(packet, Double.doubleToRawLongBits(v)); + } + + public static void writeRawDoubleLittle(ByteSequence packet, double v) throws IOException { + writeLongLittle(packet, Double.doubleToRawLongBits(v)); + } + + public static void writeRawFloatBig(ByteSequence packet, float v) throws IOException { + writeIntBig(packet, Float.floatToRawIntBits(v)); + } + + public static void writeRawFloatLittle(ByteSequence packet, float v) throws IOException { + writeIntLittle(packet, Float.floatToRawIntBits(v)); + } + +} Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/FactoryFinder.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/FactoryFinder.java?rev=780145&view=auto ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/FactoryFinder.java (added) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/FactoryFinder.java Sat May 30 00:07:45 2009 @@ -0,0 +1,110 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.util; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +public class FactoryFinder { + + private final String path; + private final ConcurrentHashMap classMap = new ConcurrentHashMap(); + + public FactoryFinder(String path) { + this.path = path; + } + + /** + * Creates a new instance of the given key + * + * @param key is the key to add to the path to find a text file containing + * the factory name + * @return a newly created instance + */ + public Object newInstance(String key) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException { + return newInstance(key, null); + } + + public Object newInstance(String key, String propertyPrefix) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException { + if (propertyPrefix == null) { + propertyPrefix = ""; + } + + Class clazz = classMap.get(propertyPrefix + key); + if (clazz == null) { + clazz = newInstance(doFindFactoryProperies(key), propertyPrefix); + classMap.put(propertyPrefix + key, clazz); + } + return clazz.newInstance(); + } + + private Class newInstance(Properties properties, String propertyPrefix) throws ClassNotFoundException, IOException { + + String className = properties.getProperty(propertyPrefix + "class"); + if (className == null) { + throw new IOException("Expected property is missing: " + propertyPrefix + "class"); + } + Class clazz = null; + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + if (loader != null) { + try { + clazz = loader.loadClass(className); + } catch (ClassNotFoundException e) { + // ignore + } + } + if (clazz == null) { + clazz = FactoryFinder.class.getClassLoader().loadClass(className); + } + + return clazz; + } + + private Properties doFindFactoryProperies(String key) throws IOException { + String uri = path + key; + + // lets try the thread context class loader first + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader == null) { + classLoader = getClass().getClassLoader(); + } + InputStream in = classLoader.getResourceAsStream(uri); + if (in == null) { + in = FactoryFinder.class.getClassLoader().getResourceAsStream(uri); + if (in == null) { + throw new IOException("Could not find factory class for resource: " + uri); + } + } + + // lets load the file + BufferedInputStream reader = null; + try { + reader = new BufferedInputStream(in); + Properties properties = new Properties(); + properties.load(reader); + return properties; + } finally { + try { + reader.close(); + } catch (Exception e) { + } + } + } +} Modified: activemq/sandbox/activemq-flow/pom.xml URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/pom.xml?rev=780145&r1=780144&r2=780145&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/pom.xml (original) +++ activemq/sandbox/activemq-flow/pom.xml Sat May 30 00:07:45 2009 @@ -121,6 +121,7 @@ activemq-transport activemq-util kahadb + activemq-protobuf