diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-04-28 02:25:27 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-04-28 02:25:27 +0000 |
| commit | e93df1d676c748f942daaf5fb0c4d4dd4ea867a2 (patch) | |
| tree | 334bdee0947d54ee5e9f366331e222db2e749d38 /qpid/java/broker-core/src | |
| parent | 206d461b36995e741ca5a1edcdb2b28f8835832a (diff) | |
| download | qpid-python-e93df1d676c748f942daaf5fb0c4d4dd4ea867a2.tar.gz | |
QPID-5726 : [Java Broker] Use annotation processing to generate object factories and service definitions
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1590547 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-core/src')
77 files changed, 377 insertions, 1510 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingFactory.java index 4050f7675e..c3f37f82a5 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingFactory.java @@ -27,8 +27,10 @@ import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.Exchange; import org.apache.qpid.server.model.Queue; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.queue.AMQQueue; +@PluggableService public class BindingFactory extends AbstractConfiguredObjectTypeFactory<BindingImpl> { public BindingFactory() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/factory/JsonConfigurationStoreFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/factory/JsonConfigurationStoreFactory.java index 517672f74b..930fb5fa23 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/factory/JsonConfigurationStoreFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/factory/JsonConfigurationStoreFactory.java @@ -26,7 +26,9 @@ import org.apache.qpid.server.configuration.ConfigurationEntryStore; import org.apache.qpid.server.configuration.store.JsonConfigurationEntryStore; import org.apache.qpid.server.model.SystemContext; import org.apache.qpid.server.plugin.ConfigurationStoreFactory; +import org.apache.qpid.server.plugin.PluggableService; +@PluggableService public class JsonConfigurationStoreFactory implements ConfigurationStoreFactory { @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/factory/MemoryConfigurationStoreFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/factory/MemoryConfigurationStoreFactory.java index 8af654084b..971e9d08db 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/factory/MemoryConfigurationStoreFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/factory/MemoryConfigurationStoreFactory.java @@ -26,7 +26,9 @@ import org.apache.qpid.server.configuration.ConfigurationEntryStore; import org.apache.qpid.server.configuration.store.MemoryConfigurationEntryStore; import org.apache.qpid.server.model.SystemContext; import org.apache.qpid.server.plugin.ConfigurationStoreFactory; +import org.apache.qpid.server.plugin.PluggableService; +@PluggableService public class MemoryConfigurationStoreFactory implements ConfigurationStoreFactory { @Override 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 bcec720cea..026182f7f3 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 @@ -40,6 +40,7 @@ import org.apache.qpid.server.filter.MessageFilter; import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; @@ -137,6 +138,7 @@ public class DirectExchange extends AbstractExchange<DirectExchange> public static final ExchangeType<DirectExchange> TYPE = new DirectExchangeType(); + @ManagedObjectFactoryConstructor public DirectExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost) { super(attributes, vhost); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeFactory.java deleted file mode 100644 index 149fc36f1c..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.exchange; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public class DirectExchangeFactory extends AbstractConfiguredObjectTypeFactory<DirectExchange> -{ - public DirectExchangeFactory() - { - super(DirectExchange.class); - } - - @Override - public DirectExchange createInstance(Map<String, Object> attributes, ConfiguredObject<?>... parents) - { - VirtualHost<?,?,?> virtualHost = getParent(VirtualHost.class, parents); - if (!(virtualHost instanceof VirtualHostImpl)) - { - throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); - } - return new DirectExchange(attributes, (VirtualHostImpl<?, ?, ?>)virtualHost); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java index 547261f5aa..b26991a50a 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 @@ -24,8 +24,10 @@ import java.util.Map; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.plugin.ExchangeType; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.virtualhost.VirtualHostImpl; +@PluggableService public class DirectExchangeType implements ExchangeType<DirectExchange> { @Override 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 b9461df0be..cba9852d80 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 @@ -37,6 +37,7 @@ import org.apache.qpid.server.filter.MessageFilter; import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; @@ -67,6 +68,7 @@ public class FanoutExchange extends AbstractExchange<FanoutExchange> public static final ExchangeType<FanoutExchange> TYPE = new FanoutExchangeType(); + @ManagedObjectFactoryConstructor public FanoutExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost) { super(attributes, vhost); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeFactory.java deleted file mode 100644 index e8fa3564ee..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.exchange; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public class FanoutExchangeFactory extends AbstractConfiguredObjectTypeFactory<FanoutExchange> -{ - public FanoutExchangeFactory() - { - super(FanoutExchange.class); - } - - @Override - public FanoutExchange createInstance(Map<String, Object> attributes, ConfiguredObject<?>... parents) - { - VirtualHost<?,?,?> virtualHost = getParent(VirtualHost.class, parents); - if (!(virtualHost instanceof VirtualHostImpl)) - { - throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); - } - return new FanoutExchange(attributes, (VirtualHostImpl<?, ?, ?>)virtualHost); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java index af64c74473..1c90b7925b 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 @@ -24,8 +24,10 @@ import java.util.Map; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.plugin.ExchangeType; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.virtualhost.VirtualHostImpl; +@PluggableService public class FanoutExchangeType implements ExchangeType<FanoutExchange> { @Override 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 e2146b3111..e49d9ea632 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 @@ -35,6 +35,7 @@ import org.apache.qpid.server.filter.Filterable; import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; @@ -82,6 +83,7 @@ public class HeadersExchange extends AbstractExchange<HeadersExchange> public static final ExchangeType<HeadersExchange> TYPE = new HeadersExchangeType(); + @ManagedObjectFactoryConstructor public HeadersExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost) { super(attributes, vhost); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeFactory.java deleted file mode 100644 index cbe7d9c612..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.exchange; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public class HeadersExchangeFactory extends AbstractConfiguredObjectTypeFactory<HeadersExchange> -{ - public HeadersExchangeFactory() - { - super(HeadersExchange.class); - } - - @Override - public HeadersExchange createInstance(Map<String, Object> attributes, ConfiguredObject<?>... parents) - { - VirtualHost<?,?,?> virtualHost = getParent(VirtualHost.class, parents); - if (!(virtualHost instanceof VirtualHostImpl)) - { - throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); - } - return new HeadersExchange(attributes, (VirtualHostImpl<?, ?, ?>)virtualHost); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java index e58628ce39..c9346f6e28 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 @@ -24,8 +24,10 @@ import java.util.Map; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.plugin.ExchangeType; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.virtualhost.VirtualHostImpl; +@PluggableService public class HeadersExchangeType implements ExchangeType<HeadersExchange> { @Override 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 6506bfc0a6..edc6fa7796 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 @@ -41,6 +41,7 @@ import org.apache.qpid.server.filter.Filterable; import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; @@ -62,6 +63,7 @@ public class TopicExchange extends AbstractExchange<TopicExchange> private final Map<BindingImpl, Map<String,Object>> _bindings = new HashMap<BindingImpl, Map<String,Object>>(); + @ManagedObjectFactoryConstructor public TopicExchange(final Map<String,Object> attributes, final VirtualHostImpl vhost) { super(attributes, vhost); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeFactory.java deleted file mode 100644 index ef9c850fc9..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.exchange; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public class TopicExchangeFactory extends AbstractConfiguredObjectTypeFactory<TopicExchange> -{ - public TopicExchangeFactory() - { - super(TopicExchange.class); - } - - @Override - public TopicExchange createInstance(Map<String, Object> attributes, ConfiguredObject<?>... parents) - { - VirtualHost<?,?,?> virtualHost = getParent(VirtualHost.class, parents); - if (!(virtualHost instanceof VirtualHostImpl)) - { - throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); - } - return new TopicExchange(attributes, (VirtualHostImpl<?, ?, ?>)virtualHost); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java index 8bf0435b02..dc2a526278 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 @@ -24,8 +24,10 @@ import java.util.Map; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.plugin.ExchangeType; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.virtualhost.VirtualHostImpl; +@PluggableService public class TopicExchangeType implements ExchangeType<TopicExchange> { @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaDataType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaDataType.java index 20e506e634..613d4d15d8 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaDataType.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaDataType.java @@ -20,16 +20,18 @@ */ package org.apache.qpid.server.message.internal; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.nio.ByteBuffer; + import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.plugin.MessageMetaDataType; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.store.StoredMessage; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; import org.apache.qpid.util.ByteBufferInputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.nio.ByteBuffer; - +@PluggableService public class InternalMessageMetaDataType implements MessageMetaDataType<InternalMessageMetaData> { public static final int INTERNAL_ORDINAL = 999; 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 e0ccc940c3..018b72c805 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 @@ -942,7 +942,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } - protected void deleted() { for (ConfiguredObject<?> parent : _parents.values()) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObjectTypeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObjectTypeFactory.java index f159f70d20..ec8b2d94fe 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObjectTypeFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObjectTypeFactory.java @@ -65,7 +65,7 @@ abstract public class AbstractConfiguredObjectTypeFactory<X extends AbstractConf { if(!parents[0].getModel().getParentTypes((Class<? extends ConfiguredObject>) getCategoryClass()).contains( - parentClass)) + Model.getCategory(parentClass))) { throw new IllegalArgumentException(parentClass.getSimpleName() + " is not a parent of " + _clazz.getSimpleName()); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java index dd5be11301..5ac25cce57 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java @@ -44,41 +44,50 @@ public class ConfiguredObjectFactoryImpl implements ConfiguredObjectFactory public ConfiguredObjectFactoryImpl(Model model) { _model = model; - - QpidServiceLoader<ConfiguredObjectTypeFactory> serviceLoader = new QpidServiceLoader<ConfiguredObjectTypeFactory>(); - Iterable<ConfiguredObjectTypeFactory> allFactories = serviceLoader.instancesOf(ConfiguredObjectTypeFactory.class); - for(ConfiguredObjectTypeFactory factory : allFactories) + try { - final Class<? extends ConfiguredObject> categoryClass = factory.getCategoryClass(); - final String categoryName = categoryClass.getSimpleName(); - - Map<String, ConfiguredObjectTypeFactory> categoryFactories = _allFactories.get(categoryName); - if(categoryFactories == null) + QpidServiceLoader<ConfiguredObjectTypeFactory> serviceLoader = + new QpidServiceLoader<ConfiguredObjectTypeFactory>(); + Iterable<ConfiguredObjectTypeFactory> allFactories = + serviceLoader.instancesOf(ConfiguredObjectTypeFactory.class); + for (ConfiguredObjectTypeFactory factory : allFactories) { - categoryFactories = new HashMap<String, ConfiguredObjectTypeFactory>(); - _allFactories.put(categoryName, categoryFactories); - _supportedTypes.put(categoryName, new ArrayList<String>()); - ManagedObject annotation = categoryClass.getAnnotation(ManagedObject.class); - if(annotation != null && !"".equals(annotation.defaultType())) + final Class<? extends ConfiguredObject> categoryClass = factory.getCategoryClass(); + final String categoryName = categoryClass.getSimpleName(); + + Map<String, ConfiguredObjectTypeFactory> categoryFactories = _allFactories.get(categoryName); + if (categoryFactories == null) { - _defaultTypes.put(categoryName, annotation.defaultType()); + categoryFactories = new HashMap<String, ConfiguredObjectTypeFactory>(); + _allFactories.put(categoryName, categoryFactories); + _supportedTypes.put(categoryName, new ArrayList<String>()); + ManagedObject annotation = categoryClass.getAnnotation(ManagedObject.class); + if (annotation != null && !"".equals(annotation.defaultType())) + { + _defaultTypes.put(categoryName, annotation.defaultType()); + } + else + { + _defaultTypes.put(categoryName, categoryName); + } + } - else + if (categoryFactories.put(factory.getType(), factory) != null) { - _defaultTypes.put(categoryName, categoryName); + throw new ServerScopedRuntimeException( + "Misconfiguration - there is more than one factory defined for class " + categoryName + + " with type " + factory.getType()); + } + if (factory.getType() != null) + { + _supportedTypes.get(categoryName).add(factory.getType()); } - - } - if(categoryFactories.put(factory.getType(),factory) != null) - { - throw new ServerScopedRuntimeException("Misconfiguration - there is more than one factory defined for class " + categoryName - + " with type " + factory.getType()); - } - if(factory.getType() != null) - { - _supportedTypes.get(categoryName).add(factory.getType()); } } + catch (RuntimeException | Error e) + { + e.printStackTrace(); + } } @Override 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 6b77833bc9..d729259236 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 @@ -100,7 +100,7 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple @ManagedAttributeField private boolean _statisticsReportingResetEnabled; - + @ManagedObjectFactoryConstructor public BrokerAdapter(Map<String, Object> attributes, SystemContext parent) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java deleted file mode 100644 index 5e07a13c41..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.adapter; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.SystemContext; - -public class BrokerAdapterFactory extends AbstractConfiguredObjectTypeFactory<BrokerAdapter> -{ - public BrokerAdapterFactory() - { - super(BrokerAdapter.class); - } - - @Override - public BrokerAdapter createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - SystemContext context = getParent(SystemContext.class, parents); - return new BrokerAdapter(attributes, context); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java deleted file mode 100644 index 8f6d96ec79..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.adapter; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; - -public class FileBasedGroupProviderFactory extends AbstractConfiguredObjectTypeFactory<FileBasedGroupProviderImpl> -{ - public FileBasedGroupProviderFactory() - { - super(FileBasedGroupProviderImpl.class); - } - - @Override - public FileBasedGroupProviderImpl createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new FileBasedGroupProviderImpl(attributes, getParent(Broker.class, parents)); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java index 4a88d13070..26886c176e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java @@ -44,6 +44,7 @@ import org.apache.qpid.server.model.GroupMember; import org.apache.qpid.server.model.GroupProvider; import org.apache.qpid.server.model.IllegalStateTransitionException; import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.State; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.security.access.Operation; @@ -67,6 +68,7 @@ public class FileBasedGroupProviderImpl @ManagedAttributeField private String _path; + @ManagedObjectFactoryConstructor public FileBasedGroupProviderImpl(Map<String, Object> attributes, Broker broker) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java deleted file mode 100644 index 9434adf97a..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.server.model.adapter; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.ConfiguredObject; - -public class FileSystemPreferencesProviderFactory extends AbstractConfiguredObjectTypeFactory<FileSystemPreferencesProviderImpl> -{ - - public FileSystemPreferencesProviderFactory() - { - super(FileSystemPreferencesProviderImpl.class); - } - - @Override - public FileSystemPreferencesProviderImpl createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new FileSystemPreferencesProviderImpl(attributes, getParent(AuthenticationProvider.class,parents)); - } -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java index 765fc149a0..013aa5ed98 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java @@ -53,6 +53,7 @@ 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.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.State; import org.apache.qpid.server.util.MapValueConverter; @@ -72,6 +73,7 @@ public class FileSystemPreferencesProviderImpl private boolean _open; + @ManagedObjectFactoryConstructor public FileSystemPreferencesProviderImpl(Map<String, Object> attributes, AuthenticationProvider<? extends AuthenticationProvider> authenticationProvider) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostFactory.java deleted file mode 100644 index 51f8897d67..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.adapter; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.virtualhost.StandardVirtualHost; - -public class StandardVirtualHostFactory extends AbstractConfiguredObjectTypeFactory<StandardVirtualHost> -{ - - public StandardVirtualHostFactory() - { - super(StandardVirtualHost.class); - } - - @Override - public StandardVirtualHost createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - final VirtualHostNode<?> virtualHostNode = getParent(VirtualHostNode.class, parents); - return new StandardVirtualHost(attributes, virtualHostNode); - } - - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java deleted file mode 100644 index d1e67c9c3f..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.port; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; - -public class AmqpPortFactory extends AbstractConfiguredObjectTypeFactory<AmqpPortImpl> -{ - public AmqpPortFactory() - { - super(AmqpPortImpl.class); - } - - @Override - public AmqpPortImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - Broker broker = getParent(Broker.class, parents); - return new AmqpPortImpl(attributes, broker); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java index 3952ea3871..eaa3d6d6ed 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java @@ -38,10 +38,10 @@ 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.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.Transport; import org.apache.qpid.server.model.TrustStore; -import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.plugin.QpidServiceLoader; import org.apache.qpid.server.plugin.TransportProviderFactory; import org.apache.qpid.server.transport.AcceptingTransport; @@ -67,6 +67,7 @@ public class AmqpPortImpl extends AbstractPortWithAuthProvider<AmqpPortImpl> imp private final Broker<?> _broker; private AcceptingTransport _transport; + @ManagedObjectFactoryConstructor public AmqpPortImpl(Map<String, Object> attributes, Broker<?> broker) { super(attributes, broker); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java deleted file mode 100644 index 0cfd37ffa0..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.port; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.Port; - -public class HttpPortFactory extends AbstractConfiguredObjectTypeFactory<HttpPortImpl> -{ - public HttpPortFactory() - { - super(HttpPortImpl.class); - } - - @Override - public HttpPortImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - Broker broker = getParent(Broker.class, parents); - return new HttpPortImpl(attributes, broker); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java index 47185659a7..a52b22a62c 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java @@ -25,10 +25,12 @@ import java.util.Map; import java.util.Set; import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.Protocol; public class HttpPortImpl extends AbstractPortWithAuthProvider<HttpPortImpl> implements HttpPort<HttpPortImpl> { + @ManagedObjectFactoryConstructor public HttpPortImpl(final Map<String, Object> attributes, final Broker<?> broker) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java deleted file mode 100644 index bb1b94f57d..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.port; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.Port; - -public class JmxPortFactory extends AbstractConfiguredObjectTypeFactory<JmxPortImpl> -{ - public JmxPortFactory() - { - super(JmxPortImpl.class); - } - - @Override - public JmxPortImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - Broker broker = getParent(Broker.class, parents); - return new JmxPortImpl(attributes, broker); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortImpl.java index f908b1818e..a71298e0e1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortImpl.java @@ -25,10 +25,12 @@ import java.util.Map; import java.util.Set; import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.Protocol; public class JmxPortImpl extends AbstractPortWithAuthProvider<JmxPortImpl> implements JmxPort<JmxPortImpl> { + @ManagedObjectFactoryConstructor public JmxPortImpl(final Map<String, Object> attributes, final Broker<?> broker) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java index 122421347e..99ec4b79cb 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java @@ -31,10 +31,12 @@ import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.Protocol.ProtocolType; import org.apache.qpid.server.model.Transport; import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.UnresolvedConfiguredObject; import org.apache.qpid.server.util.MapValueConverter; +@PluggableService public class PortFactory<X extends Port<X>> implements ConfiguredObjectTypeFactory<X> { public static final int DEFAULT_AMQP_SEND_BUFFER_SIZE = 262144; 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 69a61b3c12..b6beedd05d 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 @@ -27,12 +27,14 @@ import java.util.Set; import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.Transport; @ManagedObject( category = false, type = "RMI") public class RmiPort extends AbstractPort<RmiPort> { + @ManagedObjectFactoryConstructor public RmiPort(final Map<String, Object> attributes, final Broker<?> broker) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java deleted file mode 100644 index f234ea3ba7..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.port; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.Port; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -public class RmiPortFactory extends AbstractConfiguredObjectTypeFactory<RmiPort> -{ - public RmiPortFactory() - { - super(RmiPort.class); - } - - @Override - public RmiPort createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - Broker broker = getParent(Broker.class, parents); - return new RmiPort(attributes, broker); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueFactory.java deleted file mode 100644 index ee2edf7961..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.queue; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public class LastValueQueueFactory extends AbstractConfiguredObjectTypeFactory<LastValueQueueImpl> -{ - public LastValueQueueFactory() - { - super(LastValueQueueImpl.class); - } - - @Override - protected LastValueQueueImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - VirtualHost<?,?,?> virtualHost = getParent(VirtualHost.class, parents); - if (!(virtualHost instanceof VirtualHostImpl)) - { - throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); - } - - return new LastValueQueueImpl(attributes, (VirtualHostImpl<?,?,?>)virtualHost); - } -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueImpl.java index b1dff03329..4eef4bc6c8 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueImpl.java @@ -24,6 +24,7 @@ package org.apache.qpid.server.queue; import java.util.Map; import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class LastValueQueueImpl extends AbstractQueue<LastValueQueueImpl> implements LastValueQueue<LastValueQueueImpl> @@ -33,7 +34,7 @@ public class LastValueQueueImpl extends AbstractQueue<LastValueQueueImpl> implem @ManagedAttributeField private String _lvqKey; - + @ManagedObjectFactoryConstructor public LastValueQueueImpl(Map<String, Object> attributes, VirtualHostImpl virtualHost) { super(attributes, virtualHost); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueFactory.java deleted file mode 100644 index d35ad2b0fe..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.queue; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public class PriorityQueueFactory extends AbstractConfiguredObjectTypeFactory<PriorityQueueImpl> -{ - public PriorityQueueFactory() - { - super(PriorityQueueImpl.class); - } - - @Override - protected PriorityQueueImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - VirtualHost<?,?,?> virtualHost = getParent(VirtualHost.class, parents); - if (!(virtualHost instanceof VirtualHostImpl)) - { - throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); - } - - return new PriorityQueueImpl(attributes, (VirtualHostImpl<?,?,?>)virtualHost); - } -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueImpl.java index b06e196095..eb87748302 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueImpl.java @@ -26,6 +26,7 @@ import org.apache.qpid.server.logging.LogMessage; import org.apache.qpid.server.logging.messages.QueueMessages; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class PriorityQueueImpl extends OutOfOrderQueue<PriorityQueueImpl> implements PriorityQueue<PriorityQueueImpl> @@ -36,6 +37,7 @@ public class PriorityQueueImpl extends OutOfOrderQueue<PriorityQueueImpl> implem @ManagedAttributeField private int _priorities; + @ManagedObjectFactoryConstructor public PriorityQueueImpl(Map<String, Object> attributes, VirtualHostImpl virtualHost) { super(attributes, virtualHost); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java index d8575b17c0..19265ef453 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java @@ -27,9 +27,11 @@ import org.apache.qpid.server.model.ConfiguredObjectFactory; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.UnresolvedConfiguredObject; +@PluggableService public class QueueFactory<X extends Queue<X>> implements ConfiguredObjectTypeFactory<X> { @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueFactory.java deleted file mode 100644 index e584e7d8dd..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.queue; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public class SortedQueueFactory extends AbstractConfiguredObjectTypeFactory<SortedQueueImpl> -{ - public SortedQueueFactory() - { - super(SortedQueueImpl.class); - } - - @Override - protected SortedQueueImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - VirtualHost<?,?,?> virtualHost = getParent(VirtualHost.class, parents); - if (!(virtualHost instanceof VirtualHostImpl)) - { - throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); - } - - return new SortedQueueImpl(attributes, (VirtualHostImpl<?,?,?>)virtualHost); - } -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueImpl.java index f04b3acfe3..1d61e6fc22 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueImpl.java @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.qpid.server.message.MessageInstance; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.virtualhost.VirtualHostImpl; @@ -38,6 +39,7 @@ public class SortedQueueImpl extends OutOfOrderQueue<SortedQueueImpl> implements private String _sortKey; private SortedQueueEntryList _entries; + @ManagedObjectFactoryConstructor public SortedQueueImpl(Map<String, Object> attributes, VirtualHostImpl virtualHost) { super(attributes, virtualHost); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java deleted file mode 100644 index b0a4e2a96e..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.queue; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public class StandardQueueFactory extends AbstractConfiguredObjectTypeFactory<StandardQueueImpl> -{ - public StandardQueueFactory() - { - super(StandardQueueImpl.class); - } - - @Override - protected StandardQueueImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - VirtualHost<?,?,?> virtualHost = getParent(VirtualHost.class, parents); - if (!(virtualHost instanceof VirtualHostImpl)) - { - throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName()); - } - - return new StandardQueueImpl(attributes, (VirtualHostImpl<?,?,?>)virtualHost); - } -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java index 22390dde5f..6175cf3617 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java @@ -22,12 +22,14 @@ package org.apache.qpid.server.queue; import java.util.Map; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.virtualhost.VirtualHostImpl; public class StandardQueueImpl extends AbstractQueue<StandardQueueImpl> implements StandardQueue<StandardQueueImpl> { private StandardQueueEntryList _entries; + @ManagedObjectFactoryConstructor public StandardQueueImpl(final Map<String, Object> arguments, final VirtualHostImpl virtualHost) { super(arguments, virtualHost); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreFactory.java deleted file mode 100644 index 5aff83b109..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.security; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; - -public class FileKeyStoreFactory extends AbstractConfiguredObjectTypeFactory<FileKeyStoreImpl> -{ - public FileKeyStoreFactory() - { - super(FileKeyStoreImpl.class); - } - - - @Override - public FileKeyStoreImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - return new FileKeyStoreImpl(attributes, getParent(Broker.class, parents)); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java index ac5e334402..adfce94dc8 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java @@ -45,6 +45,7 @@ import org.apache.qpid.server.model.IntegrityViolationException; import org.apache.qpid.server.model.KeyStore; import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.State; import org.apache.qpid.server.security.access.Operation; @@ -82,6 +83,7 @@ public class FileKeyStoreImpl extends AbstractConfiguredObject<FileKeyStoreImpl> private Broker<?> _broker; + @ManagedObjectFactoryConstructor public FileKeyStoreImpl(Map<String, Object> attributes, Broker<?> broker) { super(parentsMap(broker), attributes); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreFactory.java deleted file mode 100644 index 0375cb0e3f..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.security; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; - -public class FileTrustStoreFactory extends AbstractConfiguredObjectTypeFactory<FileTrustStoreImpl> -{ - public FileTrustStoreFactory() - { - super(FileTrustStoreImpl.class); - } - - @Override - public FileTrustStoreImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents) - { - return new FileTrustStoreImpl(attributes, getParent(Broker.class, parents)); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java index aad09ca21e..08fccda4e8 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java @@ -41,6 +41,7 @@ import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.IntegrityViolationException; import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.TrustStore; @@ -66,6 +67,7 @@ public class FileTrustStoreImpl extends AbstractConfiguredObject<FileTrustStoreI private Broker<?> _broker; + @ManagedObjectFactoryConstructor public FileTrustStoreImpl(Map<String, Object> attributes, Broker<?> broker) { super(parentsMap(broker), attributes); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java index 4c3324f038..7f37c4e39f 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java @@ -19,16 +19,18 @@ */ package org.apache.qpid.server.security.auth.manager; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; 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.plugin.AuthenticationManagerFactory; +import org.apache.qpid.server.plugin.PluggableService; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - +@PluggableService public class AnonymousAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<AnonymousAuthenticationManager> implements AuthenticationManagerFactory<AnonymousAuthenticationManager> { public static final String PROVIDER_TYPE = "Anonymous"; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java index 18b2b00a6d..2fb9fd4ac3 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java @@ -32,11 +32,13 @@ 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.plugin.AuthenticationManagerFactory; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.ResolvedObject; import org.apache.qpid.server.store.UnresolvedConfiguredObject; import org.apache.qpid.server.util.ResourceBundleLoader; +@PluggableService public class Base64MD5PasswordFileAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<Base64MD5PasswordDatabaseAuthenticationManager> implements AuthenticationManagerFactory<Base64MD5PasswordDatabaseAuthenticationManager> diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java index 327243fc71..967dbedc36 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java @@ -29,8 +29,10 @@ 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.plugin.AuthenticationManagerFactory; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.util.ResourceBundleLoader; +@PluggableService public class ExternalAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<ExternalAuthenticationManagerImpl> implements AuthenticationManagerFactory<ExternalAuthenticationManagerImpl> { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java index f8c2ac043e..36c389bbdd 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java @@ -28,7 +28,9 @@ 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.plugin.AuthenticationManagerFactory; +import org.apache.qpid.server.plugin.PluggableService; +@PluggableService public class KerberosAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<KerberosAuthenticationManager> implements AuthenticationManagerFactory<KerberosAuthenticationManager> diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactory.java index 13755e52fc..5fa054a363 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactory.java @@ -32,11 +32,13 @@ 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.plugin.AuthenticationManagerFactory; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.ResolvedObject; import org.apache.qpid.server.store.UnresolvedConfiguredObject; import org.apache.qpid.server.util.ResourceBundleLoader; +@PluggableService public class PlainPasswordFileAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<PlainPasswordDatabaseAuthenticationManager> implements AuthenticationManagerFactory<PlainPasswordDatabaseAuthenticationManager> diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramAuthUser.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramAuthUser.java new file mode 100644 index 0000000000..e9d4e00254 --- /dev/null +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramAuthUser.java @@ -0,0 +1,223 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.security.auth.manager; + +import java.security.AccessControlException; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.security.sasl.SaslException; + +import org.apache.qpid.server.configuration.updater.VoidTask; +import org.apache.qpid.server.model.AbstractConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; +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.security.access.Operation; + +@ManagedObject( category = false, type = "scram") +class ScramAuthUser extends AbstractConfiguredObject<ScramAuthUser> implements User<ScramAuthUser> +{ + + private ScramSHA1AuthenticationManager _authenticationManager; + @ManagedAttributeField + private String _password; + + @ManagedObjectFactoryConstructor + ScramAuthUser(final Map<String, Object> attributes, ScramSHA1AuthenticationManager parent) + { + super(parentsMap(parent), attributes); + _authenticationManager = parent; + if(!ScramSHA1AuthenticationManager.ASCII.newEncoder().canEncode(getName())) + { + throw new IllegalArgumentException("Scram SHA1 user names are restricted to characters in the ASCII charset"); + } + + } + + @Override + protected void onOpen() + { + super.onOpen(); + _authenticationManager.getUserMap().put(getName(), this); + } + + @Override + public void validate() + { + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + @Override + protected boolean setState(final State currentState, final State desiredState) + { + if(desiredState == State.DELETED) + { + _authenticationManager.getSecurityManager().authoriseUserOperation(Operation.DELETE, getName()); + _authenticationManager.getUserMap().remove(getName()); + _authenticationManager.doDeleted(); + deleted(); + return true; + } + else + { + return false; + } + } + + @Override + public void setAttributes(final Map<String, Object> attributes) + throws IllegalStateException, AccessControlException, IllegalArgumentException + { + runTask(new VoidTask() + { + + @Override + public void execute() + { + Map<String, Object> modifiedAttributes = new HashMap<String, Object>(attributes); + final String newPassword = (String) attributes.get(User.PASSWORD); + if (attributes.containsKey(User.PASSWORD) + && !newPassword.equals(getActualAttributes().get(User.PASSWORD))) + { + try + { + modifiedAttributes.put(User.PASSWORD, + _authenticationManager.createStoredPassword(newPassword)); + } + catch (SaslException e) + { + throw new IllegalArgumentException(e); + } + } + ScramAuthUser.super.setAttributes(modifiedAttributes); + } + }); + + + } + + @Override + public Object getAttribute(final String name) + { + return super.getAttribute(name); + } + + @Override + public String getPassword() + { + return _password; + } + + @Override + public void setPassword(final String password) + { + _authenticationManager.getSecurityManager().authoriseUserOperation(Operation.UPDATE, getName()); + + try + { + changeAttribute(User.PASSWORD, getAttribute(User.PASSWORD), _authenticationManager.createStoredPassword( + password)); + } + catch (SaslException e) + { + throw new IllegalArgumentException(e); + } + } + + @Override + public State getState() + { + return State.ACTIVE; + } + + @Override + public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) + { + return Collections.emptySet(); + } + + @Override + public Map<String, Object> getPreferences() + { + PreferencesProvider preferencesProvider = _authenticationManager.getPreferencesProvider(); + if (preferencesProvider == null) + { + return null; + } + return preferencesProvider.getPreferences(this.getName()); + } + + @Override + public Object getPreference(String name) + { + Map<String, Object> preferences = getPreferences(); + if (preferences == null) + { + return null; + } + return preferences.get(name); + } + + @Override + public Map<String, Object> setPreferences(Map<String, Object> preferences) + { + PreferencesProvider preferencesProvider = _authenticationManager.getPreferencesProvider(); + if (preferencesProvider == null) + { + return null; + } + return preferencesProvider.setPreferences(this.getName(), preferences); + } + + @Override + public boolean deletePreferences() + { + PreferencesProvider preferencesProvider = _authenticationManager.getPreferencesProvider(); + if (preferencesProvider == null) + { + return false; + } + String[] deleted = preferencesProvider.deletePreferences(this.getName()); + return deleted.length == 1; + } + +} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java index 00091490c5..22e34edab1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java @@ -22,17 +22,14 @@ package org.apache.qpid.server.security.auth.manager; import java.io.IOException; import java.nio.charset.Charset; -import java.security.AccessControlException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Principal; import java.security.SecureRandom; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -44,15 +41,11 @@ import javax.security.sasl.SaslServer; import javax.xml.bind.DatatypeConverter; import org.apache.qpid.server.configuration.updater.Task; -import org.apache.qpid.server.configuration.updater.VoidTask; import org.apache.qpid.server.configuration.updater.VoidTaskWithException; -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.ManagedAttributeField; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.PasswordCredentialManagingAuthenticationProvider; -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.security.SecurityManager; @@ -67,7 +60,7 @@ public class ScramSHA1AuthenticationManager implements PasswordCredentialManagingAuthenticationProvider<ScramSHA1AuthenticationManager> { public static final String SCRAM_USER_TYPE = "scram"; - private static final Charset ASCII = Charset.forName("ASCII"); + static final Charset ASCII = Charset.forName("ASCII"); public static final String HMAC_SHA_1 = "HmacSHA1"; private final SecureRandom _random = new SecureRandom(); private int _iterationCount = 4096; @@ -283,7 +276,7 @@ public class ScramSHA1AuthenticationManager }); } - private SecurityManager getSecurityManager() + SecurityManager getSecurityManager() { return getBroker().getSecurityManager(); } @@ -357,187 +350,6 @@ public class ScramSHA1AuthenticationManager } - @ManagedObject( category = false, type = "scram") - static class ScramAuthUser extends AbstractConfiguredObject<ScramAuthUser> implements User<ScramAuthUser> - { - - private ScramSHA1AuthenticationManager _authenticationManager; - @ManagedAttributeField - private String _password; - - protected ScramAuthUser(final Map<String, Object> attributes, ScramSHA1AuthenticationManager parent) - { - super(parentsMap(parent), attributes); - _authenticationManager = parent; - if(!ASCII.newEncoder().canEncode(getName())) - { - throw new IllegalArgumentException("Scram SHA1 user names are restricted to characters in the ASCII charset"); - } - - } - - @Override - protected void onOpen() - { - super.onOpen(); - _authenticationManager._users.put(getName(), this); - } - - @Override - public void validate() - { - super.validate(); - if(!isDurable()) - { - throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); - } - } - - @Override - protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) - { - super.validateChange(proxyForValidation, changedAttributes); - if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) - { - throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); - } - } - @Override - protected boolean setState(final State currentState, final State desiredState) - { - if(desiredState == State.DELETED) - { - _authenticationManager.getSecurityManager().authoriseUserOperation(Operation.DELETE, getName()); - _authenticationManager._users.remove(getName()); - _authenticationManager.deleted(); - deleted(); - return true; - } - else - { - return false; - } - } - - @Override - public void setAttributes(final Map<String, Object> attributes) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - runTask(new VoidTask() - { - - @Override - public void execute() - { - Map<String, Object> modifiedAttributes = new HashMap<String, Object>(attributes); - final String newPassword = (String) attributes.get(User.PASSWORD); - if (attributes.containsKey(User.PASSWORD) - && !newPassword.equals(getActualAttributes().get(User.PASSWORD))) - { - try - { - modifiedAttributes.put(User.PASSWORD, - _authenticationManager.createStoredPassword(newPassword)); - } - catch (SaslException e) - { - throw new IllegalArgumentException(e); - } - } - ScramSHA1AuthenticationManager.ScramAuthUser.super.setAttributes(modifiedAttributes); - } - }); - - - } - - @Override - public Object getAttribute(final String name) - { - return super.getAttribute(name); - } - - @Override - public String getPassword() - { - return _password; - } - - @Override - public void setPassword(final String password) - { - _authenticationManager.getSecurityManager().authoriseUserOperation(Operation.UPDATE, getName()); - - try - { - changeAttribute(User.PASSWORD, getAttribute(User.PASSWORD), _authenticationManager.createStoredPassword( - password)); - } - catch (SaslException e) - { - throw new IllegalArgumentException(e); - } - } - - @Override - public State getState() - { - return State.ACTIVE; - } - - @Override - public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) - { - return Collections.emptySet(); - } - - @Override - public Map<String, Object> getPreferences() - { - PreferencesProvider preferencesProvider = _authenticationManager.getPreferencesProvider(); - if (preferencesProvider == null) - { - return null; - } - return preferencesProvider.getPreferences(this.getName()); - } - - @Override - public Object getPreference(String name) - { - Map<String, Object> preferences = getPreferences(); - if (preferences == null) - { - return null; - } - return preferences.get(name); - } - - @Override - public Map<String, Object> setPreferences(Map<String, Object> preferences) - { - PreferencesProvider preferencesProvider = _authenticationManager.getPreferencesProvider(); - if (preferencesProvider == null) - { - return null; - } - return preferencesProvider.setPreferences(this.getName(), preferences); - } - - @Override - public boolean deletePreferences() - { - PreferencesProvider preferencesProvider = _authenticationManager.getPreferencesProvider(); - if (preferencesProvider == null) - { - return false; - } - String[] deleted = preferencesProvider.deletePreferences(this.getName()); - return deleted.length == 1; - } - - } - @Override public void recoverUser(final User user) { @@ -577,4 +389,13 @@ public class ScramSHA1AuthenticationManager return super.addChild(childClass, attributes, otherParents); } + void doDeleted() + { + deleted(); + } + + Map<String, ScramAuthUser> getUserMap() + { + return _users; + } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java index e4096f6055..30c97dfead 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java @@ -29,7 +29,9 @@ 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.plugin.AuthenticationManagerFactory; +import org.apache.qpid.server.plugin.PluggableService; +@PluggableService public class ScramSHA1AuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<ScramSHA1AuthenticationManager> implements AuthenticationManagerFactory<ScramSHA1AuthenticationManager> diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1UserRecoverer.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1UserRecoverer.java deleted file mode 100644 index b5e369269c..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1UserRecoverer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.security.auth.manager; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.ConfiguredObject; - -import java.util.Map; - -public class ScramSHA1UserRecoverer extends AbstractConfiguredObjectTypeFactory<ScramSHA1AuthenticationManager.ScramAuthUser> -{ - public ScramSHA1UserRecoverer() - { - super(ScramSHA1AuthenticationManager.ScramAuthUser.class); - } - - @Override - public ScramSHA1AuthenticationManager.ScramAuthUser createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new ScramSHA1AuthenticationManager.ScramAuthUser(attributes, (ScramSHA1AuthenticationManager)getParent(AuthenticationProvider.class, parents)); - } -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java index 7dfa128a37..cce7864e26 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java @@ -29,8 +29,10 @@ 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.plugin.AuthenticationManagerFactory; +import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.util.ResourceBundleLoader; +@PluggableService public class SimpleLDAPAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<SimpleLDAPAuthenticationManagerImpl> implements AuthenticationManagerFactory<SimpleLDAPAuthenticationManagerImpl> diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java index b69bd6f45f..ea1f41d7ab 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java @@ -22,9 +22,10 @@ package org.apache.qpid.server.store; import java.util.Map; -import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; +import org.apache.qpid.server.plugin.PluggableService; +@PluggableService public class JsonFileConfigStoreFactory implements DurableConfigurationStoreFactory { @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/transport/TCPandSSLTransportProviderFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/transport/TCPandSSLTransportProviderFactory.java index 9b61d1d037..f255e265a6 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/transport/TCPandSSLTransportProviderFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/transport/TCPandSSLTransportProviderFactory.java @@ -20,14 +20,16 @@ */ package org.apache.qpid.server.transport; -import org.apache.qpid.server.model.Transport; -import org.apache.qpid.server.plugin.TransportProviderFactory; - import java.util.Arrays; import java.util.EnumSet; import java.util.HashSet; import java.util.Set; +import org.apache.qpid.server.model.Transport; +import org.apache.qpid.server.plugin.PluggableService; +import org.apache.qpid.server.plugin.TransportProviderFactory; + +@PluggableService public class TCPandSSLTransportProviderFactory implements TransportProviderFactory { 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 645ee7ceef..2568d7be97 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 @@ -25,6 +25,7 @@ import java.util.Map; import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.VirtualHostNode; import org.apache.qpid.server.plugin.MessageStoreFactory; import org.apache.qpid.server.store.MessageStore; @@ -38,6 +39,7 @@ public class StandardVirtualHost extends AbstractVirtualHost<StandardVirtualHost private MessageStoreLogSubject _messageStoreLogSubject; + @ManagedObjectFactoryConstructor public StandardVirtualHost(final Map<String, Object> attributes, VirtualHostNode<?> virtualHostNode) { super(attributes, virtualHostNode); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java index 87470fb3cf..72c619ec1c 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java @@ -28,7 +28,7 @@ import java.util.Map; import javax.security.auth.Subject; import org.apache.log4j.Logger; -import org.apache.qpid.server.configuration.updater.TaskExecutor; + import org.apache.qpid.server.logging.messages.ConfigStoreMessages; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.BrokerModel; @@ -48,9 +48,10 @@ public abstract class AbstractStandardVirtualHostNode<X extends AbstractStandard { private static final Logger LOGGER = Logger.getLogger(AbstractStandardVirtualHostNode.class); - public AbstractStandardVirtualHostNode(Broker<?> parent, Map<String, Object> attributes, TaskExecutor taskExecutor) + public AbstractStandardVirtualHostNode(Map<String, Object> attributes, + Broker<?> parent) { - super(parent, attributes, taskExecutor); + super(parent, attributes); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java index 1db15003ed..0a67169e4b 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java @@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicReference; import javax.security.auth.Subject; import org.apache.log4j.Logger; -import org.apache.qpid.server.configuration.updater.TaskExecutor; + import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.messages.ConfigStoreMessages; import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject; @@ -66,10 +66,10 @@ public abstract class AbstractVirtualHostNode<X extends AbstractVirtualHostNode< @ManagedAttributeField private boolean _messageStoreProvider; - public AbstractVirtualHostNode(Broker<?> parent, Map<String, Object> attributes, TaskExecutor taskExecutor) + public AbstractVirtualHostNode(Broker<?> parent, Map<String, Object> attributes) { super(Collections.<Class<? extends ConfiguredObject>,ConfiguredObject<?>>singletonMap(Broker.class, parent), - attributes, taskExecutor); + attributes); _broker = parent; SystemContext<?> systemContext = _broker.getParent(SystemContext.class); _eventLogger = systemContext.getEventLogger(); @@ -286,4 +286,4 @@ public abstract class AbstractVirtualHostNode<X extends AbstractVirtualHostNode< protected abstract void activate(); -}
\ No newline at end of file +} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeFactory.java deleted file mode 100644 index 5a753444cc..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.virtualhostnode; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; - -public class JsonVirtualHostNodeFactory extends AbstractConfiguredObjectTypeFactory<JsonVirtualHostNodeImpl> -{ - public JsonVirtualHostNodeFactory() - { - super(JsonVirtualHostNodeImpl.class); - } - - @Override - public JsonVirtualHostNodeImpl createInstance(Map<String, Object> attributes, ConfiguredObject<?>... parents) - { - Broker<?> parent = getParent(Broker.class, parents); - return new JsonVirtualHostNodeImpl(parent, attributes, parent.getTaskExecutor()); - } - -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java index 8f697ada76..f41b794953 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java @@ -22,10 +22,10 @@ package org.apache.qpid.server.virtualhostnode; import java.util.Map; -import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; import org.apache.qpid.server.store.JsonFileConfigStoreFactory; @@ -35,9 +35,10 @@ public class JsonVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<Jso @ManagedAttributeField private String _storePath; - public JsonVirtualHostNodeImpl(Broker<?> parent, Map<String, Object> attributes, TaskExecutor taskExecutor) + @ManagedObjectFactoryConstructor + public JsonVirtualHostNodeImpl(Map<String, Object> attributes, Broker<?> parent) { - super(parent, attributes, taskExecutor); + super(attributes, parent); } @Override diff --git a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AuthenticationManagerFactory b/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AuthenticationManagerFactory deleted file mode 100644 index a1139b386c..0000000000 --- a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AuthenticationManagerFactory +++ /dev/null @@ -1,26 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.Base64MD5PasswordFileAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.KerberosAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.PlainPasswordFileAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.ScramSHA1AuthenticationManagerFactory - diff --git a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfigurationStoreFactory b/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfigurationStoreFactory deleted file mode 100644 index cd314abcae..0000000000 --- a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfigurationStoreFactory +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.configuration.store.factory.JsonConfigurationStoreFactory -org.apache.qpid.server.configuration.store.factory.MemoryConfigurationStoreFactory diff --git a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory b/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory deleted file mode 100644 index 6d8dd61ab1..0000000000 --- a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory +++ /dev/null @@ -1,49 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.security.FileKeyStoreFactory -org.apache.qpid.server.security.FileTrustStoreFactory -org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.Base64MD5PasswordFileAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.KerberosAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.PlainPasswordFileAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.ScramSHA1AuthenticationManagerFactory -org.apache.qpid.server.security.auth.manager.ScramSHA1UserRecoverer -org.apache.qpid.server.model.port.AmqpPortFactory -org.apache.qpid.server.model.port.HttpPortFactory -org.apache.qpid.server.model.port.JmxPortFactory -org.apache.qpid.server.model.port.RmiPortFactory -org.apache.qpid.server.model.port.PortFactory -org.apache.qpid.server.model.adapter.BrokerAdapterFactory -org.apache.qpid.server.model.adapter.StandardVirtualHostFactory -org.apache.qpid.server.model.adapter.FileBasedGroupProviderFactory -org.apache.qpid.server.model.adapter.FileSystemPreferencesProviderFactory -org.apache.qpid.server.queue.LastValueQueueFactory -org.apache.qpid.server.queue.PriorityQueueFactory -org.apache.qpid.server.queue.QueueFactory -org.apache.qpid.server.queue.SortedQueueFactory -org.apache.qpid.server.queue.StandardQueueFactory -org.apache.qpid.server.exchange.DirectExchangeFactory -org.apache.qpid.server.exchange.FanoutExchangeFactory -org.apache.qpid.server.exchange.HeadersExchangeFactory -org.apache.qpid.server.exchange.TopicExchangeFactory -org.apache.qpid.server.binding.BindingFactory -org.apache.qpid.server.virtualhostnode.JsonVirtualHostNodeFactory - diff --git a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.DurableConfigurationStoreFactory b/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.DurableConfigurationStoreFactory deleted file mode 100644 index d183d91f18..0000000000 --- a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.DurableConfigurationStoreFactory +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.store.JsonFileConfigStoreFactory diff --git a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ExchangeType b/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ExchangeType deleted file mode 100644 index 4ad646b7a0..0000000000 --- a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ExchangeType +++ /dev/null @@ -1,22 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.exchange.DirectExchangeType -org.apache.qpid.server.exchange.TopicExchangeType -org.apache.qpid.server.exchange.FanoutExchangeType -org.apache.qpid.server.exchange.HeadersExchangeType diff --git a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.MessageMetaDataType b/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.MessageMetaDataType deleted file mode 100644 index a744bfff53..0000000000 --- a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.MessageMetaDataType +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.message.internal.InternalMessageMetaDataType diff --git a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PreferencesProviderFactory b/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PreferencesProviderFactory deleted file mode 100644 index 9fe8379120..0000000000 --- a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PreferencesProviderFactory +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.model.adapter.FileSystemPreferencesProviderFactory
\ No newline at end of file diff --git a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.TransportProviderFactory b/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.TransportProviderFactory deleted file mode 100644 index 3838a9c39f..0000000000 --- a/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.TransportProviderFactory +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.transport.TCPandSSLTransportProviderFactory
\ No newline at end of file diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java deleted file mode 100644 index 0e792a4929..0000000000 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.server.model.adapter; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.apache.qpid.server.configuration.IllegalConfigurationException; -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.PreferencesProvider; -import org.apache.qpid.server.util.BrokerTestHelper; -import org.apache.qpid.test.utils.QpidTestCase; -import org.apache.qpid.test.utils.TestFileUtils; - -public class FileSystemPreferencesProviderFactoryTest extends QpidTestCase -{ - private AuthenticationProvider _authenticationProvider; - private Broker _broker; - private FileSystemPreferencesProviderFactory _factory; - - public void setUp() throws Exception - { - super.setUp(); - BrokerTestHelper.setUp(); - _authenticationProvider = mock(AuthenticationProvider.class); - _broker = BrokerTestHelper.createBrokerMock(); - when(_authenticationProvider.getParent(Broker.class)).thenReturn(_broker); - ConfiguredObjectFactory objectFactory = _broker.getObjectFactory(); - when(_authenticationProvider.getModel()).thenReturn(objectFactory.getModel()); - when(_authenticationProvider.getObjectFactory()).thenReturn(objectFactory); - when(_authenticationProvider.getCategoryClass()).thenReturn(AuthenticationProvider.class); - - _factory = new FileSystemPreferencesProviderFactory(); - } - - public void tearDown() throws Exception - { - try - { - BrokerTestHelper.tearDown(); - } - finally - { - super.tearDown(); - } - } - - public void testGetType() - { - assertEquals(FileSystemPreferencesProvider.PROVIDER_TYPE, _factory.getType()); - } - - public void testCreateInstanceRecovering() - { - Map<String, Object> attributes = new HashMap<String, Object>(); - UUID id = UUID.randomUUID(); - attributes.put(PreferencesProvider.TYPE, "FileSystemPreferences"); - attributes.put(PreferencesProvider.NAME, "test-provider"); - File file = TestFileUtils.createTempFile(this, ".prefs.json", "{\"test_user\":{\"pref1\": \"pref1Value\", \"pref2\": 1.0} }"); - try - { - attributes.put(FileSystemPreferencesProvider.PATH, file.getAbsolutePath()); - attributes.put(ConfiguredObject.ID, id); - PreferencesProvider provider = _factory.create(null, attributes, _authenticationProvider); - assertNotNull("Preferences provider was not instantiated", provider); - assertEquals("Unexpected name", "test-provider", provider.getName()); - assertEquals("Unexpected id", id, provider.getId()); - assertEquals("Unexpected path", file.getAbsolutePath(), - provider.getAttribute(FileSystemPreferencesProvider.PATH)); - } - finally - { - file.delete(); - } - } - - public void testCreateInstanceRecoveringWhenPrefStoreDoesNotExist() - { - Map<String, Object> attributes = new HashMap<String, Object>(); - UUID id = UUID.randomUUID(); - attributes.put(PreferencesProvider.TYPE, "FileSystemPreferences"); - attributes.put(PreferencesProvider.NAME, "test-provider"); - File file = new File(TMP_FOLDER, UUID.randomUUID() + "prefs.json"); - assertFalse("Preferences store file should not exist", file.exists()); - try - { - attributes.put(FileSystemPreferencesProvider.PATH, file.getAbsolutePath()); - attributes.put(ConfiguredObject.ID, id); - _factory.create(null, attributes, _authenticationProvider); - } - catch (IllegalConfigurationException e) - { - // exception should be thrown if preferences store does not exist - } - } - - public void testCreateInstanceNotRecovering() - { - Map<String, Object> attributes = new HashMap<String, Object>(); - UUID id = UUID.randomUUID(); - attributes.put(PreferencesProvider.TYPE, "FileSystemPreferences"); - attributes.put(PreferencesProvider.NAME, "test-provider"); - File file = new File(TMP_FOLDER, UUID.randomUUID() + "prefs.json"); - assertFalse("Preferences store file should not exist", file.exists()); - try - { - attributes.put(FileSystemPreferencesProvider.PATH, file.getAbsolutePath()); - attributes.put(ConfiguredObject.ID, id); - PreferencesProvider provider = _factory.create(null, attributes, _authenticationProvider); - assertNotNull("Preferences provider was not recovered", provider); - assertEquals("Unexpected name", "test-provider", provider.getName()); - assertEquals("Unexpected id", id, provider.getId()); - assertEquals("Unexpected path", file.getAbsolutePath(), provider.getAttribute( - FileSystemPreferencesProvider.PATH)); - assertTrue("Preferences store file should exist", file.exists()); - } - finally - { - file.delete(); - } - } - -} diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java index dc13c24f5d..68fcf3b868 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java @@ -108,7 +108,7 @@ public class AbstractStandardVirtualHostNodeTest extends QpidTestCase nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME); nodeAttributes.put(VirtualHostNode.ID, _nodeId); - VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, _taskExecutor, _configStore); + VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, _configStore); node.open(); node.setDesiredState(node.getState(), State.ACTIVE); @@ -138,7 +138,7 @@ public class AbstractStandardVirtualHostNodeTest extends QpidTestCase nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME); nodeAttributes.put(VirtualHostNode.ID, _nodeId); - VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, _taskExecutor, _configStore); + VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, _configStore); node.open(); node.setDesiredState(node.getState(), State.ACTIVE); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNode.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNode.java index e129ce778f..eda07bd846 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNode.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNode.java @@ -23,7 +23,6 @@ package org.apache.qpid.server.virtualhostnode; import java.util.Collections; import java.util.Map; -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.plugin.DurableConfigurationStoreFactory; @@ -36,14 +35,16 @@ public class TestVirtualHostNode extends AbstractStandardVirtualHostNode<TestVir { private final DurableConfigurationStore _store; - public TestVirtualHostNode(Broker<?> parent, Map<String, Object> attributes, TaskExecutor taskExecutor) + public TestVirtualHostNode(Broker<?> parent, Map<String, Object> attributes) { - this(parent, attributes, taskExecutor, null); + this(parent, attributes, null); } - public TestVirtualHostNode(Broker<?> parent, Map<String, Object> attributes, TaskExecutor taskExecutor, DurableConfigurationStore store) + public TestVirtualHostNode(Broker<?> parent, + Map<String, Object> attributes, + DurableConfigurationStore store) { - super(parent, attributes, taskExecutor); + super(attributes, parent); _store = store; } @@ -82,4 +83,4 @@ public class TestVirtualHostNode extends AbstractStandardVirtualHostNode<TestVir { return Collections.<String, Object>singletonMap(MessageStore.STORE_TYPE, TestMemoryMessageStore.TYPE); } -}
\ No newline at end of file +} diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNodeFactory.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNodeFactory.java index 2f21c21e67..5018e50e0d 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNodeFactory.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNodeFactory.java @@ -37,7 +37,7 @@ public class TestVirtualHostNodeFactory extends AbstractConfiguredObjectTypeFact public TestVirtualHostNode createInstance(Map<String, Object> attributes, ConfiguredObject<?>... parents) { Broker<?> broker = getParent(Broker.class, parents); - return new TestVirtualHostNode(broker, attributes, broker.getTaskExecutor()); + return new TestVirtualHostNode(broker, attributes); } } |
