[jboss-cvs] JBoss Messaging SVN: r5659 - trunk/src/main/org/jboss/messaging/core/server/impl.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 19 10:10:17 EST 2009
Author: timfox
Date: 2009-01-19 10:10:16 -0500 (Mon, 19 Jan 2009)
New Revision: 5659
Added:
trunk/src/main/org/jboss/messaging/core/server/impl/DivertImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java
Log:
Postoffice, transactions, routing refactoring again
Added: trunk/src/main/org/jboss/messaging/core/server/impl/DivertImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/DivertImpl.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/DivertImpl.java 2009-01-19 15:10:16 UTC (rev 5659)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * 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.server.impl;
+
+import static org.jboss.messaging.core.message.impl.MessageImpl.HDR_ORIGINAL_DESTINATION;
+
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Divert;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.server.cluster.Transformer;
+import org.jboss.messaging.core.transaction.Transaction;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * A DivertImpl simply diverts a message to a different forwardAddress
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ * Created 19 Dec 2008 10:57:49
+ *
+ *
+ */
+public class DivertImpl implements Divert
+{
+ private static final Logger log = Logger.getLogger(DivertImpl.class);
+
+ private final PostOffice postOffice;
+
+ private final SimpleString forwardAddress;
+
+ private final SimpleString uniqueName;
+
+ private final SimpleString routingName;
+
+ private final boolean exclusive;
+
+ private final Filter filter;
+
+ private final Transformer transformer;
+
+ public DivertImpl(final SimpleString forwardAddress,
+ final SimpleString uniqueName,
+ final SimpleString routingName,
+ final boolean exclusive,
+ final Filter filter,
+ final Transformer transformer,
+ final PostOffice postOffice)
+ {
+ this.forwardAddress = forwardAddress;
+
+ this.uniqueName = uniqueName;
+
+ this.routingName = routingName;
+
+ this.exclusive = exclusive;
+
+ this.filter = filter;
+
+ this.transformer = transformer;
+
+ this.postOffice = postOffice;
+ }
+
+ public void route(ServerMessage message, final Transaction tx) throws Exception
+ {
+ SimpleString originalDestination = message.getDestination();
+
+ message.setDestination(forwardAddress);
+
+ message.putStringProperty(HDR_ORIGINAL_DESTINATION, originalDestination);
+
+ if (transformer != null)
+ {
+ message = transformer.transform(message);
+ }
+
+ postOffice.route(message, tx);
+ }
+
+ public boolean accept(final ServerMessage message)
+ {
+ if (filter != null && !filter.match(message))
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ public SimpleString getRoutingName()
+ {
+ return routingName;
+ }
+
+ public SimpleString getUniqueName()
+ {
+ return uniqueName;
+ }
+
+ public boolean isExclusive()
+ {
+ return exclusive;
+ }
+
+
+}
Added: trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java 2009-01-19 15:10:16 UTC (rev 5659)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * 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.server.impl;
+
+import java.util.concurrent.ScheduledExecutorService;
+
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ *
+ * A QueueFactoryImpl
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ *
+ */
+public class QueueFactoryImpl implements QueueFactory
+{
+ private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
+
+ private final ScheduledExecutorService scheduledExecutor;
+
+ /** This is required for delete-all-reference to work correctly with paging, and controlling global-size */
+ private PostOffice postOffice;
+
+ private final StorageManager storageManager;
+
+ public QueueFactoryImpl(final ScheduledExecutorService scheduledExecutor,
+ final HierarchicalRepository<QueueSettings> queueSettingsRepository,
+ final StorageManager storageManager)
+ {
+ this.queueSettingsRepository = queueSettingsRepository;
+
+ this.scheduledExecutor = scheduledExecutor;
+
+ this.storageManager = storageManager;
+ }
+
+ public void setPostOffice(final PostOffice postOffice)
+ {
+ this.postOffice = postOffice;
+ }
+
+ public Queue createQueue(final long persistenceID,
+ final SimpleString name,
+ final Filter filter,
+ final boolean durable,
+ final boolean temporary)
+ {
+ QueueSettings queueSettings = queueSettingsRepository.getMatch(name.toString());
+
+ Queue queue = new QueueImpl(persistenceID,
+ name,
+ filter,
+ durable,
+ temporary,
+ scheduledExecutor,
+ postOffice,
+ storageManager,
+ queueSettingsRepository);
+
+ queue.setDistributionPolicy(queueSettings.getDistributionPolicy());
+
+ return queue;
+ }
+}
More information about the jboss-cvs-commits
mailing list