diff options
172 files changed, 2329 insertions, 1154 deletions
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java index 3bb44b3e9c..87fc10530e 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java @@ -59,9 +59,9 @@ public class BDBHAVirtualHost extends AbstractVirtualHost<BDBHAVirtualHost> @Override - protected void validateAttributes() + public void validate() { - super.validateAttributes(); + super.validate(); Map<String, Object> attributes = getActualAttributes(); @SuppressWarnings("unchecked") Map<String, Object> messageStoreSettings = (Map<String, Object>)attributes.get(org.apache.qpid.server.model.VirtualHost.MESSAGE_STORE_SETTINGS); diff --git a/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackupTest.java b/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackupTest.java index 07e5999429..c682f44d60 100644 --- a/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackupTest.java +++ b/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackupTest.java @@ -31,11 +31,13 @@ import javax.jms.MessageConsumer; import javax.jms.Session; import org.apache.log4j.Logger; + import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.test.utils.Piper; import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.apache.qpid.util.FileUtils; +import org.apache.qpid.util.Strings; import org.apache.qpid.util.SystemUtils; /** @@ -63,7 +65,7 @@ public class BDBBackupTest extends QpidBrokerTestCase _backupToDir.mkdirs(); Map<String, Object> virtualHostAttributes = getBrokerConfiguration().getObjectAttributes(VirtualHost.class,TEST_VHOST); Map<String, Object> messageStoreSettings = (Map<String, Object>) virtualHostAttributes.get(VirtualHost.MESSAGE_STORE_SETTINGS); - _backupFromDir = new File((String)messageStoreSettings.get(MessageStore.STORE_PATH)); + _backupFromDir = new File(Strings.expand((String) messageStoreSettings.get(MessageStore.STORE_PATH))); boolean fromDirExistsAndIsDir = _backupFromDir.isDirectory(); assertTrue("backupFromDir " + _backupFromDir + " should already exist", fromDirExistsAndIsDir); } diff --git a/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java b/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java index a7b6ea107d..55d4c78ccb 100644 --- a/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java +++ b/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java @@ -53,6 +53,7 @@ import org.apache.qpid.test.utils.JMXTestUtils; import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.apache.qpid.test.utils.TestBrokerConfiguration; import org.apache.qpid.util.FileUtils; +import org.apache.qpid.util.Strings; /** * Tests upgrading a BDB store on broker startup. @@ -88,7 +89,7 @@ public class BDBUpgradeTest extends QpidBrokerTestCase Map<String, Object> virtualHostAttributes = getBrokerConfiguration().getObjectAttributes(VirtualHost.class,TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST); @SuppressWarnings("unchecked") Map<String, Object> messageStoreSettings = (Map<String, Object>) virtualHostAttributes.get(VirtualHost.MESSAGE_STORE_SETTINGS); - _storeLocation = (String)messageStoreSettings.get(MessageStore.STORE_PATH); + _storeLocation = Strings.expand((String)messageStoreSettings.get(MessageStore.STORE_PATH)); //Clear the two target directories if they exist. File directory = new File(_storeLocation); 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 c5e6a01749..2af06cfa8e 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 @@ -20,30 +20,30 @@ */ package org.apache.qpid.server.binding; +import java.security.AccessControlException; +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; + import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.messages.BindingMessages; import org.apache.qpid.server.logging.subjects.BindingLogSubject; +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; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.State; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.util.StateChangeListener; -import java.security.AccessControlException; -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; - public class BindingImpl extends AbstractConfiguredObject<BindingImpl> implements org.apache.qpid.server.model.Binding<BindingImpl> @@ -83,7 +83,7 @@ public class BindingImpl public BindingImpl(UUID id, Map<String, Object> attributes, AMQQueue queue, ExchangeImpl exchange) { - super(id,Collections.EMPTY_MAP,attributes,queue.getVirtualHost().getTaskExecutor()); + super(parentsMap(queue,exchange),Collections.EMPTY_MAP,combineIdWithAttributes(id,attributes),queue.getVirtualHost().getTaskExecutor()); _id = id; _bindingKey = (String)attributes.get(org.apache.qpid.server.model.Binding.NAME); _queue = queue; @@ -102,6 +102,14 @@ public class BindingImpl } + private static Map<Class<? extends ConfiguredObject>, ConfiguredObject<?>> parentsMap(final AMQQueue queue, final ExchangeImpl exchange) + { + final Map<Class<? extends ConfiguredObject>, ConfiguredObject<?>> parents = new HashMap<Class<? extends ConfiguredObject>, ConfiguredObject<?>>(); + parents.put(Queue.class, queue); + parents.put(Exchange.class, exchange); + return parents; + } + public String getBindingKey() { @@ -294,20 +302,6 @@ public class BindingImpl } @Override - public <T extends ConfiguredObject> T getParent(final Class<T> clazz) - { - if(clazz == Exchange.class) - { - return (T) getExchange(); - } - else if(clazz == Queue.class) - { - return (T) getQueue(); - } - return super.getParent(clazz); - } - - @Override public Object setAttribute(final String name, final Object expected, final Object desired) throws IllegalStateException, AccessControlException, IllegalArgumentException { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java index cdf44822ef..88817be972 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java @@ -38,6 +38,7 @@ 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.VirtualHost; +import org.apache.qpid.server.model.adapter.BrokerAdapter; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.ConfiguredObjectRecordImpl; import org.apache.qpid.server.store.DurableConfigurationStore; @@ -330,7 +331,7 @@ public class ManagementModeStoreHandler implements DurableConfigurationStore attributes.put(Port.NAME, MANAGEMENT_MODE_PORT_PREFIX + protocol.name()); if (protocol != Protocol.RMI) { - attributes.put(Port.AUTHENTICATION_PROVIDER, MANAGEMENT_MODE_AUTH_PROVIDER); + attributes.put(Port.AUTHENTICATION_PROVIDER, BrokerAdapter.MANAGEMENT_MODE_AUTHENTICATION); } ConfiguredObjectRecord portEntry = new ConfiguredObjectRecordImpl(UUID.randomUUID(), PORT_TYPE, attributes, Collections.singletonMap(parent.getType(),parent)); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStore.java index d534814410..b3f91d7ee1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStore.java @@ -61,8 +61,6 @@ import org.apache.qpid.server.model.UUIDGenerator; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler; -import org.apache.qpid.util.Strings; -import org.apache.qpid.util.Strings.ChainedResolver; public class MemoryConfigurationEntryStore implements ConfigurationEntryStore { @@ -85,7 +83,6 @@ public class MemoryConfigurationEntryStore implements ConfigurationEntryStore private boolean _generatedObjectIdDuringLoad; - private ChainedResolver _resolver; private ConfiguredObject<?> _parent; protected MemoryConfigurationEntryStore(Map<String, String> configProperties) @@ -95,8 +92,6 @@ public class MemoryConfigurationEntryStore implements ConfigurationEntryStore _objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); _entries = new HashMap<UUID, ConfigurationEntry>(); _brokerChildrenRelationshipMap = buildRelationshipClassMap(); - _resolver = new Strings.ChainedResolver(Strings.SYSTEM_RESOLVER, - new Strings.MapResolver(configProperties)); } MemoryConfigurationEntryStore(String json, Map<String, String> configProperties) @@ -872,7 +867,7 @@ public class MemoryConfigurationEntryStore implements ConfigurationEntryStore } else { - return Strings.expand(node.asText(), _resolver); + return node.asText(); } } else if (node.isArray()) @@ -923,4 +918,5 @@ public class MemoryConfigurationEntryStore implements ConfigurationEntryStore { return _util; } + } 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 2625fe83bc..3fbc0076a5 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 @@ -22,7 +22,20 @@ package org.apache.qpid.server.exchange; import java.security.AccessControlException; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + import org.apache.log4j.Logger; + import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.LogSubject; @@ -32,13 +45,13 @@ import org.apache.qpid.server.message.InstanceProperties; 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.ConfiguredObject; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Publisher; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.UUIDGenerator; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; @@ -51,19 +64,7 @@ import org.apache.qpid.server.util.StateChangeListener; import org.apache.qpid.server.virtualhost.ExchangeIsAlternateException; import org.apache.qpid.server.virtualhost.RequiredExchangeException; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public abstract class AbstractExchange<T extends AbstractExchange<T>> extends AbstractConfiguredObject<T> @@ -77,7 +78,7 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> private boolean _durable; - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; private final List<Action<ExchangeImpl>> _closeTaskList = new CopyOnWriteArrayList<Action<ExchangeImpl>>(); @@ -105,10 +106,10 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> private StateChangeListener<BindingImpl, State> _bindingListener; - public AbstractExchange(VirtualHost vhost, Map<String, Object> attributes) throws UnknownExchangeException + public AbstractExchange(VirtualHostImpl vhost, Map<String, Object> attributes) throws UnknownExchangeException { - super(MapValueConverter.getUUIDAttribute(org.apache.qpid.server.model.Exchange.ID, attributes), - Collections.<String,Object>emptyMap(), attributes, vhost.getTaskExecutor()); + super(Collections.<Class<? extends ConfiguredObject>, ConfiguredObject<?>>singletonMap(org.apache.qpid.server.model.VirtualHost.class, (org.apache.qpid.server.model.VirtualHost)vhost), + Collections.<String,Object>emptyMap(), attributes, vhost.getTaskExecutor()); _virtualHost = vhost; _durable = MapValueConverter.getBooleanAttribute(org.apache.qpid.server.model.Exchange.DURABLE, attributes); @@ -227,7 +228,7 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> return getClass().getSimpleName() + "[" + getName() +"]"; } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _virtualHost; } @@ -887,17 +888,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> } } - - @Override - public <T extends ConfiguredObject> T getParent(final Class<T> clazz) - { - if(clazz == org.apache.qpid.server.model.VirtualHost.class) - { - return (T) _virtualHost.getModel(); - } - return super.getParent(clazz); - } - @Override public Collection<String> getAttributeNames() { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultDestination.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultDestination.java index c3ddc6c27a..e9e6bbd30a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultDestination.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultDestination.java @@ -29,15 +29,15 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.store.StorableMessageMetaData; import org.apache.qpid.server.txn.ServerTransaction; import org.apache.qpid.server.util.Action; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class DefaultDestination implements MessageDestination { - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; private static final Logger _logger = Logger.getLogger(DefaultDestination.class); - public DefaultDestination(VirtualHost virtualHost) + public DefaultDestination(VirtualHostImpl virtualHost) { _virtualHost = virtualHost; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java index 99d6487af8..ac139a2c66 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java @@ -27,7 +27,7 @@ import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.plugin.QpidServiceLoader; import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.Collection; import java.util.HashMap; @@ -45,10 +45,10 @@ public class DefaultExchangeFactory implements ExchangeFactory ExchangeDefaults.HEADERS_EXCHANGE_CLASS, ExchangeDefaults.TOPIC_EXCHANGE_CLASS}; - private final VirtualHost _host; + private final VirtualHostImpl _host; private Map<String, ExchangeType<? extends ExchangeImpl>> _exchangeClassMap = new HashMap<String, ExchangeType<? extends ExchangeImpl>>(); - public DefaultExchangeFactory(VirtualHost host) + public DefaultExchangeFactory(VirtualHostImpl host) { _host = host; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java index 1e0226308b..a79601bced 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java @@ -20,7 +20,17 @@ */ package org.apache.qpid.server.exchange; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + import org.apache.log4j.Logger; + import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.message.MessageDestination; import org.apache.qpid.server.model.UUIDGenerator; @@ -30,16 +40,7 @@ import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.DurableConfigurationStoreHelper; import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class DefaultExchangeRegistry implements ExchangeRegistry { @@ -51,13 +52,13 @@ public class DefaultExchangeRegistry implements ExchangeRegistry private MessageDestination _defaultExchange; - private final VirtualHost _host; + private final VirtualHostImpl _host; private final QueueRegistry _queueRegistry; private final Collection<RegistryChangeListener> _listeners = Collections.synchronizedCollection(new ArrayList<RegistryChangeListener>()); - public DefaultExchangeRegistry(VirtualHost host, QueueRegistry queueRegistry) + public DefaultExchangeRegistry(VirtualHostImpl host, QueueRegistry queueRegistry) { _host = host; _queueRegistry = queueRegistry; @@ -97,6 +98,7 @@ public class DefaultExchangeRegistry implements ExchangeRegistry attributes.put(org.apache.qpid.server.model.Exchange.TYPE, type); attributes.put(org.apache.qpid.server.model.Exchange.DURABLE, true); ExchangeImpl<?> exchange = f.createExchange(attributes); + exchange.open(); registerExchange(exchange); if(exchange.isDurable()) { 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 a67cacf821..ca5800547e 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 @@ -36,7 +36,7 @@ import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.ArrayList; import java.util.Collections; @@ -130,7 +130,7 @@ public class DirectExchange extends AbstractExchange<DirectExchange> public static final ExchangeType<DirectExchange> TYPE = new DirectExchangeType(); - public DirectExchange(final VirtualHost vhost, + public DirectExchange(final VirtualHostImpl vhost, final Map<String, Object> attributes) throws UnknownExchangeException { super(vhost, attributes); 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 8e7b392fe9..3f480af607 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 @@ -21,12 +21,11 @@ package org.apache.qpid.server.exchange; import java.util.Map; -import java.util.UUID; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class DirectExchangeType implements ExchangeType<DirectExchange> { @@ -37,7 +36,7 @@ public class DirectExchangeType implements ExchangeType<DirectExchange> } @Override - public DirectExchange newInstance(final VirtualHost virtualHost, + public DirectExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) throws UnknownExchangeException { return new DirectExchange(virtualHost, attributes); 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 b7810e8112..893ffee4c1 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 @@ -38,7 +38,7 @@ import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.ArrayList; @@ -66,7 +66,7 @@ public class FanoutExchange extends AbstractExchange<FanoutExchange> public static final ExchangeType<FanoutExchange> TYPE = new FanoutExchangeType(); - public FanoutExchange(final VirtualHost vhost, + public FanoutExchange(final VirtualHostImpl vhost, final Map<String, Object> attributes) throws UnknownExchangeException { super(vhost, attributes); 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 25e6afeeca..c66ea9eefb 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 @@ -21,12 +21,11 @@ package org.apache.qpid.server.exchange; import java.util.Map; -import java.util.UUID; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class FanoutExchangeType implements ExchangeType<FanoutExchange> { @@ -37,7 +36,7 @@ public class FanoutExchangeType implements ExchangeType<FanoutExchange> } @Override - public FanoutExchange newInstance(final VirtualHost virtualHost, final Map<String, Object> attributes) + public FanoutExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) throws UnknownExchangeException { return new FanoutExchange(virtualHost, attributes); 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 9d3ce0a415..dd5fa5fb4b 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 @@ -30,7 +30,7 @@ import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -80,7 +80,7 @@ public class HeadersExchange extends AbstractExchange<HeadersExchange> public static final ExchangeType<HeadersExchange> TYPE = new HeadersExchangeType(); - public HeadersExchange(final VirtualHost vhost, + public HeadersExchange(final VirtualHostImpl vhost, final Map<String, Object> attributes) throws UnknownExchangeException { super(vhost, attributes); 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 3afc6f71c1..d0056416cc 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 @@ -21,12 +21,11 @@ package org.apache.qpid.server.exchange; import java.util.Map; -import java.util.UUID; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class HeadersExchangeType implements ExchangeType<HeadersExchange> { @@ -37,7 +36,7 @@ public class HeadersExchangeType implements ExchangeType<HeadersExchange> } @Override - public HeadersExchange newInstance(final VirtualHost virtualHost, final Map<String, Object> attributes) + public HeadersExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) throws UnknownExchangeException { return new HeadersExchange(virtualHost, attributes); 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 db73e842b8..409d77a460 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 @@ -43,7 +43,7 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class TopicExchange extends AbstractExchange<TopicExchange> { @@ -59,7 +59,7 @@ public class TopicExchange extends AbstractExchange<TopicExchange> private final Map<BindingImpl, Map<String,Object>> _bindings = new HashMap<BindingImpl, Map<String,Object>>(); - public TopicExchange(final VirtualHost vhost, final Map attributes) throws UnknownExchangeException + public TopicExchange(final VirtualHostImpl vhost, final Map attributes) throws UnknownExchangeException { super(vhost, attributes); } 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 27778ff502..12274f951e 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 @@ -21,12 +21,11 @@ package org.apache.qpid.server.exchange; import java.util.Map; -import java.util.UUID; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class TopicExchangeType implements ExchangeType<TopicExchange> { @@ -37,7 +36,7 @@ public class TopicExchangeType implements ExchangeType<TopicExchange> } @Override - public TopicExchange newInstance(final VirtualHost virtualHost, final Map<String, Object> attributes) + public TopicExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) throws UnknownExchangeException { return new TopicExchange(virtualHost, attributes); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java index 95b044d241..7400eb8221 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java @@ -25,7 +25,7 @@ import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.BINDING_F import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class BindingLogSubject extends AbstractLogSubject { @@ -42,7 +42,7 @@ public class BindingLogSubject extends AbstractLogSubject public BindingLogSubject(String routingKey, ExchangeImpl exchange, AMQQueue queue) { - VirtualHost virtualHost = queue.getVirtualHost(); + VirtualHostImpl virtualHost = queue.getVirtualHost(); ExchangeType exchangeType = exchange.getExchangeType(); setLogStringWithFormat(BINDING_FORMAT, virtualHost.getName(), diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java index 2ad1b63dea..946b8dada5 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java @@ -21,7 +21,7 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.exchange.ExchangeImpl; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.EXCHANGE_FORMAT; @@ -29,7 +29,7 @@ public class ExchangeLogSubject extends AbstractLogSubject { /** Create an ExchangeLogSubject that Logs in the following format. */ - public ExchangeLogSubject(ExchangeImpl exchange, VirtualHost vhost) + public ExchangeLogSubject(ExchangeImpl exchange, VirtualHostImpl vhost) { setLogStringWithFormat(EXCHANGE_FORMAT, vhost.getName(), exchange.getExchangeType().getType(), exchange.getName()); 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 a31a4f0ab7..a31c2db85c 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 @@ -20,6 +20,36 @@ */ package org.apache.qpid.server.model; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.security.AccessControlException; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.AbstractCollection; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.security.auth.Subject; + +import org.apache.log4j.Logger; + import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.configuration.updater.ChangeAttributesTask; import org.apache.qpid.server.configuration.updater.ChangeStateTask; @@ -29,20 +59,13 @@ import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; import org.apache.qpid.server.store.ConfiguredObjectRecord; +import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.ServerScopedRuntimeException; - -import javax.security.auth.Subject; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.security.AccessControlException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.*; +import org.apache.qpid.util.Strings; public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> implements ConfiguredObject<X> { + private static final Logger LOGGER = Logger.getLogger(AbstractConfiguredObject.class); private static final String ID = "id"; private static final Map<Class<? extends ConfiguredObject>, Collection<Attribute<?,?>>> _allAttributes = @@ -71,6 +94,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im SECURE_VALUES = Collections.unmodifiableMap(secureValues); } + private final AtomicBoolean _open = new AtomicBoolean(); private final Map<String,Object> _attributes = new HashMap<String, Object>(); private final Map<Class<? extends ConfiguredObject>, ConfiguredObject> _parents = @@ -78,6 +102,9 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im private final Collection<ConfigurationChangeListener> _changeListeners = new ArrayList<ConfigurationChangeListener>(); + private final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObject<?>>> _children = + new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObject<?>>>(); + @ManagedAttributeField private final UUID _id; @@ -99,6 +126,9 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im @ManagedAttributeField private String _name; + @ManagedAttributeField + private Map<String,String> _context; + private final Map<String, Attribute<?,?>> _attributeTypes; private final Map<String, Field> _automatedFields; @@ -149,17 +179,43 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im boolean filterAttributes) { _taskExecutor = taskExecutor; - final UUID uuid = (UUID) attributes.get(ID); - _id = uuid == null ? UUID.randomUUID() : uuid; + Object idObj = attributes.get(ID); + + UUID uuid; + if(idObj == null) + { + uuid = UUID.randomUUID(); + } + else + { + uuid = UUID_CONVERTER.convert(idObj, this); + } + _id = uuid; + + _attributeTypes = getAttributeTypes(getClass()); _automatedFields = getAutomatedFields(getClass()); + for (Class<? extends ConfiguredObject> childClass : Model.getInstance().getChildTypes(getCategoryClass())) + { + _children.put(childClass, new CopyOnWriteArrayList<ConfiguredObject<?>>()); + } + + for(ConfiguredObject<?> parent : parents.values()) + { + if(parent instanceof AbstractConfiguredObject<?>) + { + ((AbstractConfiguredObject<?>)parent).registerChild(this); + } + } for(Map.Entry<Class<? extends ConfiguredObject>, ConfiguredObject<?>> entry : parents.entrySet()) { addParent((Class<ConfiguredObject>) entry.getKey(), entry.getValue()); } + _name = STRING_CONVERTER.convert(attributes.get(NAME),this); + Collection<String> names = getAttributeNames(); if(names!=null) { @@ -174,10 +230,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im { _attributes.put(name, value); } - if(_automatedFields.containsKey(name)) - { - automatedSetValue(name, value); - } } } } @@ -188,10 +240,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im if(entry.getValue()!=null) { _attributes.put(entry.getKey(),entry.getValue()); - if(_automatedFields.containsKey(entry.getKey())) - { - automatedSetValue(entry.getKey(), entry.getValue()); - } } } } @@ -201,13 +249,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im if (defaults != null) { _defaultAttributes.putAll(defaults); - for(Map.Entry<String,Object> defaultedEntry : defaults.entrySet()) - { - if(_automatedFields.containsKey(defaultedEntry.getKey()) && !attributes.containsKey(defaultedEntry.getKey())) - { - automatedSetValue(defaultedEntry.getKey(),defaultedEntry.getValue()); - } - } } if(!_attributes.containsKey(CREATED_BY)) { @@ -223,20 +264,14 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } for(Attribute<?,?> attr : _attributeTypes.values()) { - if(attr.getAnnotation().mandatory() && !(attributes.containsKey(attr.getName())|| defaults.containsKey(attr.getName()))) + if(attr.getAnnotation().mandatory() && !(_attributes.containsKey(attr.getName()) + || _defaultAttributes.containsKey(attr.getName()) + || !"".equals(attr.getAnnotation().defaultValue()))) { throw new IllegalArgumentException("Mandatory attribute " + attr.getName() + " not supplied for instance of " + getClass().getName()); } } - for(ConfiguredObject<?> parent : parents.values()) - { - if(parent instanceof AbstractConfiguredObject<?>) - { - ((AbstractConfiguredObject<?>)parent).instantiateChild(this); - } - } - } private void automatedSetValue(final String name, final Object value) @@ -257,6 +292,145 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im this(id, Collections.<String,Object>emptyMap(), Collections.<String,Object>emptyMap(), taskExecutor); } + public void open() + { + if(_open.compareAndSet(false,true)) + { + doResolution(); + doValidation(); + doOpening(); + } + } + + + public void create() + { + if(_open.compareAndSet(false,true)) + { + doResolution(); + doValidation(); + doCreation(); + doOpening(); + } + } + + protected void doOpening() + { + onOpen(); + applyToChildren(new Action<ConfiguredObject<?>>() + { + @Override + public void performAction(final ConfiguredObject<?> child) + { + if(child instanceof AbstractConfiguredObject) + { + ((AbstractConfiguredObject)child).doOpening(); + } + } + }); + } + + protected void doValidation() + { + applyToChildren(new Action<ConfiguredObject<?>>() + { + @Override + public void performAction(final ConfiguredObject<?> child) + { + if(child instanceof AbstractConfiguredObject) + { + ((AbstractConfiguredObject)child).doValidation(); + } + } + }); + validate(); + } + + protected void doResolution() + { + resolve(); + applyToChildren(new Action<ConfiguredObject<?>>() + { + @Override + public void performAction(final ConfiguredObject<?> child) + { + if(child instanceof AbstractConfiguredObject) + { + ((AbstractConfiguredObject)child).doResolution(); + } + } + }); + } + + protected void doCreation() + { + onCreate(); + applyToChildren(new Action<ConfiguredObject<?>>() + { + @Override + public void performAction(final ConfiguredObject<?> child) + { + if(child instanceof AbstractConfiguredObject) + { + ((AbstractConfiguredObject)child).doCreation(); + } + } + }); + } + + private void applyToChildren(Action<ConfiguredObject<?>> action) + { + for (Class<? extends ConfiguredObject> childClass : Model.getInstance().getChildTypes(getCategoryClass())) + { + Collection<? extends ConfiguredObject> children = getChildren(childClass); + if (children != null) + { + for (ConfiguredObject<?> child : children) + { + action.performAction(child); + } + } + } + } + + public void validate() + { + } + + protected void resolve() + { + for (Attribute<?, ?> attr : _attributeTypes.values()) + { + String attrName = attr.getName(); + ManagedAttribute attrAnnotation = attr.getAnnotation(); + if (attrAnnotation.automate()) + { + if (_attributes.containsKey(attrName)) + { + automatedSetValue(attrName, _attributes.get(attrName)); + } + else if (_defaultAttributes.containsKey(attrName)) + { + automatedSetValue(attrName, _defaultAttributes.get(attrName)); + } + else if (!"".equals(attrAnnotation.defaultValue())) + { + automatedSetValue(attrName, attrAnnotation.defaultValue()); + } + + } + } + } + + protected void onOpen() + { + } + + + protected void onCreate() + { + } + public final UUID getId() { return _id; @@ -272,6 +446,11 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im return getCategory(getClass()); } + public Map<String,String> getContext() + { + return _context == null ? null : Collections.unmodifiableMap(_context); + } + public State getDesiredState() { return null; //TODO @@ -424,10 +603,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } } - protected void create() - { - } - protected <T extends ConfiguredObject<?>> Object getAttribute(String name, T parent, String parentAttributeName) { Object value = getActualAttribute(name); @@ -666,39 +841,37 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im throw new UnsupportedOperationException(); } - protected <C extends ConfiguredObject> void instantiateChild(final C child) + private <C extends ConfiguredObject> void registerChild(final C child) { + _children.get(child.getCategoryClass()).add(child); + } - Class<? extends ConfiguredObject> childCategory = child.getCategoryClass(); - if(!Model.getInstance().getChildTypes(getCategoryClass()).contains(childCategory)) - { - throw new IllegalArgumentException("Cannot instantiate a child of category " + childCategory.getSimpleName() - + " to a parent of category " + getCategoryClass().getSimpleName()); - } - try - { - final String methodName = "instantiate" + childCategory.getSimpleName(); - Method recoveryMethod = getClass().getMethod(methodName, childCategory); - recoveryMethod.setAccessible(true); - recoveryMethod.invoke(this, child); - } - catch (NoSuchMethodException e) - { - throw new IllegalArgumentException("Cannot instantiate a child of category " + childCategory.getSimpleName() - + " to a parent of category " + getCategoryClass().getSimpleName() - + ". No instatiation method defined. "); - } - catch (InvocationTargetException e) - { - throw new IllegalArgumentException("Error recovering child", e.getTargetException()); - } - catch (IllegalAccessException e) + protected void deleted() + { + for(ConfiguredObject<?> parent : _parents.values()) { - throw new ServerScopedRuntimeException("Error recovering child, method for recovery cannot be called", e); + if(parent instanceof AbstractConfiguredObject<?>) + { + ((AbstractConfiguredObject<?>)parent).unregisterChild(this); + } } } + + protected <C extends ConfiguredObject> void unregisterChild(final C child) + { + _children.get(child.getCategoryClass()).remove(child); + } + + + + @Override + public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) + { + return Collections.unmodifiableList((List<? extends C>) _children.get(clazz)); + } + public TaskExecutor getTaskExecutor() { return _taskExecutor; @@ -903,13 +1076,13 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im protected final Converter<T> _converter; protected final Method _getter; - private AttributeOrStatistic( - String name, final Method getter, Class<T> type) + private AttributeOrStatistic(final Method getter) { - _name = name; + _getter = getter; - _type = type; - _converter = getConverter(type); + _type = (Class<T>) getTypeFromMethod(getter); + _name = getNameFromMethod(getter, _type); + _converter = getConverter(_type, getter.getGenericReturnType()); } @@ -950,9 +1123,18 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im private static final class Statistic<C extends ConfiguredObject, T extends Number> extends AttributeOrStatistic<C,T> { - private Statistic(Class<C> clazz, String name, Class<T> type, final Method getter) + private Statistic(Class<C> clazz, final Method getter) { - super(name, getter, type); + super(getter); + if(getter.getParameterTypes().length != 0) + { + throw new IllegalArgumentException("ManagedStatistic annotation should only be added to no-arg getters"); + } + + if(!Number.class.isAssignableFrom(getType())) + { + throw new IllegalArgumentException("ManagedStatistic annotation should only be added to getters returning a Number type"); + } addToStatisticsSet(clazz, this); } } @@ -963,12 +1145,14 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im private final ManagedAttribute _annotation; private Attribute(Class<C> clazz, - String name, - Class<T> type, final Method getter, final ManagedAttribute annotation) { - super(name, getter, type); + super(getter); + if(getter.getParameterTypes().length != 0) + { + throw new IllegalArgumentException("ManagedAttribute annotation should only be added to no-arg getters"); + } _annotation = annotation; addToAttributesSet(clazz, this); } @@ -984,6 +1168,31 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } } + private static String interpolate(ConfiguredObject<?> object, String value) + { + Map<String,String> inheritedContext = new HashMap<String, String>(); + generateInheritedContext(object, inheritedContext); + return Strings.expand(value, false, Strings.ENV_VARS_RESOLVER, Strings.JAVA_SYS_PROPS_RESOLVER, new Strings.MapResolver(inheritedContext)); + } + + private static void generateInheritedContext(final ConfiguredObject<?> object, + final Map<String, String> inheritedContext) + { + Collection<Class<? extends ConfiguredObject>> parents = + Model.getInstance().getParentTypes(object.getCategoryClass()); + if(parents != null && !parents.isEmpty()) + { + ConfiguredObject parent = object.getParent(parents.iterator().next()); + if(parent != null) + { + generateInheritedContext(parent, inheritedContext); + } + } + if(object.getContext() != null) + { + inheritedContext.putAll(object.getContext()); + } + } private static interface Converter<T> { @@ -995,7 +1204,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im @Override public String convert(final Object value, final ConfiguredObject object) { - return value == null ? null : value.toString(); + return value == null ? null : interpolate(object, value.toString()); } }; @@ -1010,7 +1219,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } else if(value instanceof String) { - return UUID.fromString((String) value); + return UUID.fromString(interpolate(object, (String) value)); } else if(value == null) { @@ -1039,7 +1248,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } else if(value instanceof String) { - return Long.valueOf((String) value); + return Long.valueOf(interpolate(object, (String) value)); } else if(value == null) { @@ -1068,7 +1277,17 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } else if(value instanceof String) { - return Integer.valueOf((String) value); + try + { + return Integer.valueOf(interpolate(object, (String) value)); + } + catch (NumberFormatException e) + { + Map<String,String> context = new HashMap<String, String>(); + generateInheritedContext(object, context); + LOGGER.debug(context.toString()); + throw e; + } } else if(value == null) { @@ -1098,7 +1317,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } else if(value instanceof String) { - return Short.valueOf((String) value); + return Short.valueOf(interpolate(object, (String) value)); } else if(value == null) { @@ -1123,7 +1342,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } else if(value instanceof String) { - return Boolean.valueOf((String) value); + return Boolean.valueOf(interpolate(object, (String) value)); } else if(value == null) { @@ -1143,7 +1362,96 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im { if(value instanceof List) { - return (List) value; + return Collections.unmodifiableList((List) value); + } + else if(value instanceof Object[]) + { + return convert(Arrays.asList((Object[])value),object); + } + else if(value == null) + { + return null; + } + else + { + throw new IllegalArgumentException("Cannot convert type " + value.getClass() + " to a List"); + } + } + }; + + public static class GenericListConverter implements Converter<List> + { + + private final Converter<?> _memberConverter; + + public GenericListConverter(final Type genericType) + { + _memberConverter = getConverter(getRawType(genericType),genericType); + } + + private static Class getRawType(Type t) + { + if(t instanceof Class) + { + return (Class)t; + } + else if(t instanceof ParameterizedType) + { + return (Class)((ParameterizedType)t).getRawType(); + } + else if(t instanceof TypeVariable) + { + Type[] bounds = ((TypeVariable)t).getBounds(); + if(bounds.length == 1) + { + return getRawType(bounds[0]); + } + } + throw new ServerScopedRuntimeException("Unable to process type when constructing configuration model: " + t); + } + + @Override + public List convert(final Object value, final ConfiguredObject object) + { + if(value instanceof Collection) + { + Collection original = (Collection)value; + List converted = new ArrayList(original.size()); + for(Object member : original) + { + converted.add(_memberConverter.convert(member, object)); + } + return Collections.unmodifiableList(converted); + } + else if(value instanceof Object[]) + { + return convert(Arrays.asList((Object[])value),object); + } + else if(value == null) + { + return null; + } + else + { + return Collections.unmodifiableList(Collections.singletonList(_memberConverter.convert(value, object))); + } + } + } + + + private static final Converter<Set> SET_CONVERTER = new Converter<Set>() + { + @Override + public Set convert(final Object value, final ConfiguredObject object) + { + if(value instanceof Set) + { + return Collections.unmodifiableSet((Set) value); + } + + else if(value instanceof Object[]) + { + return convert(new HashSet(Arrays.asList((Object[])value)),object); } else if(value == null) { @@ -1156,6 +1464,66 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } }; + public static class GenericSetConverter implements Converter<Set> + { + + private final Converter<?> _memberConverter; + + public GenericSetConverter(final Type genericType) + { + _memberConverter = getConverter(getRawType(genericType),genericType); + } + + private static Class getRawType(Type t) + { + if(t instanceof Class) + { + return (Class)t; + } + else if(t instanceof ParameterizedType) + { + return (Class)((ParameterizedType)t).getRawType(); + } + else if(t instanceof TypeVariable) + { + Type[] bounds = ((TypeVariable)t).getBounds(); + if(bounds.length == 1) + { + return getRawType(bounds[0]); + } + } + throw new ServerScopedRuntimeException("Unable to process type when constructing configuration model: " + t); + } + + @Override + public Set convert(final Object value, final ConfiguredObject object) + { + if(value instanceof Collection) + { + Collection original = (Collection)value; + Set converted = new HashSet(original.size()); + for(Object member : original) + { + converted.add(_memberConverter.convert(member, object)); + } + return Collections.unmodifiableSet(converted); + } + else if(value instanceof Object[]) + { + return convert(new HashSet(Arrays.asList((Object[])value)),object); + } + else if(value == null) + { + return null; + } + else + { + return Collections.unmodifiableSet(Collections.singleton(_memberConverter.convert(value, object))); + } + } + } + + private static final Converter<Collection> COLLECTION_CONVERTER = new Converter<Collection>() { @Override @@ -1163,7 +1531,11 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im { if(value instanceof Collection) { - return (Collection) value; + return Collections.unmodifiableCollection((Collection) value); + } + else if(value instanceof Object[]) + { + return convert(Arrays.asList((Object[]) value), object); } else if(value == null) { @@ -1176,6 +1548,66 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } }; + + public static class GenericCollectionConverter implements Converter<Collection> + { + + private final Converter<?> _memberConverter; + + public GenericCollectionConverter(final Type genericType) + { + _memberConverter = getConverter(getRawType(genericType),genericType); + } + + private static Class getRawType(Type t) + { + if(t instanceof Class) + { + return (Class)t; + } + else if(t instanceof ParameterizedType) + { + return (Class)((ParameterizedType)t).getRawType(); + } + else if(t instanceof TypeVariable) + { + Type[] bounds = ((TypeVariable)t).getBounds(); + if(bounds.length == 1) + { + return getRawType(bounds[0]); + } + } + throw new ServerScopedRuntimeException("Unable to process type when constructing configuration model: " + t); + } + + @Override + public Collection convert(final Object value, final ConfiguredObject object) + { + if(value instanceof Collection) + { + Collection original = (Collection)value; + Collection converted = new ArrayList(original.size()); + for(Object member : original) + { + converted.add(_memberConverter.convert(member, object)); + } + return Collections.unmodifiableCollection(converted); + } + else if(value instanceof Object[]) + { + return convert(Arrays.asList((Object[])value),object); + } + else if(value == null) + { + return null; + } + else + { + return Collections.unmodifiableCollection(Collections.singletonList(_memberConverter.convert(value, object))); + } + } + } + private static final Converter<Map> MAP_CONVERTER = new Converter<Map>() { @Override @@ -1183,7 +1615,16 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im { if(value instanceof Map) { - return (Map) value; + Map<Object,Object> originalMap = (Map) value; + Map resolvedMap = new LinkedHashMap(originalMap.size()); + for(Map.Entry<Object,Object> entry : originalMap.entrySet()) + { + Object key = entry.getKey(); + Object val = entry.getValue(); + resolvedMap.put(key instanceof String ? interpolate(object, (String)key) : key, + val instanceof String ? interpolate(object, (String)val) : val); + } + return Collections.unmodifiableMap(resolvedMap); } else if(value == null) { @@ -1218,7 +1659,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } else if(value instanceof String) { - return Enum.valueOf(_klazz,(String) value); + return Enum.valueOf(_klazz, interpolate(object, (String) value)); } else { @@ -1262,22 +1703,23 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } else if(value instanceof String) { + String valueStr = interpolate(object, (String) value); Collection<X> reachable = getReachableObjects(object,_klazz); for(X candidate : reachable) { - if(candidate.getName().equals(value)) + if(candidate.getName().equals(valueStr)) { return candidate; } } try { - UUID id = UUID.fromString((String)value); + UUID id = UUID.fromString(valueStr); return convert(id, object); } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("Cannot find a " + _klazz.getSimpleName() + " with name '" + value + "'"); + throw new IllegalArgumentException("Cannot find a " + _klazz.getSimpleName() + " with name '" + valueStr + "'"); } } else @@ -1288,7 +1730,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } - private static <X> Converter<X> getConverter(final Class<X> type) + private static <X> Converter<X> getConverter(final Class<X> type, final Type returnType) { if(type == String.class) { @@ -1320,7 +1762,27 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } else if(List.class.isAssignableFrom(type)) { - return (Converter<X>) LIST_CONVERTER; + if (returnType instanceof ParameterizedType) + { + Type parameterizedType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; + return (Converter<X>) new GenericListConverter(parameterizedType); + } + else + { + return (Converter<X>) LIST_CONVERTER; + } + } + else if(Set.class.isAssignableFrom(type)) + { + if (returnType instanceof ParameterizedType) + { + Type parameterizedType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; + return (Converter<X>) new GenericSetConverter(parameterizedType); + } + else + { + return (Converter<X>) SET_CONVERTER; + } } else if(Map.class.isAssignableFrom(type)) { @@ -1328,7 +1790,15 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } else if(Collection.class.isAssignableFrom(type)) { - return (Converter<X>) COLLECTION_CONVERTER; + if (returnType instanceof ParameterizedType) + { + Type parameterizedType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; + return (Converter<X>) new GenericCollectionConverter(parameterizedType); + } + else + { + return (Converter<X>) COLLECTION_CONVERTER; + } } else if(ConfiguredObject.class.isAssignableFrom(type)) { @@ -1472,31 +1942,14 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class); if(annotation != null) { - if(m.getParameterTypes().length != 0) - { - throw new IllegalArgumentException("ManagedAttribute annotation should only be added to no-arg getters"); - } - Class<?> type = getType(m); - String name = getName(m, type); - Attribute<X,?> newAttr = new Attribute(clazz,name,type,m, annotation); - + Attribute<X,?> newAttr = new Attribute(clazz, m, annotation); } else { ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class); if(statAnnotation != null) { - if(m.getParameterTypes().length != 0) - { - throw new IllegalArgumentException("ManagedStatistic annotation should only be added to no-arg getters"); - } - Class<?> type = getType(m); - if(!Number.class.isAssignableFrom(type)) - { - throw new IllegalArgumentException("ManagedStatistic annotation should only be added to getters returning a Number type"); - } - String name = getName(m, type); - Statistic<X,?> newStat = new Statistic(clazz,name,type,m); + Statistic<X,?> newStat = new Statistic(clazz,m); } } } @@ -1542,7 +1995,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im throw new ServerScopedRuntimeException("Unable to find field definition for automated field " + attr.getName() + " in class " + objClass.getName()); } - private static String getName(final Method m, final Class<?> type) + private static String getNameFromMethod(final Method m, final Class<?> type) { String methodName = m.getName(); String baseName; @@ -1579,7 +2032,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im return name; } - private static Class<?> getType(final Method m) + private static Class<?> getTypeFromMethod(final Method m) { Class<?> type = m.getReturnType(); if(type.isPrimitive()) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java index 6e03ccdf8a..eff8bb30b6 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java @@ -20,6 +20,13 @@ */ package org.apache.qpid.server.model; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.UUID; + import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.store.ConfiguredObjectDependency; import org.apache.qpid.server.store.ConfiguredObjectIdDependency; @@ -27,12 +34,6 @@ import org.apache.qpid.server.store.ConfiguredObjectNameDependency; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.UnresolvedConfiguredObject; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.UUID; - public abstract class AbstractUnresolvedObject<C extends ConfiguredObject<C>> implements UnresolvedConfiguredObject<C> { private final Class<C> _clazz; @@ -60,41 +61,74 @@ public abstract class AbstractUnresolvedObject<C extends ConfiguredObject<C>> im else if(Collection.class.isAssignableFrom(attributeType)) { Type returnType = attribute.getGetter().getGenericReturnType(); - if (returnType instanceof ParameterizedType) + Class<? extends ConfiguredObject> attrClass = getMemberType(returnType); + if(attrClass != null) { - Type type = ((ParameterizedType) returnType).getActualTypeArguments()[0]; - if(ConfiguredObject.class.isAssignableFrom((Class)type)) + Object attrValue = _record.getAttributes().get(attribute.getName()); + if(attrValue != null) { - Class<? extends ConfiguredObject> attrClass = (Class<? extends ConfiguredObject>) type; - Object attrValue = _record.getAttributes().get(attribute.getName()); - if(attrValue != null) + if (attrValue instanceof Collection) { - if (attrValue instanceof Collection) - { - for (Object val : (Collection) attrValue) - { - addUnresolvedObject(attrClass, attribute.getName(), val); - } - } - else if(attrValue instanceof Object[]) + for (Object val : (Collection) attrValue) { - for (Object val : (Object[]) attrValue) - { - addUnresolvedObject(attrClass, attribute.getName(), val); - } + addUnresolvedObject(attrClass, attribute.getName(), val); } - else + } + else if(attrValue instanceof Object[]) + { + for (Object val : (Object[]) attrValue) { - addUnresolvedObject(attrClass, attribute.getName(), attrValue); + addUnresolvedObject(attrClass, attribute.getName(), val); } } + else + { + addUnresolvedObject(attrClass, attribute.getName(), attrValue); + } } } + + } + } + } + + private Class<? extends ConfiguredObject> getMemberType(Type returnType) + { + Class<? extends ConfiguredObject> categoryClass = null; + + if (returnType instanceof ParameterizedType) + { + Type type = ((ParameterizedType) returnType).getActualTypeArguments()[0]; + if (type instanceof Class && ConfiguredObject.class.isAssignableFrom((Class)type)) + { + categoryClass = (Class<? extends ConfiguredObject>) type; + } + else if (type instanceof ParameterizedType) + { + Type rawType = ((ParameterizedType) type).getRawType(); + if (rawType instanceof Class && ConfiguredObject.class.isAssignableFrom((Class)rawType)) + { + categoryClass = (Class<? extends ConfiguredObject>) rawType; + } + } + else if (type instanceof TypeVariable) + { + Type[] bounds = ((TypeVariable) type).getBounds(); + for(Type boundType : bounds) + { + categoryClass = getMemberType(boundType); + if(categoryClass != null) + { + break; + } + } } } + return categoryClass; } + public ConfiguredObjectRecord getRecord() { return _record; @@ -126,7 +160,7 @@ public abstract class AbstractUnresolvedObject<C extends ConfiguredObject<C>> im { if(attrValue instanceof UUID) { - _unresolvedObjects.add(new IdDependency(clazz, attributeName,(UUID)attrValue)); + _unresolvedObjects.add(new IdDependency(clazz, attributeName, (UUID) attrValue)); } else if(attrValue instanceof String) { @@ -154,6 +188,15 @@ public abstract class AbstractUnresolvedObject<C extends ConfiguredObject<C>> im return _unresolvedObjects; } + @Override + public String toString() + { + return getClass().getSimpleName() + "{" + + "class=" + _clazz.getSimpleName() + + ", unresolvedObjects=" + _unresolvedObjects + + '}'; + } + private abstract class Dependency<X extends ConfiguredObject<X>> implements ConfiguredObjectDependency<X> { private final Class<X> _clazz; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java index fc0a8ab7e5..8f40ca4060 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java @@ -20,13 +20,11 @@ */ package org.apache.qpid.server.model; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import org.apache.qpid.server.security.SubjectCreator; -@ManagedObject +@ManagedObject( creatable = false ) public interface AuthenticationProvider<X extends AuthenticationProvider<X>> extends ConfiguredObject<X> { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java index 26c48fd92e..80d6e31471 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java @@ -75,31 +75,31 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL String VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE = "virtualhost.storeTransactionOpenTimeoutClose"; String VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_WARN = "virtualhost.storeTransactionOpenTimeoutWarn"; - @ManagedAttribute + @ManagedAttribute( derived = true ) String getBuildVersion(); - @ManagedAttribute + @ManagedAttribute( derived = true ) String getOperatingSystem(); - @ManagedAttribute + @ManagedAttribute( derived = true ) String getPlatform(); - @ManagedAttribute + @ManagedAttribute( derived = true ) String getProcessPid(); - @ManagedAttribute + @ManagedAttribute( derived = true ) String getProductVersion(); - @ManagedAttribute + @ManagedAttribute( derived = true ) Collection<String> getSupportedVirtualHostStoreTypes(); - @ManagedAttribute + @ManagedAttribute( derived = true ) Collection<String> getSupportedAuthenticationProviders(); - @ManagedAttribute + @ManagedAttribute( derived = true ) Collection<String> getSupportedPreferencesProviderTypes(); - @ManagedAttribute + @ManagedAttribute( automate = true ) String getDefaultVirtualHost(); @ManagedAttribute @@ -147,7 +147,7 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL @ManagedAttribute boolean getStatisticsReportingResetEnabled(); - @ManagedAttribute + @ManagedAttribute( derived = true ) String getModelVersion(); @ManagedAttribute @@ -233,4 +233,6 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL EventLogger getEventLogger(); void setEventLogger(EventLogger eventLogger); + + AuthenticationProvider<?> getManagementModeAuthenticationProvider(); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java index e329b015c6..b4321a2625 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java @@ -20,13 +20,13 @@ */ package org.apache.qpid.server.model; -import org.apache.qpid.server.store.ConfiguredObjectRecord; - import java.security.AccessControlException; import java.util.Collection; import java.util.Map; import java.util.UUID; +import org.apache.qpid.server.store.ConfiguredObjectRecord; + @ManagedObject( creatable = false, category = false ) /** * An object that can be "managed" (eg via the web interface) and usually read from configuration. @@ -37,6 +37,7 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>> public static final String NAME = "name"; public static final String TYPE = "type"; public static final String DESCRIPTION = "description"; + public static final String CONTEXT = "context"; public static final String LAST_UPDATED_BY = "lastUpdatedBy"; public static final String LAST_UPDATED_TIME = "lastUpdatedTime"; public static final String STATE = "state"; @@ -67,6 +68,9 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>> @ManagedAttribute String getType(); + @ManagedAttribute(automate = true) + Map<String, String> getContext(); + @ManagedAttribute String getLastUpdatedBy(); @@ -284,4 +288,7 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>> // TODO - remove this when objects become responsible for their own storage ConfiguredObjectRecord asObjectRecord(); + void open(); + + void validate(); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactory.java index 2389fc742f..324fc41ec1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactory.java @@ -20,18 +20,18 @@ */ package org.apache.qpid.server.model; -import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; -import org.apache.qpid.server.plugin.QpidServiceLoader; -import org.apache.qpid.server.store.ConfiguredObjectRecord; -import org.apache.qpid.server.store.UnresolvedConfiguredObject; -import org.apache.qpid.server.util.ServerScopedRuntimeException; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; +import org.apache.qpid.server.plugin.QpidServiceLoader; +import org.apache.qpid.server.store.ConfiguredObjectRecord; +import org.apache.qpid.server.store.UnresolvedConfiguredObject; +import org.apache.qpid.server.util.ServerScopedRuntimeException; + public class ConfiguredObjectFactory { private final Map<String, String> _defaultTypes = new HashMap<String, String>(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java index 99a1e59872..20d8a3c311 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java @@ -31,4 +31,5 @@ public @interface ManagedAttribute boolean derived() default false; boolean automate() default false; boolean mandatory() default false; + String defaultValue() default ""; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Port.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Port.java index 7c404fdef4..b1e699486f 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Port.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Port.java @@ -22,6 +22,7 @@ package org.apache.qpid.server.model; import java.security.AccessControlException; import java.util.Collection; +import java.util.Set; @ManagedObject public interface Port<X extends Port<X>> extends ConfiguredObject<X> @@ -43,37 +44,22 @@ public interface Port<X extends Port<X>> extends ConfiguredObject<X> // Attributes - @ManagedAttribute + @ManagedAttribute(automate = true) String getBindingAddress(); - @ManagedAttribute + @ManagedAttribute(mandatory = true, automate = true) int getPort(); - @ManagedAttribute - Collection<Protocol> getProtocols(); + @ManagedAttribute( automate = true ) + Set<Protocol> getProtocols(); - @ManagedAttribute - Collection<Transport> getTransports(); + @ManagedAttribute( automate = true ) + Set<Transport> getTransports(); - @ManagedAttribute - boolean isTcpNoDelay(); - - @ManagedAttribute - int getSendBufferSize(); - - @ManagedAttribute - int getReceiveBufferSize(); - - @ManagedAttribute - boolean getNeedClientAuth(); - - @ManagedAttribute - boolean getWantClientAuth(); - - @ManagedAttribute + @ManagedAttribute( automate = true ) KeyStore getKeyStore(); - @ManagedAttribute + @ManagedAttribute( automate = true ) Collection<TrustStore> getTrustStores(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContext.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContext.java index 74e6eefb33..367df3ea5c 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContext.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContext.java @@ -20,12 +20,22 @@ */ package org.apache.qpid.server.model; +import java.security.AccessControlException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; + import org.apache.qpid.server.BrokerOptions; +import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.LogRecorder; import org.apache.qpid.server.logging.messages.BrokerMessages; -import org.apache.qpid.server.model.adapter.BrokerAdapter; import org.apache.qpid.server.store.ConfiguredObjectDependency; import org.apache.qpid.server.store.ConfiguredObjectIdDependency; import org.apache.qpid.server.store.ConfiguredObjectNameDependency; @@ -33,9 +43,6 @@ import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.UnresolvedConfiguredObject; import org.apache.qpid.server.util.ServerScopedRuntimeException; -import java.security.AccessControlException; -import java.util.*; - @ManagedObject (creatable = false) public class SystemContext extends AbstractConfiguredObject<SystemContext> { @@ -50,7 +57,6 @@ public class SystemContext extends AbstractConfiguredObject<SystemContext> @ManagedAttributeField private String _storeType; - private Broker _broker; public SystemContext(final TaskExecutor taskExecutor, final ConfiguredObjectFactory configuredObjectFactory, @@ -64,6 +70,7 @@ public class SystemContext extends AbstractConfiguredObject<SystemContext> _objectFactory = configuredObjectFactory; _logRecorder = logRecorder; _brokerOptions = brokerOptions; + open(); } public static Map<String, Object> createAttributes(final BrokerOptions brokerOptions) @@ -72,6 +79,7 @@ public class SystemContext extends AbstractConfiguredObject<SystemContext> attributes.put(NAME, "System"); attributes.put("storePath", brokerOptions.getConfigurationStoreLocation()); attributes.put("storeTye", brokerOptions.getConfigurationStoreType()); + attributes.put(ConfiguredObject.CONTEXT, brokerOptions.getConfigProperties()); return attributes; } @@ -237,17 +245,6 @@ public class SystemContext extends AbstractConfiguredObject<SystemContext> throw new IllegalArgumentException("Cannot change the lifetime of the SystemContext object"); } - @Override - public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) - { - if(clazz == Broker.class) - { - return (Collection<C>) Collections.singleton(_broker); - } - - return Collections.emptySet(); - } - public ConfiguredObjectFactory getObjectFactory() { return _objectFactory; @@ -312,13 +309,17 @@ public class SystemContext extends AbstractConfiguredObject<SystemContext> return getAttributeNames(getClass()); } - public void instantiateBroker(final Broker broker) - { - _broker = broker; - } - public Broker getBroker() { - return _broker; + Collection<Broker> children = getChildren(Broker.class); + if(children == null || children.isEmpty()) + { + return null; + } + else if(children.size() != 1) + { + throw new IllegalConfigurationException("More than one broker has been registered in a single context"); + } + return children.iterator().next(); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java index 0a262b0c31..d5b037e299 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java @@ -113,10 +113,10 @@ public interface VirtualHost<X extends VirtualHost<X, Q, E>, Q extends Queue<?>, @ManagedAttribute int getHouseKeepingThreadCount(); - @ManagedAttribute + @ManagedAttribute( automate = true ) Map<String, Object> getMessageStoreSettings(); - @ManagedAttribute + @ManagedAttribute( automate = true ) Map<String, Object> getConfigurationStoreSettings(); @ManagedStatistic 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 8845b278d8..3d3fb1a2bf 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 @@ -52,8 +52,6 @@ import org.apache.qpid.server.model.port.AmqpPort; import org.apache.qpid.server.model.port.PortWithAuthProvider; import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; import org.apache.qpid.server.plugin.MessageStoreFactory; -import org.apache.qpid.server.security.FileKeyStore; -import org.apache.qpid.server.security.FileTrustStore; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.security.SubjectCreator; import org.apache.qpid.server.security.access.Operation; @@ -61,6 +59,7 @@ 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; @@ -146,6 +145,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple put(Broker.VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE, DEFAULT_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE); put(Broker.VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_WARN, DEFAULT_STORE_TRANSACTION_OPEN_TIMEOUT_WARN); }}); + public static final String MANAGEMENT_MODE_AUTHENTICATION = "MANAGEMENT_MODE_AUTHENTICATION"; private final ConfiguredObjectFactory _objectFactory; private String[] POSITIVE_NUMERIC_ATTRIBUTES = { QUEUE_ALERT_THRESHOLD_MESSAGE_AGE, QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, @@ -174,23 +174,24 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private final Collection<String> _supportedVirtualHostStoreTypes; - private AuthenticationProvider<?> _managementAuthenticationProvider; + private AuthenticationProvider<?> _managementModeAuthenticationProvider; private BrokerOptions _brokerOptions; private Timer _reportingTimer; private StatisticsCounter _messagesDelivered, _dataDelivered, _messagesReceived, _dataReceived; + @ManagedAttributeField + private String _defaultVirtualHost; + public BrokerAdapter(UUID id, Map<String, Object> attributes, SystemContext parent) { super(Collections.<Class<? extends ConfiguredObject>, ConfiguredObject<?>>singletonMap(SystemContext.class, parent), DEFAULTS, combineIdWithAttributes(id,MapValueConverter.convert(attributes, ATTRIBUTE_TYPES)), parent.getTaskExecutor()); - validateModelVersion(); _objectFactory = parent.getObjectFactory(); _virtualHostRegistry = new VirtualHostRegistry(parent.getEventLogger()); - _virtualHostRegistry.setDefaultVirtualHostName((String)getAttribute(Broker.DEFAULT_VIRTUAL_HOST)); _logRecorder = parent.getLogRecorder(); _eventLogger = parent.getEventLogger(); @@ -204,13 +205,14 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple authManagerAttrs.put(ID, UUID.randomUUID()); SimpleAuthenticationManager authManager = new SimpleAuthenticationManager(this, Collections.<String,Object>emptyMap(), authManagerAttrs); authManager.addUser(BrokerOptions.MANAGEMENT_MODE_USER_NAME, _brokerOptions.getManagementModePassword()); - _managementAuthenticationProvider = authManager; + _managementModeAuthenticationProvider = authManager; } initialiseStatistics(); } - private void validateModelVersion() + public void validate() { + super.validate(); String modelVersion = (String) getActualAttributes().get(Broker.MODEL_VERSION); if (modelVersion == null) { @@ -236,6 +238,52 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple } + protected void onOpen() + { + super.onOpen(); + if(_brokerOptions.isManagementMode()) + { + _managementModeAuthenticationProvider.open(); + } + _virtualHostRegistry.setDefaultVirtualHostName(getDefaultVirtualHost()); + + for(KeyStore<?> keyStore : getChildren(KeyStore.class)) + { + addKeyStore(keyStore); + } + for(TrustStore<?> trustStore : getChildren(TrustStore.class)) + { + addTrustStore(trustStore); + } + for(AuthenticationProvider<?> authenticationProvider : getChildren(AuthenticationProvider.class)) + { + addAuthenticationProvider(authenticationProvider); + } + for(Port<?> port : getChildren(Port.class)) + { + addPort(port); + } + for(Plugin<?> plugin : getChildren(Plugin.class)) + { + addPlugin(plugin); + } + for(GroupProvider<?> groupProvider : getChildren(GroupProvider.class)) + { + addGroupProvider(groupProvider); + } + for(AccessControlProvider<?> accessControlProvider : getChildren(AccessControlProvider.class)) + { + addAccessControlProvider(accessControlProvider); + } + for(VirtualHost<?,?,?> virtualHost : getChildren(VirtualHost.class)) + { + addVirtualHost(virtualHost); + } + + + initialiseStatistics(); + } + private void initialiseStatisticsReporting() { long report = ((Number)getAttribute(Broker.STATISTICS_REPORTING_PERIOD)).intValue() * 1000; // convert to ms @@ -303,7 +351,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple @Override public String getDefaultVirtualHost() { - return (String) getAttribute(DEFAULT_VIRTUAL_HOST); + return _defaultVirtualHost; } @Override @@ -454,7 +502,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple { if (isManagementMode()) { - return _managementAuthenticationProvider; + return _managementModeAuthenticationProvider; } Collection<AuthenticationProvider<?>> providers = getAuthenticationProviders(); for (AuthenticationProvider<?> authenticationProvider : providers) @@ -593,45 +641,6 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple { return getMessageDeliveryStatistics().getTotal(); } - @SuppressWarnings("unchecked") - @Override - public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz) - { - if(clazz == VirtualHost.class) - { - return (Collection<C>) getVirtualHosts(); - } - else if(clazz == Port.class) - { - return (Collection<C>) getPorts(); - } - else if(clazz == AccessControlProvider.class) - { - return (Collection<C>) getAccessControlProviders(); - } - else if(clazz == AuthenticationProvider.class) - { - return (Collection<C>) getAuthenticationProviders(); - } - else if(clazz == GroupProvider.class) - { - return (Collection<C>) getGroupProviders(); - } - else if(clazz == KeyStore.class) - { - return (Collection<C>) getKeyStores(); - } - else if(clazz == TrustStore.class) - { - return (Collection<C>) getTrustStores(); - } - else if(clazz == Plugin.class) - { - return (Collection<C>) getPlugins(); - } - - return Collections.emptySet(); - } @SuppressWarnings("unchecked") @Override @@ -677,7 +686,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private Port<?> createPort(Map<String, Object> attributes) { Port<?> port = createChild(Port.class, attributes); - + addPort(port); //1. AMQP ports are disabled during ManagementMode. //2. The management plugins can currently only start ports at broker startup and // not when they are newly created via the management interfaces. @@ -727,6 +736,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple synchronized (_accessControlProviders) { accessControlProvider = (AccessControlProvider<?>) createChild(AccessControlProvider.class, attributes); + addAccessControlProvider(accessControlProvider); } boolean quiesce = isManagementMode() ; @@ -741,7 +751,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private void addAccessControlProvider(AccessControlProvider<?> accessControlProvider) { String name = accessControlProvider.getName(); - synchronized (_authenticationProviders) + synchronized (_accessControlProviders) { if (_accessControlProviders.containsKey(accessControlProvider.getId())) { @@ -781,6 +791,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private AuthenticationProvider createAuthenticationProvider(Map<String, Object> attributes) { AuthenticationProvider<?> authenticationProvider = createChild(AuthenticationProvider.class, attributes); + addAuthenticationProvider(authenticationProvider); authenticationProvider.setDesiredState(State.INITIALISING, State.ACTIVE); return authenticationProvider; } @@ -826,6 +837,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private GroupProvider<?> createGroupProvider(Map<String, Object> attributes) { GroupProvider<?> groupProvider = createChild(GroupProvider.class, attributes); + addGroupProvider(groupProvider); groupProvider.setDesiredState(State.INITIALISING, State.ACTIVE); return groupProvider; } @@ -862,13 +874,17 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private KeyStore createKeyStore(Map<String, Object> attributes) { - KeyStore keyStore = new FileKeyStore(UUIDGenerator.generateRandomUUID(), this, attributes); + + KeyStore<?> keyStore = createChild(KeyStore.class, attributes); + + addKeyStore(keyStore); return keyStore; } private TrustStore createTrustStore(Map<String, Object> attributes) { - TrustStore trustStore = new FileTrustStore(UUIDGenerator.generateRandomUUID(), this, attributes); + TrustStore trustStore = createChild(TrustStore.class, attributes); + addTrustStore(trustStore); return trustStore; } @@ -1216,46 +1232,6 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple } } - public void instantiateAuthenticationProvider(AuthenticationProvider object) - { - addAuthenticationProvider(object); - } - - public void instantiateAccessControlProvider(AccessControlProvider object) - { - addAccessControlProvider(object); - } - - public void instantiatePort(Port object) - { - addPort(object); - } - - public void instantiateVirtualHost(VirtualHost object) - { - addVirtualHost(object); - } - - public void instantiateGroupProvider(GroupProvider object) - { - addGroupProvider(object); - } - - public void instantiateKeyStore(KeyStore object) - { - addKeyStore(object); - } - - public void instantiateTrustStore(TrustStore object) - { - addTrustStore(object); - } - - public void instantiatePlugin(Plugin object) - { - addPlugin(object); - } - @Override public SecurityManager getSecurityManager() { @@ -1502,7 +1478,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple _messagesReceived.reset(); _dataReceived.reset(); - for (org.apache.qpid.server.virtualhost.VirtualHost vhost : _virtualHostRegistry.getVirtualHosts()) + for (VirtualHostImpl vhost : _virtualHostRegistry.getVirtualHosts()) { vhost.resetStatistics(); } @@ -1555,11 +1531,11 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple _eventLogger.message(BrokerMessages.STATS_MSGS(RECEIVED, _messagesReceived.getPeak(), _messagesReceived.getTotal())); - Collection<org.apache.qpid.server.virtualhost.VirtualHost> hosts = _virtualHostRegistry.getVirtualHosts(); + Collection<VirtualHostImpl> hosts = _virtualHostRegistry.getVirtualHosts(); if (hosts.size() > 1) { - for (org.apache.qpid.server.virtualhost.VirtualHost vhost : hosts) + for (VirtualHostImpl vhost : hosts) { String name = vhost.getName(); StatisticsCounter dataDelivered = vhost.getDataDeliveryStatistics(); @@ -1589,5 +1565,8 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple } } - + public AuthenticationProvider<?> getManagementModeAuthenticationProvider() + { + return _managementModeAuthenticationProvider; + } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java index fb9fde9b02..595a262486 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java @@ -62,6 +62,7 @@ public final class ConnectionAdapter extends AbstractConfiguredObject<Connection { super(Collections.<String,Object>emptyMap(), createAttributes(conn), taskExecutor); _connection = conn; + open(); conn.addSessionListener(this); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java index 06c3f9a74c..22877a4ea9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java @@ -42,7 +42,7 @@ public class FileBasedGroupProvider { private static Logger LOGGER = Logger.getLogger(FileBasedGroupProvider.class); - private final GroupManager _groupManager; + private GroupManager _groupManager; private final Broker<?> _broker; private AtomicReference<State> _state; @@ -56,15 +56,14 @@ public class FileBasedGroupProvider super(Collections.<Class<? extends ConfiguredObject>,ConfiguredObject<?>>singletonMap(Broker.class, broker), Collections.<String,Object>emptyMap(), combineIdWithAttributes(id, attributes), broker.getTaskExecutor()); - _groupManager = new FileGroupManager(getPath()); + _broker = broker; State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING); _state = new AtomicReference<State>(state); - validateUniqueFile(); } - private void validateUniqueFile() + public void validate() { Collection<GroupProvider<?>> groupProviders = _broker.getGroupProviders(); for(GroupProvider<?> provider : groupProviders) @@ -86,12 +85,21 @@ public class FileBasedGroupProvider } } + protected void onOpen() + { + super.onOpen(); + if(_groupManager == null) + { + _groupManager = new FileGroupManager(getPath()); + } + } @Override - protected void create() + protected void onCreate() { + super.onCreate(); + _groupManager = new FileGroupManager(getPath()); _groupManager.onCreate(); - super.create(); } @ManagedAttribute( automate = true, mandatory = true) @@ -193,7 +201,7 @@ public class FileBasedGroupProvider { if (clazz == Group.class) { - Set<Principal> groups = _groupManager.getGroupPrincipals(); + Set<Principal> groups = _groupManager == null ? Collections.<Principal>emptySet() : _groupManager.getGroupPrincipals(); Collection<Group> principals = new ArrayList<Group>(groups.size()); for (Principal group : groups) { @@ -273,6 +281,7 @@ public class FileBasedGroupProvider { _groupManager.close(); _groupManager.onDelete(); + deleted(); return true; } else diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java index 7fc11e1644..ec2a0574fa 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java @@ -21,16 +21,6 @@ package org.apache.qpid.server.model.adapter; -import org.apache.log4j.Logger; -import org.apache.qpid.server.configuration.IllegalConfigurationException; -import org.apache.qpid.server.model.*; -import org.apache.qpid.server.util.MapValueConverter; -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig; -import org.codehaus.jackson.type.TypeReference; - import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -41,9 +31,36 @@ import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; import java.security.AccessControlException; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +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; +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.codehaus.jackson.type.TypeReference; + +import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.model.AbstractConfiguredObject; +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.IllegalStateTransitionException; +import org.apache.qpid.server.model.LifetimePolicy; +import org.apache.qpid.server.model.ManagedAttribute; +import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.PreferencesProvider; +import org.apache.qpid.server.model.State; +import org.apache.qpid.server.util.MapValueConverter; + @ManagedObject( category = false, type = "FileSystemPreferences" ) public class FileSystemPreferencesProvider extends AbstractConfiguredObject<FileSystemPreferencesProvider> implements PreferencesProvider<FileSystemPreferencesProvider> { @@ -177,6 +194,7 @@ public class FileSystemPreferencesProvider extends AbstractConfiguredObject<File finally { _store.delete(); + deleted(); _authenticationProvider.setPreferencesProvider(null); } return true; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java index 91d91d5f67..959f5757e2 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java @@ -61,6 +61,7 @@ final class SessionAdapter extends AbstractConfiguredObject<SessionAdapter> impl childRemoved(consumer); } }); + open(); } private static Map<String, Object> createAttributes(final AMQSessionModel session) 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 0c859007a0..592968ab94 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 @@ -65,6 +65,24 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo private final Broker<?> _broker; private AtomicReference<State> _state; + @ManagedAttributeField + private int _port; + + @ManagedAttributeField + private String _bindingAddress; + + @ManagedAttributeField + private KeyStore<?> _keyStore; + + @ManagedAttributeField + private Collection<TrustStore> _trustStores; + + @ManagedAttributeField + private Set<Transport> _transports; + + @ManagedAttributeField + private Set<Protocol> _protocols; + public AbstractPort(UUID id, Broker<?> broker, Map<String, Object> attributes, @@ -73,41 +91,27 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo { super(Collections.<Class<? extends ConfiguredObject>,ConfiguredObject<?>>singletonMap(Broker.class, broker), updateDefaults(defaults, attributes), - combineIdWithAttributes(id,MapValueConverter.convert(attributes, ATTRIBUTE_TYPES)), + combineIdWithAttributes(id,attributes), taskExecutor); _broker = broker; - Object portValue = attributes.get(Port.PORT); - if (portValue == null) - { - throw new IllegalConfigurationException("Port attribute is not specified for port: " + attributes); - } - State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING); _state = new AtomicReference<State>(state); + } - - boolean useClientAuth = Boolean.TRUE.equals(getAttribute(Port.NEED_CLIENT_AUTH)) - || Boolean.TRUE.equals(getAttribute(Port.WANT_CLIENT_AUTH)); - - if(useClientAuth && getTrustStores().isEmpty()) - { - throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but has no trust stores configured."); - } + @Override + public void validate() + { + super.validate(); boolean useTLSTransport = getTransports().contains(Transport.SSL) || getTransports().contains(Transport.WSS); - if(useClientAuth && !useTLSTransport) - { - throw new IllegalConfigurationException( - "Can't create port which requests SSL client certificates but doesn't use SSL transport."); - } + if(useTLSTransport && getKeyStore() == null) { throw new IllegalConfigurationException("Can't create a port which uses a secure transport but has no KeyStore"); } } - private static Map<String, Object> updateDefaults(final Map<String, Object> defaults, final Map<String, Object> attributes) { @@ -126,20 +130,19 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo @Override public String getBindingAddress() { - return (String)getAttribute(BINDING_ADDRESS); + return _bindingAddress; } @Override public int getPort() { - return (Integer)getAttribute(PORT); + return _port; } - @SuppressWarnings("unchecked") @Override - public Collection<Transport> getTransports() + public Set<Transport> getTransports() { - return (Collection<Transport>)getAttribute(TRANSPORTS); + return _transports; } @Override @@ -156,11 +159,10 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo throw new IllegalStateException(); } - @SuppressWarnings("unchecked") @Override - public Collection<Protocol> getProtocols() + public Set<Protocol> getProtocols() { - return (Collection<Protocol>)getAttribute(PROTOCOLS); + return _protocols; } @Override @@ -290,6 +292,7 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo if( _state.compareAndSet(state, State.DELETED)) { onStop(); + deleted(); return true; } } @@ -363,14 +366,20 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo throw new IllegalConfigurationException("Changing the port name is not allowed"); } - Integer newPort = (Integer) merged.get(PORT); - if(getPort() != newPort) + if(converted.containsKey(PORT)) { - for(Port p : _broker.getPorts()) + Integer newPort = (Integer) merged.get(PORT); + if (getPort() != newPort) { - if(p.getPort() == newPort) + for (Port p : _broker.getPorts()) { - throw new IllegalConfigurationException("Port number " + newPort + " is already in use by port " + p.getName()); + if (p.getPort() == newPort) + { + throw new IllegalConfigurationException("Port number " + + newPort + + " is already in use by port " + + p.getName()); + } } } } @@ -393,7 +402,7 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo } } - Set<String> trustStoreNames = (Set<String>) merged.get(TRUST_STORES); + Collection<String> trustStoreNames = (Collection<String>) merged.get(TRUST_STORES); boolean hasTrustStore = trustStoreNames != null && !trustStoreNames.isEmpty(); if(hasTrustStore) { @@ -460,7 +469,7 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo } } - super.changeAttributes(converted); + super.changeAttributes(attributes); } @Override @@ -496,39 +505,13 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo @Override public KeyStore getKeyStore() { - String keyStoreName = (String)getAttribute(Port.KEY_STORE); - KeyStore keyStore = _broker.findKeyStoreByName(keyStoreName); - - if (keyStoreName != null && keyStore == null) - { - throw new IllegalConfigurationException("Can't find key store with name '" + keyStoreName + "' for port " + getName()); - } - - return keyStore; + return _keyStore; } @Override public Collection<TrustStore> getTrustStores() { - Set<String> trustStoreNames = (Set<String>) getAttribute(TRUST_STORES); - boolean hasTrustStoreName = trustStoreNames != null && !trustStoreNames.isEmpty(); - - final Collection<TrustStore> trustStores = new ArrayList<TrustStore>(); - if(hasTrustStoreName) - { - for (String name : trustStoreNames) - { - TrustStore trustStore = _broker.findTrustStoreByName(name); - if (trustStore == null) - { - throw new IllegalConfigurationException("Can't find trust store with name '" + name + "' for port " + getName()); - } - - trustStores.add(trustStore); - } - } - - return trustStores; + return _trustStores; } @Override @@ -537,38 +520,10 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo return getClass().getSimpleName() + " [id=" + getId() + ", name=" + getName() + ", port=" + getPort() + "]"; } - @Override - public boolean isTcpNoDelay() - { - return (Boolean)getAttribute(TCP_NO_DELAY); - } - - @Override - public int getSendBufferSize() - { - return (Integer)getAttribute(SEND_BUFFER_SIZE); - } - - @Override - public int getReceiveBufferSize() - { - return (Integer)getAttribute(RECEIVE_BUFFER_SIZE); - } - - @Override - public boolean getNeedClientAuth() - { - return (Boolean)getAttribute(NEED_CLIENT_AUTH); - } - - @Override - public boolean getWantClientAuth() - { - return (Boolean)getAttribute(WANT_CLIENT_AUTH); - } - protected void validateOnlyOneInstance(final Broker<?> broker) + protected void validateOnlyOneInstance() { + Broker<?> broker = getParent(Broker.class); if(!broker.isManagementMode()) { //ManagementMode needs this relaxed to allow its overriding management ports to be inserted. diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java index 02cdc6e740..9db653c853 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java @@ -32,6 +32,8 @@ import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.logging.messages.BrokerMessages; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.KeyStore; +import org.apache.qpid.server.model.ManagedAttribute; +import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.Transport; @@ -48,13 +50,21 @@ import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager; @ManagedObject( category = false, type = "AMQP") public class AmqpPort extends PortWithAuthProvider<AmqpPort> { - public static final int DEFAULT_AMQP_SEND_BUFFER_SIZE = 262144; - public static final int DEFAULT_AMQP_RECEIVE_BUFFER_SIZE = 262144; - public static final boolean DEFAULT_AMQP_NEED_CLIENT_AUTH = false; - public static final boolean DEFAULT_AMQP_WANT_CLIENT_AUTH = false; - public static final boolean DEFAULT_AMQP_TCP_NO_DELAY = true; + public static final String DEFAULT_AMQP_SEND_BUFFER_SIZE = "262144"; + public static final String DEFAULT_AMQP_RECEIVE_BUFFER_SIZE = "262144"; + + public static final String DEFAULT_AMQP_TCP_NO_DELAY = "true"; public static final String DEFAULT_AMQP_BINDING = "*"; + @ManagedAttributeField + private boolean _tcpNoDelay; + + @ManagedAttributeField + private int _sendBufferSize; + + @ManagedAttributeField + private int _receiveBufferSize; + private final Broker<?> _broker; private AcceptingTransport _transport; @@ -74,16 +84,30 @@ public class AmqpPort extends PortWithAuthProvider<AmqpPort> defaults.put(BINDING_ADDRESS, DEFAULT_AMQP_BINDING); defaults.put(NAME, attributes.containsKey(BINDING_ADDRESS) ? attributes.get(BINDING_ADDRESS) : DEFAULT_AMQP_BINDING + ":" + attributes.get(PORT)); defaults.put(PROTOCOLS, getDefaultProtocols()); - defaults.put(TCP_NO_DELAY, DEFAULT_AMQP_TCP_NO_DELAY); - defaults.put(WANT_CLIENT_AUTH, DEFAULT_AMQP_WANT_CLIENT_AUTH); - defaults.put(NEED_CLIENT_AUTH, DEFAULT_AMQP_NEED_CLIENT_AUTH); - defaults.put(RECEIVE_BUFFER_SIZE, DEFAULT_AMQP_RECEIVE_BUFFER_SIZE); - defaults.put(SEND_BUFFER_SIZE, DEFAULT_AMQP_SEND_BUFFER_SIZE); + return defaults; } + @ManagedAttribute( automate = true , defaultValue = DEFAULT_AMQP_TCP_NO_DELAY ) + public boolean isTcpNoDelay() + { + return _tcpNoDelay; + } + + @ManagedAttribute( automate = true , defaultValue = DEFAULT_AMQP_SEND_BUFFER_SIZE ) + public int getSendBufferSize() + { + return _sendBufferSize; + } + + @ManagedAttribute( automate = true , defaultValue = DEFAULT_AMQP_RECEIVE_BUFFER_SIZE ) + public int getReceiveBufferSize() + { + return _receiveBufferSize; + } + private static Set<Protocol> getDefaultProtocols() { Set<Protocol> defaultProtocols = EnumSet.of(Protocol.AMQP_0_8, Protocol.AMQP_0_9, Protocol.AMQP_0_9_1, diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java index c334f7e766..48b59f2c75 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java @@ -20,14 +20,14 @@ */ package org.apache.qpid.server.model.port; -import org.apache.qpid.server.configuration.updater.TaskExecutor; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ManagedObject; - import java.util.Collections; import java.util.Map; 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.ManagedObject; + @ManagedObject( category = false, type = "JMX") public class JmxPort extends PortWithAuthProvider<JmxPort> { @@ -37,8 +37,12 @@ public class JmxPort extends PortWithAuthProvider<JmxPort> final TaskExecutor taskExecutor) { super(id, broker, attributes, Collections.<String,Object>emptyMap(), taskExecutor); + } - validateOnlyOneInstance(broker); - + @Override + public void validate() + { + super.validate(); + validateOnlyOneInstance(); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortWithAuthProvider.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortWithAuthProvider.java index b21b418ce4..afd053cf02 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortWithAuthProvider.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortWithAuthProvider.java @@ -20,20 +20,31 @@ */ package org.apache.qpid.server.model.port; +import java.util.Map; +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.AuthenticationProvider; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedAttribute; -import org.apache.qpid.server.model.Port; - -import java.util.Map; -import java.util.UUID; +import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.Transport; abstract public class PortWithAuthProvider<X extends PortWithAuthProvider<X>> extends AbstractPort<X> { + public static final String DEFAULT_AMQP_NEED_CLIENT_AUTH = "false"; + public static final String DEFAULT_AMQP_WANT_CLIENT_AUTH = "false"; + + @ManagedAttributeField private AuthenticationProvider _authenticationProvider; + @ManagedAttributeField + private boolean _needClientAuth; + + @ManagedAttributeField + private boolean _wantClientAuth; + public PortWithAuthProvider(final UUID id, final Broker<?> broker, final Map<String, Object> attributes, @@ -41,23 +52,48 @@ abstract public class PortWithAuthProvider<X extends PortWithAuthProvider<X>> ex final TaskExecutor taskExecutor) { super(id, broker, attributes, defaults, taskExecutor); - String authProvider = (String)getAttribute(Port.AUTHENTICATION_PROVIDER); - if (authProvider == null) - { - throw new IllegalConfigurationException("An authentication provider must be specified for port : " + getName()); - } - _authenticationProvider = broker.findAuthenticationProviderByName(authProvider); + } - if(_authenticationProvider == null) - { - throw new IllegalConfigurationException("The authentication provider '" + authProvider + "' could not be found for port : " + getName()); - } + @ManagedAttribute( automate = true, defaultValue = DEFAULT_AMQP_NEED_CLIENT_AUTH ) + public boolean getNeedClientAuth() + { + return _needClientAuth; } + @ManagedAttribute( automate = true, defaultValue = DEFAULT_AMQP_WANT_CLIENT_AUTH ) + public boolean getWantClientAuth() + { + return _wantClientAuth; + } - @ManagedAttribute + @ManagedAttribute( automate = true, mandatory = true ) public AuthenticationProvider getAuthenticationProvider() { + Broker<?> broker = getParent(Broker.class); + if(broker.isManagementMode()) + { + return broker.getManagementModeAuthenticationProvider(); + } return _authenticationProvider; } + + @Override + public void validate() + { + super.validate(); + boolean useClientAuth = getNeedClientAuth() || getWantClientAuth(); + + if(useClientAuth && (getTrustStores() == null || getTrustStores().isEmpty())) + { + throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but has no trust stores configured."); + } + + boolean useTLSTransport = getTransports().contains(Transport.SSL) || getTransports().contains(Transport.WSS); + if(useClientAuth && !useTLSTransport) + { + 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/RmiPort.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPort.java index 1671971dff..f27f6fbcdb 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 @@ -20,16 +20,16 @@ */ package org.apache.qpid.server.model.port; +import java.util.Collections; +import java.util.Map; +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.Transport; -import java.util.Collections; -import java.util.Map; -import java.util.UUID; - @ManagedObject( category = false, type = "RMI") public class RmiPort extends AbstractPort<RmiPort> { @@ -39,12 +39,19 @@ public class RmiPort extends AbstractPort<RmiPort> final TaskExecutor taskExecutor) { super(id, broker, attributes, Collections.<String,Object>emptyMap(), taskExecutor); + } - validateOnlyOneInstance(broker); + @Override + public void validate() + { + super.validate(); + + validateOnlyOneInstance(); if (getTransports().contains(Transport.SSL)) { throw new IllegalConfigurationException("Can't create RMI registry port which requires SSL"); } + } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java index 87d10f745b..841dc3aacb 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java @@ -24,13 +24,13 @@ import java.util.Map; import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public interface ExchangeType<T extends ExchangeImpl<T>> extends Pluggable { public String getType(); - public T newInstance(final VirtualHost virtualHost, Map<String, Object> attributes) throws UnknownExchangeException; + public T newInstance(final VirtualHostImpl virtualHost, Map<String, Object> attributes) throws UnknownExchangeException; public String getDefaultExchangeName(); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageConverter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageConverter.java index cf3860ba92..c8d3b22652 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageConverter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageConverter.java @@ -21,12 +21,12 @@ package org.apache.qpid.server.plugin; import org.apache.qpid.server.message.ServerMessage; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public interface MessageConverter<M extends ServerMessage, N extends ServerMessage> extends Pluggable { Class<M> getInputClass(); Class<N> getOutputClass(); - N convert(M message, VirtualHost vhost); + N convert(M message, VirtualHostImpl vhost); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/SystemNodeCreator.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/SystemNodeCreator.java index 5b371c0851..eb3a21e77e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/SystemNodeCreator.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/SystemNodeCreator.java @@ -21,7 +21,7 @@ package org.apache.qpid.server.plugin; import org.apache.qpid.server.message.MessageNode; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public interface SystemNodeCreator extends Pluggable { @@ -30,7 +30,7 @@ public interface SystemNodeCreator extends Pluggable void registerSystemNode(MessageNode node); void removeSystemNode(MessageNode node); - VirtualHost getVirtualHost(); + VirtualHostImpl getVirtualHost(); org.apache.qpid.server.model.VirtualHost getVirtualHostModel(); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java index e9c5f8206a..07fd594144 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java @@ -26,14 +26,13 @@ import org.apache.qpid.server.exchange.ExchangeReferrer; import org.apache.qpid.server.logging.LogSubject; import org.apache.qpid.server.message.MessageDestination; import org.apache.qpid.server.message.MessageSource; -import org.apache.qpid.server.model.Binding; import org.apache.qpid.server.model.ExclusivityPolicy; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.QueueNotificationListener; import org.apache.qpid.server.protocol.CapacityChecker; import org.apache.qpid.server.util.Deletable; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.Collection; import java.util.List; @@ -68,7 +67,7 @@ public interface AMQQueue<X extends AMQQueue<X>> String getOwner(); - VirtualHost getVirtualHost(); + VirtualHostImpl getVirtualHost(); public Collection<QueueConsumer<?>> getConsumers(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java index 5006908cee..8b5ea1e964 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java @@ -39,7 +39,7 @@ import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.apache.qpid.server.virtualhost.ExchangeExistsException; import org.apache.qpid.server.virtualhost.ReservedExchangeNameException; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.server.virtualhost.QueueExistsException; public class AMQQueueFactory implements QueueFactory @@ -50,10 +50,10 @@ public class AMQQueueFactory implements QueueFactory public static final String DLQ_ROUTING_KEY = "dlq"; private static final int MAX_LENGTH = 255; - private final VirtualHost _virtualHost; + private final VirtualHostImpl _virtualHost; private final QueueRegistry _queueRegistry; - public AMQQueueFactory(VirtualHost virtualHost, QueueRegistry queueRegistry) + public AMQQueueFactory(VirtualHostImpl virtualHost, QueueRegistry queueRegistry) { _virtualHost = virtualHost; _queueRegistry = queueRegistry; @@ -99,7 +99,7 @@ public class AMQQueueFactory implements QueueFactory { queue = new StandardQueue(_virtualHost, attributes); } - + queue.open(); //Register the new queue _queueRegistry.registerQueue(queue); 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 d9195cca38..e403781d15 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 @@ -23,7 +23,15 @@ import java.security.AccessControlException; import java.security.AccessController; import java.security.Principal; import java.security.PrivilegedAction; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentSkipListSet; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executor; @@ -32,30 +40,40 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import javax.security.auth.Subject; + import org.apache.log4j.Logger; + +import org.apache.qpid.pool.ReferenceCountingExecutorService; import org.apache.qpid.server.binding.BindingImpl; +import org.apache.qpid.server.configuration.BrokerProperties; import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.connection.SessionPrincipal; import org.apache.qpid.server.consumer.ConsumerImpl; +import org.apache.qpid.server.consumer.ConsumerTarget; import org.apache.qpid.server.exchange.ExchangeImpl; -import org.apache.qpid.server.logging.EventLogger; -import org.apache.qpid.server.message.MessageSource; -import org.apache.qpid.server.model.*; -import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.model.AbstractConfiguredObject; -import org.apache.qpid.server.protocol.AMQConnectionModel; -import org.apache.qpid.pool.ReferenceCountingExecutorService; -import org.apache.qpid.server.configuration.BrokerProperties; import org.apache.qpid.server.filter.FilterManager; +import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.LogSubject; import org.apache.qpid.server.logging.messages.QueueMessages; import org.apache.qpid.server.logging.subjects.QueueLogSubject; import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.MessageInstance; import org.apache.qpid.server.message.MessageReference; +import org.apache.qpid.server.message.MessageSource; 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.ConfigurationChangeListener; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.Exchange; +import org.apache.qpid.server.model.ExclusivityPolicy; +import org.apache.qpid.server.model.LifetimePolicy; +import org.apache.qpid.server.model.Queue; +import org.apache.qpid.server.model.QueueNotificationListener; +import org.apache.qpid.server.model.State; +import org.apache.qpid.server.protocol.AMQConnectionModel; import org.apache.qpid.server.protocol.AMQSessionModel; -import org.apache.qpid.server.consumer.ConsumerTarget; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; import org.apache.qpid.server.store.DurableConfigurationStoreHelper; @@ -68,9 +86,7 @@ import org.apache.qpid.server.util.Deletable; import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.apache.qpid.server.util.StateChangeListener; -import org.apache.qpid.server.virtualhost.VirtualHost; - -import javax.security.auth.Subject; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public abstract class AbstractQueue extends AbstractConfiguredObject<AbstractQueue> @@ -98,13 +114,13 @@ public abstract class AbstractQueue } }; - private final VirtualHost _virtualHost; + private final VirtualHostImpl _virtualHost; private final DeletedChildListener _deletedChildListener = new DeletedChildListener(); /** null means shared */ private String _description; - private final boolean _durable; + private boolean _durable; private ExchangeImpl _alternateExchange; @@ -186,14 +202,14 @@ public abstract class AbstractQueue private final AtomicBoolean _overfull = new AtomicBoolean(false); private final CopyOnWriteArrayList<BindingImpl> _bindings = new CopyOnWriteArrayList<BindingImpl>(); - private final Map<String, Object> _arguments; + private Map<String, Object> _arguments; //TODO : persist creation time private long _createTime = System.currentTimeMillis(); /** the maximum delivery count for each message on this queue or 0 if maximum delivery count is not to be enforced. */ private int _maximumDeliveryCount; - private final MessageGroupManager _messageGroupManager; + private MessageGroupManager _messageGroupManager; private final Collection<ConsumerRegistrationListener<? super MessageSource>> _consumerListeners = new ArrayList<ConsumerRegistrationListener<? super MessageSource>>(); @@ -201,14 +217,25 @@ public abstract class AbstractQueue private QueueNotificationListener _notificationListener; private final long[] _lastNotificationTimes = new long[NotificationCheck.values().length]; - protected AbstractQueue(VirtualHost virtualHost, + protected AbstractQueue(VirtualHostImpl virtualHost, Map<String, Object> attributes, QueueEntryListFactory entryListFactory) { - super(MapValueConverter.getUUIDAttribute(Queue.ID, attributes), + super(Collections.<Class<? extends ConfiguredObject>, ConfiguredObject<?>>singletonMap(org.apache.qpid.server.model.VirtualHost.class, (org.apache.qpid.server.model.VirtualHost)virtualHost), Collections.<String,Object>emptyMap(), attributes, virtualHost.getTaskExecutor()); - if (virtualHost == null) + _entries = entryListFactory.createQueueEntryList(this); + _virtualHost = virtualHost; + _asyncDelivery = ReferenceCountingExecutorService.getInstance().acquireExecutorService(); + + + + } + + public void validate() + { + super.validate(); + if (_virtualHost == null) { throw new IllegalArgumentException("Virtual Host must not be null"); } @@ -218,7 +245,16 @@ public abstract class AbstractQueue throw new IllegalArgumentException("Queue name must not be null"); } - boolean durable = MapValueConverter.getBooleanAttribute(Queue.DURABLE,attributes,false); + + } + + protected void onOpen() + { + super.onOpen(); + + Map<String,Object> attributes = getActualAttributes(); + + boolean durable = MapValueConverter.getBooleanAttribute(Queue.DURABLE, attributes, false); _exclusivityPolicy = MapValueConverter.getEnumAttribute(ExclusivityPolicy.class, @@ -231,8 +267,6 @@ public abstract class AbstractQueue LifetimePolicy.PERMANENT); _durable = durable; - _virtualHost = virtualHost; - _entries = entryListFactory.createQueueEntryList(this); final LinkedHashMap<String, Object> arguments = new LinkedHashMap<String, Object>(attributes); arguments.put(Queue.EXCLUSIVE, _exclusivityPolicy); @@ -243,11 +277,10 @@ public abstract class AbstractQueue _noLocal = MapValueConverter.getBooleanAttribute(Queue.NO_LOCAL, attributes, false); - _asyncDelivery = ReferenceCountingExecutorService.getInstance().acquireExecutorService(); _logSubject = new QueueLogSubject(this); - virtualHost.getSecurityManager().authoriseCreateQueue(this); + _virtualHost.getSecurityManager().authoriseCreateQueue(this); Subject activeSubject = Subject.getSubject(AccessController.getContext()); Set<SessionPrincipal> sessionPrincipals = activeSubject == null ? Collections.<SessionPrincipal>emptySet() : activeSubject.getPrincipals(SessionPrincipal.class); @@ -338,15 +371,13 @@ public abstract class AbstractQueue } - - if (attributes.containsKey(Queue.ALERT_THRESHOLD_MESSAGE_AGE)) { setMaximumMessageAge(MapValueConverter.getLongAttribute(Queue.ALERT_THRESHOLD_MESSAGE_AGE, attributes)); } else { - setMaximumMessageAge(virtualHost.getDefaultAlertThresholdMessageAge()); + setMaximumMessageAge(_virtualHost.getDefaultAlertThresholdMessageAge()); } if (attributes.containsKey(Queue.ALERT_THRESHOLD_MESSAGE_SIZE)) { @@ -354,7 +385,7 @@ public abstract class AbstractQueue } else { - setMaximumMessageSize(virtualHost.getDefaultAlertThresholdMessageSize()); + setMaximumMessageSize(_virtualHost.getDefaultAlertThresholdMessageSize()); } if (attributes.containsKey(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES)) { @@ -363,7 +394,7 @@ public abstract class AbstractQueue } else { - setMaximumMessageCount(virtualHost.getDefaultAlertThresholdQueueDepthMessages()); + setMaximumMessageCount(_virtualHost.getDefaultAlertThresholdQueueDepthMessages()); } if (attributes.containsKey(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_BYTES)) { @@ -372,7 +403,7 @@ public abstract class AbstractQueue } else { - setMaximumQueueDepth(virtualHost.getDefaultAlertThresholdQueueDepthBytes()); + setMaximumQueueDepth(_virtualHost.getDefaultAlertThresholdQueueDepthBytes()); } if (attributes.containsKey(Queue.ALERT_REPEAT_GAP)) { @@ -380,7 +411,7 @@ public abstract class AbstractQueue } else { - setMinimumAlertRepeatGap(virtualHost.getDefaultAlertRepeatGap()); + setMinimumAlertRepeatGap(_virtualHost.getDefaultAlertRepeatGap()); } if (attributes.containsKey(Queue.QUEUE_FLOW_CONTROL_SIZE_BYTES)) { @@ -388,7 +419,7 @@ public abstract class AbstractQueue } else { - setCapacity(virtualHost.getDefaultQueueFlowControlSizeBytes()); + setCapacity(_virtualHost.getDefaultQueueFlowControlSizeBytes()); } if (attributes.containsKey(Queue.QUEUE_FLOW_RESUME_SIZE_BYTES)) { @@ -396,7 +427,7 @@ public abstract class AbstractQueue } else { - setFlowResumeCapacity(virtualHost.getDefaultQueueFlowResumeSizeBytes()); + setFlowResumeCapacity(_virtualHost.getDefaultQueueFlowResumeSizeBytes()); } if (attributes.containsKey(Queue.MAXIMUM_DELIVERY_ATTEMPTS)) { @@ -404,7 +435,7 @@ public abstract class AbstractQueue } else { - setMaximumDeliveryCount(virtualHost.getDefaultMaximumDeliveryAttempts()); + setMaximumDeliveryCount(_virtualHost.getDefaultMaximumDeliveryAttempts()); } final String ownerString = getOwner(); @@ -443,7 +474,6 @@ public abstract class AbstractQueue } resetNotifications(); - } private void addLifetimeConstraint(final Deletable<? extends Deletable> lifetimeObject) @@ -670,7 +700,7 @@ public abstract class AbstractQueue return null; } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _virtualHost; } @@ -2854,16 +2884,6 @@ public abstract class AbstractQueue } @Override - public <T extends ConfiguredObject> T getParent(final Class<T> clazz) - { - if(clazz == org.apache.qpid.server.model.VirtualHost.class) - { - return (T) _virtualHost.getModel(); - } - return super.getParent(clazz); - } - - @Override protected <C extends ConfiguredObject> C addChild(final Class<C> childClass, final Map<String, Object> attributes, final ConfiguredObject... otherParents) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java index dd5c6ea119..9b5b7b23cb 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java @@ -24,16 +24,15 @@ package org.apache.qpid.server.queue; import java.util.Map; import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.util.MapValueConverter; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class ConflationQueue extends AbstractQueue { public static final String DEFAULT_LVQ_KEY = "qpid.LVQ_key"; - protected ConflationQueue(VirtualHost virtualHost, + protected ConflationQueue(VirtualHostImpl virtualHost, Map<String, Object> attributes) { super(virtualHost, attributes, entryList(attributes)); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java index b6b4719e90..c2778085d1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java @@ -26,22 +26,22 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class DefaultQueueRegistry implements QueueRegistry { private ConcurrentMap<String, AMQQueue<?>> _queueMap = new ConcurrentHashMap<String, AMQQueue<?>>(); - private final VirtualHost _virtualHost; + private final VirtualHostImpl _virtualHost; private final Collection<RegistryChangeListener> _listeners = new ArrayList<RegistryChangeListener>(); - public DefaultQueueRegistry(VirtualHost virtualHost) + public DefaultQueueRegistry(VirtualHostImpl virtualHost) { _virtualHost = virtualHost; } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _virtualHost; } 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 d0a001677d..3ecf134b5f 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 @@ -20,14 +20,14 @@ */ package org.apache.qpid.server.queue; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.Map; public abstract class OutOfOrderQueue extends AbstractQueue { - protected OutOfOrderQueue(VirtualHost virtualHost, + protected OutOfOrderQueue(VirtualHostImpl virtualHost, Map<String, Object> attributes, QueueEntryListFactory entryListFactory) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java index c65b0a3060..04e94f24f6 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java @@ -21,9 +21,8 @@ package org.apache.qpid.server.queue; import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.util.MapValueConverter; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.Map; @@ -32,7 +31,7 @@ public class PriorityQueue extends OutOfOrderQueue public static final int DEFAULT_PRIORITY_LEVELS = 10; - protected PriorityQueue(VirtualHost virtualHost, + protected PriorityQueue(VirtualHostImpl virtualHost, Map<String, Object> attributes) { super(virtualHost, attributes, entryList(attributes)); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java index 0805566d4f..b42eb1e67f 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java @@ -20,7 +20,26 @@ */ package org.apache.qpid.server.queue; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SUBSCRIPTION_FORMAT; + +import java.security.AccessControlException; +import java.text.MessageFormat; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + import org.apache.log4j.Logger; + +import org.apache.qpid.server.consumer.ConsumerTarget; import org.apache.qpid.server.filter.FilterManager; import org.apache.qpid.server.filter.JMSSelectorFilter; import org.apache.qpid.server.filter.MessageFilter; @@ -31,26 +50,15 @@ import org.apache.qpid.server.logging.subjects.QueueLogSubject; import org.apache.qpid.server.message.MessageInstance; import org.apache.qpid.server.message.MessageSource; import org.apache.qpid.server.message.ServerMessage; +import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.State; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.protocol.MessageConverterRegistry; -import org.apache.qpid.server.consumer.ConsumerTarget; import org.apache.qpid.server.util.StateChangeListener; -import java.security.AccessControlException; -import java.text.MessageFormat; -import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SUBSCRIPTION_FORMAT; - class QueueConsumerImpl extends AbstractConfiguredObject<QueueConsumerImpl> implements QueueConsumer<QueueConsumerImpl>, LogSubject @@ -125,11 +133,13 @@ class QueueConsumerImpl _isTransient = optionSet.contains(Option.TRANSIENT); _target = target; _queue = queue; - setupLogging(); // Access control _queue.getVirtualHost().getSecurityManager().authoriseCreateConsumer(this); + open(); + + setupLogging(); _target.setStateListener( new StateChangeListener<ConsumerTarget, ConsumerTarget.State>() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java index 981d476801..747e0d8959 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java @@ -23,11 +23,11 @@ package org.apache.qpid.server.queue; import java.util.Collection; import java.util.UUID; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public interface QueueRegistry { - VirtualHost getVirtualHost(); + VirtualHostImpl getVirtualHost(); void registerQueue(AMQQueue<?> queue); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java index 899c556ec7..5f7ea14889 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java @@ -24,7 +24,7 @@ import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.MapValueConverter; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.Map; @@ -36,7 +36,7 @@ public class SortedQueue extends OutOfOrderQueue private final Object _sortedQueueLock = new Object(); private final String _sortedPropertyName; - protected SortedQueue(VirtualHost virtualHost, + protected SortedQueue(VirtualHostImpl virtualHost, Map<String, Object> attributes, QueueEntryListFactory factory) { @@ -45,7 +45,7 @@ public class SortedQueue extends OutOfOrderQueue } - protected SortedQueue(VirtualHost virtualHost, + protected SortedQueue(VirtualHostImpl virtualHost, Map<String, Object> attributes) { this(virtualHost, @@ -69,4 +69,4 @@ public class SortedQueue extends OutOfOrderQueue super.enqueue(message, action); } } -}
\ No newline at end of file +} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueue.java index 1386196405..44578375e0 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueue.java @@ -20,14 +20,13 @@ */ package org.apache.qpid.server.queue; -import org.apache.qpid.server.protocol.AMQSessionModel; -import org.apache.qpid.server.virtualhost.VirtualHost; - import java.util.Map; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; + public class StandardQueue extends AbstractQueue { - public StandardQueue(final VirtualHost virtualHost, + public StandardQueue(final VirtualHostImpl virtualHost, final Map<String, Object> arguments) { super(virtualHost, arguments, new StandardQueueEntryList.Factory()); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java index be24a09dfb..d70b32f7ca 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java @@ -80,6 +80,7 @@ public class ApplicationRegistry implements IApplicationRegistry _broker = upgrader.upgrade(_store); _broker.setEventLogger(startupLogger); + _broker.open(); // starting the broker _broker.setDesiredState(State.INITIALISING, State.ACTIVE); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStore.java index 54e94c61cf..c162a66e64 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStore.java @@ -87,12 +87,16 @@ public class FileKeyStore extends AbstractKeyStoreAdapter<FileKeyStore> implemen { super(id, broker, DEFAULTS, attributes); _broker = broker; + } + @Override + public void validate() + { + super.validate(); validateKeyStoreAttributes(_keyStoreType, _path, getPassword(), _certificateAlias, _keyManagerFactoryAlgorithm); } - @Override public Collection<String> getAttributeNames() { @@ -110,12 +114,12 @@ public class FileKeyStore extends AbstractKeyStoreAdapter<FileKeyStore> implemen Collection<Port> ports = new ArrayList<Port>(_broker.getPorts()); for (Port port : ports) { - if (storeName.equals(port.getAttribute(Port.KEY_STORE))) + if (port.getKeyStore() == this) { throw new IntegrityViolationException("Key store '" + storeName + "' can't be deleted as it is in use by a port:" + port.getName()); } } - + deleted(); return true; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStore.java index f4f0d81bea..c97668e5a9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStore.java @@ -83,7 +83,12 @@ public class FileTrustStore extends AbstractKeyStoreAdapter<FileTrustStore> impl { super(id, broker, DEFAULTS, attributes); _broker = broker; + } + @Override + public void validate() + { + super.validate(); validateTrustStoreAttributes(_trustStoreType, _path, getPassword(), _trustManagerFactoryAlgorithm); } @@ -105,11 +110,17 @@ public class FileTrustStore extends AbstractKeyStoreAdapter<FileTrustStore> impl for (Port port : ports) { Collection<TrustStore> trustStores = port.getTrustStores(); - for(TrustStore store : trustStores) + if(trustStores != null) { - if (storeName.equals(store.getAttribute(TrustStore.NAME))) + for (TrustStore store : trustStores) { - throw new IntegrityViolationException("Trust store '" + storeName + "' can't be deleted as it is in use by a port: " + port.getName()); + if (storeName.equals(store.getAttribute(TrustStore.NAME))) + { + throw new IntegrityViolationException("Trust store '" + + storeName + + "' can't be deleted as it is in use by a port: " + + port.getName()); + } } } } @@ -125,7 +136,7 @@ public class FileTrustStore extends AbstractKeyStoreAdapter<FileTrustStore> impl throw new IntegrityViolationException("Trust store '" + storeName + "' can't be deleted as it is in use by an authentication manager: " + authProvider.getName()); } } - + deleted(); return true; } return false; 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 7a5adcf92e..928dacdfdd 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 @@ -20,16 +20,6 @@ */ package org.apache.qpid.server.security.auth.manager; -import org.apache.log4j.Logger; -import org.apache.qpid.server.configuration.IllegalConfigurationException; -import org.apache.qpid.server.model.*; -import org.apache.qpid.server.model.AbstractConfiguredObject; -import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; -import org.apache.qpid.server.plugin.PreferencesProviderFactory; -import org.apache.qpid.server.security.SubjectCreator; -import org.apache.qpid.server.security.access.Operation; -import org.apache.qpid.server.util.MapValueConverter; - import java.security.AccessControlException; import java.util.ArrayList; import java.util.Collection; @@ -39,6 +29,27 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; +import org.apache.log4j.Logger; + +import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.model.AbstractConfiguredObject; +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.ConfiguredObjectFactory; +import org.apache.qpid.server.model.IllegalStateTransitionException; +import org.apache.qpid.server.model.IntegrityViolationException; +import org.apache.qpid.server.model.LifetimePolicy; +import org.apache.qpid.server.model.Port; +import org.apache.qpid.server.model.PreferencesProvider; +import org.apache.qpid.server.model.State; +import org.apache.qpid.server.model.User; +import org.apache.qpid.server.model.VirtualHostAlias; +import org.apache.qpid.server.model.port.PortWithAuthProvider; +import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; +import org.apache.qpid.server.security.SubjectCreator; +import org.apache.qpid.server.security.access.Operation; + public abstract class AbstractAuthenticationManager<T extends AbstractAuthenticationManager<T>> extends AbstractConfiguredObject<T> implements AuthenticationProvider<T>, AuthenticationManager @@ -58,12 +69,34 @@ public abstract class AbstractAuthenticationManager<T extends AbstractAuthentica _broker = broker; } + @Override + public void validate() + { + super.validate(); + Collection<PreferencesProvider> prefsProviders = getChildren(PreferencesProvider.class); + if(prefsProviders != null && prefsProviders.size() > 1) + { + throw new IllegalConfigurationException("Only one preference provider can be configured for an authentication provider"); + } + } + protected final Broker getBroker() { return _broker; } @Override + protected void onOpen() + { + super.onOpen(); + Collection<PreferencesProvider> prefsProviders = getChildren(PreferencesProvider.class); + if(prefsProviders != null && !prefsProviders.isEmpty()) + { + _preferencesProvider = prefsProviders.iterator().next(); + } + } + + @Override public Collection<VirtualHostAlias> getVirtualHostPortBindings() { return null; @@ -188,17 +221,6 @@ public abstract class AbstractAuthenticationManager<T extends AbstractAuthentica } } - @SuppressWarnings("unchecked") - @Override - public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz) - { - if (clazz == PreferencesProvider.class && _preferencesProvider != null) - { - return (Collection<C>) Collections.<PreferencesProvider>singleton(_preferencesProvider); - } - return Collections.emptySet(); - } - @Override public boolean setState(State currentState, State desiredState) throws IllegalStateTransitionException, AccessControlException @@ -212,7 +234,7 @@ public abstract class AbstractAuthenticationManager<T extends AbstractAuthentica Collection<Port> ports = new ArrayList<Port>(_broker.getPorts()); for (Port port : ports) { - if (providerName.equals(port.getAttribute(Port.AUTHENTICATION_PROVIDER))) + if(port instanceof PortWithAuthProvider && ((PortWithAuthProvider<?>)port).getAuthenticationProvider() == this) { throw new IntegrityViolationException("Authentication provider '" + providerName + "' is set on port " + port.getName()); } @@ -227,6 +249,7 @@ public abstract class AbstractAuthenticationManager<T extends AbstractAuthentica { _preferencesProvider.setDesiredState(_preferencesProvider.getState(), State.DELETED); } + deleted(); return true; } else 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 5b6e8f51c0..130413d99d 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 @@ -54,7 +54,7 @@ public abstract class PrincipalDatabaseAuthenticationManager<T extends Principal private static final Logger LOGGER = Logger.getLogger(PrincipalDatabaseAuthenticationManager.class); - private final PrincipalDatabase _principalDatabase; + private PrincipalDatabase _principalDatabase; @ManagedAttributeField private String _path; @@ -64,26 +64,34 @@ public abstract class PrincipalDatabaseAuthenticationManager<T extends Principal boolean recovering) { super(broker, defaults, attributes); + } - if(!recovering) + @Override + protected void onCreate() + { + super.onCreate(); + try { - try + File passwordFile = new File(_path); + if (!passwordFile.exists()) { - File passwordFile = new File(_path); - if (!passwordFile.exists()) - { - passwordFile.createNewFile(); - } - else if (!passwordFile.canRead()) - { - throw new IllegalConfigurationException("Cannot read password file" + _path + ". Check permissions."); - } + passwordFile.createNewFile(); } - catch (IOException e) + else if (!passwordFile.canRead()) { - throw new IllegalConfigurationException("Cannot use password database at :" + _path, e); + throw new IllegalConfigurationException("Cannot read password file" + _path + ". Check permissions."); } } + catch (IOException e) + { + throw new IllegalConfigurationException("Cannot use password database at :" + _path, e); + } + } + + @Override + protected void onOpen() + { + super.onOpen(); _principalDatabase = createDatabase(); } @@ -271,7 +279,8 @@ public abstract class PrincipalDatabaseAuthenticationManager<T extends Principal { if(clazz == User.class) { - List<Principal> users = getPrincipalDatabase().getUsers(); + PrincipalDatabase principalDatabase = getPrincipalDatabase(); + List<Principal> users = principalDatabase == null ? Collections.<Principal>emptyList() : principalDatabase.getUsers(); Collection<User> principals = new ArrayList<User>(users.size()); for(Principal user : users) { 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 b10adffbf7..2d5211011c 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 @@ -36,7 +36,7 @@ import javax.security.sasl.SaslException; import javax.security.sasl.SaslServer; import org.apache.log4j.Logger; -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.security.auth.AuthenticationResult; @@ -55,8 +55,8 @@ 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> defaults, - final Map<String, Object> attributes) + final Map<String, Object> defaults, + final Map<String, Object> attributes) { super(broker, defaults, attributes); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordRecoveverAndUpgrader.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordRecoveverAndUpgrader.java index 85265d986e..2cadb8ac4c 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordRecoveverAndUpgrader.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordRecoveverAndUpgrader.java @@ -24,14 +24,14 @@ import java.util.Map; import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler; import org.apache.qpid.server.virtualhost.DefaultUpgraderProvider; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class ConfiguredObjectRecordRecoveverAndUpgrader implements ConfiguredObjectRecordHandler { private DurableConfigurationRecoverer _configRecoverer; private DurableConfigurationStore _store; - public ConfiguredObjectRecordRecoveverAndUpgrader(VirtualHost virtualHost, Map<String, DurableConfiguredObjectRecoverer> recoverers) + public ConfiguredObjectRecordRecoveverAndUpgrader(VirtualHostImpl virtualHost, Map<String, DurableConfiguredObjectRecoverer> recoverers) { DefaultUpgraderProvider upgraderProvider = new DefaultUpgraderProvider(virtualHost); _configRecoverer = new DurableConfigurationRecoverer(virtualHost.getName(), recoverers, upgraderProvider, virtualHost.getEventLogger()); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DistributedTransaction.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DistributedTransaction.java index 4a7c16a7cd..cb713f671f 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DistributedTransaction.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DistributedTransaction.java @@ -25,14 +25,12 @@ import org.apache.qpid.server.message.EnqueueableMessage; import org.apache.qpid.server.message.MessageInstance; import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.queue.BaseQueue; -import org.apache.qpid.server.queue.QueueEntry; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.TransactionLogResource; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.Xid; import java.util.Collection; -import java.util.Collections; import java.util.List; public class DistributedTransaction implements ServerTransaction @@ -42,10 +40,10 @@ public class DistributedTransaction implements ServerTransaction private DtxBranch _branch; private AMQSessionModel _session; - private VirtualHost _vhost; + private VirtualHostImpl _vhost; - public DistributedTransaction(AMQSessionModel session, MessageStore store, VirtualHost vhost) + public DistributedTransaction(AMQSessionModel session, MessageStore store, VirtualHostImpl vhost) { _session = session; _vhost = vhost; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java index e4a89b23c0..aa689cc7e0 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java @@ -34,7 +34,7 @@ import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.Transaction; import org.apache.qpid.server.store.TransactionLogResource; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.Xid; public class DtxBranch @@ -51,7 +51,7 @@ public class DtxBranch private Transaction _transaction; private long _expiration; - private VirtualHost _vhost; + private VirtualHostImpl _vhost; private ScheduledFuture<?> _timeoutFuture; private MessageStore _store; @@ -69,7 +69,7 @@ public class DtxBranch } - public DtxBranch(Xid xid, MessageStore store, VirtualHost vhost) + public DtxBranch(Xid xid, MessageStore store, VirtualHostImpl vhost) { _xid = xid; _store = store; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java index c4df125175..84680ebe19 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java @@ -22,6 +22,7 @@ package org.apache.qpid.server.virtualhost; import java.lang.reflect.Type; import java.security.AccessControlException; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -37,6 +38,8 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import javax.security.auth.Subject; + import org.apache.log4j.Logger; import org.apache.qpid.server.configuration.IllegalConfigurationException; @@ -58,20 +61,7 @@ import org.apache.qpid.server.message.MessageInstance; import org.apache.qpid.server.message.MessageNode; import org.apache.qpid.server.message.MessageSource; import org.apache.qpid.server.message.ServerMessage; -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.Exchange; -import org.apache.qpid.server.model.IntegrityViolationException; -import org.apache.qpid.server.model.LifetimePolicy; -import org.apache.qpid.server.model.Port; -import org.apache.qpid.server.model.Protocol; -import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.model.QueueType; -import org.apache.qpid.server.model.State; -import org.apache.qpid.server.model.UUIDGenerator; -import org.apache.qpid.server.model.VirtualHostAlias; +import org.apache.qpid.server.model.*; import org.apache.qpid.server.model.adapter.ConnectionAdapter; import org.apache.qpid.server.model.adapter.VirtualHostAliasAdapter; import org.apache.qpid.server.plugin.ExchangeType; @@ -102,8 +92,8 @@ import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.server.util.ParameterizedTypeImpl; public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> extends AbstractConfiguredObject<X> - implements VirtualHost<AMQQueue<?>, ExchangeImpl<?>>, IConnectionRegistry.RegistryChangeListener, EventListener, - org.apache.qpid.server.model.VirtualHost<X,AMQQueue<?>, ExchangeImpl<?>> + implements VirtualHostImpl<X, AMQQueue<?>, ExchangeImpl<?>>, IConnectionRegistry.RegistryChangeListener, EventListener, + VirtualHost<X,AMQQueue<?>, ExchangeImpl<?>> { private static final Logger _logger = Logger.getLogger(AbstractVirtualHost.class); @@ -181,6 +171,12 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte private final List<VirtualHostAlias> _aliases = new ArrayList<VirtualHostAlias>(); private final AtomicBoolean _deleted = new AtomicBoolean(); + @ManagedAttributeField + private Map<String, Object> _messageStoreSettings; + + @ManagedAttributeField + private Map<String, Object> _configurationStoreSettings; + public AbstractVirtualHost(final Map<String, Object> attributes, Broker<?> broker) { @@ -206,7 +202,6 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte _exchangeRegistry = new DefaultExchangeRegistry(this, _queueRegistry); - validateAttributes(); } private static Map<String, Object> enhanceWithId(Map<String, Object> attributes) @@ -226,8 +221,9 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte return parentsMap; } - protected void validateAttributes() + public void validate() { + super.validate(); String name = getName(); if (name == null || "".equals(name.trim())) { @@ -240,13 +236,23 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte } } - public void onOpen() + protected void onOpen() { + super.onOpen(); + registerSystemNodes(); initialiseStatistics(); - initialiseStorage(this); + Subject.doAs(getSecurityManager().getSubjectWithAddedSystemRights(), new PrivilegedAction<Object>() + { + @Override + public Object run() + { + initialiseStorage(AbstractVirtualHost.this); + return null; + } + }); getMessageStore().addEventListener(this, Event.PERSISTENT_MESSAGE_SIZE_OVERFULL); getMessageStore().addEventListener(this, Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL); @@ -581,7 +587,15 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte protected void initialiseModel() { - _exchangeRegistry.initialise(_exchangeFactory); + Subject.doAs(getSecurityManager().getSubjectWithAddedSystemRights(), new PrivilegedAction<Object>() + { + @Override + public Object run() + { + _exchangeRegistry.initialise(_exchangeFactory); + return null; + } + }); } @@ -1346,7 +1360,7 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte } @Override - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return AbstractVirtualHost.this; } @@ -1717,14 +1731,14 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte @Override public Map<String, Object> getMessageStoreSettings() { - return (Map<String, Object>)getAttribute(org.apache.qpid.server.model.VirtualHost.MESSAGE_STORE_SETTINGS); + return _messageStoreSettings; } @SuppressWarnings("unchecked") @Override public Map<String, Object> getConfigurationStoreSettings() { - return (Map<String, Object>)getAttribute(org.apache.qpid.server.model.VirtualHost.CONFIGURATION_STORE_SETTINGS); + return _configurationStoreSettings; } @Override @@ -1788,6 +1802,7 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte { if (desiredState == State.ACTIVE) { +/* try { onOpen(); @@ -1804,6 +1819,7 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte throw e; } } +*/ return true; } else if (desiredState == State.STOPPED) @@ -1848,7 +1864,9 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte } } setAttribute(org.apache.qpid.server.model.VirtualHost.STATE, getState(), State.DELETED); + deleted(); } + return true; } return false; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java index 58721ea8b2..11623bd36b 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java @@ -41,9 +41,9 @@ public class BindingRecoverer extends AbstractDurableConfiguredObjectRecoverer<B private static final Logger _logger = Logger.getLogger(BindingRecoverer.class); private final ExchangeRegistry _exchangeRegistry; - private final VirtualHost _virtualHost; + private final VirtualHostImpl _virtualHost; - public BindingRecoverer(final VirtualHost virtualHost, + public BindingRecoverer(final VirtualHostImpl virtualHost, final ExchangeRegistry exchangeRegistry) { _exchangeRegistry = exchangeRegistry; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/DefaultUpgraderProvider.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/DefaultUpgraderProvider.java index 46b5dbb9fc..8c3ebaf9be 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/DefaultUpgraderProvider.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/DefaultUpgraderProvider.java @@ -51,7 +51,7 @@ public class DefaultUpgraderProvider implements UpgraderProvider public static final String EXCLUSIVE = "exclusive"; public static final String NAME = "name"; - private final VirtualHost _virtualHost; + private final VirtualHostImpl _virtualHost; @SuppressWarnings("serial") private static final Map<String, String> DEFAULT_EXCHANGES = Collections.unmodifiableMap(new HashMap<String, String>() @@ -64,7 +64,7 @@ public class DefaultUpgraderProvider implements UpgraderProvider private final Map<String, UUID> _defaultExchangeIds; - public DefaultUpgraderProvider(final VirtualHost virtualHost) + public DefaultUpgraderProvider(final VirtualHostImpl virtualHost) { _virtualHost = virtualHost; Map<String, UUID> defaultExchangeIds = new HashMap<String, UUID>(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java index 6e5ac79559..fe2a8f1f2b 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java @@ -22,25 +22,22 @@ package org.apache.qpid.server.virtualhost; import org.apache.log4j.Logger; -import org.apache.qpid.server.security.*; import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.server.security.auth.TaskPrincipal; import javax.security.auth.Subject; import java.security.PrivilegedAction; -import java.util.Collections; public abstract class HouseKeepingTask implements Runnable { private Logger _logger = Logger.getLogger(this.getClass()); - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; private String _name; private final Subject _subject; - public HouseKeepingTask(VirtualHost vhost) + public HouseKeepingTask(VirtualHostImpl vhost) { _virtualHost = vhost; _name = _virtualHost.getName() + ":" + this.getClass().getSimpleName(); @@ -78,7 +75,7 @@ public abstract class HouseKeepingTask implements Runnable } } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _virtualHost; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/MessageStoreRecoverer.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/MessageStoreRecoverer.java index df47c85f64..662a26bb2e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/MessageStoreRecoverer.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/MessageStoreRecoverer.java @@ -55,7 +55,7 @@ public class MessageStoreRecoverer { private static final Logger _logger = Logger.getLogger(MessageStoreRecoverer.class); - private final VirtualHost _virtualHost; + private final VirtualHostImpl _virtualHost; private final Map<String, Integer> _queueRecoveries = new TreeMap<String, Integer>(); private final Map<Long, ServerMessage<?>> _recoveredMessages = new HashMap<Long, ServerMessage<?>>(); @@ -66,7 +66,7 @@ public class MessageStoreRecoverer private final MessageStore _store; - public MessageStoreRecoverer(VirtualHost virtualHost, MessageStoreLogSubject logSubject) + public MessageStoreRecoverer(VirtualHostImpl virtualHost, MessageStoreLogSubject logSubject) { super(); _virtualHost = virtualHost; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java index eb1bc883ca..d7fc08f249 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java @@ -39,11 +39,11 @@ import org.apache.qpid.server.store.UnresolvedObject; public class QueueRecoverer extends AbstractDurableConfiguredObjectRecoverer<AMQQueue> { private static final Logger _logger = Logger.getLogger(QueueRecoverer.class); - private final VirtualHost _virtualHost; + private final VirtualHostImpl _virtualHost; private final ExchangeRegistry _exchangeRegistry; private final QueueFactory _queueFactory; - public QueueRecoverer(final VirtualHost virtualHost, + public QueueRecoverer(final VirtualHostImpl virtualHost, final ExchangeRegistry exchangeRegistry, final QueueFactory queueFactory) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHost.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHost.java index 9faf74f81a..6f75a67197 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHost.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHost.java @@ -55,11 +55,11 @@ public class StandardVirtualHost extends AbstractVirtualHost<StandardVirtualHost } @Override - protected void validateAttributes() + public void validate() { - super.validateAttributes(); + super.validate(); Map<String,Object> attributes = getActualAttributes(); - Map<String, Object> messageStoreSettings = (Map<String, Object>)attributes.get(org.apache.qpid.server.model.VirtualHost.MESSAGE_STORE_SETTINGS); + Map<String, Object> messageStoreSettings = getMessageStoreSettings(); if (messageStoreSettings == null) { throw new IllegalArgumentException("Attribute '"+ org.apache.qpid.server.model.VirtualHost.MESSAGE_STORE_SETTINGS + "' is required."); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java index 8c931583a3..db97fe3c0a 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java @@ -34,6 +34,7 @@ import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.EventLoggerProvider; import org.apache.qpid.server.message.MessageDestination; import org.apache.qpid.server.message.MessageSource; +import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.protocol.LinkRegistry; import org.apache.qpid.server.queue.AMQQueue; @@ -43,8 +44,11 @@ import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.txn.DtxRegistry; -public interface VirtualHost< Q extends AMQQueue<?>, E extends ExchangeImpl<?> > extends DurableConfigurationStore.Source, Closeable, StatisticsGatherer, - EventLoggerProvider +public interface VirtualHostImpl< X extends VirtualHostImpl<X,Q,E>, Q extends AMQQueue<?>, E extends ExchangeImpl<?> > + extends DurableConfigurationStore.Source, + Closeable, StatisticsGatherer, + EventLoggerProvider, + VirtualHost<X,Q,E> { IConnectionRegistry getConnectionRegistry(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostRegistry.java index 563db8e0f3..cc9ff549c4 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostRegistry.java @@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap; public class VirtualHostRegistry implements Closeable { - private final Map<String, VirtualHost> _registry = new ConcurrentHashMap<String, VirtualHost>(); + private final Map<String, VirtualHostImpl> _registry = new ConcurrentHashMap<String, VirtualHostImpl>(); private String _defaultVirtualHostName; private final EventLogger _eventLogger; @@ -41,7 +41,7 @@ public class VirtualHostRegistry implements Closeable _eventLogger = eventLogger; } - public synchronized void registerVirtualHost(VirtualHost host) + public synchronized void registerVirtualHost(VirtualHostImpl host) { if(_registry.containsKey(host.getName())) { @@ -50,12 +50,12 @@ public class VirtualHostRegistry implements Closeable _registry.put(host.getName(),host); } - public synchronized void unregisterVirtualHost(VirtualHost host) + public synchronized void unregisterVirtualHost(VirtualHostImpl host) { _registry.remove(host.getName()); } - public VirtualHost getVirtualHost(String name) + public VirtualHostImpl getVirtualHost(String name) { if(name == null || name.trim().length() == 0 || "/".equals(name.trim())) { @@ -65,7 +65,7 @@ public class VirtualHostRegistry implements Closeable return _registry.get(name); } - public VirtualHost getDefaultVirtualHost() + public VirtualHostImpl getDefaultVirtualHost() { return getVirtualHost(getDefaultVirtualHostName()); } @@ -81,14 +81,14 @@ public class VirtualHostRegistry implements Closeable } - public Collection<VirtualHost> getVirtualHosts() + public Collection<VirtualHostImpl> getVirtualHosts() { - return new ArrayList<VirtualHost>(_registry.values()); + return new ArrayList<VirtualHostImpl>(_registry.values()); } public void close() { - for (VirtualHost virtualHost : getVirtualHosts()) + for (VirtualHostImpl virtualHost : getVirtualHosts()) { virtualHost.close(); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java index ad0cf7e1f2..0e2df22367 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java @@ -20,7 +20,18 @@ */ package org.apache.qpid.server.configuration.startup; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + import junit.framework.TestCase; + import org.apache.qpid.server.BrokerOptions; import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; import org.apache.qpid.server.configuration.IllegalConfigurationException; @@ -28,22 +39,20 @@ import org.apache.qpid.server.configuration.RecovererProvider; import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.LogRecorder; -import org.apache.qpid.server.model.*; +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.ConfiguredObjectFactory; +import org.apache.qpid.server.model.GroupProvider; +import org.apache.qpid.server.model.Model; +import org.apache.qpid.server.model.Port; +import org.apache.qpid.server.model.SystemContext; +import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.ConfiguredObjectRecordImpl; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.TestMemoryMessageStore; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class BrokerRecovererTest extends TestCase { private ConfiguredObjectRecord _brokerEntry = mock(ConfiguredObjectRecord.class); @@ -111,6 +120,9 @@ public class BrokerRecovererTest extends TestCase Broker broker = _systemContext.getBroker(); assertNotNull(broker); + + broker.open(); + assertEquals(_brokerId, broker.getId()); for (Map.Entry<String, Object> attribute : attributes.entrySet()) @@ -133,6 +145,7 @@ public class BrokerRecovererTest extends TestCase Broker<?> broker = _systemContext.getBroker(); assertNotNull(broker); + broker.open(); assertEquals(_brokerId, broker.getId()); assertEquals(1, broker.getVirtualHosts().size()); assertEquals(vhostId, broker.getVirtualHosts().iterator().next().getId()); @@ -198,6 +211,7 @@ public class BrokerRecovererTest extends TestCase assertNotNull(broker); + broker.open(); assertEquals(_brokerId, broker.getId()); assertEquals(1, broker.getPorts().size()); } @@ -211,6 +225,7 @@ public class BrokerRecovererTest extends TestCase assertNotNull(broker); + broker.open(); assertEquals(_brokerId, broker.getId()); assertEquals(1, broker.getAuthenticationProviders().size()); @@ -232,6 +247,7 @@ public class BrokerRecovererTest extends TestCase assertNotNull(broker); + broker.open(); assertEquals(_brokerId, broker.getId()); assertEquals(2, broker.getPorts().size()); @@ -249,6 +265,7 @@ public class BrokerRecovererTest extends TestCase assertNotNull(broker); + broker.open(); assertEquals(_brokerId, broker.getId()); assertEquals(1, broker.getGroupProviders().size()); @@ -260,6 +277,8 @@ public class BrokerRecovererTest extends TestCase String[] incompatibleVersions = {Integer.MAX_VALUE + "." + 0, "0.0"}; for (String incompatibleVersion : incompatibleVersions) { + // need to reset all the shared objects for every iteration of the test + setUp(); brokerAttributes.put(Broker.MODEL_VERSION, incompatibleVersion); when(_brokerEntry.getAttributes()).thenReturn(brokerAttributes); @@ -267,6 +286,7 @@ public class BrokerRecovererTest extends TestCase { _systemContext.resolveObjects(_brokerEntry); Broker<?> broker = _systemContext.getBroker(); + broker.open(); fail("The broker creation should fail due to unsupported model version"); } catch (IllegalConfigurationException e) @@ -288,6 +308,7 @@ public class BrokerRecovererTest extends TestCase try { Broker broker = (Broker) _configuredObjectFactory.recover(_brokerEntry, _systemContext).resolve(); + broker.open(); fail("The broker creation should fail due to unsupported model version"); } catch (IllegalConfigurationException e) @@ -309,7 +330,7 @@ public class BrokerRecovererTest extends TestCase try { Broker broker = (Broker) _configuredObjectFactory.recover(_brokerEntry, _systemContext).resolve(); - + broker.open(); fail("The broker creation should fail due to unsupported model version"); } catch (IllegalConfigurationException e) diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileKeyStoreCreationTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileKeyStoreCreationTest.java index 580870c66e..177fecb72c 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileKeyStoreCreationTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileKeyStoreCreationTest.java @@ -20,38 +20,51 @@ */ package org.apache.qpid.server.configuration.startup; -import junit.framework.TestCase; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.KeyStore; -import org.apache.qpid.server.security.AbstractKeyStoreAdapter; -import org.apache.qpid.server.security.FileKeyStore; -import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.test.utils.TestSSLConstants; +import static org.mockito.Mockito.mock; -import javax.net.ssl.KeyManagerFactory; -import javax.security.auth.Subject; import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Map; import java.util.UUID; -import static org.mockito.Mockito.mock; +import javax.net.ssl.KeyManagerFactory; +import javax.security.auth.Subject; + +import junit.framework.TestCase; + +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectFactory; +import org.apache.qpid.server.model.KeyStore; +import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; +import org.apache.qpid.server.security.AbstractKeyStoreAdapter; +import org.apache.qpid.server.security.SecurityManager; +import org.apache.qpid.test.utils.TestSSLConstants; public class FileKeyStoreCreationTest extends TestCase { + private ConfiguredObjectFactory _factory; + + public void setUp() throws Exception + { + super.setUp(); + _factory = new ConfiguredObjectFactory(); + } + public void testCreateWithAllAttributesProvided() { Map<String, Object> attributes = getKeyStoreAttributes(); Map<String, Object> attributesCopy = new HashMap<String, Object>(attributes); - UUID id = UUID.randomUUID(); Broker broker = mock(Broker.class); - final KeyStore keyStore = new FileKeyStore(id,broker,attributes); + final KeyStore keyStore = + createKeyStore(attributes, broker); + assertNotNull("Key store configured object is not created", keyStore); - assertEquals(id, keyStore.getId()); + assertEquals(attributes.get(ConfiguredObject.ID), keyStore.getId()); //verify we can retrieve the actual password using the method Subject.doAs(SecurityManager.getSubjectWithAddedSystemRights(), new PrivilegedAction<Object>() @@ -78,6 +91,13 @@ public class FileKeyStoreCreationTest extends TestCase } } + protected KeyStore createKeyStore(final Map<String, Object> attributes, final Broker broker) + { + ConfiguredObjectTypeFactory configuredObjectTypeFactory = + _factory.getConfiguredObjectTypeFactory(KeyStore.class, attributes); + return (KeyStore) configuredObjectTypeFactory.create(attributes, broker); + } + public void testCreateWithMissedRequiredAttributes() { Map<String, Object> attributes = getKeyStoreAttributes(); @@ -92,7 +112,7 @@ public class FileKeyStoreCreationTest extends TestCase properties.remove(mandatoryProperties[i]); try { - new FileKeyStore(id, broker, properties); + createKeyStore(properties, broker); fail("Cannot create key store without a " + mandatoryProperties[i]); } catch(IllegalArgumentException e) @@ -105,6 +125,7 @@ public class FileKeyStoreCreationTest extends TestCase private Map<String, Object> getKeyStoreAttributes() { Map<String, Object> attributes = new HashMap<String, Object>(); + attributes.put(KeyStore.ID, UUID.randomUUID()); attributes.put(KeyStore.NAME, getName()); attributes.put(KeyStore.PATH, TestSSLConstants.BROKER_KEYSTORE); attributes.put(KeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD); 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 33d53e7f3d..25005407ae 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 @@ -49,6 +49,7 @@ public class FileTrustStoreCreationTest extends QpidTestCase Broker broker = mock(Broker.class); final TrustStore trustStore = new FileTrustStore(id, broker, attributes); + trustStore.open(); assertNotNull("Trust store configured object is not created", trustStore); assertEquals(id, trustStore.getId()); @@ -92,6 +93,7 @@ public class FileTrustStoreCreationTest extends QpidTestCase try { TrustStore trustStore = new FileTrustStore(id, broker, properties); + trustStore.open(); fail("Cannot create key store without a " + mandatoryProperties[i]); } catch(IllegalArgumentException e) diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java index ec68fcff56..1a4a36a62e 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java @@ -65,7 +65,7 @@ public class VirtualHostCreationTest extends TestCase when(entry.getAttributes()).thenReturn(attributes); VirtualHost host = new StandardVirtualHost(attributes,parent); - + host.open(); assertNotNull("Null is returned", host); assertEquals("Unexpected name", getName(), host.getName()); } @@ -99,6 +99,7 @@ public class VirtualHostCreationTest extends TestCase try { VirtualHost host = new StandardVirtualHost(copy,parent); + host.open(); fail("Cannot create a virtual host without a mandatory attribute " + name); } catch(IllegalConfigurationException e) diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java index c8003d909f..ea3937ea15 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java @@ -146,6 +146,13 @@ public class JsonConfigurationEntryStoreTest extends ConfigurationEntryStoreTest store.save(newParentEntry, new ConfigurationEntryImpl(id, type, attributes, Collections.<UUID> emptySet(), store)); } + /* ** + * TODO - RG : This functionality has been moved to the generic configured object. The JsonConfigurationEntryStore + * needs to be removed and replaced with the Json configuration store written for the virtual host, however testing + * resolution functionality needs to occur in a configured object resolution test + * ** + + public void testAttributeIsResolvedFromSystemProperties() { String defaultVhost = getTestName(); @@ -164,6 +171,7 @@ public class JsonConfigurationEntryStoreTest extends ConfigurationEntryStoreTest assertEquals("Unresolved default virtualhost value", defaultVhost, store2.getRootEntry().getAttributes().get(Broker.DEFAULT_VIRTUAL_HOST)); } + */ public void testCreateEmptyStore() { diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/DefaultExchangeFactoryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/DefaultExchangeFactoryTest.java index b5fe5e0072..090e8eead3 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/DefaultExchangeFactoryTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/DefaultExchangeFactoryTest.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.Map; import org.apache.qpid.server.plugin.ExchangeType; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; @SuppressWarnings("rawtypes") @@ -200,7 +200,7 @@ public class DefaultExchangeFactoryTest extends QpidTestCase } @Override - public CustomExchange newInstance(VirtualHost host, Map<String,Object> attributes) + public CustomExchange newInstance(VirtualHostImpl host, Map<String,Object> attributes) { return null; } 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 39c2a9bbf6..ddc9f5edf8 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 @@ -42,14 +42,15 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; + import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; public class FanoutExchangeTest extends TestCase { private FanoutExchange _exchange; - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; public void setUp() throws UnknownExchangeException { @@ -58,7 +59,7 @@ public class FanoutExchangeTest extends TestCase attributes.put(Exchange.NAME, "test"); attributes.put(Exchange.DURABLE, false); - _virtualHost = mock(VirtualHost.class); + _virtualHost = mock(VirtualHostImpl.class); SecurityManager securityManager = mock(SecurityManager.class); when(_virtualHost.getSecurityManager()).thenReturn(securityManager); when(_virtualHost.getEventLogger()).thenReturn(new EventLogger()); 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 607bcbf076..093a00d88a 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 @@ -20,7 +20,15 @@ */ package org.apache.qpid.server.exchange; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + import junit.framework.TestCase; import org.apache.qpid.server.binding.BindingImpl; @@ -28,14 +36,7 @@ import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.message.AMQMessageHeader; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; -import org.apache.qpid.server.virtualhost.VirtualHost; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; /** */ @@ -144,7 +145,7 @@ public class HeadersBindingTest extends TestCase { _count++; _queue = mock(AMQQueue.class); - VirtualHost vhost = mock(VirtualHost.class); + VirtualHostImpl vhost = mock(VirtualHostImpl.class); when(_queue.getVirtualHost()).thenReturn(vhost); when(vhost.getSecurityManager()).thenReturn(mock(org.apache.qpid.server.security.SecurityManager.class)); final EventLogger eventLogger = new EventLogger(); @@ -165,7 +166,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -176,7 +177,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); matchHeaders.setString("B", "Value of B"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -186,7 +187,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Altered value of A"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertFalse(new HeadersBinding(b).matches(matchHeaders)); } @@ -197,7 +198,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -209,7 +210,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertFalse(new HeadersBinding(b).matches(matchHeaders)); } @@ -222,7 +223,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); matchHeaders.setString("B", "Value of B"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -236,7 +237,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -250,7 +251,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Altered value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertFalse(new HeadersBinding(b).matches(matchHeaders)); } @@ -261,7 +262,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -273,7 +274,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -286,7 +287,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("A", "Value of A"); matchHeaders.setString("B", "Value of B"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -300,7 +301,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -314,7 +315,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Altered value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertTrue(new HeadersBinding(b).matches(matchHeaders)); } @@ -328,7 +329,7 @@ public class HeadersBindingTest extends TestCase matchHeaders.setString("B", "Altered value of B"); matchHeaders.setString("C", "Value of C"); - BindingImpl b = new BindingImpl(null, getQueueName(), _queue, _exchange, bindHeaders); + BindingImpl b = new BindingImpl(UUID.randomUUID(), getQueueName(), _queue, _exchange, bindHeaders); assertFalse(new HeadersBinding(b).matches(matchHeaders)); } 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 4a453167f7..34c1487861 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 @@ -38,7 +38,8 @@ import org.apache.qpid.server.model.Exchange; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; + import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -50,14 +51,14 @@ import static org.mockito.Mockito.when; public class HeadersExchangeTest extends TestCase { private HeadersExchange _exchange; - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; @Override public void setUp() throws Exception { super.setUp(); - _virtualHost = mock(VirtualHost.class); + _virtualHost = mock(VirtualHostImpl.class); SecurityManager securityManager = mock(SecurityManager.class); when(_virtualHost.getSecurityManager()).thenReturn(securityManager); when(_virtualHost.getEventLogger()).thenReturn(new EventLogger()); 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 21aa171551..1bf90022c0 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 @@ -20,6 +20,9 @@ */ package org.apache.qpid.server.exchange; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -31,23 +34,21 @@ 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.*; import org.apache.qpid.server.model.Exchange; +import org.apache.qpid.server.model.Queue; +import org.apache.qpid.server.model.UUIDGenerator; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.util.BrokerTestHelper; import org.apache.qpid.server.virtualhost.QueueExistsException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class TopicExchangeTest extends QpidTestCase { private TopicExchange _exchange; - private VirtualHost _vhost; + private VirtualHostImpl _vhost; @Override @@ -92,7 +93,7 @@ public class TopicExchangeTest extends QpidTestCase public void testNoRoute() throws Exception { AMQQueue<?> queue = createQueue("a*#b"); - _exchange.registerQueue(new BindingImpl(null, "a.*.#.b",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.*.#.b",queue, _exchange, null)); routeMessage("a.b", 0l); @@ -103,7 +104,7 @@ public class TopicExchangeTest extends QpidTestCase public void testDirectMatch() throws Exception { AMQQueue<?> queue = createQueue("ab"); - _exchange.registerQueue(new BindingImpl(null, "a.b",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.b",queue, _exchange, null)); routeMessage("a.b",0l); @@ -125,7 +126,7 @@ public class TopicExchangeTest extends QpidTestCase public void testStarMatch() throws Exception { AMQQueue<?> queue = createQueue("a*"); - _exchange.registerQueue(new BindingImpl(null, "a.*",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.*",queue, _exchange, null)); routeMessage("a.b",0l); @@ -156,7 +157,7 @@ public class TopicExchangeTest extends QpidTestCase public void testHashMatch() throws Exception { AMQQueue<?> queue = createQueue("a#"); - _exchange.registerQueue(new BindingImpl(null, "a.#",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.#",queue, _exchange, null)); routeMessage("a.b.c",0l); @@ -207,7 +208,7 @@ public class TopicExchangeTest extends QpidTestCase public void testMidHash() throws Exception { AMQQueue<?> queue = createQueue("a"); - _exchange.registerQueue(new BindingImpl(null, "a.*.#.b",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.*.#.b",queue, _exchange, null)); routeMessage("a.c.d.b",0l); @@ -232,7 +233,7 @@ public class TopicExchangeTest extends QpidTestCase public void testMatchAfterHash() throws Exception { AMQQueue<?> queue = createQueue("a#"); - _exchange.registerQueue(new BindingImpl(null, "a.*.#.b.c",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.*.#.b.c",queue, _exchange, null)); int queueCount = routeMessage("a.c.b.b",0l); @@ -270,7 +271,7 @@ public class TopicExchangeTest extends QpidTestCase public void testHashAfterHash() throws Exception { AMQQueue<?> queue = createQueue("a#"); - _exchange.registerQueue(new BindingImpl(null, "a.*.#.b.c.#.d",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(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); @@ -291,7 +292,7 @@ public class TopicExchangeTest extends QpidTestCase public void testHashHash() throws Exception { AMQQueue<?> queue = createQueue("a#"); - _exchange.registerQueue(new BindingImpl(null, "a.#.*.#.d",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(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); @@ -312,7 +313,7 @@ public class TopicExchangeTest extends QpidTestCase public void testSubMatchFails() throws Exception { AMQQueue<?> queue = createQueue("a"); - _exchange.registerQueue(new BindingImpl(null, "a.b.c.d",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(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); @@ -341,7 +342,7 @@ public class TopicExchangeTest extends QpidTestCase public void testMoreRouting() throws Exception { AMQQueue<?> queue = createQueue("a"); - _exchange.registerQueue(new BindingImpl(null, "a.b",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.b",queue, _exchange, null)); int queueCount = routeMessage("a.b.c",0l); @@ -354,7 +355,7 @@ public class TopicExchangeTest extends QpidTestCase public void testMoreQueue() throws Exception { AMQQueue<?> queue = createQueue("a"); - _exchange.registerQueue(new BindingImpl(null, "a.b",queue, _exchange, null)); + _exchange.registerQueue(new BindingImpl(UUID.randomUUID(), "a.b",queue, _exchange, null)); int queueCount = routeMessage("a",0l); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java index 797aa477a9..7fee259e29 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java @@ -23,12 +23,12 @@ package org.apache.qpid.server.logging.actors; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.server.protocol.AMQConnectionModel; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class BaseConnectionActorTestCase extends BaseActorTestCase { private AMQConnectionModel _session; - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; @Override public void setUp() throws Exception @@ -39,7 +39,7 @@ public class BaseConnectionActorTestCase extends BaseActorTestCase _virtualHost = BrokerTestHelper.createVirtualHost("test"); } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _virtualHost; } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java index b2582b293b..f2486ff4d8 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java @@ -28,7 +28,7 @@ import org.apache.qpid.server.logging.LogSubject; import org.apache.qpid.server.logging.UnitTestMessageLogger; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; import java.util.List; @@ -195,7 +195,7 @@ public abstract class AbstractTestLogSubject extends QpidTestCase * @param message the message to search * @param vhost the vhostName to check against */ - static public void verifyVirtualHost(String message, VirtualHost vhost) + static public void verifyVirtualHost(String message, VirtualHostImpl vhost) { String vhostSlice = getSlice("vh", message); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/BindingLogSubjectTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/BindingLogSubjectTest.java index 14e193cc86..34063226b2 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/BindingLogSubjectTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/BindingLogSubjectTest.java @@ -23,7 +23,7 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -37,7 +37,7 @@ public class BindingLogSubjectTest extends AbstractTestLogSubject private AMQQueue _queue; private String _routingKey; private ExchangeImpl _exchange; - private VirtualHost _testVhost; + private VirtualHostImpl _testVhost; @Override public void setUp() throws Exception diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java index a16e7b2936..7e3f709e8d 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java @@ -22,7 +22,7 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; /** @@ -31,7 +31,7 @@ import org.apache.qpid.server.virtualhost.VirtualHost; public class ExchangeLogSubjectTest extends AbstractTestLogSubject { private ExchangeImpl _exchange; - private VirtualHost _testVhost; + private VirtualHostImpl _testVhost; @Override public void setUp() throws Exception diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java index 3d43ef0f44..5ea6b19232 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java @@ -21,14 +21,14 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; /** * Validate MessageStoreLogSubjects are logged as expected */ public class MessageStoreLogSubjectTest extends AbstractTestLogSubject { - private VirtualHost _testVhost; + private VirtualHostImpl _testVhost; @Override public void setUp() throws Exception diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/QueueLogSubjectTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/QueueLogSubjectTest.java index ccd694837e..12fac23864 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/QueueLogSubjectTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/QueueLogSubjectTest.java @@ -22,7 +22,7 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -34,7 +34,7 @@ public class QueueLogSubjectTest extends AbstractTestLogSubject { private AMQQueue _queue; - private VirtualHost _testVhost; + private VirtualHostImpl _testVhost; @Override public void setUp() throws Exception diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java index c7cc51426b..dad2f0dad4 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java @@ -79,6 +79,7 @@ public class VirtualHostTest extends QpidTestCase VirtualHost host = createHost(); host.setDesiredState(State.INITIALISING, State.ACTIVE); + host.open(); assertEquals("Unexpected state", State.ACTIVE, host.getAttribute(VirtualHost.STATE)); } @@ -87,7 +88,7 @@ public class VirtualHostTest extends QpidTestCase VirtualHost host = createHost(); assertEquals("Unexpected state", State.INITIALISING, host.getAttribute(VirtualHost.STATE)); - + host.open(); host.setDesiredState(State.INITIALISING, State.ACTIVE); assertEquals("Unexpected state", State.ACTIVE, host.getAttribute(VirtualHost.STATE)); @@ -108,6 +109,7 @@ public class VirtualHostTest extends QpidTestCase public void testCreateQueueChildHavingMessageGroupingAttributes() { VirtualHost host = createHost(); + host.open(); host.setDesiredState(State.INITIALISING, State.ACTIVE); String queueName = getTestName(); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/PortFactoryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/PortFactoryTest.java index d9dffc6855..99afa91367 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/PortFactoryTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/PortFactoryTest.java @@ -20,9 +20,9 @@ */ package org.apache.qpid.server.model.adapter; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.mockito.Mockito.any; import java.util.Arrays; import java.util.Collection; @@ -52,9 +52,9 @@ public class PortFactoryTest extends QpidTestCase private UUID _portId = UUID.randomUUID(); private int _portNumber = 123; private Set<String> _tcpStringSet = Collections.singleton(Transport.TCP.name()); - private Set<Transport> _tcpTransportSet = Collections.singleton(Transport.TCP); + private Set<Transport> _tcpTransports = Collections.singleton(Transport.TCP); private Set<String> _sslStringSet = Collections.singleton(Transport.SSL.name()); - private Set<Transport> _sslTransportSet = Collections.singleton(Transport.SSL); + private Set<Transport> _sslTransports = Collections.singleton(Transport.SSL); private Map<String, Object> _attributes = new HashMap<String, Object>(); @@ -69,7 +69,8 @@ public class PortFactoryTest extends QpidTestCase @Override protected void setUp() throws Exception { - when(_broker.findAuthenticationProviderByName(_authProviderName)).thenReturn(_authProvider); + when(_authProvider.getName()).thenReturn(_authProviderName); + when(_broker.getChildren(eq(AuthenticationProvider.class))).thenReturn(Collections.singleton(_authProvider)); setTestSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES, null); setTestSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_INCLUDES, null); @@ -178,7 +179,8 @@ public class PortFactoryTest extends QpidTestCase public void testCreateAmqpPortUsingSslSucceedsWithKeyStore() { String keyStoreName = "myKeyStore"; - when(_broker.findKeyStoreByName(keyStoreName)).thenReturn(_keyStore); + when(_keyStore.getName()).thenReturn(keyStoreName); + when(_broker.getChildren(eq(KeyStore.class))).thenReturn(Collections.singletonList(_keyStore)); createAmqpPortTestImpl(true, false, false, keyStoreName, null); } @@ -186,10 +188,9 @@ public class PortFactoryTest extends QpidTestCase public void testCreateAmqpPortNeedingClientAuthFailsWithoutTrustStore() { String keyStoreName = "myKeyStore"; - when(_broker.findKeyStoreByName(keyStoreName)).thenReturn(_keyStore); - - when(_broker.findTrustStoreByName(any(String.class))).thenReturn(null); - + when(_keyStore.getName()).thenReturn(keyStoreName); + when(_broker.getChildren(eq(KeyStore.class))).thenReturn(Collections.singletonList(_keyStore)); + when(_broker.getChildren(eq(TrustStore.class))).thenReturn(Collections.emptyList()); try { createAmqpPortTestImpl(true, true, false, keyStoreName, null); @@ -204,10 +205,12 @@ public class PortFactoryTest extends QpidTestCase public void testCreateAmqpPortNeedingClientAuthSucceedsWithTrustStore() { String keyStoreName = "myKeyStore"; - when(_broker.findKeyStoreByName(keyStoreName)).thenReturn(_keyStore); + when(_keyStore.getName()).thenReturn(keyStoreName); + when(_broker.getChildren(eq(KeyStore.class))).thenReturn(Collections.singletonList(_keyStore)); String trustStoreName = "myTrustStore"; - when(_broker.findTrustStoreByName(trustStoreName)).thenReturn(_trustStore); + when(_trustStore.getName()).thenReturn(trustStoreName); + when(_broker.getChildren(eq(TrustStore.class))).thenReturn(Collections.singletonList(_trustStore)); createAmqpPortTestImpl(true, true, false, keyStoreName, new String[]{trustStoreName}); } @@ -215,7 +218,8 @@ public class PortFactoryTest extends QpidTestCase public void testCreateAmqpPortWantingClientAuthFailsWithoutTrustStore() { String keyStoreName = "myKeyStore"; - when(_broker.findKeyStoreByName(keyStoreName)).thenReturn(_keyStore); + when(_keyStore.getName()).thenReturn(keyStoreName); + when(_broker.getChildren(eq(KeyStore.class))).thenReturn(Collections.singletonList(_keyStore)); try { @@ -231,10 +235,12 @@ public class PortFactoryTest extends QpidTestCase public void testCreateAmqpPortWantingClientAuthSucceedsWithTrustStore() { String keyStoreName = "myKeyStore"; - when(_broker.findKeyStoreByName(keyStoreName)).thenReturn(_keyStore); + when(_keyStore.getName()).thenReturn(keyStoreName); + when(_broker.getChildren(eq(KeyStore.class))).thenReturn(Collections.singletonList(_keyStore)); String trustStoreName = "myTrustStore"; - when(_broker.findTrustStoreByName(trustStoreName)).thenReturn(_trustStore); + when(_trustStore.getName()).thenReturn(trustStoreName); + when(_broker.getChildren(eq(TrustStore.class))).thenReturn(Collections.singletonList(_trustStore)); createAmqpPortTestImpl(true, false, true, keyStoreName, new String[]{trustStoreName}); } @@ -279,11 +285,11 @@ public class PortFactoryTest extends QpidTestCase assertEquals(_portNumber, port.getPort()); if(useSslTransport) { - assertEquals(_sslTransportSet, port.getTransports()); + assertEquals(_sslTransports, port.getTransports()); } else { - assertEquals(_tcpTransportSet, port.getTransports()); + assertEquals(_tcpTransports, port.getTransports()); } assertEquals(amqp010ProtocolSet, port.getProtocols()); assertEquals("Unexpected send buffer size", 2, port.getAttribute(Port.SEND_BUFFER_SIZE)); @@ -296,8 +302,8 @@ public class PortFactoryTest extends QpidTestCase public void testCreateNonAmqpPort() { - Set<Protocol> nonAmqpProtocolSet = Collections.singleton(Protocol.JMX_RMI); - Set<String> nonAmqpStringSet = Collections.singleton(Protocol.JMX_RMI.name()); + Set<Protocol> nonAmqpProtocolSet = Collections.singleton(Protocol.RMI); + Set<String> nonAmqpStringSet = Collections.singleton(Protocol.RMI.name()); _attributes = new HashMap<String, Object>(); _attributes.put(Port.PROTOCOLS, nonAmqpStringSet); _attributes.put(Port.AUTHENTICATION_PROVIDER, _authProviderName); @@ -310,7 +316,7 @@ public class PortFactoryTest extends QpidTestCase assertFalse("Port should be a PortAdapter, not its AMQP-specific subclass", port instanceof AmqpPort); assertEquals(_portId, port.getId()); assertEquals(_portNumber, port.getPort()); - assertEquals(_tcpTransportSet, port.getTransports()); + assertEquals(_tcpTransports, port.getTransports()); assertEquals(nonAmqpProtocolSet, port.getProtocols()); assertNull("Unexpected send buffer size", port.getAttribute(Port.SEND_BUFFER_SIZE)); assertNull("Unexpected receive buffer size", port.getAttribute(Port.RECEIVE_BUFFER_SIZE)); @@ -322,8 +328,8 @@ public class PortFactoryTest extends QpidTestCase public void testCreateNonAmqpPortWithPartiallySetAttributes() { - Set<Protocol> nonAmqpProtocolSet = Collections.singleton(Protocol.JMX_RMI); - Set<String> nonAmqpStringSet = Collections.singleton(Protocol.JMX_RMI.name()); + Set<Protocol> nonAmqpProtocolSet = Collections.singleton(Protocol.RMI); + Set<String> nonAmqpStringSet = Collections.singleton(Protocol.RMI.name()); _attributes = new HashMap<String, Object>(); _attributes.put(Port.PROTOCOLS, nonAmqpStringSet); _attributes.put(Port.AUTHENTICATION_PROVIDER, _authProviderName); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java index 02921f987c..663ffd17f6 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java @@ -42,7 +42,7 @@ import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.util.MapValueConverter; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; import org.mockito.ArgumentCaptor; import org.mockito.invocation.InvocationOnMock; @@ -51,7 +51,7 @@ import org.mockito.stubbing.Answer; public class AMQQueueFactoryTest extends QpidTestCase { private QueueRegistry _queueRegistry; - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; private AMQQueueFactory _queueFactory; private List<AMQQueue> _queues; @@ -62,7 +62,7 @@ public class AMQQueueFactoryTest extends QpidTestCase _queues = new ArrayList<AMQQueue>(); - _virtualHost = mock(VirtualHost.class); + _virtualHost = mock(VirtualHostImpl.class); when(_virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(_virtualHost.getEventLogger()).thenReturn(new EventLogger()); 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 913f400a5f..518f90c863 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 @@ -49,7 +49,7 @@ import org.apache.qpid.server.queue.AbstractQueue.QueueEntryFilter; import org.apache.qpid.server.consumer.MockConsumer; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; abstract class AbstractQueueTestBase extends QpidTestCase @@ -58,7 +58,7 @@ abstract class AbstractQueueTestBase extends QpidTestCase private AMQQueue<?> _queue; - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; private String _qname = "qname"; private String _owner = "owner"; private String _routingKey = "routing key"; @@ -650,6 +650,7 @@ abstract class AbstractQueueTestBase extends QpidTestCase public void testProcessQueueWithUniqueSelectors() throws Exception { AbstractQueue testQueue = createNonAsyncDeliverQueue(); + testQueue.open(); // retrieve the QueueEntryList the queue creates and insert the test // messages, thus avoiding straight-through delivery attempts during @@ -1015,7 +1016,7 @@ abstract class AbstractQueueTestBase extends QpidTestCase } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _virtualHost; } @@ -1106,7 +1107,7 @@ abstract class AbstractQueueTestBase extends QpidTestCase private static class NonAsyncDeliverQueue extends AbstractQueue { - public NonAsyncDeliverQueue(final TestSimpleQueueEntryListFactory factory, VirtualHost vhost) + public NonAsyncDeliverQueue(final TestSimpleQueueEntryListFactory factory, VirtualHostImpl vhost) { super(vhost, attributes(), factory); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/ConflationQueueListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/ConflationQueueListTest.java index f8d06392e2..5c049b7d3f 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/ConflationQueueListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/ConflationQueueListTest.java @@ -28,9 +28,8 @@ import org.apache.qpid.server.message.MessageReference; import org.apache.qpid.server.message.AMQMessageHeader; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.security.*; import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.HashMap; import java.util.Map; @@ -55,7 +54,7 @@ public class ConflationQueueListTest extends TestCase queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); queueAttributes.put(Queue.LVQ_KEY, CONFLATION_KEY); - final VirtualHost virtualHost = mock(VirtualHost.class); + final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); _queue = new ConflationQueue(virtualHost, queueAttributes); @@ -219,7 +218,7 @@ public class ConflationQueueListTest extends TestCase private AMQQueue createTestQueue() { AMQQueue queue = mock(AMQQueue.class); - VirtualHost virtualHost = mock(VirtualHost.class); + VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(queue.getVirtualHost()).thenReturn(virtualHost); return queue; 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 34371b1b11..50cf4f44aa 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 @@ -30,7 +30,7 @@ import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; import java.util.HashMap; @@ -55,7 +55,7 @@ public class PriorityQueueListTest extends QpidTestCase queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); queueAttributes.put(Queue.PRIORITIES, 10); - final VirtualHost virtualHost = mock(VirtualHost.class); + final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); PriorityQueue queue = new PriorityQueue(virtualHost, queueAttributes); 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 c1f2986ab9..ef2a8ebccf 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 @@ -26,7 +26,7 @@ import org.apache.qpid.server.message.MessageReference; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.message.MessageInstance.EntryState; import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.lang.reflect.Field; import java.util.HashMap; @@ -195,7 +195,7 @@ public abstract class QueueEntryImplTestBase extends TestCase Map<String,Object> queueAttributes = new HashMap<String, Object>(); queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); - final VirtualHost virtualHost = mock(VirtualHost.class); + final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(org.apache.qpid.server.security.SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueThreadPoolTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueThreadPoolTest.java index 234ac5dffa..5f07efd149 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueThreadPoolTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueThreadPoolTest.java @@ -24,7 +24,7 @@ import org.apache.qpid.pool.ReferenceCountingExecutorService; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.UUIDGenerator; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; import java.util.HashMap; @@ -50,7 +50,7 @@ public class QueueThreadPoolTest extends QpidTestCase public void test() throws Exception { int initialCount = ReferenceCountingExecutorService.getInstance().getReferenceCount(); - VirtualHost test = BrokerTestHelper.createVirtualHost("test"); + VirtualHostImpl test = BrokerTestHelper.createVirtualHost("test"); try { 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 ae59f9ec65..cb2e9bf062 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 @@ -24,8 +24,7 @@ import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.message.MessageReference; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.security.*; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.HashMap; import java.util.Map; @@ -45,7 +44,7 @@ public class SimpleQueueEntryImplTest extends QueueEntryImplTestBase Map<String,Object> queueAttributes = new HashMap<String, Object>(); queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, "SimpleQueueEntryImplTest"); - final VirtualHost virtualHost = mock(VirtualHost.class); + final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(org.apache.qpid.server.security.SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); StandardQueue queue = new StandardQueue(virtualHost, queueAttributes); 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 3caafa1b3d..0334b9d93b 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 @@ -28,7 +28,7 @@ import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.Arrays; import java.util.HashMap; @@ -84,7 +84,7 @@ public class SortedQueueEntryListTest extends QueueEntryListTestBase attributes.put(Queue.SORT_KEY, "KEY"); // Create test list - final VirtualHost virtualHost = mock(VirtualHost.class); + final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); _testQueue = new SortedQueue(virtualHost, attributes, new QueueEntryListFactory() 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 06c00d7e61..2a96f08c53 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 @@ -30,8 +30,7 @@ import org.apache.qpid.server.message.MessageReference; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.security.*; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; @@ -54,7 +53,7 @@ public class SortedQueueEntryTest extends QueueEntryImplTestBase attributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.PERMANENT); attributes.put(Queue.SORT_KEY, "KEY"); - final VirtualHost virtualHost = mock(VirtualHost.class); + final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(org.apache.qpid.server.security.SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); SortedQueue queue = new SortedQueue(virtualHost, attributes, new QueueEntryListFactory() 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 8ee570733c..27cbe7dc8d 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 @@ -25,7 +25,7 @@ import org.apache.qpid.server.message.MessageReference; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.util.HashMap; import java.util.Map; @@ -52,7 +52,7 @@ public class StandardQueueEntryListTest extends QueueEntryListTestBase Map<String,Object> queueAttributes = new HashMap<String, Object>(); queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); - final VirtualHost virtualHost = mock(VirtualHost.class); + final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); _testQueue = new StandardQueue(virtualHost, queueAttributes); @@ -98,7 +98,7 @@ public class StandardQueueEntryListTest extends QueueEntryListTestBase Map<String,Object> queueAttributes = new HashMap<String, Object>(); queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); - final VirtualHost virtualHost = mock(VirtualHost.class); + final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(virtualHost.getEventLogger()).thenReturn(new EventLogger()); StandardQueue queue = new StandardQueue(virtualHost, queueAttributes); 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 1627de22f2..e38e4daea0 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 @@ -20,15 +20,6 @@ */ package org.apache.qpid.server.queue; -import org.apache.qpid.server.consumer.ConsumerImpl; -import org.apache.qpid.server.consumer.ConsumerTarget; -import org.apache.qpid.server.consumer.MockConsumer; -import org.apache.qpid.server.message.MessageInstance; -import org.apache.qpid.server.message.ServerMessage; -import org.apache.qpid.server.model.LifetimePolicy; -import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.virtualhost.VirtualHost; - import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; @@ -38,7 +29,14 @@ import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import static org.mockito.Mockito.mock; +import org.apache.qpid.server.consumer.ConsumerImpl; +import org.apache.qpid.server.consumer.ConsumerTarget; +import org.apache.qpid.server.consumer.MockConsumer; +import org.apache.qpid.server.message.MessageInstance; +import org.apache.qpid.server.message.ServerMessage; +import org.apache.qpid.server.model.LifetimePolicy; +import org.apache.qpid.server.model.Queue; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class StandardQueueTest extends AbstractQueueTestBase { @@ -51,7 +49,7 @@ public class StandardQueueTest extends AbstractQueueTestBase queueAttributes.put(Queue.NAME, getQname()); queueAttributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS); final StandardQueue queue = new StandardQueue(getVirtualHost(), queueAttributes); - + queue.open(); setQueue(queue); ServerMessage message = createMessage(25l); @@ -74,7 +72,7 @@ public class StandardQueueTest extends AbstractQueueTestBase queueAttributes.put(Queue.NAME, "testActiveConsumerCount"); queueAttributes.put(Queue.OWNER, "testOwner"); final StandardQueue queue = new StandardQueue(getVirtualHost(), queueAttributes); - + queue.open(); //verify adding an active consumer increases the count final MockConsumer consumer1 = new MockConsumer(); consumer1.setActive(true); @@ -143,6 +141,7 @@ public class StandardQueueTest extends AbstractQueueTestBase { // create a queue where each even entry is considered a dequeued AbstractQueue queue = new DequeuedQueue(getVirtualHost()); + queue.open(); // create a consumer MockConsumer consumer = new MockConsumer(); @@ -188,6 +187,7 @@ public class StandardQueueTest extends AbstractQueueTestBase // do nothing } }; + testQueue.open(); // put messages List<StandardQueueEntry> entries = @@ -248,7 +248,7 @@ public class StandardQueueTest extends AbstractQueueTestBase private static class DequeuedQueue extends AbstractQueue { - public DequeuedQueue(VirtualHost virtualHost) + public DequeuedQueue(VirtualHostImpl virtualHost) { super(virtualHost, attributes(), new DequeuedQueueEntryListFactory()); } 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 cdd9abf0ab..7ae4ad1bed 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 @@ -21,6 +21,11 @@ package org.apache.qpid.server.security.auth.manager; import static org.apache.qpid.server.security.auth.AuthenticatedPrincipalTestHelper.assertOnlyContainsWrapped; import static org.mockito.Mockito.mock; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + import javax.security.auth.x500.X500Principal; import javax.security.sasl.SaslException; import javax.security.sasl.SaslServer; @@ -31,15 +36,10 @@ import org.apache.qpid.server.security.auth.AuthenticationResult; import org.apache.qpid.server.security.auth.UsernamePrincipal; import org.apache.qpid.test.utils.QpidTestCase; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - public class ExternalAuthenticationManagerTest extends QpidTestCase { - private AuthenticationManager _manager; - private AuthenticationManager _managerUsingFullDN; + private ExternalAuthenticationManager _manager; + private ExternalAuthenticationManager _managerUsingFullDN; @Override public void setUp() throws Exception @@ -50,11 +50,13 @@ public class ExternalAuthenticationManagerTest extends QpidTestCase attrs.put(AuthenticationProvider.NAME, getTestName()); attrs.put("useFullDN",false); _manager = new ExternalAuthenticationManager(mock(Broker.class), Collections.<String,Object>emptyMap(), attrs); + _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 ExternalAuthenticationManager(mock(Broker.class), Collections.<String,Object>emptyMap(), attrsFullDN); + _managerUsingFullDN.open(); } public void testGetMechanisms() throws Exception 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 7b7ed2218e..35c4977fff 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 @@ -59,7 +59,7 @@ public class PrincipalDatabaseAuthenticationManagerTest extends QpidTestCase private static final String MOCK_MECH_NAME = "MOCK-MECH-NAME"; private static final UsernamePrincipal PRINCIPAL = new UsernamePrincipal("guest"); - private AuthenticationManager _manager = null; // Class under test + private PrincipalDatabaseAuthenticationManager _manager = null; // Class under test private PrincipalDatabase _principalDatabase; private String _passwordFileLocation; @@ -115,6 +115,14 @@ public class PrincipalDatabaseAuthenticationManagerTest extends QpidTestCase } }; + if(recovering) + { + _manager.open(); + } + else + { + _manager.create(); + } } public void testInitialiseWhenPasswordFileNotFound() throws Exception @@ -123,6 +131,7 @@ public class PrincipalDatabaseAuthenticationManagerTest extends QpidTestCase setupManager(true); try { + _manager.initialise(); fail("Initialisiation should fail when users file does not exist"); } 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 b38d9d7bd2..697aee12eb 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 @@ -48,6 +48,7 @@ import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.util.FileUtils; import org.mockito.ArgumentCaptor; @@ -414,7 +415,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest when(queue.isExclusive()).thenReturn(exclusive); when(queue.getId()).thenReturn(_queueId); when(queue.getAlternateExchange()).thenReturn(alternateExchange); - final org.apache.qpid.server.virtualhost.VirtualHost vh = mock(org.apache.qpid.server.virtualhost.VirtualHost.class); + final VirtualHostImpl vh = mock(VirtualHostImpl.class); when(vh.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(queue.getVirtualHost()).thenReturn(vh); final Map<String,Object> attributes = arguments == null ? new LinkedHashMap<String, Object>() : new LinkedHashMap<String, Object>(arguments); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java index 29a3e109b9..af0d38b011 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java @@ -52,7 +52,7 @@ import org.apache.qpid.server.store.TestMemoryMessageStore; import org.apache.qpid.server.virtualhost.AbstractVirtualHost; import org.apache.qpid.server.virtualhost.QueueExistsException; import org.apache.qpid.server.virtualhost.StandardVirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.server.virtualhost.VirtualHostRegistry; public class BrokerTestHelper @@ -91,7 +91,7 @@ public class BrokerTestHelper { } - public static VirtualHost createVirtualHost(VirtualHostRegistry virtualHostRegistry, Map<String,Object> attributes) + public static VirtualHostImpl createVirtualHost(VirtualHostRegistry virtualHostRegistry, Map<String,Object> attributes) throws Exception { @@ -120,16 +120,19 @@ public class BrokerTestHelper AbstractVirtualHost host = (AbstractVirtualHost) factory.create(attributes, broker); host.setDesiredState(host.getState(), State.ACTIVE); - + /*if(virtualHostRegistry != null) + { + virtualHostRegistry.registerVirtualHost(host); + }*/ return host; } - public static VirtualHost createVirtualHost(String name) throws Exception + public static VirtualHostImpl createVirtualHost(String name) throws Exception { return createVirtualHost(name, new VirtualHostRegistry(new EventLogger())); } - public static VirtualHost createVirtualHost(String name, VirtualHostRegistry virtualHostRegistry) throws Exception + public static VirtualHostImpl createVirtualHost(String name, VirtualHostRegistry virtualHostRegistry) throws Exception { Map<String,Object> attributes = new HashMap<String, Object>(); attributes.put(org.apache.qpid.server.model.VirtualHost.TYPE, StandardVirtualHost.TYPE); @@ -169,7 +172,7 @@ public class BrokerTestHelper public static AMQConnectionModel createConnection(String hostName) throws Exception { - VirtualHost virtualHost = createVirtualHost(hostName); + VirtualHostImpl virtualHost = createVirtualHost(hostName); AMQConnectionModel connection = mock(AMQConnectionModel.class); return connection; } @@ -177,7 +180,7 @@ public class BrokerTestHelper public static ExchangeImpl createExchange(String hostName, final boolean durable, final EventLogger eventLogger) throws Exception { SecurityManager securityManager = new SecurityManager(mock(Broker.class), false); - VirtualHost virtualHost = mock(VirtualHost.class); + VirtualHostImpl virtualHost = mock(VirtualHostImpl.class); when(virtualHost.getName()).thenReturn(hostName); when(virtualHost.getSecurityManager()).thenReturn(securityManager); when(virtualHost.getEventLogger()).thenReturn(eventLogger); @@ -190,7 +193,7 @@ public class BrokerTestHelper return factory.createExchange(attributes); } - public static AMQQueue createQueue(String queueName, VirtualHost virtualHost) + public static AMQQueue createQueue(String queueName, VirtualHostImpl virtualHost) throws QueueExistsException { Map<String,Object> attributes = new HashMap<String, Object>(); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java index f6a251a691..5d5856bf4a 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java @@ -78,7 +78,7 @@ public class DurableConfigurationRecovererTest extends QpidTestCase private ExchangeImpl<?> _topicExchange; private ExchangeImpl<?> _matchExchange; private ExchangeImpl<?> _fanoutExchange; - private VirtualHost _vhost; + private VirtualHostImpl _vhost; private DurableConfigurationStore _store; private ExchangeFactory _exchangeFactory; private ExchangeRegistry _exchangeRegistry; @@ -98,7 +98,7 @@ public class DurableConfigurationRecovererTest extends QpidTestCase AMQQueue<?> queue = mock(AMQQueue.class); - _vhost = mock(VirtualHost.class); + _vhost = mock(VirtualHostImpl.class); when(_vhost.getName()).thenReturn(VIRTUAL_HOST_NAME); _exchangeRegistry = mock(ExchangeRegistry.class); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java index 7d5a24f1aa..e30ab2e52b 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java @@ -48,7 +48,7 @@ public class HouseKeepingTaskTest extends QpidTestCase { private String _threadNameDuringExecution; - private ThreadNameRememberingTask(VirtualHost vhost) + private ThreadNameRememberingTask(VirtualHostImpl vhost) { super(vhost); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MessageStoreRecovererTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MessageStoreRecovererTest.java index ce5616b9ca..2a5e0ff763 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MessageStoreRecovererTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MessageStoreRecovererTest.java @@ -62,14 +62,14 @@ import org.mockito.ArgumentMatcher; public class MessageStoreRecovererTest extends TestCase { - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; @Override protected void setUp() throws Exception { super.setUp(); - _virtualHost = mock(VirtualHost.class); + _virtualHost = mock(VirtualHostImpl.class); when(_virtualHost.getEventLogger()).thenReturn(new EventLogger()); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java index 13c7dc8de2..b1d5ea2a5c 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java @@ -20,6 +20,7 @@ */ package org.apache.qpid.server.virtualhost; +import java.security.AccessControlException; import java.util.Collection; import java.util.Map; import java.util.UUID; @@ -31,6 +32,14 @@ import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.message.MessageDestination; import org.apache.qpid.server.message.MessageSource; +import org.apache.qpid.server.model.AbstractConfiguredObject; +import org.apache.qpid.server.model.ConfigurationChangeListener; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.Connection; +import org.apache.qpid.server.model.IllegalStateTransitionException; +import org.apache.qpid.server.model.LifetimePolicy; +import org.apache.qpid.server.model.State; +import org.apache.qpid.server.model.VirtualHostAlias; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.protocol.LinkRegistry; import org.apache.qpid.server.queue.AMQQueue; @@ -38,11 +47,12 @@ import org.apache.qpid.server.queue.QueueRegistry; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.security.auth.manager.AuthenticationManager; import org.apache.qpid.server.stats.StatisticsCounter; +import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.txn.DtxRegistry; -public class MockVirtualHost implements VirtualHost<AMQQueue<?>, ExchangeImpl<?>> +public class MockVirtualHost implements VirtualHostImpl<MockVirtualHost, AMQQueue<?>, ExchangeImpl<?>> { private String _name; @@ -102,6 +112,86 @@ public class MockVirtualHost implements VirtualHost<AMQQueue<?>, ExchangeImpl<?> return null; } + @Override + public String getType() + { + return null; + } + + @Override + public Map<String, String> getContext() + { + return null; + } + + @Override + public String getLastUpdatedBy() + { + return null; + } + + @Override + public long getLastUpdatedTime() + { + return 0; + } + + @Override + public String getCreatedBy() + { + return null; + } + + @Override + public long getCreatedTime() + { + return 0; + } + + @Override + public String setName(final String currentName, final String desiredName) + throws IllegalStateException, AccessControlException + { + return null; + } + + @Override + public State getDesiredState() + { + return null; + } + + @Override + public State setDesiredState(final State currentState, final State desiredState) + throws IllegalStateTransitionException, AccessControlException + { + return null; + } + + @Override + public State getState() + { + return null; + } + + @Override + public void addChangeListener(final ConfigurationChangeListener listener) + { + + } + + @Override + public boolean removeChangeListener(final ConfigurationChangeListener listener) + { + return false; + } + + @Override + public <T extends ConfiguredObject> T getParent(final Class<T> clazz) + { + return null; + } + public DurableConfigurationStore getDurableConfigurationStore() { return null; @@ -112,6 +202,12 @@ public class MockVirtualHost implements VirtualHost<AMQQueue<?>, ExchangeImpl<?> return _name; } + @Override + public String getDescription() + { + return null; + } + public QueueRegistry getQueueRegistry() { return null; @@ -136,6 +232,180 @@ public class MockVirtualHost implements VirtualHost<AMQQueue<?>, ExchangeImpl<?> } @Override + public Collection<String> getSupportedExchangeTypes() + { + return null; + } + + @Override + public Collection<String> getSupportedQueueTypes() + { + return null; + } + + @Override + public boolean isQueue_deadLetterQueueEnabled() + { + return false; + } + + @Override + public long getHousekeepingCheckPeriod() + { + return 0; + } + + @Override + public int getQueue_maximumDeliveryAttempts() + { + return 0; + } + + @Override + public long getQueue_flowControlSizeBytes() + { + return 0; + } + + @Override + public long getQueue_flowResumeSizeBytes() + { + return 0; + } + + @Override + public long getStoreTransactionIdleTimeoutClose() + { + return 0; + } + + @Override + public long getStoreTransactionIdleTimeoutWarn() + { + return 0; + } + + @Override + public long getStoreTransactionOpenTimeoutClose() + { + return 0; + } + + @Override + public long getStoreTransactionOpenTimeoutWarn() + { + return 0; + } + + @Override + public long getQueue_alertRepeatGap() + { + return 0; + } + + @Override + public long getQueue_alertThresholdMessageAge() + { + return 0; + } + + @Override + public long getQueue_alertThresholdMessageSize() + { + return 0; + } + + @Override + public long getQueue_alertThresholdQueueDepthBytes() + { + return 0; + } + + @Override + public long getQueue_alertThresholdQueueDepthMessages() + { + return 0; + } + + @Override + public String getSecurityAcl() + { + return null; + } + + @Override + public int getHouseKeepingThreadCount() + { + return 0; + } + + @Override + public Map<String, Object> getMessageStoreSettings() + { + return null; + } + + @Override + public Map<String, Object> getConfigurationStoreSettings() + { + return null; + } + + @Override + public long getQueueCount() + { + return 0; + } + + @Override + public long getExchangeCount() + { + return 0; + } + + @Override + public long getConnectionCount() + { + return 0; + } + + @Override + public long getBytesIn() + { + return 0; + } + + @Override + public long getBytesOut() + { + return 0; + } + + @Override + public long getMessagesIn() + { + return 0; + } + + @Override + public long getMessagesOut() + { + return 0; + } + + @Override + public Collection<VirtualHostAlias> getAliases() + { + return null; + } + + @Override + public Collection<Connection> getConnections() + { + return null; + } + + @Override public Collection<AMQQueue<?>> getQueues() { return null; @@ -154,6 +424,18 @@ public class MockVirtualHost implements VirtualHost<AMQQueue<?>, ExchangeImpl<?> } @Override + public Collection<String> getExchangeTypeNames() + { + return null; + } + + @Override + public void executeTransaction(final TransactionalOperation op) + { + + } + + @Override public ExchangeImpl createExchange(Map<String,Object> attributes) { return null; @@ -195,6 +477,18 @@ public class MockVirtualHost implements VirtualHost<AMQQueue<?>, ExchangeImpl<?> } @Override + public ExchangeImpl<?> createExchange(final String name, + final State initialState, + final boolean durable, + final LifetimePolicy lifetime, + final String type, + final Map<String, Object> attributes) + throws AccessControlException, IllegalArgumentException + { + return null; + } + + @Override public Collection<ExchangeType<? extends ExchangeImpl>> getExchangeTypes() { return null; @@ -246,6 +540,114 @@ public class MockVirtualHost implements VirtualHost<AMQQueue<?>, ExchangeImpl<?> return false; } + @Override + public void setDurable(final boolean durable) + throws IllegalStateException, AccessControlException, IllegalArgumentException + { + + } + + @Override + public LifetimePolicy getLifetimePolicy() + { + return null; + } + + @Override + public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) + throws IllegalStateException, AccessControlException, IllegalArgumentException + { + return null; + } + + @Override + public Collection<String> getAttributeNames() + { + return null; + } + + @Override + public Object getAttribute(final String name) + { + return null; + } + + @Override + public <T> T getAttribute(final AbstractConfiguredObject.Attribute<? super MockVirtualHost, T> attr) + { + return null; + } + + @Override + public Map<String, Object> getActualAttributes() + { + return null; + } + + @Override + public Object setAttribute(final String name, final Object expected, final Object desired) + throws IllegalStateException, AccessControlException, IllegalArgumentException + { + return null; + } + + @Override + public Map<String, Number> getStatistics() + { + return null; + } + + @Override + public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) + { + return null; + } + + @Override + public <C extends ConfiguredObject> C createChild(final Class<C> childClass, + final Map<String, Object> attributes, + final ConfiguredObject... otherParents) + { + return null; + } + + @Override + public void setAttributes(final Map<String, Object> attributes) + throws IllegalStateException, AccessControlException, IllegalArgumentException + { + + } + + @Override + public Class<? extends ConfiguredObject> getCategoryClass() + { + return null; + } + + @Override + public <C extends ConfiguredObject<C>> C findConfiguredObject(final Class<C> clazz, final String name) + { + return null; + } + + @Override + public ConfiguredObjectRecord asObjectRecord() + { + return null; + } + + @Override + public void open() + { + + } + + @Override + public void validate() + { + + } + public StatisticsCounter getDataDeliveryStatistics() { return null; diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java index 7772925382..be2f2e3163 100644 --- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java +++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java @@ -60,7 +60,6 @@ public class ACLFileAccessControlProvider Collections.<String,Object>emptyMap(), attributes, broker.getTaskExecutor()); - _accessControl = new DefaultAccessControl(getPath(), broker); _broker = broker; State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING); @@ -68,6 +67,13 @@ public class ACLFileAccessControlProvider } + @Override + protected void onOpen() + { + super.onOpen(); + _accessControl = new DefaultAccessControl(getPath(), _broker); + } + @ManagedAttribute( automate = true, mandatory = true ) public String getPath() { @@ -155,6 +161,7 @@ public class ACLFileAccessControlProvider if(desiredState == State.DELETED) { + deleted(); return _state.compareAndSet(state, State.DELETED); } else if (desiredState == State.QUIESCED) diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_Internal_to_v0_10.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_Internal_to_v0_10.java index 7ff3873856..0d43c84fdd 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_Internal_to_v0_10.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_Internal_to_v0_10.java @@ -20,12 +20,11 @@ */ package org.apache.qpid.server.protocol.v0_10; -import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.message.internal.InternalMessage; import org.apache.qpid.server.plugin.MessageConverter; import org.apache.qpid.server.store.StoreFuture; import org.apache.qpid.server.store.StoredMessage; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.DeliveryProperties; import org.apache.qpid.transport.Header; import org.apache.qpid.transport.MessageDeliveryPriority; @@ -48,7 +47,7 @@ public class MessageConverter_Internal_to_v0_10 implements MessageConverter<Inte } @Override - public MessageTransferMessage convert(InternalMessage serverMsg, VirtualHost vhost) + public MessageTransferMessage convert(InternalMessage serverMsg, VirtualHostImpl vhost) { return new MessageTransferMessage(convertToStoredMessage(serverMsg), null); } diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java index 9ebf4570d0..e788eb071e 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java @@ -33,7 +33,7 @@ import org.apache.qpid.server.plugin.MessageConverter; import org.apache.qpid.server.store.StoreFuture; import org.apache.qpid.server.store.StoredMessage; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.DeliveryProperties; import org.apache.qpid.transport.Header; import org.apache.qpid.transport.MessageDeliveryPriority; @@ -58,7 +58,7 @@ public class MessageConverter_v0_10 implements MessageConverter<ServerMessage, M } @Override - public MessageTransferMessage convert(ServerMessage serverMsg, VirtualHost vhost) + public MessageTransferMessage convert(ServerMessage serverMsg, VirtualHostImpl vhost) { return new MessageTransferMessage(convertToStoredMessage(serverMsg), null); } diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java index 68997bbb01..f034f8159d 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java @@ -21,17 +21,10 @@ package org.apache.qpid.server.protocol.v0_10; import org.apache.qpid.server.message.AMQMessageHeader; -import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.message.internal.InternalMessage; -import org.apache.qpid.server.message.internal.InternalMessageMetaData; import org.apache.qpid.server.plugin.MessageConverter; -import org.apache.qpid.server.store.StoreFuture; -import org.apache.qpid.server.store.StoredMessage; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; -import org.apache.qpid.transport.DeliveryProperties; -import org.apache.qpid.transport.Header; -import org.apache.qpid.transport.MessageDeliveryPriority; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.MessageProperties; import org.apache.qpid.transport.ReplyTo; import org.apache.qpid.transport.codec.BBDecoder; @@ -44,7 +37,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; -import java.util.ListIterator; import java.util.Map; import java.util.Set; @@ -63,7 +55,7 @@ public class MessageConverter_v0_10_to_Internal implements MessageConverter<Mess } @Override - public InternalMessage convert(MessageTransferMessage serverMessage, VirtualHost vhost) + public InternalMessage convert(MessageTransferMessage serverMessage, VirtualHostImpl vhost) { final String mimeType = serverMessage.getMessageHeader().getMimeType(); byte[] data = new byte[(int) serverMessage.getSize()]; diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java index 5e899aa635..718a1d0b9b 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java @@ -46,7 +46,7 @@ import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; import org.apache.qpid.server.stats.StatisticsCounter; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.ServerScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.Connection; import org.apache.qpid.transport.ConnectionCloseCode; import org.apache.qpid.transport.ExecutionErrorCode; @@ -72,7 +72,7 @@ public class ServerConnection extends Connection implements AMQConnectionModel<S private StatisticsCounter _messagesDelivered, _dataDelivered, _messagesReceived, _dataReceived; private final long _connectionId; private final Object _reference = new Object(); - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; private Port _port; private AtomicLong _lastIoTime = new AtomicLong(); private boolean _blocking; @@ -165,12 +165,12 @@ public class ServerConnection extends Connection implements AMQConnectionModel<S super.setConnectionDelegate(delegate); } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _virtualHost; } - public void setVirtualHost(VirtualHost virtualHost) + public void setVirtualHost(VirtualHostImpl virtualHost) { _virtualHost = virtualHost; diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java index 1f72b5dde8..ecb51235d3 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java @@ -41,8 +41,8 @@ import org.apache.qpid.server.protocol.AMQConnectionModel; import org.apache.qpid.server.security.SubjectCreator; import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus; import org.apache.qpid.server.security.auth.SubjectAuthenticationResult; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.server.virtualhost.VirtualHostState; -import org.apache.qpid.server.virtualhost.VirtualHost; import org.apache.qpid.transport.*; import org.apache.qpid.transport.network.NetworkConnection; @@ -177,7 +177,7 @@ public class ServerConnectionDelegate extends ServerDelegate { final ServerConnection sconn = (ServerConnection) conn; - VirtualHost vhost; + VirtualHostImpl vhost; String vhostName; if(open.hasVirtualHost()) { diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java index 0bb3008d13..8c752061ef 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java @@ -49,7 +49,6 @@ import org.apache.qpid.server.consumer.ConsumerImpl; import org.apache.qpid.server.model.ConfigurationChangeListener; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.Consumer; -import org.apache.qpid.server.model.State; import org.apache.qpid.server.protocol.ConsumerListener; import org.apache.qpid.server.store.StoreException; import org.apache.qpid.protocol.AMQConstant; @@ -84,7 +83,7 @@ import org.apache.qpid.server.txn.TimeoutDtxException; import org.apache.qpid.server.txn.UnknownDtxBranchException; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.Deletable; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -686,7 +685,7 @@ public class ServerSession extends Session return getVirtualHost().getMessageStore(); } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return getConnection().getVirtualHost(); } diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java index 999da2da6c..4fa4dcaa11 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java @@ -195,7 +195,7 @@ public class ServerSessionDelegate extends SessionDelegate else { String queueName = method.getQueue(); - VirtualHost vhost = getVirtualHost(session); + VirtualHostImpl vhost = getVirtualHost(session); final MessageSource queue = vhost.getMessageSource(queueName); @@ -288,7 +288,7 @@ public class ServerSessionDelegate extends SessionDelegate final MessageMetaData_0_10 messageMetaData = new MessageMetaData_0_10(xfr); - final VirtualHost virtualHost = getVirtualHost(ssn); + final VirtualHostImpl virtualHost = getVirtualHost(ssn); try { virtualHost.getSecurityManager().authorisePublish(messageMetaData.isImmediate(), messageMetaData.getRoutingKey(), exchange.getName(), virtualHost.getName()); @@ -673,7 +673,7 @@ public class ServerSessionDelegate extends SessionDelegate public void exchangeDeclare(Session session, ExchangeDeclare method) { String exchangeName = method.getExchange(); - VirtualHost virtualHost = getVirtualHost(session); + VirtualHostImpl virtualHost = getVirtualHost(session); //we must check for any unsupported arguments present and throw not-implemented if(method.hasArguments()) @@ -803,7 +803,7 @@ public class ServerSessionDelegate extends SessionDelegate private MessageDestination getDestinationForMessage(Session ssn, MessageTransfer xfr) { - VirtualHost virtualHost = getVirtualHost(ssn); + VirtualHostImpl virtualHost = getVirtualHost(ssn); MessageDestination destination; if(xfr.hasDestination()) @@ -821,10 +821,10 @@ public class ServerSessionDelegate extends SessionDelegate return destination; } - private VirtualHost getVirtualHost(Session session) + private VirtualHostImpl getVirtualHost(Session session) { ServerConnection conn = getServerConnection(session); - VirtualHost vhost = conn.getVirtualHost(); + VirtualHostImpl vhost = conn.getVirtualHost(); return vhost; } @@ -837,7 +837,7 @@ public class ServerSessionDelegate extends SessionDelegate @Override public void exchangeDelete(Session session, ExchangeDelete method) { - VirtualHost virtualHost = getVirtualHost(session); + VirtualHostImpl virtualHost = getVirtualHost(session); try { @@ -932,7 +932,7 @@ public class ServerSessionDelegate extends SessionDelegate public void exchangeBind(Session session, ExchangeBind method) { - VirtualHost virtualHost = getVirtualHost(session); + VirtualHostImpl virtualHost = getVirtualHost(session); if (!method.hasQueue()) { @@ -997,7 +997,7 @@ public class ServerSessionDelegate extends SessionDelegate @Override public void exchangeUnbind(Session session, ExchangeUnbind method) { - VirtualHost virtualHost = getVirtualHost(session); + VirtualHostImpl virtualHost = getVirtualHost(session); if (!method.hasQueue()) { @@ -1045,7 +1045,7 @@ public class ServerSessionDelegate extends SessionDelegate { ExchangeBoundResult result = new ExchangeBoundResult(); - VirtualHost virtualHost = getVirtualHost(session); + VirtualHostImpl virtualHost = getVirtualHost(session); ExchangeImpl exchange; AMQQueue queue; boolean isDefaultExchange; @@ -1229,7 +1229,7 @@ public class ServerSessionDelegate extends SessionDelegate public void queueDeclare(Session session, final QueueDeclare method) { - final VirtualHost virtualHost = getVirtualHost(session); + final VirtualHostImpl virtualHost = getVirtualHost(session); DurableConfigurationStore store = virtualHost.getDurableConfigurationStore(); String queueName = method.getQueue(); @@ -1386,7 +1386,7 @@ public class ServerSessionDelegate extends SessionDelegate } else { - VirtualHost virtualHost = getVirtualHost(session); + VirtualHostImpl virtualHost = getVirtualHost(session); try { diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionTest.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionTest.java index 5ea3de7c6e..01dd523e3e 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionTest.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionTest.java @@ -18,20 +18,18 @@ */ package org.apache.qpid.server.protocol.v0_10; -import org.apache.qpid.server.logging.MessageLogger; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.transport.Binary; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class ServerSessionTest extends QpidTestCase { - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; @Override public void setUp() throws Exception diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java index 7bde83cc99..c7e615f075 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java @@ -88,7 +88,7 @@ import org.apache.qpid.server.txn.LocalTransaction.ActivityTimeAccessor; import org.apache.qpid.server.txn.ServerTransaction; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.TransportException; import javax.security.auth.Subject; @@ -303,7 +303,7 @@ public class AMQChannel<T extends AMQProtocolSession<T>> public void setPublishFrame(MessagePublishInfo info, final MessageDestination e) { String routingKey = info.getRoutingKey() == null ? null : info.getRoutingKey().asString(); - VirtualHost virtualHost = getVirtualHost(); + VirtualHostImpl virtualHost = getVirtualHost(); SecurityManager securityManager = virtualHost.getSecurityManager(); securityManager.authorisePublish(info.isImmediate(), routingKey, e.getName(), virtualHost.getName()); @@ -1534,7 +1534,7 @@ public class AMQChannel<T extends AMQProtocolSession<T>> return _blocking.get(); } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return getProtocolSession().getVirtualHost(); } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java index a86530fe0e..7b04c99ca2 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java @@ -79,7 +79,7 @@ import org.apache.qpid.server.stats.StatisticsCounter; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; import org.apache.qpid.server.util.ServerScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.Sender; import org.apache.qpid.transport.TransportException; import org.apache.qpid.transport.network.NetworkConnection; @@ -100,7 +100,7 @@ public class AMQProtocolEngine implements ServerProtocolEngine, AMQProtocolSessi private String _clientVersion = null; private String _clientProduct = null; - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; private final Map<Integer, AMQChannel<AMQProtocolEngine>> _channelMap = new HashMap<Integer, AMQChannel<AMQProtocolEngine>>(); @@ -1152,12 +1152,12 @@ public class AMQProtocolEngine implements ServerProtocolEngine, AMQProtocolSessi return getMethodRegistry(); } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _virtualHost; } - public void setVirtualHost(VirtualHost virtualHost) throws AMQException + public void setVirtualHost(VirtualHostImpl virtualHost) throws AMQException { _virtualHost = virtualHost; diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java index ade087ef21..bab0aaf3da 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java @@ -38,7 +38,7 @@ import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; import org.apache.qpid.server.protocol.AMQConnectionModel; import org.apache.qpid.server.protocol.v0_8.output.ProtocolOutputConverter; import org.apache.qpid.server.security.AuthorizationHolder; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public interface AMQProtocolSession<T extends AMQProtocolSession<T>> @@ -174,9 +174,9 @@ public interface AMQProtocolSession<T extends AMQProtocolSession<T>> Object getReference(); - VirtualHost getVirtualHost(); + VirtualHostImpl getVirtualHost(); - void setVirtualHost(VirtualHost virtualHost) throws AMQException; + void setVirtualHost(VirtualHostImpl virtualHost) throws AMQException; public ProtocolOutputConverter getProtocolOutputConverter(); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_Internal_to_v0_8.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_Internal_to_v0_8.java index 9ba212d1ed..28c1e528f4 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_Internal_to_v0_8.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_Internal_to_v0_8.java @@ -30,7 +30,7 @@ import org.apache.qpid.server.plugin.MessageConverter; import org.apache.qpid.server.store.StoreFuture; import org.apache.qpid.server.store.StoredMessage; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.codec.BBEncoder; import java.io.ByteArrayOutputStream; @@ -60,7 +60,7 @@ public class MessageConverter_Internal_to_v0_8 implements MessageConverter<Inter } @Override - public AMQMessage convert(InternalMessage serverMsg, VirtualHost vhost) + public AMQMessage convert(InternalMessage serverMsg, VirtualHostImpl vhost) { return new AMQMessage(convertToStoredMessage(serverMsg), null); } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_v0_8_to_Internal.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_v0_8_to_Internal.java index b244e7626f..f077617446 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_v0_8_to_Internal.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_v0_8_to_Internal.java @@ -25,8 +25,7 @@ import org.apache.qpid.server.message.AMQMessageHeader; import org.apache.qpid.server.message.internal.InternalMessage; import org.apache.qpid.server.plugin.MessageConverter; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; -import org.apache.qpid.transport.ReplyTo; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.codec.BBDecoder; import org.apache.qpid.typedmessage.TypedBytesContentReader; import org.apache.qpid.typedmessage.TypedBytesFormatException; @@ -57,7 +56,7 @@ public class MessageConverter_v0_8_to_Internal implements MessageConverter<AMQMe } @Override - public InternalMessage convert(AMQMessage serverMessage, VirtualHost vhost) + public InternalMessage convert(AMQMessage serverMessage, VirtualHostImpl vhost) { final String mimeType = serverMessage.getMessageHeader().getMimeType(); byte[] data = new byte[(int) serverMessage.getSize()]; diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java index 37e531bd2a..ff0e4199cf 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java @@ -35,7 +35,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; @@ -59,7 +59,7 @@ public class BasicConsumeMethodHandler implements StateAwareMethodListener<Basic AMQProtocolSession protocolConnection = stateManager.getProtocolSession(); AMQChannel channel = protocolConnection.getChannel(channelId); - VirtualHost vHost = protocolConnection.getVirtualHost(); + VirtualHostImpl vHost = protocolConnection.getVirtualHost(); if (channel == null) { diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java index 76b5cbbbb9..0026bad063 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java @@ -45,7 +45,7 @@ import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; import org.apache.qpid.server.protocol.v0_8.ClientDeliveryMethod; import org.apache.qpid.server.protocol.v0_8.RecordDeliveryMethod; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; import java.util.EnumSet; @@ -70,7 +70,7 @@ public class BasicGetMethodHandler implements StateAwareMethodListener<BasicGetB AMQProtocolSession protocolConnection = stateManager.getProtocolSession(); - VirtualHost vHost = protocolConnection.getVirtualHost(); + VirtualHostImpl vHost = protocolConnection.getVirtualHost(); AMQChannel channel = protocolConnection.getChannel(channelId); if (channel == null) diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java index fc085e8ab1..0d09c31ec8 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java @@ -32,7 +32,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQChannel; import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; @@ -61,7 +61,7 @@ public class BasicPublishMethodHandler implements StateAwareMethodListener<Basic } AMQShortString exchangeName = body.getExchange(); - VirtualHost vHost = session.getVirtualHost(); + VirtualHostImpl vHost = session.getVirtualHost(); // TODO: check the delivery tag field details - is it unique across the broker or per subscriber? diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ChannelOpenHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ChannelOpenHandler.java index 2594242db4..63c6857216 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ChannelOpenHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ChannelOpenHandler.java @@ -36,7 +36,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -61,7 +61,7 @@ public class ChannelOpenHandler implements StateAwareMethodListener<ChannelOpenB public void methodReceived(AMQStateManager stateManager, ChannelOpenBody body, int channelId) throws AMQException { AMQProtocolSession session = stateManager.getProtocolSession(); - VirtualHost virtualHost = session.getVirtualHost(); + VirtualHostImpl virtualHost = session.getVirtualHost(); // Protect the broker against out of order frame request. if (virtualHost == null) diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ConnectionOpenMethodHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ConnectionOpenMethodHandler.java index 9ab308cd8a..3608b81e2a 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ConnectionOpenMethodHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ConnectionOpenMethodHandler.java @@ -34,7 +34,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.protocol.v0_8.state.AMQState; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.server.virtualhost.VirtualHostState; public class ConnectionOpenMethodHandler implements StateAwareMethodListener<ConnectionOpenBody> @@ -72,7 +72,7 @@ public class ConnectionOpenMethodHandler implements StateAwareMethodListener<Con virtualHostName = body.getVirtualHost() == null ? null : String.valueOf(body.getVirtualHost()); } - VirtualHost virtualHost = stateManager.getVirtualHostRegistry().getVirtualHost(virtualHostName); + VirtualHostImpl virtualHost = stateManager.getVirtualHostRegistry().getVirtualHost(virtualHostName); if (virtualHost == null) { diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeBoundHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeBoundHandler.java index d30961b13c..2ea638a358 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeBoundHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeBoundHandler.java @@ -31,7 +31,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; /** * @author Apache Software Foundation @@ -68,7 +68,7 @@ public class ExchangeBoundHandler implements StateAwareMethodListener<ExchangeBo public void methodReceived(AMQStateManager stateManager, ExchangeBoundBody body, int channelId) throws AMQException { AMQProtocolSession session = stateManager.getProtocolSession(); - VirtualHost virtualHost = session.getVirtualHost(); + VirtualHostImpl virtualHost = session.getVirtualHost(); MethodRegistry methodRegistry = session.getMethodRegistry(); final AMQChannel channel = session.getChannel(channelId); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java index fd7d9c10ff..3e1c2ad987 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java @@ -40,7 +40,7 @@ import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; import org.apache.qpid.server.virtualhost.ExchangeExistsException; import org.apache.qpid.server.virtualhost.ReservedExchangeNameException; import org.apache.qpid.server.virtualhost.UnknownExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; import java.util.HashMap; @@ -64,7 +64,7 @@ public class ExchangeDeclareHandler implements StateAwareMethodListener<Exchange public void methodReceived(AMQStateManager stateManager, ExchangeDeclareBody body, int channelId) throws AMQException { AMQProtocolSession session = stateManager.getProtocolSession(); - VirtualHost virtualHost = session.getVirtualHost(); + VirtualHostImpl virtualHost = session.getVirtualHost(); final AMQChannel channel = session.getChannel(channelId); if (channel == null) { diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java index 9af383c3ca..1c01a24f63 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java @@ -32,7 +32,7 @@ import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; import org.apache.qpid.server.virtualhost.ExchangeIsAlternateException; import org.apache.qpid.server.virtualhost.RequiredExchangeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; @@ -52,7 +52,7 @@ public class ExchangeDeleteHandler implements StateAwareMethodListener<ExchangeD public void methodReceived(AMQStateManager stateManager, ExchangeDeleteBody body, int channelId) throws AMQException { AMQProtocolSession session = stateManager.getProtocolSession(); - VirtualHost virtualHost = session.getVirtualHost(); + VirtualHostImpl virtualHost = session.getVirtualHost(); final AMQChannel channel = session.getChannel(channelId); if (channel == null) { diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java index c14ac72818..e3f40c3555 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java @@ -36,7 +36,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; import java.util.Map; @@ -59,7 +59,7 @@ public class QueueBindHandler implements StateAwareMethodListener<QueueBindBody> public void methodReceived(AMQStateManager stateManager, QueueBindBody body, int channelId) throws AMQException { AMQProtocolSession protocolConnection = stateManager.getProtocolSession(); - VirtualHost virtualHost = protocolConnection.getVirtualHost(); + VirtualHostImpl virtualHost = protocolConnection.getVirtualHost(); AMQChannel channel = protocolConnection.getChannel(channelId); if (channel == null) diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java index 97aac8424a..19550e8c8d 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java @@ -40,7 +40,7 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.QueueArgumentsConverter; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; import java.util.Map; @@ -62,7 +62,7 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar { final AMQProtocolSession protocolConnection = stateManager.getProtocolSession(); final AMQSessionModel session = protocolConnection.getChannel(channelId); - VirtualHost virtualHost = protocolConnection.getVirtualHost(); + VirtualHostImpl virtualHost = protocolConnection.getVirtualHost(); final AMQShortString queueName; @@ -178,7 +178,7 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar protected AMQQueue createQueue(final AMQChannel channel, final AMQShortString queueName, QueueDeclareBody body, - final VirtualHost virtualHost, + final VirtualHostImpl virtualHost, final AMQProtocolSession session) throws AMQException, QueueExistsException { diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java index d7545c844a..84efcb68b8 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java @@ -31,7 +31,7 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; import org.apache.qpid.server.store.DurableConfigurationStore; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; @@ -60,7 +60,7 @@ public class QueueDeleteHandler implements StateAwareMethodListener<QueueDeleteB public void methodReceived(AMQStateManager stateManager, QueueDeleteBody body, int channelId) throws AMQException { AMQProtocolSession protocolConnection = stateManager.getProtocolSession(); - VirtualHost virtualHost = protocolConnection.getVirtualHost(); + VirtualHostImpl virtualHost = protocolConnection.getVirtualHost(); DurableConfigurationStore store = virtualHost.getDurableConfigurationStore(); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java index 569654c64d..68ecf0324c 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java @@ -31,7 +31,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; @@ -59,7 +59,7 @@ public class QueuePurgeHandler implements StateAwareMethodListener<QueuePurgeBod public void methodReceived(AMQStateManager stateManager, QueuePurgeBody body, int channelId) throws AMQException { AMQProtocolSession protocolConnection = stateManager.getProtocolSession(); - VirtualHost virtualHost = protocolConnection.getVirtualHost(); + VirtualHostImpl virtualHost = protocolConnection.getVirtualHost(); AMQChannel channel = protocolConnection.getChannel(channelId); if (channel == null) diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java index f1bcce2ade..4e2d1bc8a2 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java @@ -36,7 +36,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.security.AccessControlException; @@ -58,7 +58,7 @@ public class QueueUnbindHandler implements StateAwareMethodListener<QueueUnbindB public void methodReceived(AMQStateManager stateManager, QueueUnbindBody body, int channelId) throws AMQException { AMQProtocolSession session = stateManager.getProtocolSession(); - VirtualHost virtualHost = session.getVirtualHost(); + VirtualHostImpl virtualHost = session.getVirtualHost(); final AMQQueue queue; final AMQShortString routingKey; diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQChannelTest.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQChannelTest.java index face730195..21680ff4e4 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQChannelTest.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQChannelTest.java @@ -35,12 +35,12 @@ import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.message.MessageContentSource; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; public class AMQChannelTest extends QpidTestCase { - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; private AMQProtocolSession _protocolSession; private Map<Integer,String> _replies; private Broker _broker; diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java index 6b697f8221..e1e37ad3bd 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java @@ -36,7 +36,7 @@ import org.apache.qpid.server.store.TestMemoryMessageStore; import org.apache.qpid.server.txn.AutoCommitTransaction; import org.apache.qpid.server.txn.ServerTransaction; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; import java.util.ArrayList; @@ -60,7 +60,7 @@ public class AckTest extends QpidTestCase private AMQQueue _queue; private static final AMQShortString DEFAULT_CONSUMER_TAG = new AMQShortString("conTag"); - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; @Override public void setUp() throws Exception diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java index 399564f5a4..34331973e8 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java @@ -26,7 +26,7 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.TestMemoryMessageStore; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; import java.util.List; @@ -44,7 +44,7 @@ public class AcknowledgeTest extends QpidTestCase super.setUp(); BrokerTestHelper.setUp(); _channel = BrokerTestHelper_0_8.createChannel(); - VirtualHost virtualHost = _channel.getVirtualHost(); + VirtualHostImpl virtualHost = _channel.getVirtualHost(); _queueName = getTestName(); _queue = BrokerTestHelper.createQueue(_queueName, virtualHost); _messageStore = virtualHost.getMessageStore(); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java index 580b912552..8b80504d6e 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java @@ -25,10 +25,9 @@ import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.BasicContentHeaderProperties; import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.framing.abstraction.MessagePublishInfo; -import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.message.MessageDestination; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -61,7 +60,7 @@ public class BrokerTestHelper_0_8 extends BrokerTestHelper public static InternalTestProtocolSession createProtocolSession(String hostName) throws Exception { - VirtualHost virtualHost = createVirtualHost(hostName); + VirtualHostImpl virtualHost = createVirtualHost(hostName); return new InternalTestProtocolSession(virtualHost, createBrokerMock()); } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java index 18949bba50..2322865c80 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java @@ -49,7 +49,7 @@ import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.protocol.v0_8.output.ProtocolOutputConverter; import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; import org.apache.qpid.server.security.auth.UsernamePrincipal; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.Sender; import org.apache.qpid.transport.network.NetworkConnection; @@ -61,7 +61,7 @@ public class InternalTestProtocolSession extends AMQProtocolEngine implements Pr private AtomicInteger _deliveryCount = new AtomicInteger(0); private static final AtomicLong ID_GENERATOR = new AtomicLong(0); - public InternalTestProtocolSession(VirtualHost virtualHost, Broker broker) throws AMQException + public InternalTestProtocolSession(VirtualHostImpl virtualHost, Broker broker) throws AMQException { super(broker, new TestNetworkConnection(), ID_GENERATOR.getAndIncrement(), null, null); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java index 520e35fe39..211c17b746 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java @@ -20,7 +20,6 @@ */ package org.apache.qpid.server.protocol.v0_8; -import org.apache.qpid.AMQException; import org.apache.qpid.common.AMQPFilterTypes; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.framing.AMQShortString; @@ -29,7 +28,7 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.TestMemoryMessageStore; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; import java.util.List; @@ -47,7 +46,7 @@ public class QueueBrowserUsesNoAckTest extends QpidTestCase super.setUp(); BrokerTestHelper.setUp(); _channel = BrokerTestHelper_0_8.createChannel(); - VirtualHost virtualHost = _channel.getVirtualHost(); + VirtualHostImpl virtualHost = _channel.getVirtualHost(); _queueName = getTestName(); _queue = BrokerTestHelper.createQueue(_queueName, virtualHost); _messageStore = virtualHost.getMessageStore(); diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Connection_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Connection_1_0.java index 00c78581e1..ddd88a0df8 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Connection_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Connection_1_0.java @@ -20,18 +20,28 @@ */ package org.apache.qpid.server.protocol.v1_0; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CONNECTION_FORMAT; + import java.net.SocketAddress; import java.security.Principal; import java.security.PrivilegedAction; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; + +import javax.security.auth.Subject; + import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint; import org.apache.qpid.amqp_1_0.transport.ConnectionEventListener; import org.apache.qpid.amqp_1_0.transport.LinkEndpoint; import org.apache.qpid.amqp_1_0.transport.SessionEndpoint; - import org.apache.qpid.amqp_1_0.transport.SessionEventListener; -import org.apache.qpid.amqp_1_0.type.transport.*; +import org.apache.qpid.amqp_1_0.type.transport.AmqpError; +import org.apache.qpid.amqp_1_0.type.transport.End; import org.apache.qpid.amqp_1_0.type.transport.Error; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.server.connection.ConnectionPrincipal; @@ -46,16 +56,7 @@ import org.apache.qpid.server.security.SubjectCreator; import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; import org.apache.qpid.server.stats.StatisticsCounter; import org.apache.qpid.server.util.Action; -import org.apache.qpid.server.virtualhost.VirtualHost; - -import javax.security.auth.Subject; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; - -import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CONNECTION_FORMAT; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class Connection_1_0 implements ConnectionEventListener, AMQConnectionModel<Connection_1_0,Session_1_0> { @@ -63,7 +64,7 @@ public class Connection_1_0 implements ConnectionEventListener, AMQConnectionMod private final Port _port; private final Broker _broker; private final SubjectCreator _subjectCreator; - private VirtualHost _vhost; + private VirtualHostImpl _vhost; private final Transport _transport; private final ConnectionEndpoint _conn; private final long _connectionId; @@ -130,7 +131,7 @@ public class Connection_1_0 implements ConnectionEventListener, AMQConnectionMod String host = _conn.getLocalHostname(); if(host == null || host.trim().equals("")) { - host = (String)_broker.getAttribute(Broker.DEFAULT_VIRTUAL_HOST); + host = _broker.getDefaultVirtualHost(); } _vhost = _broker.getVirtualHostRegistry().getVirtualHost(host); _vhost.getConnectionRegistry().registerConnection(this); @@ -432,7 +433,7 @@ public class Connection_1_0 implements ConnectionEventListener, AMQConnectionMod return _subject; } - VirtualHost getVirtualHost() + VirtualHostImpl getVirtualHost() { return _vhost; } diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java index 40f738b8e7..b8157b8f9e 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java @@ -40,7 +40,7 @@ import org.apache.qpid.server.plugin.MessageConverter; import org.apache.qpid.server.store.StoreFuture; import org.apache.qpid.server.store.StoredMessage; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.codec.BBDecoder; import org.apache.qpid.typedmessage.TypedBytesContentReader; import org.apache.qpid.typedmessage.TypedBytesFormatException; @@ -60,7 +60,7 @@ public abstract class MessageConverter_to_1_0<M extends ServerMessage> implement } @Override - public final Message_1_0 convert(M message, VirtualHost vhost) + public final Message_1_0 convert(M message, VirtualHostImpl vhost) { SectionEncoder sectionEncoder = new SectionEncoderImpl(_typeRegistry); diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_Internal.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_Internal.java index bb01ddad7f..077ea7819b 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_Internal.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_Internal.java @@ -23,18 +23,7 @@ package org.apache.qpid.server.protocol.v1_0; import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry; import org.apache.qpid.server.message.internal.InternalMessage; import org.apache.qpid.server.plugin.MessageConverter; -import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; -import org.apache.qpid.transport.codec.BBDecoder; -import org.apache.qpid.typedmessage.TypedBytesContentReader; -import org.apache.qpid.typedmessage.TypedBytesFormatException; - -import java.io.EOFException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class MessageConverter_v1_0_to_Internal implements MessageConverter<Message_1_0, InternalMessage> { @@ -61,7 +50,7 @@ public class MessageConverter_v1_0_to_Internal implements MessageConverter<Messa } @Override - public InternalMessage convert(Message_1_0 serverMessage, VirtualHost vhost) + public InternalMessage convert(Message_1_0 serverMessage, VirtualHostImpl vhost) { Object bodyObject = MessageConverter_from_1_0.convertBodyToObject(serverMessage); diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java index 3c3c17a6fb..03b56bfb74 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java @@ -56,7 +56,6 @@ import org.apache.qpid.server.model.Transport; import org.apache.qpid.server.security.SubjectCreator; import org.apache.qpid.server.security.auth.UsernamePrincipal; import org.apache.qpid.server.util.ServerScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; import org.apache.qpid.transport.Sender; import org.apache.qpid.transport.TransportException; import org.apache.qpid.transport.network.NetworkConnection; diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ReceivingLink_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ReceivingLink_1_0.java index 927972c8b2..3944774dfa 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ReceivingLink_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ReceivingLink_1_0.java @@ -45,11 +45,11 @@ import org.apache.qpid.server.message.MessageReference; import org.apache.qpid.server.store.StoredMessage; import org.apache.qpid.server.txn.AutoCommitTransaction; import org.apache.qpid.server.txn.ServerTransaction; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class ReceivingLink_1_0 implements ReceivingLinkListener, Link_1_0, DeliveryStateHandler { - private VirtualHost _vhost; + private VirtualHostImpl _vhost; private ReceivingDestination _destination; private SectionDecoderImpl _sectionDecoder; @@ -65,7 +65,7 @@ public class ReceivingLink_1_0 implements ReceivingLinkListener, Link_1_0, Deliv private ReceiverSettleMode _receivingSettlementMode; - public ReceivingLink_1_0(ReceivingLinkAttachment receivingLinkAttachment, VirtualHost vhost, + public ReceivingLink_1_0(ReceivingLinkAttachment receivingLinkAttachment, VirtualHostImpl vhost, ReceivingDestination destination) { _vhost = vhost; diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java index eb1f75b771..aa0c3f2e4b 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java @@ -59,14 +59,14 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.txn.AutoCommitTransaction; import org.apache.qpid.server.txn.ServerTransaction; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.server.virtualhost.QueueExistsException; public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryStateHandler { private static final Logger _logger = Logger.getLogger(SendingLink_1_0.class); - private VirtualHost _vhost; + private VirtualHostImpl _vhost; private SendingDestination _destination; private ConsumerImpl _consumer; @@ -87,7 +87,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS public SendingLink_1_0(final SendingLinkAttachment linkAttachment, - final VirtualHost vhost, + final VirtualHostImpl vhost, final SendingDestination destination) throws AmqpErrorException { @@ -687,7 +687,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS _closeAction = action; } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _vhost; } diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java index e124b4d5ac..ba76e43db2 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java @@ -58,7 +58,7 @@ import org.apache.qpid.server.txn.AutoCommitTransaction; import org.apache.qpid.server.txn.ServerTransaction; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.server.virtualhost.QueueExistsException; import javax.security.auth.Subject; @@ -73,7 +73,7 @@ public class Session_1_0 implements SessionEventListener, AMQSessionModel<Sessio private static final Logger _logger = Logger.getLogger(Session_1_0.class); private static final Symbol LIFETIME_POLICY = Symbol.valueOf("lifetime-policy"); private final SessionEndpoint _endpoint; - private VirtualHost _vhost; + private VirtualHostImpl _vhost; private AutoCommitTransaction _transaction; private final LinkedHashMap<Integer, ServerTransaction> _openTransactions = @@ -721,7 +721,7 @@ public class Session_1_0 implements SessionEventListener, AMQSessionModel<Sessio return _subject; } - VirtualHost getVirtualHost() + VirtualHostImpl getVirtualHost() { return _connection.getVirtualHost(); } diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/TxnCoordinatorLink_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/TxnCoordinatorLink_1_0.java index 3dd9b565ad..b5c82c7aa0 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/TxnCoordinatorLink_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/TxnCoordinatorLink_1_0.java @@ -35,7 +35,7 @@ import org.apache.qpid.amqp_1_0.type.transport.*; import org.apache.qpid.amqp_1_0.type.transport.Error; import org.apache.qpid.server.txn.LocalTransaction; import org.apache.qpid.server.txn.ServerTransaction; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.nio.ByteBuffer; import java.util.*; @@ -43,7 +43,7 @@ import java.util.*; public class TxnCoordinatorLink_1_0 implements ReceivingLinkListener, Link_1_0 { private static final Logger _logger = Logger.getLogger(TxnCoordinatorLink_1_0.class); - private VirtualHost _vhost; + private VirtualHostImpl _vhost; private ReceivingLinkEndpoint _endpoint; private ArrayList<Transfer> _incompleteMessage; @@ -52,7 +52,7 @@ public class TxnCoordinatorLink_1_0 implements ReceivingLinkListener, Link_1_0 private Session_1_0 _session; - public TxnCoordinatorLink_1_0(VirtualHost vhost, + public TxnCoordinatorLink_1_0(VirtualHostImpl vhost, Session_1_0 session_1_0, ReceivingLinkEndpoint endpoint, LinkedHashMap<Integer, ServerTransaction> openTransactions) { diff --git a/qpid/java/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10.java b/qpid/java/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10.java index a3c7ea31e0..01477ebb05 100644 --- a/qpid/java/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10.java +++ b/qpid/java/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10.java @@ -21,7 +21,6 @@ package org.apache.qpid.server.protocol.converter.v0_10_v1_0; import org.apache.qpid.server.message.AMQMessageHeader; -import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.plugin.MessageConverter; import org.apache.qpid.server.protocol.v0_10.MessageMetaData_0_10; import org.apache.qpid.server.protocol.v0_10.MessageTransferMessage; @@ -29,7 +28,7 @@ import org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0; import org.apache.qpid.server.protocol.v1_0.Message_1_0; import org.apache.qpid.server.store.StoreFuture; import org.apache.qpid.server.store.StoredMessage; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.DeliveryProperties; import org.apache.qpid.transport.Header; import org.apache.qpid.transport.MessageDeliveryPriority; @@ -53,13 +52,13 @@ public class MessageConverter_1_0_to_v0_10 implements MessageConverter<Message_1 } @Override - public MessageTransferMessage convert(Message_1_0 serverMsg, VirtualHost vhost) + public MessageTransferMessage convert(Message_1_0 serverMsg, VirtualHostImpl vhost) { return new MessageTransferMessage(convertToStoredMessage(serverMsg, vhost), null); } private StoredMessage<MessageMetaData_0_10> convertToStoredMessage(final Message_1_0 serverMsg, - final VirtualHost vhost) + final VirtualHostImpl vhost) { Object bodyObject = MessageConverter_from_1_0.convertBodyToObject(serverMsg); @@ -124,7 +123,7 @@ public class MessageConverter_1_0_to_v0_10 implements MessageConverter<Message_1 } private MessageMetaData_0_10 convertMetaData(Message_1_0 serverMsg, - final VirtualHost vhost, + final VirtualHostImpl vhost, final String bodyMimeType, final int size) { diff --git a/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java b/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java index bde7d1446b..9a28efbf1a 100644 --- a/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java +++ b/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java @@ -37,7 +37,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQMessage; import org.apache.qpid.server.protocol.v0_8.MessageMetaData; import org.apache.qpid.server.store.StoreFuture; import org.apache.qpid.server.store.StoredMessage; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.DeliveryProperties; import org.apache.qpid.transport.Header; import org.apache.qpid.transport.MessageDeliveryMode; @@ -49,7 +49,7 @@ public class MessageConverter_0_10_to_0_8 implements MessageConverter<MessageTra private static final int BASIC_CLASS_ID = 60; public static BasicContentHeaderProperties convertContentHeaderProperties(MessageTransferMessage messageTransferMessage, - VirtualHost vhost) + VirtualHostImpl vhost) { BasicContentHeaderProperties props = new BasicContentHeaderProperties(); @@ -166,13 +166,13 @@ public class MessageConverter_0_10_to_0_8 implements MessageConverter<MessageTra } @Override - public AMQMessage convert(MessageTransferMessage message, VirtualHost vhost) + public AMQMessage convert(MessageTransferMessage message, VirtualHostImpl vhost) { return new AMQMessage(convertToStoredMessage(message, vhost)); } private StoredMessage<MessageMetaData> convertToStoredMessage(final MessageTransferMessage message, - VirtualHost vhost) + VirtualHostImpl vhost) { final MessageMetaData metaData = convertMetaData(message, vhost); return new StoredMessage<org.apache.qpid.server.protocol.v0_8.MessageMetaData>() @@ -221,14 +221,14 @@ public class MessageConverter_0_10_to_0_8 implements MessageConverter<MessageTra }; } - private MessageMetaData convertMetaData(MessageTransferMessage message, VirtualHost vhost) + private MessageMetaData convertMetaData(MessageTransferMessage message, VirtualHostImpl vhost) { return new MessageMetaData(convertPublishBody(message), convertContentHeaderBody(message, vhost), message.getArrivalTime()); } - private ContentHeaderBody convertContentHeaderBody(MessageTransferMessage message, VirtualHost vhost) + private ContentHeaderBody convertContentHeaderBody(MessageTransferMessage message, VirtualHostImpl vhost) { BasicContentHeaderProperties props = convertContentHeaderProperties(message, vhost); ContentHeaderBody chb = new ContentHeaderBody(props, BASIC_CLASS_ID); diff --git a/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_8_to_0_10.java b/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_8_to_0_10.java index dd371acc3d..c9f43b36f8 100644 --- a/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_8_to_0_10.java +++ b/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_8_to_0_10.java @@ -33,7 +33,7 @@ import org.apache.qpid.server.protocol.v0_10.MessageTransferMessage; import org.apache.qpid.server.protocol.v0_8.AMQMessage; import org.apache.qpid.server.store.StoreFuture; import org.apache.qpid.server.store.StoredMessage; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.transport.DeliveryProperties; import org.apache.qpid.transport.Header; import org.apache.qpid.transport.MessageDeliveryPriority; @@ -56,7 +56,7 @@ public class MessageConverter_0_8_to_0_10 implements MessageConverter<AMQMessag } @Override - public MessageTransferMessage convert(AMQMessage message_0_8, VirtualHost vhost) + public MessageTransferMessage convert(AMQMessage message_0_8, VirtualHostImpl vhost) { return new MessageTransferMessage(convertToStoredMessage(message_0_8), null); } diff --git a/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_1_0_to_v0_8.java b/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_1_0_to_v0_8.java index d9391d89a5..576db8f83e 100644 --- a/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_1_0_to_v0_8.java +++ b/qpid/java/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_1_0_to_v0_8.java @@ -33,7 +33,7 @@ import org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0; import org.apache.qpid.server.protocol.v1_0.Message_1_0; import org.apache.qpid.server.store.StoreFuture; import org.apache.qpid.server.store.StoredMessage; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.nio.ByteBuffer; import java.util.LinkedHashMap; @@ -56,7 +56,7 @@ public class MessageConverter_1_0_to_v0_8 implements MessageConverter<Message_1_ } @Override - public AMQMessage convert(Message_1_0 serverMsg, VirtualHost vhost) + public AMQMessage convert(Message_1_0 serverMsg, VirtualHostImpl vhost) { return new AMQMessage(convertToStoredMessage(serverMsg), null); } diff --git a/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java b/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java index 42a04b3c0f..e6fd437b90 100644 --- a/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java +++ b/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java @@ -48,7 +48,7 @@ import org.apache.qpid.server.txn.AutoCommitTransaction; import org.apache.qpid.server.txn.ServerTransaction; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.StateChangeListener; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import java.nio.charset.Charset; import java.security.AccessControlException; @@ -92,7 +92,7 @@ class ManagementNode implements MessageSource, MessageDestination public static final String RESULTS = "results"; - private final VirtualHost _virtualHost; + private final VirtualHostImpl _virtualHost; private final UUID _id; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java index 2cf7f3f80c..b4e386a685 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java @@ -69,6 +69,22 @@ public class ConfiguredObjectToMapConverter { object.put(name, ((ConfiguredObject) value).getName()); } + else if(value instanceof Collection) + { + List<Object> converted = new ArrayList(); + for(Object member : (Collection)value) + { + if(member instanceof ConfiguredObject) + { + converted.add(((ConfiguredObject)member).getName()); + } + else + { + converted.add(member); + } + } + object.put(name, converted); + } else if(value != null) { object.put(name, value); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java index 00126200f8..22316fcf54 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java @@ -20,17 +20,32 @@ import java.io.BufferedWriter; import java.io.IOException; import java.io.Writer; import java.security.AccessControlException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; -import org.apache.qpid.server.model.*; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.Model; +import org.apache.qpid.server.model.State; + public class RestServlet extends AbstractServlet { private static final Logger LOGGER = Logger.getLogger(RestServlet.class); @@ -458,7 +473,6 @@ public class RestServlet extends AbstractServlet catch (RuntimeException e) { setResponseStatus(response, e); - e.printStackTrace(); } } diff --git a/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/JMXManagementFactoryTest.java b/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/JMXManagementFactoryTest.java index 62f0ad558a..d0da48fb3a 100644 --- a/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/JMXManagementFactoryTest.java +++ b/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/JMXManagementFactoryTest.java @@ -18,15 +18,15 @@ */ package org.apache.qpid.server.jmx; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.test.utils.QpidTestCase; +import static org.mockito.Mockito.mock; import java.util.HashMap; import java.util.Map; import java.util.UUID; -import static org.mockito.Mockito.mock; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.test.utils.QpidTestCase; public class JMXManagementFactoryTest extends QpidTestCase { @@ -41,7 +41,7 @@ public class JMXManagementFactoryTest extends QpidTestCase _attributes.put(ConfiguredObject.TYPE, JMXManagement.PLUGIN_TYPE); JMXManagement jmxManagement = _jmxManagementFactory.createInstance( _attributes, _broker); - + jmxManagement.open(); assertNotNull(jmxManagement); assertEquals("Unexpected plugin type", JMXManagement.PLUGIN_TYPE, jmxManagement.getType()); assertEquals("Unexpected default mbean platform", JMXManagement.DEFAULT_USE_PLATFORM_MBEAN_SERVER, jmxManagement.getAttribute(JMXManagement.USE_PLATFORM_MBEAN_SERVER)); diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java b/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java index f2d51ccfde..3a1a619981 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java @@ -102,11 +102,39 @@ public final class Strings private static final Pattern VAR = Pattern.compile("(?:\\$\\{([^\\}]*)\\})|(?:\\$(\\$))"); + public static Resolver chain(Resolver... resolvers) + { + Resolver resolver; + if(resolvers.length == 0) + { + resolver = NULL_RESOLVER; + } + else + { + resolver = resolvers[resolvers.length - 1]; + for (int i = resolvers.length - 2; i >= 0; i--) + { + resolver = new ChainedResolver(resolvers[i], resolver); + } + } + return resolver; + } + public static interface Resolver { String resolve(String variable); } + private static final Resolver NULL_RESOLVER = + new Resolver() + { + @Override + public String resolve(final String variable) + { + return null; + } + }; + public static class MapResolver implements Resolver { @@ -161,19 +189,28 @@ public final class Strings } } - public static final Resolver SYSTEM_RESOLVER = new Resolver() - { - public String resolve(String variable) + public static final Resolver ENV_VARS_RESOLVER = new Resolver() { - String result = System.getProperty(variable); - if (result == null) + @Override + public String resolve(final String variable) { - result = System.getenv(variable); + return System.getenv(variable); } - return result; + }; + + + public static final Resolver JAVA_SYS_PROPS_RESOLVER = new Resolver() + { + @Override + public String resolve(final String variable) + { + return System.getProperty(variable); } }; + + public static final Resolver SYSTEM_RESOLVER = chain(JAVA_SYS_PROPS_RESOLVER, ENV_VARS_RESOLVER); + public static final String expand(String input) { return expand(input, SYSTEM_RESOLVER); @@ -181,10 +218,14 @@ public final class Strings public static final String expand(String input, Resolver resolver) { - return expand(input, resolver, new Stack<String>()); + return expand(input, resolver, new Stack<String>(),true); + } + public static final String expand(String input, boolean failOnUnresolved, Resolver... resolvers) + { + return expand(input, chain(resolvers), new Stack<String>(), failOnUnresolved); } - private static final String expand(String input, Resolver resolver, Stack<String> stack) + private static final String expand(String input, Resolver resolver, Stack<String> stack, boolean failOnUnresolved) { Matcher m = VAR.matcher(input); StringBuffer result = new StringBuffer(); @@ -205,14 +246,17 @@ public final class Strings } else { - m.appendReplacement(result, Matcher.quoteReplacement(resolve(var, resolver, stack))); + m.appendReplacement(result, Matcher.quoteReplacement(resolve(var, resolver, stack, failOnUnresolved))); } } m.appendTail(result); return result.toString(); } - private static final String resolve(String var, Resolver resolver, Stack<String> stack) + private static final String resolve(String var, + Resolver resolver, + Stack<String> stack, + final boolean failOnUnresolved) { if (stack.contains(var)) { @@ -224,13 +268,20 @@ public final class Strings String result = resolver.resolve(var); if (result == null) { - throw new IllegalArgumentException("no such variable: " + var); + if(failOnUnresolved) + { + throw new IllegalArgumentException("no such variable: " + var); + } + else + { + return "${"+var+"}"; + } } stack.push(var); try { - return expand(result, resolver, stack); + return expand(result, resolver, stack, failOnUnresolved); } finally { diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java index 099e011054..74ef6ad0e0 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java @@ -32,7 +32,7 @@ import java.util.Set; import org.apache.qpid.protocol.ServerProtocolEngine; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.server.virtualhost.VirtualHostRegistry; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.transport.Sender; @@ -40,7 +40,7 @@ import org.apache.qpid.transport.network.NetworkConnection; public class MultiVersionProtocolEngineFactoryTest extends QpidTestCase { - private VirtualHost _virtualHost; + private VirtualHostImpl _virtualHost; private Broker _broker; @Override @@ -51,6 +51,7 @@ public class MultiVersionProtocolEngineFactoryTest extends QpidTestCase _broker = BrokerTestHelper.createBrokerMock(); VirtualHostRegistry virtualHostRegistry = _broker.getVirtualHostRegistry(); when(_broker.getAttribute(Broker.DEFAULT_VIRTUAL_HOST)).thenReturn("default"); + when(_broker.getDefaultVirtualHost()).thenReturn("default"); // AMQP 1-0 connection needs default vhost to be present _virtualHost = BrokerTestHelper.createVirtualHost("default", virtualHostRegistry); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java index 1baf998562..1ecf43aa9b 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java @@ -20,7 +20,6 @@ package org.apache.qpid.server.security.acl; import org.apache.qpid.management.common.mbeans.ServerInformation; import org.apache.qpid.server.security.access.ObjectType; -import org.apache.qpid.server.virtualhost.VirtualHost; import org.apache.qpid.test.utils.JMXTestUtils; import org.apache.qpid.test.utils.TestBrokerConfiguration; diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/VirtualHostMessageStoreTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/VirtualHostMessageStoreTest.java index 5ab6800612..9750cbf612 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/VirtualHostMessageStoreTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/VirtualHostMessageStoreTest.java @@ -58,7 +58,7 @@ import org.apache.qpid.server.txn.ServerTransaction; import org.apache.qpid.server.util.BrokerTestHelper; import org.apache.qpid.server.virtualhost.AbstractVirtualHost; import org.apache.qpid.server.virtualhost.StandardVirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.server.virtualhost.VirtualHostRegistry; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.util.FileUtils; @@ -154,14 +154,14 @@ public class VirtualHostMessageStoreTest extends QpidTestCase } } - public VirtualHost getVirtualHost() + public VirtualHostImpl getVirtualHost() { return _virtualHost; } protected void reloadVirtualHost() { - VirtualHost original = getVirtualHost(); + VirtualHostImpl original = getVirtualHost(); if (getVirtualHost() != null) { diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java index 207c877fa6..dd7444a0d5 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java @@ -31,6 +31,7 @@ import java.util.Map; import javax.jms.JMSException; import org.apache.qpid.client.AMQConnection; +import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.Binding; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; @@ -43,7 +44,6 @@ import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.test.utils.TestBrokerConfiguration; public class Asserts @@ -60,6 +60,7 @@ public class Asserts ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT, VirtualHost.SUPPORTED_QUEUE_TYPES, VirtualHost.TYPE, VirtualHost.CONFIGURATION_STORE_SETTINGS, @@ -117,7 +118,8 @@ public class Asserts Queue.SORT_KEY, Queue.MESSAGE_GROUP_KEY, Queue.MESSAGE_GROUP_SHARED_GROUPS, - Queue.PRIORITIES); + Queue.PRIORITIES, + ConfiguredObject.CONTEXT); assertEquals("Unexpected value of queue attribute " + Queue.NAME, queueName, queueData.get(Queue.NAME)); assertNotNull("Unexpected value of queue attribute " + Queue.ID, queueData.get(Queue.ID)); @@ -222,7 +224,8 @@ public class Asserts ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, - ConfiguredObject.DESCRIPTION); + ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT); assertEquals("Unexpected value for connection attribute " + Connection.PORT, TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT, connectionData.get(Connection.PORT)); @@ -283,6 +286,7 @@ public class Asserts ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT, Port.AUTHENTICATION_PROVIDER, Port.KEY_STORE, Port.TRUST_STORES); @@ -298,6 +302,7 @@ public class Asserts ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT, Port.AUTHENTICATION_PROVIDER, Port.BINDING_ADDRESS, Port.TCP_NO_DELAY, @@ -332,7 +337,8 @@ public class Asserts ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, - ConfiguredObject.DESCRIPTION); + ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT); assertEquals("Unexpected value of exchange attribute " + Exchange.NAME, exchangeName, exchangeData.get(Exchange.NAME)); @@ -367,7 +373,8 @@ public class Asserts ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, - ConfiguredObject.DESCRIPTION); + ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT); assertEquals("Unexpected binding attribute " + Binding.NAME, bindingName, binding.get(Binding.NAME)); assertEquals("Unexpected binding attribute " + Binding.QUEUE, queueName, binding.get(Binding.QUEUE)); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java index 7dd52d3aa3..8d9f1997f0 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java @@ -306,7 +306,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase { Asserts.assertAttributesPresent(provider, AbstractConfiguredObject.getAttributeNames( AuthenticationProvider.class), - AuthenticationProvider.DESCRIPTION, ConfiguredObject.CREATED_BY, + AuthenticationProvider.DESCRIPTION, ConfiguredObject.CONTEXT, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME); assertEquals("Unexpected value of provider attribute " + AuthenticationProvider.STATE, State.ACTIVE.name(), provider.get(AuthenticationProvider.STATE)); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java index 4c8997bec5..fd7dbf0831 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java @@ -70,6 +70,7 @@ public class BrokerRestHttpsTest extends QpidRestTestCase ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, - ConfiguredObject.DESCRIPTION); + ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT); } } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java index faf19d8bab..e0c18c0caf 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java @@ -33,14 +33,13 @@ import javax.jms.Session; import javax.jms.TextMessage; import org.apache.qpid.common.QpidProperties; -import org.apache.qpid.server.configuration.BrokerConfigurationStoreCreator; +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.LifetimePolicy; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.plugin.MessageStoreFactory; import org.apache.qpid.test.client.UnroutableMessageTestExceptionListener; import org.apache.qpid.test.utils.TestBrokerConfiguration; @@ -241,7 +240,8 @@ public class BrokerRestTest extends QpidRestTestCase ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, - ConfiguredObject.DESCRIPTION); + ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT); assertEquals("Unexpected value of attribute " + Broker.BUILD_VERSION, QpidProperties.getBuildVersion(), brokerDetails.get(Broker.BUILD_VERSION)); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/ConnectionRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/ConnectionRestTest.java index ba1b1e2c26..f924dae56e 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/ConnectionRestTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/ConnectionRestTest.java @@ -181,6 +181,7 @@ public class ConnectionRestTest extends QpidRestTestCase ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT, Session.STATE, Session.DURABLE, Session.LIFETIME_POLICY); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/GroupProviderRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/GroupProviderRestTest.java index 3ec8818c8d..d9320a93d0 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/GroupProviderRestTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/GroupProviderRestTest.java @@ -328,7 +328,8 @@ public class GroupProviderRestTest extends QpidRestTestCase ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, - ConfiguredObject.DESCRIPTION); + ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT); assertEquals("Unexpected value of provider attribute " + GroupProvider.STATE, State.ACTIVE.name(), provider.get(GroupProvider.STATE)); assertEquals("Unexpected value of provider attribute " + GroupProvider.LIFETIME_POLICY, diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/PreferencesProviderRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/PreferencesProviderRestTest.java index a06b41498c..6ef3dd500a 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/PreferencesProviderRestTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/PreferencesProviderRestTest.java @@ -167,7 +167,8 @@ public class PreferencesProviderRestTest extends QpidRestTestCase ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, - ConfiguredObject.DESCRIPTION); + ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT); assertEquals("Unexpected value of provider attribute " + PreferencesProvider.STATE, State.ACTIVE.name(), provider.get(PreferencesProvider.STATE)); assertEquals("Unexpected value of provider attribute " + PreferencesProvider.LIFETIME_POLICY, diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QueueRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QueueRestTest.java index 3d4c6fe6cf..3063f9182c 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QueueRestTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QueueRestTest.java @@ -218,7 +218,8 @@ public class QueueRestTest extends QpidRestTestCase ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME, - ConfiguredObject.DESCRIPTION); + ConfiguredObject.DESCRIPTION, + ConfiguredObject.CONTEXT); assertEquals("Unexpected binding attribute " + Consumer.NAME, "1", consumer.get(Consumer.NAME)); assertEquals("Unexpected binding attribute " + Consumer.DURABLE, Boolean.FALSE, consumer.get(Consumer.DURABLE)); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java index 89611ab727..4dc4001c4b 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java @@ -179,7 +179,7 @@ public class RestTestHelper JsonParseException, JsonMappingException { byte[] data = readConnectionInputStream(connection); - +String dataAsString = new String(data); ObjectMapper mapper = new ObjectMapper(); TypeReference<List<LinkedHashMap<String, Object>>> typeReference = new TypeReference<List<LinkedHashMap<String, Object>>>() diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java index 20a3347895..040774b5ff 100755 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java @@ -17,8 +17,39 @@ */ package org.apache.qpid.test.utils; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.StreamMessage; +import javax.jms.TextMessage; +import javax.jms.Topic; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; + import org.apache.qpid.AMQException; import org.apache.qpid.client.AMQConnectionFactory; import org.apache.qpid.client.AMQConnectionURL; @@ -41,23 +72,6 @@ import org.apache.qpid.url.URLSyntaxException; import org.apache.qpid.util.FileUtils; import org.apache.qpid.util.SystemUtils; -import javax.jms.*; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.lang.IllegalStateException; - /** * Qpid base class for system testing test cases. */ @@ -529,6 +543,16 @@ public class QpidBrokerTestCase extends QpidTestCase setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES); setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_INCLUDES); + setSystemProperty("test.port"); + setSystemProperty("test.mport"); + setSystemProperty("test.cport"); + setSystemProperty("test.hport"); + setSystemProperty("test.port.ssl"); + setSystemProperty("test.port.alt"); + setSystemProperty("test.port.alt.ssl"); + setSystemProperty("messagestore.type"); + + // Add all the specified system properties to QPID_OPTS if (!_propertiesSetForBroker.isEmpty()) { |