From 07bcf1792bd28910baaa870f590e2d36b303aa1b Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Fri, 21 Feb 2014 20:15:20 +0000 Subject: QPID-5577 : [Java Broker] create exchanges using an attribute map rather than multiple construction parameters git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1570697 13f79535-47bb-0310-9956-ffa450edef68 --- .../protocol/v0_10/ServerSessionDelegate.java | 25 +++++++++++----------- .../v0_8/handler/ExchangeDeclareHandler.java | 22 +++++++++++++------ 2 files changed, 28 insertions(+), 19 deletions(-) (limited to 'qpid/java/broker-plugins') diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java index 5d36aa5321..c03daf20b3 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java @@ -22,6 +22,7 @@ package org.apache.qpid.server.protocol.v0_10; import java.security.AccessControlException; import java.util.EnumSet; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.UUID; import org.apache.log4j.Logger; @@ -61,13 +62,7 @@ import org.apache.qpid.server.txn.SuspendAndFailDtxException; import org.apache.qpid.server.txn.TimeoutDtxException; import org.apache.qpid.server.txn.UnknownDtxBranchException; import org.apache.qpid.server.util.ServerScopedRuntimeException; -import org.apache.qpid.server.virtualhost.ExchangeExistsException; -import org.apache.qpid.server.virtualhost.ExchangeIsAlternateException; -import org.apache.qpid.server.virtualhost.RequiredExchangeException; -import org.apache.qpid.server.virtualhost.ReservedExchangeNameException; -import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; -import org.apache.qpid.server.virtualhost.QueueExistsException; +import org.apache.qpid.server.virtualhost.*; import org.apache.qpid.transport.*; import java.nio.ByteBuffer; @@ -712,12 +707,16 @@ public class ServerSessionDelegate extends SessionDelegate try { - virtualHost.createExchange(null, - method.getExchange(), - method.getType(), - method.getDurable(), - method.getAutoDelete(), - method.getAlternateExchange()); + Map attributes = new HashMap(); + + attributes.put(org.apache.qpid.server.model.Exchange.ID, null); + attributes.put(org.apache.qpid.server.model.Exchange.NAME, method.getExchange()); + attributes.put(org.apache.qpid.server.model.Exchange.TYPE, method.getType()); + attributes.put(org.apache.qpid.server.model.Exchange.DURABLE, method.getDurable()); + attributes.put(org.apache.qpid.server.model.Exchange.LIFETIME_POLICY, + method.getAutoDelete() ? LifetimePolicy.DELETE_ON_NO_LINKS : LifetimePolicy.PERMANENT); + attributes.put(org.apache.qpid.server.model.Exchange.ALTERNATE_EXCHANGE, method.getAlternateExchange()); + virtualHost.createExchange(attributes); } catch(ReservedExchangeNameException e) { diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java index 87622b88e7..9446f53188 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java @@ -30,17 +30,21 @@ import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.ExchangeDeclareBody; import org.apache.qpid.framing.MethodRegistry; import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.protocol.v0_8.AMQChannel; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.virtualhost.AbstractVirtualHost; import org.apache.qpid.server.virtualhost.ExchangeExistsException; import org.apache.qpid.server.virtualhost.ReservedExchangeNameException; import org.apache.qpid.server.virtualhost.UnknownExchangeException; import org.apache.qpid.server.virtualhost.VirtualHost; import java.security.AccessControlException; +import java.util.HashMap; +import java.util.Map; public class ExchangeDeclareHandler implements StateAwareMethodListener { @@ -95,12 +99,18 @@ public class ExchangeDeclareHandler implements StateAwareMethodListener attributes = new HashMap(); + + attributes.put(org.apache.qpid.server.model.Exchange.ID, null); + attributes.put(org.apache.qpid.server.model.Exchange.NAME,name); + attributes.put(org.apache.qpid.server.model.Exchange.TYPE,type); + attributes.put(org.apache.qpid.server.model.Exchange.DURABLE, body.getDurable()); + attributes.put(org.apache.qpid.server.model.Exchange.LIFETIME_POLICY, + body.getAutoDelete() ? LifetimePolicy.DELETE_ON_NO_LINKS : LifetimePolicy.PERMANENT); + attributes.put(org.apache.qpid.server.model.Exchange.ALTERNATE_EXCHANGE, null); + exchange = virtualHost.createExchange(attributes); } catch(ReservedExchangeNameException e) -- cgit v1.2.1