diff options
94 files changed, 399 insertions, 782 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java index a533c0bc75..38542fce42 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java @@ -25,7 +25,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.UUID; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; @@ -59,34 +58,9 @@ public class BindingImpl final CopyOnWriteArrayList<StateChangeListener<BindingImpl,State>> _stateChangeListeners = new CopyOnWriteArrayList<StateChangeListener<BindingImpl, State>>(); - - public BindingImpl(UUID id, - final String bindingKey, - final AMQQueue queue, - final ExchangeImpl exchange, - final Map<String, Object> arguments) - { - this(id, convertToAttributes(bindingKey, arguments), queue, exchange); - } - - private static Map<String, Object> convertToAttributes(final String bindingKey, final Map<String, Object> arguments) - { - Map<String, Object> attributes = new HashMap<String, Object>(); - attributes.put(org.apache.qpid.server.model.Binding.NAME,bindingKey); - if(arguments != null) - { - attributes.put(org.apache.qpid.server.model.Binding.ARGUMENTS, arguments); - } - return attributes; - } - - public BindingImpl(UUID id, Map<String, Object> attributes, AMQQueue queue, ExchangeImpl exchange) - { - this(enhanceWithDurable(combineIdWithAttributes(id,attributes), queue, exchange), queue, exchange); - } public BindingImpl(Map<String, Object> attributes, AMQQueue queue, ExchangeImpl exchange) { - super(parentsMap(queue,exchange),attributes,queue.getVirtualHost().getTaskExecutor()); + super(parentsMap(queue,exchange),enhanceWithDurable(attributes,queue,exchange),queue.getVirtualHost().getTaskExecutor()); _bindingKey = (String)attributes.get(org.apache.qpid.server.model.Binding.NAME); _queue = queue; _exchange = exchange; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java index 4f1643967e..80f3ce930a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java @@ -48,6 +48,7 @@ import org.apache.qpid.server.message.MessageInstance; import org.apache.qpid.server.message.MessageReference; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.AbstractConfiguredObject; +import org.apache.qpid.server.model.Binding; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.Exchange; import org.apache.qpid.server.model.LifetimePolicy; @@ -107,7 +108,7 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> private StateChangeListener<BindingImpl, State> _bindingListener; - public AbstractExchange(VirtualHostImpl vhost, Map<String, Object> attributes) throws UnknownExchangeException + public AbstractExchange(Map<String, Object> attributes, VirtualHostImpl vhost) throws UnknownExchangeException { super(parentsMap(vhost), attributes, vhost.getTaskExecutor()); _virtualHost = vhost; @@ -691,13 +692,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> id = UUID.randomUUID(); } - Map<String,Object> attributes = new HashMap<String, Object>(); - attributes.put(org.apache.qpid.server.model.Binding.NAME,bindingKey); - if(arguments != null) - { - attributes.put(org.apache.qpid.server.model.Binding.ARGUMENTS, arguments); - } - BindingImpl existingMapping; synchronized(this) { @@ -706,7 +700,13 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> if (existingMapping == null) { - BindingImpl b = new BindingImpl(id, attributes, queue, this); + + Map<String,Object> attributes = new HashMap<String, Object>(); + attributes.put(Binding.NAME,bindingKey); + attributes.put(Binding.ID, id); + attributes.put(Binding.ARGUMENTS, arguments); + + BindingImpl b = new BindingImpl(attributes, queue, this); b.create(); addBinding(b); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java index 7b011f6cc1..7e408bd1c2 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java @@ -138,10 +138,9 @@ public class DirectExchange extends AbstractExchange<DirectExchange> public static final ExchangeType<DirectExchange> TYPE = new DirectExchangeType(); - public DirectExchange(final VirtualHostImpl vhost, - final Map<String, Object> attributes) throws UnknownExchangeException + public DirectExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost) throws UnknownExchangeException { - super(vhost, attributes); + super(attributes, vhost); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeFactory.java index c5deb7e3b3..149fc36f1c 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeFactory.java @@ -42,7 +42,7 @@ public class DirectExchangeFactory extends AbstractConfiguredObjectTypeFactory<D { throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); } - return new DirectExchange((VirtualHostImpl<?, ?, ?>)virtualHost , attributes); + return new DirectExchange(attributes, (VirtualHostImpl<?, ?, ?>)virtualHost); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java index 3f480af607..887a5ec28e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java @@ -39,7 +39,7 @@ public class DirectExchangeType implements ExchangeType<DirectExchange> public DirectExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) throws UnknownExchangeException { - return new DirectExchange(virtualHost, attributes); + return new DirectExchange(attributes, virtualHost); } public String getDefaultExchangeName() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java index 97c2ebe5e3..fd6eb8e410 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java @@ -68,10 +68,9 @@ public class FanoutExchange extends AbstractExchange<FanoutExchange> public static final ExchangeType<FanoutExchange> TYPE = new FanoutExchangeType(); - public FanoutExchange(final VirtualHostImpl vhost, - final Map<String, Object> attributes) throws UnknownExchangeException + public FanoutExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost) throws UnknownExchangeException { - super(vhost, attributes); + super(attributes, vhost); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeFactory.java index 5884776778..e8fa3564ee 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeFactory.java @@ -42,7 +42,7 @@ public class FanoutExchangeFactory extends AbstractConfiguredObjectTypeFactory<F { throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); } - return new FanoutExchange((VirtualHostImpl<?, ?, ?>)virtualHost , attributes); + return new FanoutExchange(attributes, (VirtualHostImpl<?, ?, ?>)virtualHost); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java index c66ea9eefb..d513c25e9f 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java @@ -39,7 +39,7 @@ public class FanoutExchangeType implements ExchangeType<FanoutExchange> public FanoutExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) throws UnknownExchangeException { - return new FanoutExchange(virtualHost, attributes); + return new FanoutExchange(attributes, virtualHost); } public String getDefaultExchangeName() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java index 10dd33dee1..45c484690e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java @@ -83,10 +83,9 @@ public class HeadersExchange extends AbstractExchange<HeadersExchange> public static final ExchangeType<HeadersExchange> TYPE = new HeadersExchangeType(); - public HeadersExchange(final VirtualHostImpl vhost, - final Map<String, Object> attributes) throws UnknownExchangeException + public HeadersExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost) throws UnknownExchangeException { - super(vhost, attributes); + super(attributes, vhost); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeFactory.java index b3f9834889..cbe7d9c612 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeFactory.java @@ -42,7 +42,7 @@ public class HeadersExchangeFactory extends AbstractConfiguredObjectTypeFactory< { throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); } - return new HeadersExchange((VirtualHostImpl<?, ?, ?>)virtualHost , attributes); + return new HeadersExchange(attributes, (VirtualHostImpl<?, ?, ?>)virtualHost); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java index d0056416cc..b401132ade 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java @@ -39,7 +39,7 @@ public class HeadersExchangeType implements ExchangeType<HeadersExchange> public HeadersExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) throws UnknownExchangeException { - return new HeadersExchange(virtualHost, attributes); + return new HeadersExchange(attributes, virtualHost); } public String getDefaultExchangeName() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java index 683b7b1aa4..d46ea44239 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java @@ -61,9 +61,9 @@ public class TopicExchange extends AbstractExchange<TopicExchange> private final Map<BindingImpl, Map<String,Object>> _bindings = new HashMap<BindingImpl, Map<String,Object>>(); - public TopicExchange(final VirtualHostImpl vhost, final Map attributes) throws UnknownExchangeException + public TopicExchange(final Map<String,Object> attributes, final VirtualHostImpl vhost) throws UnknownExchangeException { - super(vhost, attributes); + super(attributes, vhost); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeFactory.java index 550377a02f..ef9c850fc9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeFactory.java @@ -42,7 +42,7 @@ public class TopicExchangeFactory extends AbstractConfiguredObjectTypeFactory<To { throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); } - return new TopicExchange((VirtualHostImpl<?, ?, ?>)virtualHost , attributes); + return new TopicExchange(attributes, (VirtualHostImpl<?, ?, ?>)virtualHost); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java index 12274f951e..a7de341430 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java @@ -39,7 +39,7 @@ public class TopicExchangeType implements ExchangeType<TopicExchange> public TopicExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) throws UnknownExchangeException { - return new TopicExchange(virtualHost, attributes); + return new TopicExchange(attributes, virtualHost); } public String getDefaultExchangeName() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java index c2be3ee3cf..4789da7126 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java @@ -153,13 +153,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im @ManagedAttributeField private String _type; - protected static Map<String,Object> combineIdWithAttributes(UUID id, Map<String,Object> attributes) - { - Map<String,Object> combined = new HashMap<String, Object>(attributes); - combined.put(ID, id); - return combined; - } - protected static Map<Class<? extends ConfiguredObject>, ConfiguredObject<?>> parentsMap(ConfiguredObject<?>... parents) { final Map<Class<? extends ConfiguredObject>, ConfiguredObject<?>> parentsMap = diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java index 6d04a9d2eb..68ca0f76c6 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java @@ -62,7 +62,7 @@ public class SystemContextImpl extends AbstractConfiguredObject<SystemContextImp final BrokerOptions brokerOptions) { super(parentsMap(), - combineIdWithAttributes(SYSTEM_ID, createAttributes(brokerOptions)), + createAttributes(brokerOptions), taskExecutor); _eventLogger = eventLogger; getTaskExecutor().start(); @@ -75,6 +75,7 @@ public class SystemContextImpl extends AbstractConfiguredObject<SystemContextImp public static Map<String, Object> createAttributes(final BrokerOptions brokerOptions) { Map<String,Object> attributes = new HashMap<String, Object>(); + attributes.put(ID, SYSTEM_ID); attributes.put(NAME, "System"); attributes.put("storePath", brokerOptions.getConfigurationStoreLocation()); attributes.put("storeTye", brokerOptions.getConfigurationStoreType()); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java index dfb1514e9c..68e1f9d7f2 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java @@ -25,7 +25,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Set; -import java.util.UUID; import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.Broker; @@ -38,10 +37,10 @@ public abstract class AbstractPluginAdapter<X extends Plugin<X>> extends Abstrac { private Broker _broker; - protected AbstractPluginAdapter(UUID id, Map<String, Object> attributes, Broker broker) + protected AbstractPluginAdapter(Map<String, Object> attributes, Broker broker) { super(parentsMap(broker), - combineIdWithAttributes(id, attributes), broker.getTaskExecutor()); + attributes, broker.getTaskExecutor()); _broker = broker; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java index d0b4809303..c9954467e4 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java @@ -20,7 +20,6 @@ */ package org.apache.qpid.server.model.adapter; -import java.lang.reflect.Type; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.security.AccessControlException; @@ -59,7 +58,6 @@ import org.apache.qpid.server.security.access.Operation; import org.apache.qpid.server.security.auth.manager.SimpleAuthenticationManager; import org.apache.qpid.server.stats.StatisticsCounter; import org.apache.qpid.server.stats.StatisticsGatherer; -import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.server.virtualhost.VirtualHostRegistry; import org.apache.qpid.util.SystemUtils; @@ -70,22 +68,6 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private static final Pattern MODEL_VERSION_PATTERN = Pattern.compile("^\\d+\\.\\d+$"); - @SuppressWarnings("serial") - public static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>(){{ - - put(STATISTICS_REPORTING_RESET_ENABLED, Boolean.class); - - put(CONNECTION_SESSION_COUNT_LIMIT, Integer.class); - put(CONNECTION_HEART_BEAT_DELAY, Integer.class); - put(CONNECTION_CLOSE_WHEN_NO_ROUTE, Boolean.class); - put(STATISTICS_REPORTING_PERIOD, Integer.class); - - put(NAME, String.class); - put(DEFAULT_VIRTUAL_HOST, String.class); - - put(MODEL_VERSION, String.class); - put(STORE_VERSION, String.class); - }}); public static final String MANAGEMENT_MODE_AUTHENTICATION = "MANAGEMENT_MODE_AUTHENTICATION"; private final ConfiguredObjectFactory _objectFactory; @@ -132,12 +114,11 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private boolean _statisticsReportingResetEnabled; - public BrokerAdapter(UUID id, - Map<String, Object> attributes, + public BrokerAdapter(Map<String, Object> attributes, SystemContext parent) { super(parentsMap(parent), - combineIdWithAttributes(id, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES)), + attributes, parent.getTaskExecutor()); _objectFactory = parent.getObjectFactory(); @@ -153,7 +134,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple Map<String,Object> authManagerAttrs = new HashMap<String, Object>(); authManagerAttrs.put(NAME,"MANAGEMENT_MODE_AUTHENTICATION"); authManagerAttrs.put(ID, UUID.randomUUID()); - SimpleAuthenticationManager authManager = new SimpleAuthenticationManager(this, authManagerAttrs); + SimpleAuthenticationManager authManager = new SimpleAuthenticationManager(authManagerAttrs, this); authManager.addUser(BrokerOptions.MANAGEMENT_MODE_USER_NAME, _brokerOptions.getManagementModePassword()); _managementModeAuthenticationProvider = authManager; } @@ -204,6 +185,32 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple { throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); } + Broker updated = (Broker) proxyForValidation; + if (changedAttributes.contains(MODEL_VERSION) && !Model.MODEL_VERSION.equals(updated.getModelVersion())) + { + throw new IllegalConfigurationException("Cannot change the model version"); + } + + String defaultVirtualHost = updated.getDefaultVirtualHost(); + if (defaultVirtualHost != null) + { + VirtualHost foundHost = findVirtualHostByName(defaultVirtualHost); + if (foundHost == null) + { + throw new IllegalConfigurationException("Virtual host with name " + defaultVirtualHost + + " cannot be set as a default as it does not exist"); + } + } + + for (String attributeName : POSITIVE_NUMERIC_ATTRIBUTES) + { + Number value = (Number) updated.getAttribute(attributeName); + if (value != null && value.longValue() < 0) + { + throw new IllegalConfigurationException("Only positive integer value can be specified for the attribute " + + attributeName); + } + } } protected void onOpen() @@ -1115,44 +1122,6 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple } @Override - protected void changeAttributes(Map<String, Object> attributes) - { - Map<String, Object> convertedAttributes = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES); - validateAttributes(convertedAttributes); - - super.changeAttributes(convertedAttributes); - } - - private void validateAttributes(Map<String, Object> convertedAttributes) - { - if (convertedAttributes.containsKey(MODEL_VERSION) && !Model.MODEL_VERSION.equals(convertedAttributes.get(MODEL_VERSION))) - { - throw new IllegalConfigurationException("Cannot change the model version"); - } - - String defaultVirtualHost = (String) convertedAttributes.get(DEFAULT_VIRTUAL_HOST); - if (defaultVirtualHost != null) - { - VirtualHost foundHost = findVirtualHostByName(defaultVirtualHost); - if (foundHost == null) - { - throw new IllegalConfigurationException("Virtual host with name " + defaultVirtualHost - + " cannot be set as a default as it does not exist"); - } - } - - for (String attributeName : POSITIVE_NUMERIC_ATTRIBUTES) - { - Number value = (Number) convertedAttributes.get(attributeName); - if (value != null && value.longValue() < 0) - { - throw new IllegalConfigurationException("Only positive integer value can be specified for the attribute " - + attributeName); - } - } - } - - @Override protected <C extends ConfiguredObject> void authoriseCreateChild(Class<C> childClass, Map<String, Object> attributes, ConfiguredObject... otherParents) throws AccessControlException { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java index ca28aa1a68..5e07a13c41 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java @@ -20,9 +20,7 @@ */ package org.apache.qpid.server.model.adapter; -import java.util.HashMap; import java.util.Map; -import java.util.UUID; import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; import org.apache.qpid.server.model.ConfiguredObject; @@ -39,10 +37,7 @@ public class BrokerAdapterFactory extends AbstractConfiguredObjectTypeFactory<B public BrokerAdapter createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { SystemContext context = getParent(SystemContext.class, parents); - Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(ConfiguredObject.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new BrokerAdapter(id, attributesWithoutId, context); + return new BrokerAdapter(attributes, context); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java index 10673596a3..8f6d96ec79 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java @@ -39,10 +39,7 @@ public class FileBasedGroupProviderFactory extends AbstractConfiguredObjectTypeF public FileBasedGroupProviderImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(ConfiguredObject.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new FileBasedGroupProviderImpl(id, getParent(Broker.class, parents), attributesWithoutId); + return new FileBasedGroupProviderImpl(attributes, getParent(Broker.class, parents)); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java index ae2c412077..db60a5b0fe 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java @@ -68,12 +68,11 @@ public class FileBasedGroupProviderImpl @ManagedAttributeField private String _path; - public FileBasedGroupProviderImpl(UUID id, - Broker broker, - Map<String, Object> attributes) + public FileBasedGroupProviderImpl(Map<String, Object> attributes, + Broker broker) { super(parentsMap(broker), - combineIdWithAttributes(id, attributes), broker.getTaskExecutor()); + attributes, broker.getTaskExecutor()); _broker = broker; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java index 18f1884778..14f017ac7a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java @@ -44,6 +44,6 @@ public class FileSystemPreferencesProviderFactory extends AbstractConfiguredObje Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); Object idObj = attributesWithoutId.remove(ConfiguredObject.ID); UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new FileSystemPreferencesProviderImpl(id, attributesWithoutId, getParent(AuthenticationProvider.class,parents)); + return new FileSystemPreferencesProviderImpl(attributes, getParent(AuthenticationProvider.class,parents)); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java index bdff1521b4..c955d8d370 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java @@ -25,7 +25,6 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; -import java.lang.reflect.Type; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; @@ -38,7 +37,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.TreeMap; -import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; import org.apache.log4j.Logger; @@ -64,14 +62,6 @@ public class FileSystemPreferencesProviderImpl { private static final Logger LOGGER = Logger.getLogger(FileSystemPreferencesProviderImpl.class); - - @SuppressWarnings("serial") - private static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>() - {{ - put(NAME, String.class); - put(PATH, String.class); - }}); - private final AuthenticationProvider<? extends AuthenticationProvider> _authenticationProvider; private AtomicReference<State> _state; @@ -82,11 +72,11 @@ public class FileSystemPreferencesProviderImpl private boolean _open; - public FileSystemPreferencesProviderImpl(UUID id, Map<String, Object> attributes, + public FileSystemPreferencesProviderImpl(Map<String, Object> attributes, AuthenticationProvider<? extends AuthenticationProvider> authenticationProvider) { super(parentsMap(authenticationProvider), - combineIdWithAttributes(id,MapValueConverter.convert(attributes, ATTRIBUTE_TYPES)), + attributes, authenticationProvider.getParent(Broker.class).getTaskExecutor()); State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING); _state = new AtomicReference<State>(state); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java index 94c6276c77..45b02c7ab3 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java @@ -30,15 +30,25 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; -import org.apache.qpid.server.model.*; +import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.model.AbstractConfiguredObject; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.Connection; +import org.apache.qpid.server.model.KeyStore; +import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.Port; +import org.apache.qpid.server.model.Protocol; +import org.apache.qpid.server.model.State; +import org.apache.qpid.server.model.Transport; +import org.apache.qpid.server.model.TrustStore; +import org.apache.qpid.server.model.VirtualHost; +import org.apache.qpid.server.model.VirtualHostAlias; import org.apache.qpid.server.security.access.Operation; import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.server.util.ParameterizedTypeImpl; -import org.apache.qpid.server.configuration.IllegalConfigurationException; -import org.apache.qpid.server.configuration.updater.TaskExecutor; abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractConfiguredObject<X> implements Port<X> { @@ -83,20 +93,20 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo @ManagedAttributeField private Set<Protocol> _protocols; - public AbstractPort(UUID id, - Broker<?> broker, - Map<String, Object> attributes, - TaskExecutor taskExecutor) + public AbstractPort(Map<String, Object> attributes, + Broker<?> broker) { super(parentsMap(broker), - combineIdWithAttributes(id,attributes), - taskExecutor); + attributes, + broker.getTaskExecutor()); + _broker = broker; State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING); _state = new AtomicReference<State>(state); } + @Override public void validate() { @@ -123,6 +133,52 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo { throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); } + Port<?> updated = (Port<?>)proxyForValidation; + + + if(!getName().equals(updated.getName())) + { + throw new IllegalConfigurationException("Changing the port name is not allowed"); + } + + if(changedAttributes.contains(PORT)) + { + int newPort = updated.getPort(); + if (getPort() != newPort) + { + for (Port p : _broker.getPorts()) + { + if (p.getPort() == newPort) + { + throw new IllegalConfigurationException("Port number " + + newPort + + " is already in use by port " + + p.getName()); + } + } + } + } + + + Collection<Transport> transports = updated.getTransports(); + + Collection<Protocol> protocols = updated.getProtocols(); + + + boolean usesSsl = transports != null && transports.contains(Transport.SSL); + if (usesSsl) + { + if (updated.getKeyStore() == null) + { + throw new IllegalConfigurationException("Can't create port which requires SSL but has no key store configured."); + } + } + + if (protocols != null && protocols.contains(Protocol.RMI) && usesSsl) + { + throw new IllegalConfigurationException("Can't create RMI Registry port which requires SSL."); + } + } @Override @@ -317,125 +373,6 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo @Override - protected void changeAttributes(Map<String, Object> attributes) - { - Map<String, Object> converted = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES); - - Map<String, Object> merged = generateEffectiveAttributes(converted); - - String newName = (String) merged.get(NAME); - if(!getName().equals(newName)) - { - throw new IllegalConfigurationException("Changing the port name is not allowed"); - } - - if(converted.containsKey(PORT)) - { - Integer newPort = (Integer) merged.get(PORT); - if (getPort() != newPort) - { - for (Port p : _broker.getPorts()) - { - if (p.getPort() == newPort) - { - throw new IllegalConfigurationException("Port number " - + newPort - + " is already in use by port " - + p.getName()); - } - } - } - } - - @SuppressWarnings("unchecked") - Collection<Transport> transports = (Collection<Transport>)merged.get(TRANSPORTS); - @SuppressWarnings("unchecked") - Collection<Protocol> protocols = (Collection<Protocol>)merged.get(PROTOCOLS); - Boolean needClientCertificate = (Boolean)merged.get(NEED_CLIENT_AUTH); - Boolean wantClientCertificate = (Boolean)merged.get(WANT_CLIENT_AUTH); - boolean requiresCertificate = (needClientCertificate != null && needClientCertificate.booleanValue()) - || (wantClientCertificate != null && wantClientCertificate.booleanValue()); - - String keyStoreName = (String) merged.get(KEY_STORE); - if(keyStoreName != null) - { - if (_broker.findKeyStoreByName(keyStoreName) == null) - { - throw new IllegalConfigurationException("Can't find key store with name '" + keyStoreName + "' for port " + getName()); - } - } - - Collection<String> trustStoreNames = (Collection<String>) merged.get(TRUST_STORES); - boolean hasTrustStore = trustStoreNames != null && !trustStoreNames.isEmpty(); - if(hasTrustStore) - { - for (String trustStoreName : trustStoreNames) - { - if (_broker.findTrustStoreByName(trustStoreName) == null) - { - throw new IllegalConfigurationException("Cannot find trust store with name '" + trustStoreName + "'"); - } - } - } - - boolean usesSsl = transports != null && transports.contains(Transport.SSL); - if (usesSsl) - { - if (keyStoreName == null) - { - throw new IllegalConfigurationException("Can't create port which requires SSL but has no key store configured."); - } - - if (!hasTrustStore && requiresCertificate) - { - throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but has no trust store configured."); - } - } - else - { - if (requiresCertificate) - { - throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but doesn't use SSL transport."); - } - } - - if (protocols != null && protocols.contains(Protocol.RMI) && usesSsl) - { - throw new IllegalConfigurationException("Can't create RMI Registry port which requires SSL."); - } - - String authenticationProviderName = (String)merged.get(AUTHENTICATION_PROVIDER); - if (authenticationProviderName != null) - { - Collection<AuthenticationProvider<?>> providers = _broker.getAuthenticationProviders(); - AuthenticationProvider<?> provider = null; - for (AuthenticationProvider<?> p : providers) - { - if (p.getName().equals(authenticationProviderName)) - { - provider = p; - break; - } - } - - if (provider == null) - { - throw new IllegalConfigurationException("Cannot find authentication provider with name '" - + authenticationProviderName + "'"); - } - } - else - { - if (protocols != null && !protocols.contains(Protocol.RMI)) - { - throw new IllegalConfigurationException("An authentication provider must be specified"); - } - } - - super.changeAttributes(attributes); - } - - @Override protected void authoriseSetDesiredState(State currentState, State desiredState) throws AccessControlException { if(desiredState == State.DELETED) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPortWithAuthProvider.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPortWithAuthProvider.java index db3d9897c7..3c1b649b51 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPortWithAuthProvider.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPortWithAuthProvider.java @@ -21,13 +21,14 @@ package org.apache.qpid.server.model.port; import java.util.Map; -import java.util.UUID; +import java.util.Set; import org.apache.qpid.server.configuration.IllegalConfigurationException; -import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.Transport; abstract public class AbstractPortWithAuthProvider<X extends AbstractPortWithAuthProvider<X>> extends AbstractPort<X> @@ -44,13 +45,10 @@ abstract public class AbstractPortWithAuthProvider<X extends AbstractPortWithAut @ManagedAttributeField private boolean _wantClientAuth; - public AbstractPortWithAuthProvider(final UUID id, - final Broker<?> broker, - final Map<String, Object> attributes, - final Map<String, Object> defaults, - final TaskExecutor taskExecutor) + public AbstractPortWithAuthProvider(final Map<String, Object> attributes, + final Broker<?> broker) { - super(id, broker, attributes, taskExecutor); + super(attributes, broker); } public boolean getNeedClientAuth() @@ -92,4 +90,35 @@ abstract public class AbstractPortWithAuthProvider<X extends AbstractPortWithAut } } + + + @Override + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + Port<?> updated = (Port<?>)proxyForValidation; + + boolean needClientCertificate = (Boolean) updated.getAttribute(NEED_CLIENT_AUTH); + boolean wantClientCertificate = (Boolean) updated.getAttribute(WANT_CLIENT_AUTH); + boolean requiresCertificate = needClientCertificate || wantClientCertificate; + + boolean usesSsl = updated.getTransports().contains(Transport.SSL); + if (usesSsl) + { + if ((updated.getTrustStores() == null || updated.getTrustStores().isEmpty() ) && requiresCertificate) + { + throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but has no trust store configured."); + } + } + else + { + if (requiresCertificate) + { + throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but doesn't use SSL transport."); + } + } + + + + } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java index cdb8b8c7cb..d1e67c9c3f 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java @@ -20,14 +20,11 @@ */ package org.apache.qpid.server.model.port; -import java.util.HashMap; import java.util.Map; -import java.util.UUID; import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.Port; public class AmqpPortFactory extends AbstractConfiguredObjectTypeFactory<AmqpPortImpl> { @@ -40,11 +37,7 @@ public class AmqpPortFactory extends AbstractConfiguredObjectTypeFactory<AmqpPor public AmqpPortImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { Broker broker = getParent(Broker.class, parents); - Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(Port.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - - return new AmqpPortImpl(id, broker, attributesWithoutId, broker.getTaskExecutor()); + return new AmqpPortImpl(attributes, broker); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java index 7e496c97ed..8c6744fbf2 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java @@ -22,12 +22,10 @@ package org.apache.qpid.server.model.port; import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.UUID; import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; @@ -36,7 +34,6 @@ import javax.net.ssl.X509TrustManager; import org.apache.qpid.server.configuration.BrokerProperties; import org.apache.qpid.server.configuration.IllegalConfigurationException; -import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.logging.messages.BrokerMessages; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.KeyStore; @@ -68,12 +65,9 @@ public class AmqpPortImpl extends AbstractPortWithAuthProvider<AmqpPortImpl> imp private final Broker<?> _broker; private AcceptingTransport _transport; - public AmqpPortImpl(UUID id, - Broker<?> broker, - Map<String, Object> attributes, - TaskExecutor taskExecutor) + public AmqpPortImpl(Map<String, Object> attributes, Broker<?> broker) { - super(id, broker, attributes, Collections.<String,Object>emptyMap(), taskExecutor); + super(attributes, broker); _broker = broker; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java index ec849c8b48..0cfd37ffa0 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java @@ -40,10 +40,7 @@ public class HttpPortFactory extends AbstractConfiguredObjectTypeFactory<HttpPor public HttpPortImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { Broker broker = getParent(Broker.class, parents); - Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(Port.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new HttpPortImpl(id, broker, attributesWithoutId, broker.getTaskExecutor()); + return new HttpPortImpl(attributes, broker); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java index 654156f782..47185659a7 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java @@ -23,20 +23,16 @@ package org.apache.qpid.server.model.port; import java.util.Collections; import java.util.Map; import java.util.Set; -import java.util.UUID; -import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.Protocol; public class HttpPortImpl extends AbstractPortWithAuthProvider<HttpPortImpl> implements HttpPort<HttpPortImpl> { - public HttpPortImpl(final UUID id, - final Broker<?> broker, - final Map<String, Object> attributes, - final TaskExecutor taskExecutor) + public HttpPortImpl(final Map<String, Object> attributes, + final Broker<?> broker) { - super(id, broker, attributes, Collections.<String,Object>emptyMap(), taskExecutor); + super(attributes, broker); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java index dd47965dcc..bb1b94f57d 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java @@ -40,10 +40,7 @@ public class JmxPortFactory extends AbstractConfiguredObjectTypeFactory<JmxPortI public JmxPortImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { Broker broker = getParent(Broker.class, parents); - Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(Port.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new JmxPortImpl(id, broker, attributesWithoutId, broker.getTaskExecutor()); + return new JmxPortImpl(attributes, broker); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortImpl.java index 78a4b824cb..f908b1818e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortImpl.java @@ -23,20 +23,16 @@ package org.apache.qpid.server.model.port; import java.util.Collections; import java.util.Map; import java.util.Set; -import java.util.UUID; -import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.Protocol; public class JmxPortImpl extends AbstractPortWithAuthProvider<JmxPortImpl> implements JmxPort<JmxPortImpl> { - public JmxPortImpl(final UUID id, - final Broker<?> broker, - final Map<String, Object> attributes, - final TaskExecutor taskExecutor) + public JmxPortImpl(final Map<String, Object> attributes, + final Broker<?> broker) { - super(id, broker, attributes, Collections.<String,Object>emptyMap(), taskExecutor); + super(attributes, broker); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java index fd8e680bef..c8a9270f1e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java @@ -140,15 +140,6 @@ public class PortFactory<X extends Port<X>> implements ConfiguredObjectTypeFacto return _configuredObjectFactory.getConfiguredObjectTypeFactory(Port.class.getSimpleName(), type); } - private Broker getBroker(final ConfiguredObject<?>[] parents) - { - if(parents.length != 1 || !(parents[0] instanceof Broker)) - { - throw new IllegalConfigurationException("Port should have exactly one parent, of type Broker"); - } - return (Broker<?>) parents[0]; - } - @Override public String getType() { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPort.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPort.java index c58fc1d344..69a61b3c12 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPort.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPort.java @@ -23,10 +23,8 @@ package org.apache.qpid.server.model.port; import java.util.Collections; import java.util.Map; import java.util.Set; -import java.util.UUID; import org.apache.qpid.server.configuration.IllegalConfigurationException; -import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.Protocol; @@ -35,12 +33,10 @@ import org.apache.qpid.server.model.Transport; @ManagedObject( category = false, type = "RMI") public class RmiPort extends AbstractPort<RmiPort> { - public RmiPort(final UUID id, - final Broker<?> broker, - final Map<String, Object> attributes, - final TaskExecutor taskExecutor) + public RmiPort(final Map<String, Object> attributes, + final Broker<?> broker) { - super(id, broker, attributes, taskExecutor); + super(attributes, broker); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java index 69d2ebfc19..f234ea3ba7 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java @@ -40,10 +40,7 @@ public class RmiPortFactory extends AbstractConfiguredObjectTypeFactory<RmiPort> public RmiPort createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { Broker broker = getParent(Broker.class, parents); - Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(Port.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new RmiPort(id, broker, attributesWithoutId, broker.getTaskExecutor()); + return new RmiPort(attributes, broker); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java index faa44b2288..e637701d60 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java @@ -228,8 +228,7 @@ public abstract class AbstractQueue<X extends AbstractQueue<X>> @ManagedAttributeField private int _maximumDistinctGroups; - protected AbstractQueue(VirtualHostImpl virtualHost, - Map<String, Object> attributes) + protected AbstractQueue(Map<String, Object> attributes, VirtualHostImpl virtualHost) { super(parentsMap(virtualHost), attributes, virtualHost.getTaskExecutor()); @@ -309,11 +308,6 @@ public abstract class AbstractQueue<X extends AbstractQueue<X>> Map<String,Object> attributes = getActualAttributes(); - _exclusive = MapValueConverter.getEnumAttribute(ExclusivityPolicy.class, - Queue.EXCLUSIVE, - attributes, - ExclusivityPolicy.NONE); - final LinkedHashMap<String, Object> arguments = new LinkedHashMap<String, Object>(attributes); arguments.put(Queue.EXCLUSIVE, _exclusive); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueFactory.java index 2e34d0fc3e..ee2edf7961 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueFactory.java @@ -43,6 +43,6 @@ public class LastValueQueueFactory extends AbstractConfiguredObjectTypeFactory<L throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); } - return new LastValueQueueImpl((VirtualHostImpl<?,?,?>)virtualHost,attributes); + return new LastValueQueueImpl(attributes, (VirtualHostImpl<?,?,?>)virtualHost); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueImpl.java index d888637d80..b1dff03329 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueImpl.java @@ -34,10 +34,9 @@ public class LastValueQueueImpl extends AbstractQueue<LastValueQueueImpl> implem private String _lvqKey; - public LastValueQueueImpl(VirtualHostImpl virtualHost, - Map<String, Object> attributes) + public LastValueQueueImpl(Map<String, Object> attributes, VirtualHostImpl virtualHost) { - super(virtualHost, attributes); + super(attributes, virtualHost); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java index 39317f455d..da429e935c 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java @@ -27,10 +27,9 @@ import org.apache.qpid.server.virtualhost.VirtualHostImpl; public abstract class OutOfOrderQueue<X extends OutOfOrderQueue<X>> extends AbstractQueue<X> { - protected OutOfOrderQueue(VirtualHostImpl virtualHost, - Map<String, Object> attributes) + protected OutOfOrderQueue(Map<String, Object> attributes, VirtualHostImpl virtualHost) { - super(virtualHost, attributes); + super(attributes, virtualHost); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueFactory.java index f7a46d5bef..d35ad2b0fe 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueFactory.java @@ -43,6 +43,6 @@ public class PriorityQueueFactory extends AbstractConfiguredObjectTypeFactory<Pr throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); } - return new PriorityQueueImpl((VirtualHostImpl<?,?,?>)virtualHost,attributes); + return new PriorityQueueImpl(attributes, (VirtualHostImpl<?,?,?>)virtualHost); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueImpl.java index 20759797d2..b06e196095 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueImpl.java @@ -36,10 +36,9 @@ public class PriorityQueueImpl extends OutOfOrderQueue<PriorityQueueImpl> implem @ManagedAttributeField private int _priorities; - public PriorityQueueImpl(VirtualHostImpl virtualHost, - Map<String, Object> attributes) + public PriorityQueueImpl(Map<String, Object> attributes, VirtualHostImpl virtualHost) { - super(virtualHost, attributes); + super(attributes, virtualHost); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueFactory.java index 484e61efa9..e584e7d8dd 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueFactory.java @@ -43,6 +43,6 @@ public class SortedQueueFactory extends AbstractConfiguredObjectTypeFactory<Sort throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); } - return new SortedQueueImpl((VirtualHostImpl<?,?,?>)virtualHost,attributes); + return new SortedQueueImpl(attributes, (VirtualHostImpl<?,?,?>)virtualHost); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueImpl.java index d0bb79900d..f04b3acfe3 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueImpl.java @@ -38,10 +38,9 @@ public class SortedQueueImpl extends OutOfOrderQueue<SortedQueueImpl> implements private String _sortKey; private SortedQueueEntryList _entries; - public SortedQueueImpl(VirtualHostImpl virtualHost, - Map<String, Object> attributes) + public SortedQueueImpl(Map<String, Object> attributes, VirtualHostImpl virtualHost) { - super(virtualHost, attributes); + super(attributes, virtualHost); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java index 1e2d8f63a6..b0a4e2a96e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java @@ -43,6 +43,6 @@ public class StandardQueueFactory extends AbstractConfiguredObjectTypeFactory<St throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); } - return new StandardQueueImpl((VirtualHostImpl<?,?,?>)virtualHost,attributes); + return new StandardQueueImpl(attributes, (VirtualHostImpl<?,?,?>)virtualHost); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java index 19c808a2f2..22390dde5f 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java @@ -28,10 +28,9 @@ public class StandardQueueImpl extends AbstractQueue<StandardQueueImpl> implemen { private StandardQueueEntryList _entries; - public StandardQueueImpl(final VirtualHostImpl virtualHost, - final Map<String, Object> arguments) + public StandardQueueImpl(final Map<String, Object> arguments, final VirtualHostImpl virtualHost) { - super(virtualHost, arguments); + super(arguments, virtualHost); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreFactory.java index 5e54d01832..5aff83b109 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreFactory.java @@ -20,9 +20,7 @@ */ package org.apache.qpid.server.security; -import java.util.HashMap; import java.util.Map; -import java.util.UUID; import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; import org.apache.qpid.server.model.Broker; @@ -39,10 +37,7 @@ public class FileKeyStoreFactory extends AbstractConfiguredObjectTypeFactory<Fil @Override public FileKeyStoreImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - HashMap<String, Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(ConfiguredObject.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new FileKeyStoreImpl(id, getParent(Broker.class, parents), attributesWithoutId); + return new FileKeyStoreImpl(attributes, getParent(Broker.class, parents)); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java index 86e034a966..28adef11b9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.UUID; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; @@ -83,10 +82,10 @@ public class FileKeyStoreImpl extends AbstractConfiguredObject<FileKeyStoreImpl> private Broker<?> _broker; - public FileKeyStoreImpl(UUID id, Broker<?> broker, Map<String, Object> attributes) + public FileKeyStoreImpl(Map<String, Object> attributes, Broker<?> broker) { super(parentsMap(broker), - combineIdWithAttributes(id, attributes), + attributes, broker.getTaskExecutor()); _broker = broker; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreFactory.java index 6e08104444..0375cb0e3f 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreFactory.java @@ -20,9 +20,7 @@ */ package org.apache.qpid.server.security; -import java.util.HashMap; import java.util.Map; -import java.util.UUID; import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; import org.apache.qpid.server.model.Broker; @@ -35,22 +33,10 @@ public class FileTrustStoreFactory extends AbstractConfiguredObjectTypeFactory<F super(FileTrustStoreImpl.class); } - protected final Broker getBroker(ConfiguredObject<?>... parents) - { - if(parents.length != 1 && !(parents[0] instanceof Broker)) - { - throw new IllegalArgumentException("Should have exactly one parent of type broker"); - } - return (Broker) parents[0]; - } - @Override public FileTrustStoreImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - HashMap<String, Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(ConfiguredObject.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new FileTrustStoreImpl(id, getParent(Broker.class, parents), attributesWithoutId); + return new FileTrustStoreImpl(attributes, getParent(Broker.class, parents)); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java index 6983478ce7..954d9847d1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Map; import java.util.Set; -import java.util.UUID; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; @@ -67,10 +66,10 @@ public class FileTrustStoreImpl extends AbstractConfiguredObject<FileTrustStoreI private Broker<?> _broker; - public FileTrustStoreImpl(UUID id, Broker<?> broker, Map<String, Object> attributes) + public FileTrustStoreImpl(Map<String, Object> attributes, Broker<?> broker) { super(parentsMap(broker), - combineIdWithAttributes(id, attributes), + attributes, broker.getTaskExecutor()); _broker = broker; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java index d3eea96e16..25bf172614 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java @@ -61,8 +61,7 @@ public abstract class AbstractAuthenticationManager<T extends AbstractAuthentica private PreferencesProvider _preferencesProvider; private AtomicReference<State> _state = new AtomicReference<State>(State.INITIALISING); - protected AbstractAuthenticationManager(final Broker broker, - final Map<String, Object> attributes) + protected AbstractAuthenticationManager(final Map<String, Object> attributes, final Broker broker) { super(parentsMap(broker), attributes, broker.getTaskExecutor()); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java index 4b999446bf..10753bc1f8 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java @@ -50,10 +50,9 @@ public class AnonymousAuthenticationManager extends AbstractAuthenticationManage private static final AuthenticationResult ANONYMOUS_AUTHENTICATION = new AuthenticationResult(ANONYMOUS_PRINCIPAL); - protected AnonymousAuthenticationManager(final Broker broker, - final Map<String, Object> attributes) + protected AnonymousAuthenticationManager(final Map<String, Object> attributes, final Broker broker) { - super(broker, attributes); + super(attributes, broker); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java index 0d034ed7c9..4c3324f038 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java @@ -54,7 +54,7 @@ public class AnonymousAuthenticationManagerFactory extends AbstractConfiguredObj public AnonymousAuthenticationManager createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - return new AnonymousAuthenticationManager(getParent(Broker.class,parents), attributes); + return new AnonymousAuthenticationManager(attributes, getParent(Broker.class,parents)); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java index 23e50ee52b..2140df545a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java @@ -36,7 +36,7 @@ public class Base64MD5PasswordDatabaseAuthenticationManager protected Base64MD5PasswordDatabaseAuthenticationManager(final Broker broker, final Map<String, Object> attributes) { - super(broker, attributes); + super(attributes, broker); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java index 0191b4206d..1f933be81d 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java @@ -60,7 +60,7 @@ public class ExternalAuthenticationManagerFactory extends AbstractAuthentication public ExternalAuthenticationManagerImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - return new ExternalAuthenticationManagerImpl(getParent(Broker.class, parents), attributes); + return new ExternalAuthenticationManagerImpl(attributes, getParent(Broker.class, parents)); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java index f5b65092b2..99175bc13c 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java @@ -38,10 +38,9 @@ public class ExternalAuthenticationManagerImpl extends AbstractAuthenticationMan @ManagedAttributeField private boolean _useFullDN; - protected ExternalAuthenticationManagerImpl(final Broker broker, - final Map<String, Object> attributes) + protected ExternalAuthenticationManagerImpl(final Map<String, Object> attributes, final Broker broker) { - super(broker, attributes); + super(attributes, broker); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java index 6a00fd4306..b344c4f5b4 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java @@ -42,10 +42,9 @@ public class KerberosAuthenticationManager extends AbstractAuthenticationManager private static final String GSSAPI_MECHANISM = "GSSAPI"; private final CallbackHandler _callbackHandler = new GssApiCallbackHandler(); - protected KerberosAuthenticationManager(final Broker broker, - final Map<String, Object> attributes) + protected KerberosAuthenticationManager(final Map<String, Object> attributes, final Broker broker) { - super(broker, attributes); + super(attributes, broker); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java index 21d7b21a9d..84d5343699 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java @@ -52,7 +52,7 @@ public class KerberosAuthenticationManagerFactory extends AbstractAuthentication public KerberosAuthenticationManager createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - return new KerberosAuthenticationManager(getParent(Broker.class, parents), attributes); + return new KerberosAuthenticationManager(attributes, getParent(Broker.class, parents)); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java index 8db0cdf774..8c9ec5a3e9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java @@ -33,7 +33,7 @@ public class PlainPasswordDatabaseAuthenticationManager extends PrincipalDatabas protected PlainPasswordDatabaseAuthenticationManager(final Broker broker, final Map<String, Object> attributes) { - super(broker, attributes); + super(attributes, broker); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java index a532e2a749..67785996d9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java @@ -70,10 +70,9 @@ public abstract class PrincipalDatabaseAuthenticationManager<T extends Principal @ManagedAttributeField private String _path; - protected PrincipalDatabaseAuthenticationManager(final Broker broker, - final Map<String, Object> attributes) + protected PrincipalDatabaseAuthenticationManager(final Map<String, Object> attributes, final Broker broker) { - super(broker, attributes); + super(attributes, broker); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java index 5628d49949..2800064298 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java @@ -76,10 +76,9 @@ public class ScramSHA1AuthenticationManager private Map<String, ScramAuthUser> _users = new ConcurrentHashMap<String, ScramAuthUser>(); - protected ScramSHA1AuthenticationManager(final Broker broker, - final Map<String, Object> attributes) + protected ScramSHA1AuthenticationManager(final Map<String, Object> attributes, final Broker broker) { - super(broker, attributes); + super(attributes, broker); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java index 8a8543b022..2fff86e8bc 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java @@ -60,7 +60,7 @@ public class ScramSHA1AuthenticationManagerFactory extends AbstractAuthenticatio public ScramSHA1AuthenticationManager createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - return new ScramSHA1AuthenticationManager(getParent(Broker.class, parents), attributes); + return new ScramSHA1AuthenticationManager(attributes, getParent(Broker.class, parents)); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleAuthenticationManager.java index 0f5218dbda..a849a28904 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleAuthenticationManager.java @@ -54,10 +54,9 @@ public class SimpleAuthenticationManager extends AbstractAuthenticationManager<S private final Map<String, String> _users = Collections.synchronizedMap(new HashMap<String, String>()); - public SimpleAuthenticationManager(final Broker broker, - final Map<String, Object> attributes) + public SimpleAuthenticationManager(final Map<String, Object> attributes, final Broker broker) { - super(broker, attributes); + super(attributes, broker); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java index 28163b8800..e8fcd0d1a1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java @@ -74,7 +74,7 @@ public class SimpleLDAPAuthenticationManagerFactory extends AbstractAuthenticati public SimpleLDAPAuthenticationManagerImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - return new SimpleLDAPAuthenticationManagerImpl(getParent(Broker.class, parents), attributes); + return new SimpleLDAPAuthenticationManagerImpl(attributes, getParent(Broker.class, parents)); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java index 3756931c64..8227590dfe 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java @@ -94,10 +94,9 @@ public class SimpleLDAPAuthenticationManagerImpl extends AbstractAuthenticationM */ private Class<? extends SocketFactory> _sslSocketFactoryOverrideClass; - protected SimpleLDAPAuthenticationManagerImpl(final Broker broker, - final Map<String, Object> attributes) + protected SimpleLDAPAuthenticationManagerImpl(final Map<String, Object> attributes, final Broker broker) { - super(broker, attributes); + super(attributes, broker); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java index b759bd5dc4..9d8bf4e141 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java @@ -21,14 +21,9 @@ package org.apache.qpid.server.util; import java.lang.reflect.Array; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.UUID; public class MapValueConverter { @@ -57,40 +52,6 @@ public class MapValueConverter return String.valueOf(value); } - public static String getStringAttribute(String name, Map<String, Object> attributes) - { - assertMandatoryAttribute(name, attributes); - return getStringAttribute(name, attributes, null); - } - - public static void assertMandatoryAttribute(String name, Map<String, Object> attributes) - { - if (!attributes.containsKey(name)) - { - throw new IllegalArgumentException("Value for attribute " + name + " is not found"); - } - } - - public static Map<String,Object> getMapAttribute(String name, Map<String,Object> attributes, Map<String,Object> defaultVal) - { - final Object value = attributes.get(name); - if(value == null) - { - return defaultVal; - } - else if(value instanceof Map) - { - @SuppressWarnings("unchecked") - Map<String,Object> retVal = (Map<String,Object>) value; - return retVal; - } - else - { - throw new IllegalArgumentException("Value for attribute " + name + " is not of required type Map"); - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) public static <E extends Enum> E getEnumAttribute(Class<E> clazz, String name, Map<String,Object> attributes, E defaultVal) { @@ -113,12 +74,6 @@ public class MapValueConverter } } - public static <E extends Enum<?>> E getEnumAttribute(Class<E> clazz, String name, Map<String,Object> attributes) - { - assertMandatoryAttribute(name, attributes); - return getEnumAttribute(clazz, name, attributes, null); - } - @SuppressWarnings({ "unchecked" }) public static <T extends Enum<T>> T toEnum(String name, Object rawValue, Class<T> enumType) { @@ -174,13 +129,6 @@ public class MapValueConverter } } - - public static boolean getBooleanAttribute(String name, Map<String, Object> attributes) - { - assertMandatoryAttribute(name, attributes); - return getBooleanAttribute(name, attributes, null); - } - public static Integer getIntegerAttribute(String name, Map<String,Object> attributes, Integer defaultValue) { Object obj = attributes.get(name); @@ -212,25 +160,6 @@ public class MapValueConverter } } - public static Integer getIntegerAttribute(String name, Map<String,Object> attributes) - { - assertMandatoryAttribute(name, attributes); - return getIntegerAttribute(name, attributes, null); - } - - public static Long getLongAttribute(String name, Map<String,Object> attributes) - { - assertMandatoryAttribute(name, attributes); - Object obj = attributes.get(name); - return toLong(name, obj, null); - } - - public static Long getLongAttribute(String name, Map<String,Object> attributes, Long defaultValue) - { - Object obj = attributes.get(name); - return toLong(name, obj, defaultValue); - } - public static Long toLong(String name, Object obj) { return toLong(name, obj, null); @@ -255,31 +184,6 @@ public class MapValueConverter throw new IllegalArgumentException("Value for attribute " + name + " is not of required type Long"); } } - - public static <T> Set<T> getSetAttribute(String name, Map<String,Object> attributes) - { - assertMandatoryAttribute(name, attributes); - return getSetAttribute(name, attributes, Collections.<T>emptySet()); - } - - @SuppressWarnings("unchecked") - public static <T> Set<T> getSetAttribute(String name, Map<String,Object> attributes, Set<T> defaultValue) - { - Object obj = attributes.get(name); - if(obj == null) - { - return defaultValue; - } - else if(obj instanceof Set) - { - return (Set<T>) obj; - } - else - { - throw new IllegalArgumentException("Value for attribute " + name + " is not of required type Set"); - } - } - public static <T extends Enum<T>> Set<T> getEnumSetAttribute(String name, Map<String, Object> attributes, Class<T> clazz) { Object obj = attributes.get(name); @@ -293,107 +197,6 @@ public class MapValueConverter } } - public static Map<String, Object> convert(Map<String, Object> configurationAttributes, Map<String, Type> attributeTypes) - { - return convert(configurationAttributes, attributeTypes, true); - } - - public static Map<String, Object> convert(Map<String, Object> configurationAttributes, - Map<String, Type> attributeTypes, - boolean exclusive) - { - Map<String, Object> attributes = new HashMap<String, Object>(); - for (Map.Entry<String, Object> attribute : configurationAttributes.entrySet()) - { - String attributeName = attribute.getKey(); - Object rawValue = attribute.getValue(); - - if (attributeTypes.containsKey(attributeName)) - { - Type typeObject = attributeTypes.get(attributeName); - - Object value = null; - if (typeObject instanceof Class) - { - Class<?> classObject = (Class<?>)typeObject; - value = convert(rawValue, classObject, attributeName); - } - else if (typeObject instanceof ParameterizedType) - { - ParameterizedType parameterizedType= (ParameterizedType)typeObject; - value = convertParameterizedType(rawValue, parameterizedType, attributeName); - } - else - { - throw new IllegalArgumentException("Conversion into " + typeObject + " is not yet supported"); - } - attributes.put(attributeName, value); - } - else if(!exclusive) - { - attributes.put(attributeName, rawValue); - } - } - - return attributes; - } - - private static Object convertParameterizedType(Object rawValue, ParameterizedType parameterizedType, String attributeName) - { - Type type = parameterizedType.getRawType(); - Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); - Object convertedValue; - if (type == Set.class) - { - if (actualTypeArguments.length != 1) - { - throw new IllegalArgumentException("Unexpected number of Set type arguments " + actualTypeArguments.length); - } - Class<?> classObject = (Class<?>)actualTypeArguments[0]; - convertedValue = toSet(rawValue, classObject, attributeName); - } - else if (type == Map.class) - { - if (actualTypeArguments.length != 2) - { - throw new IllegalArgumentException("Unexpected number of Map type arguments " + actualTypeArguments.length); - } - Class<?> keyClassObject = (Class<?>)actualTypeArguments[0]; - Class<?> valueClassObject = (Class<?>)actualTypeArguments[1]; - convertedValue = toMap(rawValue, keyClassObject, valueClassObject, attributeName); - } - else - { - throw new IllegalArgumentException("Conversion into " + parameterizedType + " is not yet supported"); - } - return convertedValue; - } - - private static <K,V> Map<K, V> toMap(Object rawValue, Class<K> keyClassObject, Class<V> valueClassObject, String attributeName) - { - if (rawValue == null) - { - return null; - } - if (rawValue instanceof Map) - { - Map<K, V> convertedMap = new HashMap<K, V>(); - Map<?, ?> rawMap = (Map<?,?>)rawValue; - - for (Map.Entry<?, ?> entry : rawMap.entrySet()) - { - K convertedKey = convert(entry.getKey(), keyClassObject, attributeName + " (map key)"); - V convertedValue = convert(entry.getValue(), valueClassObject, attributeName + " (map value)"); - convertedMap.put(convertedKey, convertedValue); - } - return convertedMap; - } - else - { - throw new IllegalArgumentException("rawValue is not of unexpected type Map, was : " + rawValue.getClass()); - } - } - public static <T> Set<T> toSet(Object rawValue, Class<T> setItemClass, String attributeName) { if (rawValue == null) @@ -463,41 +266,4 @@ public class MapValueConverter return (T) value; } - - public static UUID getUUIDAttribute(String name, Map<String, Object> attributes) - { - assertMandatoryAttribute(name, attributes); - return getUUIDAttribute(name, attributes, null); - } - - public static UUID getUUIDAttribute(String name, Map<String,Object> attributes, UUID defaultVal) - { - final Object value = attributes.get(name); - return toUUID(value, defaultVal); - } - - private static UUID toUUID(final Object value, final UUID defaultVal) - { - if(value == null) - { - return defaultVal; - } - else if(value instanceof UUID) - { - return (UUID)value; - } - else if(value instanceof String) - { - return UUID.fromString((String)value); - } - else if(value instanceof byte[]) - { - return UUID.nameUUIDFromBytes((byte[])value); - } - else - { - throw new IllegalArgumentException("Cannot convert " + value.getClass().getName() + " to UUID"); - } - } - } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileTrustStoreCreationTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileTrustStoreCreationTest.java index f5e6772572..c6d3430a44 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileTrustStoreCreationTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileTrustStoreCreationTest.java @@ -43,13 +43,13 @@ public class FileTrustStoreCreationTest extends QpidTestCase { public void testCreateWithAllAttributesProvided() { - Map<String, Object> attributes = getTrustStoreAttributes(); + UUID id = UUID.randomUUID(); + Map<String, Object> attributes = getTrustStoreAttributes(id); Map<String, Object> attributesCopy = new HashMap<String, Object>(attributes); - UUID id = UUID.randomUUID(); Broker broker = mock(Broker.class); - final FileTrustStore trustStore = new FileTrustStoreImpl(id, broker, attributes); + final FileTrustStore trustStore = new FileTrustStoreImpl(attributes, broker); trustStore.open(); assertNotNull("Trust store configured object is not created", trustStore); assertEquals(id, trustStore.getId()); @@ -81,9 +81,9 @@ public class FileTrustStoreCreationTest extends QpidTestCase public void testCreateWithMissedRequiredAttributes() { - Map<String, Object> attributes = getTrustStoreAttributes(); - UUID id = UUID.randomUUID(); + Map<String, Object> attributes = getTrustStoreAttributes(id); + Broker broker = mock(Broker.class); String[] mandatoryProperties = {TrustStore.NAME, FileTrustStore.PATH, FileTrustStore.PASSWORD}; @@ -93,7 +93,7 @@ public class FileTrustStoreCreationTest extends QpidTestCase properties.remove(mandatoryProperties[i]); try { - TrustStore trustStore = new FileTrustStoreImpl(id, broker, properties); + TrustStore trustStore = new FileTrustStoreImpl(properties, broker); trustStore.open(); fail("Cannot create key store without a " + mandatoryProperties[i]); } @@ -104,10 +104,11 @@ public class FileTrustStoreCreationTest extends QpidTestCase } } - private Map<String, Object> getTrustStoreAttributes() + private Map<String, Object> getTrustStoreAttributes(UUID id) { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(TrustStore.NAME, getName()); + attributes.put(TrustStore.ID, id); attributes.put(FileTrustStore.PATH, TestSSLConstants.BROKER_TRUSTSTORE); attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.BROKER_TRUSTSTORE_PASSWORD); attributes.put(FileTrustStore.TRUST_STORE_TYPE, "jks"); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java index e451941771..af56cf049f 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java @@ -89,6 +89,7 @@ public class PreferencesProviderCreationTest extends QpidTestCase Map<String, Object> attributes = new HashMap<String, Object>(); UUID id = UUID.randomUUID(); + attributes.put(PreferencesProvider.ID, id); attributes.put(PreferencesProvider.TYPE, FileSystemPreferencesProvider.PROVIDER_TYPE); attributes.put(PreferencesProvider.NAME, "test-provider"); File file = TestFileUtils.createTempFile(this, @@ -97,7 +98,7 @@ public class PreferencesProviderCreationTest extends QpidTestCase try { attributes.put(FileSystemPreferencesProvider.PATH, file.getAbsolutePath()); - PreferencesProvider provider = new FileSystemPreferencesProviderImpl(id,attributes,_authenticationProvider); + PreferencesProvider provider = new FileSystemPreferencesProviderImpl(attributes,_authenticationProvider); provider.open(); assertNotNull("Preferences provider was not recovered", provider); assertEquals("Unexpected name", "test-provider", provider.getName()); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java index 33c333c407..6217f3ecfa 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java @@ -69,7 +69,7 @@ public class FanoutExchangeTest extends TestCase when(_virtualHost.getSecurityManager()).thenReturn(securityManager); when(_virtualHost.getEventLogger()).thenReturn(new EventLogger()); when(_virtualHost.getTaskExecutor()).thenReturn(_taskExecutor); - _exchange = new FanoutExchange(_virtualHost, attributes); + _exchange = new FanoutExchange(attributes, _virtualHost); _exchange.open(); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java index 093a00d88a..3d6ab9e76d 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java @@ -34,6 +34,7 @@ import junit.framework.TestCase; import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.message.AMQMessageHeader; +import org.apache.qpid.server.model.Binding; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.virtualhost.VirtualHostImpl; @@ -166,7 +167,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -177,7 +179,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); matchHeaders.setString("B", "Value of B"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -187,7 +190,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Altered value of A"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertFalse(new HeadersBinding(b).matches(matchHeaders)); } @@ -198,7 +202,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -210,7 +215,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertFalse(new HeadersBinding(b).matches(matchHeaders)); } @@ -223,7 +229,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); matchHeaders.setString("B", "Value of B"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -237,7 +244,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -251,7 +259,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Altered value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertFalse(new HeadersBinding(b).matches(matchHeaders)); } @@ -262,7 +271,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -274,7 +284,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -287,7 +298,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); matchHeaders.setString("B", "Value of B"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -301,7 +313,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -315,7 +328,8 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Altered value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -329,10 +343,28 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Altered value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = + createBinding(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertFalse(new HeadersBinding(b).matches(matchHeaders)); } + public static BindingImpl createBinding(UUID id, + final String bindingKey, + final AMQQueue queue, + final ExchangeImpl exchange, + final Map<String, Object> arguments) + { + Map<String, Object> attributes = new HashMap<String, Object>(); + attributes.put(Binding.NAME, bindingKey); + if(arguments != null) + { + attributes.put(Binding.ARGUMENTS, arguments); + } + attributes.put(Binding.ID, id); + return new BindingImpl(attributes, queue, exchange); + } + + public static junit.framework.Test suite() { return new junit.framework.TestSuite(HeadersBindingTest.class); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java index a450c942e6..28cb59256d 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java @@ -76,7 +76,7 @@ public class HeadersExchangeTest extends TestCase attributes.put(Exchange.NAME, "test"); attributes.put(Exchange.DURABLE, false); - _exchange = new HeadersExchange(_virtualHost, attributes); + _exchange = new HeadersExchange(attributes, _virtualHost); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java index 1bf90022c0..7b57143016 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java @@ -34,6 +34,7 @@ import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.MessageReference; import org.apache.qpid.server.message.ServerMessage; +import org.apache.qpid.server.model.Binding; import org.apache.qpid.server.model.Exchange; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.UUIDGenerator; @@ -62,7 +63,7 @@ public class TopicExchangeTest extends QpidTestCase attributes.put(Exchange.NAME, "test"); attributes.put(Exchange.DURABLE, false); - _exchange = new TopicExchange(_vhost, attributes); + _exchange = new TopicExchange(attributes, _vhost); } @Override @@ -93,7 +94,7 @@ public class TopicExchangeTest extends QpidTestCase public void testNoRoute() throws Exception { AMQQueue<?> queue = createQueue("a*#b"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.*.#.b",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.*.#.b", queue, _exchange, null)); routeMessage("a.b", 0l); @@ -104,7 +105,7 @@ public class TopicExchangeTest extends QpidTestCase public void testDirectMatch() throws Exception { AMQQueue<?> queue = createQueue("ab"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.b",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.b", queue, _exchange, null)); routeMessage("a.b",0l); @@ -126,7 +127,7 @@ public class TopicExchangeTest extends QpidTestCase public void testStarMatch() throws Exception { AMQQueue<?> queue = createQueue("a*"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.*",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.*", queue, _exchange, null)); routeMessage("a.b",0l); @@ -157,7 +158,7 @@ public class TopicExchangeTest extends QpidTestCase public void testHashMatch() throws Exception { AMQQueue<?> queue = createQueue("a#"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.#",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.#", queue, _exchange, null)); routeMessage("a.b.c",0l); @@ -208,7 +209,7 @@ public class TopicExchangeTest extends QpidTestCase public void testMidHash() throws Exception { AMQQueue<?> queue = createQueue("a"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.*.#.b",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.*.#.b", queue, _exchange, null)); routeMessage("a.c.d.b",0l); @@ -233,7 +234,7 @@ public class TopicExchangeTest extends QpidTestCase public void testMatchAfterHash() throws Exception { AMQQueue<?> queue = createQueue("a#"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.*.#.b.c",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.*.#.b.c", queue, _exchange, null)); int queueCount = routeMessage("a.c.b.b",0l); @@ -271,7 +272,11 @@ public class TopicExchangeTest extends QpidTestCase public void testHashAfterHash() throws Exception { AMQQueue<?> queue = createQueue("a#"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.*.#.b.c.#.d",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), + "a.*.#.b.c.#.d", + queue, + _exchange, + null)); int queueCount = routeMessage("a.c.b.b.c",0l); Assert.assertEquals("Message should not route to any queues", 0, queueCount); @@ -292,7 +297,7 @@ public class TopicExchangeTest extends QpidTestCase public void testHashHash() throws Exception { AMQQueue<?> queue = createQueue("a#"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.#.*.#.d",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.#.*.#.d", queue, _exchange, null)); int queueCount = routeMessage("a.c.b.b.c",0l); Assert.assertEquals("Message should not route to any queues", 0, queueCount); @@ -313,7 +318,7 @@ public class TopicExchangeTest extends QpidTestCase public void testSubMatchFails() throws Exception { AMQQueue<?> queue = createQueue("a"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.b.c.d",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.b.c.d", queue, _exchange, null)); int queueCount = routeMessage("a.b.c",0l); Assert.assertEquals("Message should not route to any queues", 0, queueCount); @@ -342,7 +347,7 @@ public class TopicExchangeTest extends QpidTestCase public void testMoreRouting() throws Exception { AMQQueue<?> queue = createQueue("a"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.b",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.b", queue, _exchange, null)); int queueCount = routeMessage("a.b.c",0l); @@ -355,7 +360,7 @@ public class TopicExchangeTest extends QpidTestCase public void testMoreQueue() throws Exception { AMQQueue<?> queue = createQueue("a"); - _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.b",queue, _exchange, null)); + _exchange.registerQueue(createBinding(UUID.randomUUID(), "a.b", queue, _exchange, null)); int queueCount = routeMessage("a",0l); @@ -365,4 +370,21 @@ public class TopicExchangeTest extends QpidTestCase } + private static BindingImpl createBinding(UUID id, + final String bindingKey, + final AMQQueue queue, + final ExchangeImpl exchange, + final Map<String, Object> arguments) + { + Map<String, Object> attributes = new HashMap<String, Object>(); + attributes.put(Binding.NAME, bindingKey); + if(arguments != null) + { + attributes.put(Binding.ARGUMENTS, arguments); + } + attributes.put(Binding.ID, id); + return new BindingImpl(attributes, queue, exchange); + } + + } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java index db9d3db2d8..9479447fe6 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java @@ -75,7 +75,7 @@ public class FileSystemPreferencesProviderFactoryTest extends QpidTestCase { Map<String, Object> attributes = new HashMap<String, Object>(); UUID id = UUID.randomUUID(); - attributes.put(PreferencesProvider.TYPE, FileSystemPreferencesProvider.class); + attributes.put(PreferencesProvider.TYPE, "FileSystemPreferences"); attributes.put(PreferencesProvider.NAME, "test-provider"); File file = TestFileUtils.createTempFile(this, ".prefs.json", "{\"test_user\":{\"pref1\": \"pref1Value\", \"pref2\": 1.0} }"); try @@ -99,7 +99,7 @@ public class FileSystemPreferencesProviderFactoryTest extends QpidTestCase { Map<String, Object> attributes = new HashMap<String, Object>(); UUID id = UUID.randomUUID(); - attributes.put(PreferencesProvider.TYPE, FileSystemPreferencesProvider.class); + attributes.put(PreferencesProvider.TYPE, "FileSystemPreferences"); attributes.put(PreferencesProvider.NAME, "test-provider"); File file = new File(TMP_FOLDER, UUID.randomUUID() + "prefs.json"); assertFalse("Preferences store file should not exist", file.exists()); @@ -119,7 +119,7 @@ public class FileSystemPreferencesProviderFactoryTest extends QpidTestCase { Map<String, Object> attributes = new HashMap<String, Object>(); UUID id = UUID.randomUUID(); - attributes.put(PreferencesProvider.TYPE, FileSystemPreferencesProvider.class); + attributes.put(PreferencesProvider.TYPE, "FileSystemPreferences"); attributes.put(PreferencesProvider.NAME, "test-provider"); File file = new File(TMP_FOLDER, UUID.randomUUID() + "prefs.json"); assertFalse("Preferences store file should not exist", file.exists()); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java index 8c069e9eca..9c6a840d76 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java @@ -97,8 +97,9 @@ public class FileSystemPreferencesProviderTest extends QpidTestCase { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(FileSystemPreferencesProvider.PATH, nonExistingFile.getAbsolutePath()); + attributes.put(ConfiguredObject.ID, UUID.randomUUID()); attributes.put(ConfiguredObject.NAME, getTestName()); - _preferencesProvider = new FileSystemPreferencesProviderImpl(UUID.randomUUID(), attributes, _authenticationProvider); + _preferencesProvider = new FileSystemPreferencesProviderImpl(attributes, _authenticationProvider); _preferencesProvider.open(); assertEquals(State.INITIALISING, _preferencesProvider.getState()); @@ -118,9 +119,10 @@ public class FileSystemPreferencesProviderTest extends QpidTestCase try { Map<String, Object> attributes = new HashMap<String, Object>(); + attributes.put(ConfiguredObject.ID, UUID.randomUUID()); attributes.put(ConfiguredObject.NAME, getTestName()); attributes.put(FileSystemPreferencesProvider.PATH, emptyPrefsFile.getAbsolutePath()); - _preferencesProvider = new FileSystemPreferencesProviderImpl(UUID.randomUUID(), attributes, _authenticationProvider); + _preferencesProvider = new FileSystemPreferencesProviderImpl(attributes, _authenticationProvider); assertEquals(State.INITIALISING, _preferencesProvider.getState()); _preferencesProvider.close(); } @@ -280,8 +282,9 @@ public class FileSystemPreferencesProviderTest extends QpidTestCase { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(FileSystemPreferencesProvider.PATH, _preferencesFile.getAbsolutePath()); + attributes.put(ConfiguredObject.ID, UUID.randomUUID()); attributes.put(ConfiguredObject.NAME, "test"); - _preferencesProvider = new FileSystemPreferencesProviderImpl(UUID.randomUUID(), attributes, _authenticationProvider); + _preferencesProvider = new FileSystemPreferencesProviderImpl(attributes, _authenticationProvider); _preferencesProvider.open(); return _preferencesProvider; } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AbstractQueueTestBase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AbstractQueueTestBase.java index 5fd8de9ac9..706edca7b6 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AbstractQueueTestBase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AbstractQueueTestBase.java @@ -1101,7 +1101,7 @@ abstract class AbstractQueueTestBase extends QpidTestCase public NonAsyncDeliverQueue(VirtualHostImpl vhost) { - super(vhost, attributes()); + super(attributes(), vhost); } @Override diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/LastValueQueueListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/LastValueQueueListTest.java index dfb6f0ee8c..d4914e7ecf 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/LastValueQueueListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/LastValueQueueListTest.java @@ -58,7 +58,7 @@ public class LastValueQueueListTest extends TestCase final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); - _queue = new LastValueQueueImpl(virtualHost, queueAttributes); + _queue = new LastValueQueueImpl(queueAttributes, virtualHost); _queue.open(); _list = _queue.getEntries(); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java index 80e8252cb3..d619d62b10 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java @@ -58,7 +58,7 @@ public class PriorityQueueListTest extends QpidTestCase final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); - PriorityQueueImpl queue = new PriorityQueueImpl(virtualHost, queueAttributes); + PriorityQueueImpl queue = new PriorityQueueImpl(queueAttributes, virtualHost); queue.open(); _list = queue.getEntries(); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java index 80a405d112..b6f8f69843 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java @@ -199,7 +199,7 @@ public abstract class QueueEntryImplTestBase extends TestCase when(virtualHost.getSecurityManager()).thenReturn(mock(org.apache.qpid.server.security.SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); - StandardQueueImpl queue = new StandardQueueImpl(virtualHost, queueAttributes); + StandardQueueImpl queue = new StandardQueueImpl(queueAttributes, virtualHost); queue.open(); OrderedQueueEntryList queueEntryList = queue.getEntries(); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java index 26220cb8fa..b71d752fe7 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java @@ -47,7 +47,7 @@ public class SimpleQueueEntryImplTest extends QueueEntryImplTestBase final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(org.apache.qpid.server.security.SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); - StandardQueueImpl queue = new StandardQueueImpl(virtualHost, queueAttributes); + StandardQueueImpl queue = new StandardQueueImpl(queueAttributes, virtualHost); queue.open(); queueEntryList = queue.getEntries(); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java index d284324667..0f41b32696 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java @@ -86,7 +86,7 @@ public class SortedQueueEntryListTest extends QueueEntryListTestBase final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); - _testQueue = new SortedQueueImpl(virtualHost, attributes) + _testQueue = new SortedQueueImpl(attributes, virtualHost) { SelfValidatingSortedQueueEntryList _entries; @Override diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java index 1a26d2e2ec..a116af2733 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java @@ -56,7 +56,7 @@ public class SortedQueueEntryTest extends QueueEntryImplTestBase final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(org.apache.qpid.server.security.SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); - SortedQueueImpl queue = new SortedQueueImpl(virtualHost, attributes) + SortedQueueImpl queue = new SortedQueueImpl(attributes, virtualHost) { SelfValidatingSortedQueueEntryList _entries; @Override diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java index 2a6e0d0863..ef3bc0b824 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java @@ -55,7 +55,7 @@ public class StandardQueueEntryListTest extends QueueEntryListTestBase final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); - _testQueue = new StandardQueueImpl(virtualHost, queueAttributes); + _testQueue = new StandardQueueImpl(queueAttributes, virtualHost); _testQueue.open(); _sqel = _testQueue.getEntries(); for(int i = 1; i <= 100; i++) @@ -101,7 +101,7 @@ public class StandardQueueEntryListTest extends QueueEntryListTestBase final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); - StandardQueueImpl queue = new StandardQueueImpl(virtualHost, queueAttributes); + StandardQueueImpl queue = new StandardQueueImpl(queueAttributes, virtualHost); queue.open(); return queue.getEntries(); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java index db1537bcc5..35132930a6 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java @@ -49,7 +49,7 @@ public class StandardQueueTest extends AbstractQueueTestBase queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getQname()); queueAttributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS); - final StandardQueueImpl queue = new StandardQueueImpl(getVirtualHost(), queueAttributes); + final StandardQueueImpl queue = new StandardQueueImpl(queueAttributes, getVirtualHost()); queue.open(); setQueue(queue); @@ -72,7 +72,7 @@ public class StandardQueueTest extends AbstractQueueTestBase queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, "testActiveConsumerCount"); queueAttributes.put(Queue.OWNER, "testOwner"); - final StandardQueueImpl queue = new StandardQueueImpl(getVirtualHost(), queueAttributes); + final StandardQueueImpl queue = new StandardQueueImpl(queueAttributes, getVirtualHost()); queue.open(); //verify adding an active consumer increases the count final MockConsumer consumer1 = new MockConsumer(); @@ -180,7 +180,7 @@ public class StandardQueueTest extends AbstractQueueTestBase queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, "test"); // create queue with overridden method deliverAsync - StandardQueueImpl testQueue = new StandardQueueImpl(getVirtualHost(), queueAttributes) + StandardQueueImpl testQueue = new StandardQueueImpl(queueAttributes, getVirtualHost()) { @Override public void deliverAsync(QueueConsumer sub) @@ -253,7 +253,7 @@ public class StandardQueueTest extends AbstractQueueTestBase public DequeuedQueue(VirtualHostImpl virtualHost) { - super(virtualHost, attributes()); + super(attributes(), virtualHost); } @Override diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerTest.java index cf97e0296c..d57c79fc93 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerTest.java @@ -46,7 +46,7 @@ public class AnonymousAuthenticationManagerTest extends QpidTestCase Map<String,Object> attrs = new HashMap<String, Object>(); attrs.put(AuthenticationProvider.ID, UUID.randomUUID()); attrs.put(AuthenticationProvider.NAME, getTestName()); - _manager = new AnonymousAuthenticationManager(mock(Broker.class), attrs); + _manager = new AnonymousAuthenticationManager(attrs, mock(Broker.class)); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerTest.java index 68adf2c5b6..3a8a3cc190 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerTest.java @@ -48,13 +48,13 @@ public class ExternalAuthenticationManagerTest extends QpidTestCase attrs.put(AuthenticationProvider.ID, UUID.randomUUID()); attrs.put(AuthenticationProvider.NAME, getTestName()); attrs.put("useFullDN",false); - _manager = new ExternalAuthenticationManagerImpl(mock(Broker.class), attrs); + _manager = new ExternalAuthenticationManagerImpl(attrs, mock(Broker.class)); _manager.open(); HashMap<String, Object> attrsFullDN = new HashMap<String, Object>(); attrsFullDN.put(AuthenticationProvider.ID, UUID.randomUUID()); attrsFullDN.put(AuthenticationProvider.NAME, getTestName()+"FullDN"); attrsFullDN.put("useFullDN",true); - _managerUsingFullDN = new ExternalAuthenticationManagerImpl(mock(Broker.class), attrsFullDN); + _managerUsingFullDN = new ExternalAuthenticationManagerImpl(attrsFullDN, mock(Broker.class)); _managerUsingFullDN.open(); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManagerTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManagerTest.java index e373ada4c2..c2cbe8c780 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManagerTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManagerTest.java @@ -105,7 +105,7 @@ public class PrincipalDatabaseAuthenticationManagerTest extends QpidTestCase attrs.put(ConfiguredObject.ID, UUID.randomUUID()); attrs.put(ConfiguredObject.NAME, getTestName()); attrs.put("path", _passwordFileLocation); - _manager = new PrincipalDatabaseAuthenticationManager(mock(Broker.class), attrs) + _manager = new PrincipalDatabaseAuthenticationManager(attrs, mock(Broker.class)) { @Override protected PrincipalDatabase createDatabase() diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerTest.java index 0e9dce39c7..2a42cbf02f 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerTest.java @@ -58,7 +58,7 @@ public class ScramSHA1AuthenticationManagerTest extends QpidTestCase final Map<String, Object> attributesMap = new HashMap<String, Object>(); attributesMap.put(AuthenticationProvider.NAME, getTestName()); attributesMap.put(AuthenticationProvider.ID, UUID.randomUUID()); - _authManager = new ScramSHA1AuthenticationManager(_broker, attributesMap); + _authManager = new ScramSHA1AuthenticationManager(attributesMap, _broker); } @Override diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleAuthenticationManagerTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleAuthenticationManagerTest.java index 8464b2f175..27293b6651 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleAuthenticationManagerTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleAuthenticationManagerTest.java @@ -51,8 +51,8 @@ public class SimpleAuthenticationManagerTest extends QpidTestCase Map<String,Object> authManagerAttrs = new HashMap<String, Object>(); authManagerAttrs.put(AuthenticationProvider.NAME,"MANAGEMENT_MODE_AUTHENTICATION"); authManagerAttrs.put(AuthenticationProvider.ID, UUID.randomUUID()); - final SimpleAuthenticationManager authManager = new SimpleAuthenticationManager(mock(Broker.class), - authManagerAttrs); + final SimpleAuthenticationManager authManager = new SimpleAuthenticationManager(authManagerAttrs, mock(Broker.class) + ); authManager.addUser(TEST_USER, TEST_PASSWORD); _authenticationManager = authManager; diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java index b793a9182e..e37445d27e 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java @@ -168,8 +168,8 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest { ExchangeImpl<?> exchange = createTestExchange(); AMQQueue queue = createTestQueue(QUEUE_NAME, "queueOwner", false, null); - BindingImpl binding = new BindingImpl(UUIDGenerator.generateRandomUUID(), ROUTING_KEY, queue, - exchange, _bindingArgs); + BindingImpl binding = createBinding(UUIDGenerator.generateRandomUUID(), ROUTING_KEY, queue, + exchange, _bindingArgs); DurableConfigurationStoreHelper.createExchange(_configStore, exchange); DurableConfigurationStoreHelper.createQueue(_configStore, queue); DurableConfigurationStoreHelper.createBinding(_configStore, binding); @@ -260,8 +260,8 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest DurableConfigurationStoreHelper.createExchange(_configStore, exchange); AMQQueue queue = createTestQueue(QUEUE_NAME, "queueOwner", false, null); - BindingImpl binding = new BindingImpl(UUIDGenerator.generateRandomUUID(), ROUTING_KEY, queue, - exchange, _bindingArgs); + BindingImpl binding = createBinding(UUIDGenerator.generateRandomUUID(), ROUTING_KEY, queue, + exchange, _bindingArgs); DurableConfigurationStoreHelper.createBinding(_configStore, binding); DurableConfigurationStoreHelper.removeBinding(_configStore, binding); @@ -504,4 +504,21 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest _configStore.closeConfigurationStore(); } } + + private static BindingImpl createBinding(UUID id, + final String bindingKey, + final AMQQueue queue, + final ExchangeImpl exchange, + final Map<String, Object> arguments) + { + Map<String, Object> attributes = new HashMap<String, Object>(); + attributes.put(Binding.NAME, bindingKey); + if(arguments != null) + { + attributes.put(Binding.ARGUMENTS, arguments); + } + attributes.put(Binding.ID, id); + return new BindingImpl(attributes, queue, exchange); + } + } diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java index f20d468a14..9ba4618b29 100644 --- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java +++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java @@ -47,7 +47,7 @@ public class ACLFileAccessControlProviderFactory extends AbstractConfiguredObjec public ACLFileAccessControlProviderImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - return new ACLFileAccessControlProviderImpl(getParent(Broker.class,parents), attributes); + return new ACLFileAccessControlProviderImpl(attributes, getParent(Broker.class,parents)); } } diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java index fa52f33ece..be9642795b 100644 --- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java +++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java @@ -56,8 +56,7 @@ public class ACLFileAccessControlProviderImpl @ManagedAttributeField private String _path; - public ACLFileAccessControlProviderImpl(Broker broker, - Map<String, Object> attributes) + public ACLFileAccessControlProviderImpl(Map<String, Object> attributes, Broker broker) { super(parentsMap(broker), attributes, broker.getTaskExecutor()); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java index 37e85831a6..b72ecb950d 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java @@ -30,7 +30,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.UUID; +import java.util.Set; import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; @@ -70,7 +70,6 @@ import org.apache.qpid.server.management.plugin.servlet.rest.UserPreferencesServ import org.apache.qpid.server.model.*; import org.apache.qpid.server.model.adapter.AbstractPluginAdapter; import org.apache.qpid.server.model.port.AbstractPortWithAuthProvider; -import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager; @@ -122,9 +121,9 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem @ManagedAttributeField private int _sessionTimeout; - public HttpManagement(UUID id, Broker broker, Map<String, Object> attributes) + public HttpManagement(Map<String, Object> attributes, Broker broker) { - super(id, attributes, broker); + super(attributes, broker); } @Override @@ -389,7 +388,7 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem for (Connector connector : connectors) { getBroker().getEventLogger().message(ManagementConsoleMessages.LISTENING(stringifyConnectorScheme(connector), - connector.getPort())); + connector.getPort())); if (connector instanceof SslSocketConnector) { SslContextFactory sslContextFactory = ((SslSocketConnector)connector).getSslContextFactory(); @@ -460,28 +459,22 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem } @Override - protected void changeAttributes(Map<String, Object> attributes) + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) { - Map<String, Object> convertedAttributes = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES); - validateAttributes(convertedAttributes); + super.validateChange(proxyForValidation, changedAttributes); - super.changeAttributes(convertedAttributes); - } - - private void validateAttributes(Map<String, Object> convertedAttributes) - { - if(convertedAttributes.containsKey(HttpManagement.NAME)) + HttpManagementConfiguration<?> updated = (HttpManagementConfiguration<?>)proxyForValidation; + if(changedAttributes.contains(HttpManagement.NAME)) { - String newName = (String) convertedAttributes.get(HttpManagement.NAME); - if(!getName().equals(newName)) + if(!getName().equals(updated.getName())) { throw new IllegalConfigurationException("Changing the name of http management plugin is not allowed"); } } - if (convertedAttributes.containsKey(TIME_OUT)) + if (changedAttributes.contains(TIME_OUT)) { - Number value = (Number) convertedAttributes.get(TIME_OUT); - if (value == null || value.longValue() < 0) + int value = updated.getSessionTimeout(); + if (value < 0) { throw new IllegalConfigurationException("Only positive integer value can be specified for the session time out attribute"); } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java index 0431954879..518788a3d3 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java @@ -18,14 +18,13 @@ */ package org.apache.qpid.server.management.plugin; +import java.util.HashMap; +import java.util.Map; + import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - public class HttpManagementFactory extends AbstractConfiguredObjectTypeFactory<HttpManagement> { @@ -38,9 +37,7 @@ public class HttpManagementFactory extends AbstractConfiguredObjectTypeFactory<H public HttpManagement createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(ConfiguredObject.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new HttpManagement(id, getParent(Broker.class,parents), attributes); + return new HttpManagement(attributes, getParent(Broker.class,parents)); } } diff --git a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java index ff96a4223e..56dc947482 100644 --- a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java +++ b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java @@ -31,6 +31,7 @@ import java.util.UUID; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.test.utils.QpidTestCase; public class HttpManagementTest extends QpidTestCase @@ -52,7 +53,8 @@ public class HttpManagementTest extends QpidTestCase attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, true); attributes.put(HttpManagement.NAME, getTestName()); attributes.put(HttpManagement.TIME_OUT, 10000l); - _management = new HttpManagement(_id, _broker, attributes); + attributes.put(ConfiguredObject.ID, _id); + _management = new HttpManagement(attributes, _broker); _management.open(); } diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java index 0d8b36cdd9..335e4fe50f 100644 --- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java +++ b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java @@ -18,9 +18,7 @@ */ package org.apache.qpid.server.jmx; -import java.util.HashMap; import java.util.Map; -import java.util.UUID; import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; import org.apache.qpid.server.model.Broker; @@ -36,9 +34,6 @@ public class JMXManagementFactory extends AbstractConfiguredObjectTypeFactory<JM @Override public JMXManagementPluginImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); - Object idObj = attributesWithoutId.remove(ConfiguredObject.ID); - UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); - return new JMXManagementPluginImpl(id, getParent(Broker.class,parents),attributes); + return new JMXManagementPluginImpl(attributes,getParent(Broker.class,parents)); } } diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java index 3a04ca46fb..9ece703973 100644 --- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java +++ b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java @@ -26,7 +26,7 @@ import java.lang.reflect.Type; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import java.util.UUID; +import java.util.Set; import javax.management.JMException; @@ -51,7 +51,6 @@ import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.model.adapter.AbstractPluginAdapter; import org.apache.qpid.server.plugin.QpidServiceLoader; -import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.server.util.ServerScopedRuntimeException; public class JMXManagementPluginImpl @@ -80,9 +79,9 @@ public class JMXManagementPluginImpl @ManagedAttributeField private boolean _usePlatformMBeanServer; - public JMXManagementPluginImpl(UUID id, Broker broker, Map<String, Object> attributes) + public JMXManagementPluginImpl(Map<String, Object> attributes, Broker broker) { - super(id, attributes, broker); + super(attributes, broker); } @Override @@ -313,19 +312,12 @@ public class JMXManagementPluginImpl } @Override - protected void changeAttributes(Map<String, Object> attributes) + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) { - Map<String, Object> convertedAttributes = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES); - validateAttributes(convertedAttributes); - - super.changeAttributes(convertedAttributes); - } - - private void validateAttributes(Map<String, Object> convertedAttributes) - { - if(convertedAttributes.containsKey(JMXManagementPluginImpl.NAME)) + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(NAME)) { - String newName = (String) convertedAttributes.get(JMXManagementPluginImpl.NAME); + String newName = proxyForValidation.getName(); if(!getName().equals(newName)) { throw new IllegalConfigurationException("Changing the name of jmx management plugin is not allowed"); |
