summaryrefslogtreecommitdiff
path: root/qpid/java/broker-core
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-04-30 01:22:13 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-04-30 01:22:13 +0000
commitae71aa7102a41735e49ec5c98409bc69fffd9a8f (patch)
treef0709ee8c5993d6995e5de59c0cdc855a540614e /qpid/java/broker-core
parent0d49f2fa419a414e1c9548001fcbde03d442f5c1 (diff)
downloadqpid-python-ae71aa7102a41735e49ec5c98409bc69fffd9a8f.tar.gz
QPID-5578 : [Java Broker] Use annotation to allow registration of all ConfiguredObject types at startup. Use this meta data for REST servlets. Remove unnecessary pluggable factory interfaces
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1591170 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-core')
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java13
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java12
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java50
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeImpl.java5
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java14
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java49
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java13
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java50
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java13
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java49
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java4
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java6
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java491
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObjectTypeFactory.java6
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java4
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java608
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java4
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java1
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java130
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java37
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java49
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectRegistration.java (renamed from qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java)13
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java51
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java33
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java6
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java3
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java63
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java7
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java93
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java5
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java71
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationProviderAttributeDescriptions.properties19
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java3
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java64
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PasswordFileAuthenticationProviderAttributeDescriptions.properties19
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java7
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactory.java96
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java3
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java72
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java15
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java86
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationProviderAttributeDescriptions.properties24
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupProviderAttributeDescriptions.properties19
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java4
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java8
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java6
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java6
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java16
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java22
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java5
57 files changed, 808 insertions, 1653 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
index 1f0f20ef1b..72f0365240 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
@@ -56,7 +56,6 @@ import org.apache.qpid.server.model.ManagedAttributeField;
import org.apache.qpid.server.model.Publisher;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.BaseQueue;
import org.apache.qpid.server.store.StorableMessageMetaData;
@@ -168,7 +167,7 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>>
super.onOpen();
// Log Exchange creation
- getEventLogger().message(ExchangeMessages.CREATED(getExchangeType().getType(), getName(), isDurable()));
+ getEventLogger().message(ExchangeMessages.CREATED(getType(), getName(), isDurable()));
}
@Override
@@ -188,14 +187,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>>
return _virtualHost.getEventLogger();
}
- public abstract ExchangeType<T> getExchangeType();
-
- @Override
- public String getTypeName()
- {
- return getExchangeType().getType();
- }
-
public boolean isAutoDelete()
{
return getLifetimePolicy() != LifetimePolicy.PERMANENT;
@@ -210,7 +201,7 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>>
throw new ExchangeIsAlternateException(getName());
}
- if(getExchangeType().getDefaultExchangeName().equals( getName() ))
+ if(isReservedExchangeName(getName()))
{
throw new RequiredExchangeException(getName());
}
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 026182f7f3..4997095315 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
@@ -32,6 +32,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
import org.apache.log4j.Logger;
+import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.binding.BindingImpl;
import org.apache.qpid.server.filter.AMQInvalidArgumentException;
import org.apache.qpid.server.filter.FilterSupport;
@@ -41,12 +42,11 @@ 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;
import org.apache.qpid.server.virtualhost.VirtualHostImpl;
-@ManagedObject( category = false, type = "direct" )
+@ManagedObject( category = false, type = ExchangeDefaults.DIRECT_EXCHANGE_CLASS )
public class DirectExchange extends AbstractExchange<DirectExchange>
{
@@ -136,8 +136,6 @@ public class DirectExchange extends AbstractExchange<DirectExchange>
private final ConcurrentHashMap<String, BindingSet> _bindingsByKey =
new ConcurrentHashMap<String, BindingSet>();
- public static final ExchangeType<DirectExchange> TYPE = new DirectExchangeType();
-
@ManagedObjectFactoryConstructor
public DirectExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost)
{
@@ -145,12 +143,6 @@ public class DirectExchange extends AbstractExchange<DirectExchange>
}
@Override
- public ExchangeType<DirectExchange> getExchangeType()
- {
- return TYPE;
- }
-
- @Override
public List<? extends BaseQueue> doRoute(ServerMessage payload,
final String routingKey,
final InstanceProperties instanceProperties)
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
deleted file mode 100644
index b26991a50a..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java
+++ /dev/null
@@ -1,50 +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.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
- public String getType()
- {
- return ExchangeDefaults.DIRECT_EXCHANGE_CLASS;
- }
-
- @Override
- public DirectExchange newInstance(final VirtualHostImpl virtualHost,
- final Map<String, Object> attributes)
- {
- return new DirectExchange(attributes, virtualHost);
- }
-
- public String getDefaultExchangeName()
- {
- return ExchangeDefaults.DIRECT_EXCHANGE_NAME;
- }
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeImpl.java
index 38913762d8..bd515f3951 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeImpl.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeImpl.java
@@ -27,7 +27,6 @@ import org.apache.qpid.server.binding.BindingImpl;
import org.apache.qpid.server.logging.EventLogger;
import org.apache.qpid.server.message.MessageDestination;
import org.apache.qpid.server.model.Exchange;
-import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.AMQQueue;
public interface ExchangeImpl<T extends ExchangeImpl<T>> extends Exchange<T>, ExchangeReferrer, MessageDestination
@@ -37,10 +36,6 @@ public interface ExchangeImpl<T extends ExchangeImpl<T>> extends Exchange<T>, Ex
String getName();
- ExchangeType<T> getExchangeType();
-
- String getTypeName();
-
boolean isDurable();
/**
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 cba9852d80..a72cbd6396 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
@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.log4j.Logger;
+import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.binding.BindingImpl;
import org.apache.qpid.server.filter.AMQInvalidArgumentException;
import org.apache.qpid.server.filter.FilterSupport;
@@ -38,12 +39,11 @@ 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;
import org.apache.qpid.server.virtualhost.VirtualHostImpl;
-@ManagedObject( category = false, type = "fanout" )
+@ManagedObject( category = false, type = ExchangeDefaults.FANOUT_EXCHANGE_CLASS )
public class FanoutExchange extends AbstractExchange<FanoutExchange>
{
private static final Logger _logger = Logger.getLogger(FanoutExchange.class);
@@ -64,10 +64,6 @@ public class FanoutExchange extends AbstractExchange<FanoutExchange>
_filteredBindings.set(emptyMap);
}
-
-
- public static final ExchangeType<FanoutExchange> TYPE = new FanoutExchangeType();
-
@ManagedObjectFactoryConstructor
public FanoutExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost)
{
@@ -75,12 +71,6 @@ public class FanoutExchange extends AbstractExchange<FanoutExchange>
}
@Override
- public ExchangeType<FanoutExchange> getExchangeType()
- {
- return TYPE;
- }
-
- @Override
public ArrayList<BaseQueue> doRoute(ServerMessage payload,
final String routingKey,
final InstanceProperties instanceProperties)
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
deleted file mode 100644
index 1c90b7925b..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java
+++ /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.
- *
- */
-package org.apache.qpid.server.exchange;
-
-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
- public String getType()
- {
- return ExchangeDefaults.FANOUT_EXCHANGE_CLASS;
- }
-
- @Override
- public FanoutExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes)
- {
- return new FanoutExchange(attributes, virtualHost);
- }
-
- public String getDefaultExchangeName()
- {
- return ExchangeDefaults.FANOUT_EXCHANGE_NAME;
- }
-}
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 e49d9ea632..74c393c10f 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
@@ -30,13 +30,13 @@ import java.util.concurrent.CopyOnWriteArraySet;
import org.apache.log4j.Logger;
+import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.binding.BindingImpl;
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;
import org.apache.qpid.server.virtualhost.VirtualHostImpl;
@@ -68,7 +68,7 @@ import org.apache.qpid.server.virtualhost.VirtualHostImpl;
* amq.match - pub/sub on field content/value
* </pre>
*/
-@ManagedObject( category = false, type = "headers" )
+@ManagedObject( category = false, type = ExchangeDefaults.HEADERS_EXCHANGE_CLASS )
public class HeadersExchange extends AbstractExchange<HeadersExchange>
{
@@ -80,9 +80,6 @@ public class HeadersExchange extends AbstractExchange<HeadersExchange>
private final CopyOnWriteArrayList<HeadersBinding> _bindingHeaderMatchers =
new CopyOnWriteArrayList<HeadersBinding>();
-
- public static final ExchangeType<HeadersExchange> TYPE = new HeadersExchangeType();
-
@ManagedObjectFactoryConstructor
public HeadersExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost)
{
@@ -90,12 +87,6 @@ public class HeadersExchange extends AbstractExchange<HeadersExchange>
}
@Override
- public ExchangeType<HeadersExchange> getExchangeType()
- {
- return TYPE;
- }
-
- @Override
public ArrayList<BaseQueue> doRoute(ServerMessage payload,
final String routingKey,
final InstanceProperties instanceProperties)
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
deleted file mode 100644
index c9346f6e28..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java
+++ /dev/null
@@ -1,50 +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.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
- public String getType()
- {
- return ExchangeDefaults.HEADERS_EXCHANGE_CLASS;
- }
-
- @Override
- public HeadersExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes)
- {
- return new HeadersExchange(attributes, virtualHost);
- }
-
- public String getDefaultExchangeName()
- {
-
- return ExchangeDefaults.HEADERS_EXCHANGE_NAME;
- }
-}
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 edc6fa7796..40a8a8f7ee 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
@@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.log4j.Logger;
+import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.binding.BindingImpl;
import org.apache.qpid.server.exchange.topic.TopicExchangeResult;
import org.apache.qpid.server.exchange.topic.TopicMatcherResult;
@@ -42,18 +43,14 @@ 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;
import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.apache.qpid.server.virtualhost.VirtualHostImpl;
-@ManagedObject( category = false, type = "topic" )
+@ManagedObject( category = false, type = ExchangeDefaults.TOPIC_EXCHANGE_CLASS )
public class TopicExchange extends AbstractExchange<TopicExchange>
{
- public static final ExchangeType<TopicExchange> TYPE = new TopicExchangeType();
-
-
private static final Logger _logger = Logger.getLogger(TopicExchange.class);
private final TopicParser _parser = new TopicParser();
@@ -70,12 +67,6 @@ public class TopicExchange extends AbstractExchange<TopicExchange>
}
@Override
- public ExchangeType<TopicExchange> getExchangeType()
- {
- return TYPE;
- }
-
- @Override
protected synchronized void onBindingUpdated(final BindingImpl binding, final Map<String, Object> oldArguments)
{
final String bindingKey = binding.getBindingKey();
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
deleted file mode 100644
index dc2a526278..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java
+++ /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.
- *
- */
-package org.apache.qpid.server.exchange;
-
-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
- public String getType()
- {
- return ExchangeDefaults.TOPIC_EXCHANGE_CLASS;
- }
-
- @Override
- public TopicExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes)
- {
- return new TopicExchange(attributes, virtualHost);
- }
-
- public String getDefaultExchangeName()
- {
- return ExchangeDefaults.TOPIC_EXCHANGE_NAME;
- }
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java
index 7400eb8221..c5951a1a8b 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java
@@ -23,7 +23,6 @@ package org.apache.qpid.server.logging.subjects;
import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.BINDING_FORMAT;
import org.apache.qpid.server.exchange.ExchangeImpl;
-import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.virtualhost.VirtualHostImpl;
@@ -43,10 +42,9 @@ public class BindingLogSubject extends AbstractLogSubject
AMQQueue queue)
{
VirtualHostImpl virtualHost = queue.getVirtualHost();
- ExchangeType exchangeType = exchange.getExchangeType();
setLogStringWithFormat(BINDING_FORMAT,
virtualHost.getName(),
- exchangeType.getType(),
+ exchange.getType(),
exchange.getName(),
queue.getName(),
routingKey);
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java
index 946b8dada5..1039e24a18 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java
@@ -20,11 +20,11 @@
*/
package org.apache.qpid.server.logging.subjects;
+import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.EXCHANGE_FORMAT;
+
import org.apache.qpid.server.exchange.ExchangeImpl;
import org.apache.qpid.server.virtualhost.VirtualHostImpl;
-import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.EXCHANGE_FORMAT;
-
public class ExchangeLogSubject extends AbstractLogSubject
{
@@ -32,6 +32,6 @@ public class ExchangeLogSubject extends AbstractLogSubject
public ExchangeLogSubject(ExchangeImpl exchange, VirtualHostImpl vhost)
{
setLogStringWithFormat(EXCHANGE_FORMAT, vhost.getName(),
- exchange.getExchangeType().getType(), exchange.getName());
+ exchange.getType(), exchange.getName());
}
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
index 8b0e726c54..0199693bda 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
@@ -22,7 +22,6 @@ package org.apache.qpid.server.model;
import java.io.IOException;
import java.io.StringWriter;
-import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -30,11 +29,9 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.security.AccessControlException;
import java.security.PrivilegedAction;
-import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -42,8 +39,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -75,19 +70,6 @@ import org.apache.qpid.util.Strings;
public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> implements ConfiguredObject<X>
{
-
- private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?,?>>> _allAttributes =
- Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?, ?>>>());
-
- private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectStatistic<?,?>>> _allStatistics =
- Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectStatistic<?, ?>>>());
-
- private static final Map<Class<? extends ConfiguredObject>, Map<String, ConfiguredObjectAttribute<?,?>>> _allAttributeTypes =
- Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, ConfiguredObjectAttribute<?, ?>>>());
-
- private static final Map<Class<? extends ConfiguredObject>, Map<String, AutomatedField>> _allAutomatedFields =
- Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, AutomatedField>>());
-
private static final Map<Class, Object> SECURE_VALUES;
public static final String SECURED_STRING_VALUE = "********";
@@ -106,9 +88,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
SECURE_VALUES = Collections.unmodifiableMap(secureValues);
}
- private static final Map<String, String> _defaultContext =
- Collections.synchronizedMap(new HashMap<String, String>());
-
private final AtomicBoolean _open = new AtomicBoolean();
private final Map<String,Object> _attributes = new HashMap<String, Object>();
@@ -162,7 +141,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
private LifetimePolicy _lifetimePolicy;
private final Map<String, ConfiguredObjectAttribute<?,?>> _attributeTypes;
- private final Map<String, AutomatedField> _automatedFields;
+ private final Map<String, ConfiguredObjectTypeRegistry.AutomatedField> _automatedFields;
@ManagedAttributeField
private String _type;
@@ -203,10 +182,10 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
_taskExecutor = taskExecutor;
_model = model;
- _category = Model.getCategory(getClass());
+ _category = ConfiguredObjectTypeRegistry.getCategory(getClass());
- _attributeTypes = getAttributeTypes(getClass());
- _automatedFields = getAutomatedFields(getClass());
+ _attributeTypes = ConfiguredObjectTypeRegistry.getAttributeTypes(getClass());
+ _automatedFields = ConfiguredObjectTypeRegistry.getAutomatedFields(getClass());
Object idObj = attributes.get(ID);
@@ -228,7 +207,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
throw new IllegalArgumentException("The name attribute is mandatory for " + getClass().getSimpleName() + " creation.");
}
- _type = Model.getType(getClass());
+ _type = ConfiguredObjectTypeRegistry.getType(getClass());
_bestFitInterface = calculateBestFitInterface();
if(attributes.get(TYPE) != null && !_type.equals(attributes.get(TYPE)))
@@ -359,7 +338,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
{
value = attribute.getAnnotation().defaultValue();
}
- AutomatedField field = _automatedFields.get(name);
+ ConfiguredObjectTypeRegistry.AutomatedField field = _automatedFields.get(name);
if(field.getPreSettingAction() != null)
{
@@ -834,7 +813,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
public final Collection<String> getAttributeNames()
{
- return getAttributeNames(getClass());
+ return ConfiguredObjectTypeRegistry.getAttributeNames(getClass());
}
@Override
@@ -988,13 +967,13 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
@Override
public final <C extends ConfiguredObject> C getChildById(final Class<C> clazz, final UUID id)
{
- return (C) _childrenById.get(Model.getCategory(clazz)).get(id);
+ return (C) _childrenById.get(ConfiguredObjectTypeRegistry.getCategory(clazz)).get(id);
}
@Override
public final <C extends ConfiguredObject> C getChildByName(final Class<C> clazz, final String name)
{
- Class<? extends ConfiguredObject> categoryClass = Model.getCategory(clazz);
+ Class<? extends ConfiguredObject> categoryClass = ConfiguredObjectTypeRegistry.getCategory(clazz);
if(getModel().getParentTypes(categoryClass).size() != 1)
{
throw new UnsupportedOperationException("Cannot use getChildByName for objects of category "
@@ -1135,7 +1114,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
@Override
public Map<String,Number> getStatistics()
{
- Collection<ConfiguredObjectStatistic> stats = getStatistics(getClass());
+ Collection<ConfiguredObjectStatistic> stats = ConfiguredObjectTypeRegistry.getStatistics(getClass());
Map<String,Number> map = new HashMap<String,Number>();
for(ConfiguredObjectStatistic stat : stats)
{
@@ -1147,7 +1126,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
public <Y extends ConfiguredObject<Y>> Y findConfiguredObject(Class<Y> clazz, String name)
{
- Collection<Y> reachable = getReachableObjects(this,clazz);
+ Collection<Y> reachable = getModel().getReachableObjects(this, clazz);
for(Y candidate : reachable)
{
if(candidate.getName().equals(name))
@@ -1181,7 +1160,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
new Strings.MapResolver(inheritedContext),
Strings.JAVA_SYS_PROPS_RESOLVER,
Strings.ENV_VARS_RESOLVER,
- new Strings.MapResolver(_defaultContext));
+ ConfiguredObjectTypeRegistry.getDefaultContextResolver());
}
private static OwnAttributeResolver getOwnAttributeResolver(final ConfiguredObject<?> object)
@@ -1210,452 +1189,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
}
}
- private static class AutomatedField
- {
- private final Field _field;
- private final Method _preSettingAction;
- private final Method _postSettingAction;
-
- private AutomatedField(final Field field, final Method preSettingAction, final Method postSettingAction)
- {
- _field = field;
- _preSettingAction = preSettingAction;
- _postSettingAction = postSettingAction;
- }
-
- public Field getField()
- {
- return _field;
- }
-
- public Method getPreSettingAction()
- {
- return _preSettingAction;
- }
-
- public Method getPostSettingAction()
- {
- return _postSettingAction;
- }
- }
-
- private static final Comparator<ConfiguredObjectAttributeOrStatistic<?,?>> NAME_COMPARATOR = new Comparator<ConfiguredObjectAttributeOrStatistic<?, ?>>()
- {
- @Override
- public int compare(final ConfiguredObjectAttributeOrStatistic<?, ?> left,
- final ConfiguredObjectAttributeOrStatistic<?, ?> right)
- {
- return left.getName().compareTo(right.getName());
- }
- };
-
- private static <X extends ConfiguredObject> void processAttributes(final Class<X> clazz)
- {
- synchronized (_allAttributes)
- {
- if(_allAttributes.containsKey(clazz))
- {
- return;
- }
-
-
- for(Class<?> parent : clazz.getInterfaces())
- {
- if(ConfiguredObject.class.isAssignableFrom(parent))
- {
- processAttributes((Class<? extends ConfiguredObject>)parent);
- }
- }
- final Class<? super X> superclass = clazz.getSuperclass();
- if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass))
- {
- processAttributes((Class<? extends ConfiguredObject>) superclass);
- }
-
- final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet = new TreeSet<>(NAME_COMPARATOR);
- final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet = new TreeSet<>(NAME_COMPARATOR);
-
- _allAttributes.put(clazz, attributeSet);
- _allStatistics.put(clazz, statisticSet);
-
- for(Class<?> parent : clazz.getInterfaces())
- {
- if(ConfiguredObject.class.isAssignableFrom(parent))
- {
- Collection<ConfiguredObjectAttribute<?, ?>> attrs = _allAttributes.get(parent);
- for(ConfiguredObjectAttribute<?,?> attr : attrs)
- {
- if(!attributeSet.contains(attr))
- {
- attributeSet.add(attr);
- }
- }
- Collection<ConfiguredObjectStatistic<?, ?>> stats = _allStatistics.get(parent);
- for(ConfiguredObjectStatistic<?,?> stat : stats)
- {
- if(!statisticSet.contains(stat))
- {
- statisticSet.add(stat);
- }
- }
- }
- }
- if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass))
- {
- Collection<ConfiguredObjectAttribute<?, ?>> attrs = _allAttributes.get(superclass);
- Collection<ConfiguredObjectStatistic<?, ?>> stats = _allStatistics.get(superclass);
- for(ConfiguredObjectAttribute<?,?> attr : attrs)
- {
- if(!attributeSet.contains(attr))
- {
- attributeSet.add(attr);
- }
- }
- for(ConfiguredObjectStatistic<?,?> stat : stats)
- {
- if(!statisticSet.contains(stat))
- {
- statisticSet.add(stat);
- }
- }
- }
-
-
- for(Method m : clazz.getDeclaredMethods())
- {
- ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class);
- if(annotation != null)
- {
- if(!(annotation.automate() || annotation.derived() || annotation.state()))
- {
- throw new ServerScopedRuntimeException("ManagedAttributes must be either automated or derived. " + m.getName() + " on " + clazz.getSimpleName() + " does not meet this criterion.");
- }
- if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz))
- {
- throw new ServerScopedRuntimeException("Can only define ManagedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria.");
- }
-
- ConfiguredObjectAttribute attribute = new ConfiguredObjectAttribute(clazz, m, annotation);
- if(attributeSet.contains(attribute))
- {
- attributeSet.remove(attribute);
- }
- attributeSet.add(attribute);
- }
- else
- {
- ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class);
- if(statAnnotation != null)
- {
- if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz))
- {
- throw new ServerScopedRuntimeException("Can only define ManagedStatistics on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria.");
- }
- ConfiguredObjectStatistic statistic = new ConfiguredObjectStatistic(clazz, m);
- if(statisticSet.contains(statistic))
- {
- statisticSet.remove(statistic);
- }
- statisticSet.add(statistic);
- }
- }
- }
-
- Map<String,ConfiguredObjectAttribute<?,?>> attrMap = new HashMap<String, ConfiguredObjectAttribute<?, ?>>();
- Map<String,AutomatedField> fieldMap = new HashMap<String, AutomatedField>();
-
-
- Collection<ConfiguredObjectAttribute<?, ?>> attrCol = _allAttributes.get(clazz);
- for(ConfiguredObjectAttribute<?,?> attr : attrCol)
- {
- attrMap.put(attr.getName(), attr);
- if(attr.getAnnotation().automate())
- {
- fieldMap.put(attr.getName(), findField(attr, clazz));
- }
-
- }
- _allAttributeTypes.put(clazz, attrMap);
- _allAutomatedFields.put(clazz, fieldMap);
-
- for(Field field : clazz.getDeclaredFields())
- {
- if(Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.isAnnotationPresent(ManagedContextDefault.class))
- {
- try
- {
- String name = field.getAnnotation(ManagedContextDefault.class).name();
- Object value = field.get(null);
- if(!_defaultContext.containsKey(name))
- {
- _defaultContext.put(name,String.valueOf(value));
- }
- else
- {
- throw new IllegalArgumentException("Multiple definitions of the default context variable ${"+name+"}");
- }
- }
- catch (IllegalAccessException e)
- {
- throw new ServerScopedRuntimeException("Unkecpected illegal access exception (only inspecting public static fields)", e);
- }
- }
- }
- }
- }
-
- private static AutomatedField findField(final ConfiguredObjectAttribute<?, ?> attr, Class<?> objClass)
- {
- Class<?> clazz = objClass;
- while(clazz != null)
- {
- for(Field field : clazz.getDeclaredFields())
- {
- if(field.isAnnotationPresent(ManagedAttributeField.class) && field.getName().equals("_" + attr.getName().replace('.','_')))
- {
- try
- {
- ManagedAttributeField annotation = field.getAnnotation(ManagedAttributeField.class);
- field.setAccessible(true);
- Method beforeSet;
- if (!"".equals(annotation.beforeSet()))
- {
- beforeSet = clazz.getDeclaredMethod(annotation.beforeSet());
- beforeSet.setAccessible(true);
- }
- else
- {
- beforeSet = null;
- }
- Method afterSet;
- if (!"".equals(annotation.afterSet()))
- {
- afterSet = clazz.getDeclaredMethod(annotation.afterSet());
- afterSet.setAccessible(true);
- }
- else
- {
- afterSet = null;
- }
- return new AutomatedField(field, beforeSet, afterSet);
- }
- catch (NoSuchMethodException e)
- {
- throw new ServerScopedRuntimeException("Cannot find method referenced by annotation for pre/post setting action", e);
- }
-
- }
- }
- clazz = clazz.getSuperclass();
- }
- if(objClass.isInterface() || Modifier.isAbstract(objClass.getModifiers()))
- {
- return null;
- }
- throw new ServerScopedRuntimeException("Unable to find field definition for automated field " + attr.getName() + " in class " + objClass.getName());
- }
-
- public static <X extends ConfiguredObject> Collection<String> getAttributeNames(Class<X> clazz)
- {
- final Collection<ConfiguredObjectAttribute<? super X, ?>> attrs = getAttributes(clazz);
-
- return new AbstractCollection<String>()
- {
- @Override
- public Iterator<String> iterator()
- {
- final Iterator<ConfiguredObjectAttribute<? super X, ?>> underlyingIterator = attrs.iterator();
- return new Iterator<String>()
- {
- @Override
- public boolean hasNext()
- {
- return underlyingIterator.hasNext();
- }
-
- @Override
- public String next()
- {
- return underlyingIterator.next().getName();
- }
-
- @Override
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- @Override
- public int size()
- {
- return attrs.size();
- }
- };
-
- }
-
- protected static <X extends ConfiguredObject> Collection<ConfiguredObjectAttribute<? super X, ?>> getAttributes(final Class<X> clazz)
- {
- if(!_allAttributes.containsKey(clazz))
- {
- processAttributes(clazz);
- }
- final Collection<ConfiguredObjectAttribute<? super X, ?>> attributes = (Collection) _allAttributes.get(clazz);
- return attributes;
- }
-
-
- protected static Collection<ConfiguredObjectStatistic> getStatistics(final Class<? extends ConfiguredObject> clazz)
- {
- if(!_allStatistics.containsKey(clazz))
- {
- processAttributes(clazz);
- }
- final Collection<ConfiguredObjectStatistic> statistics = (Collection) _allStatistics.get(clazz);
- return statistics;
- }
-
-
- private static Map<String, ConfiguredObjectAttribute<?, ?>> getAttributeTypes(final Class<? extends ConfiguredObject> clazz)
- {
- if(!_allAttributeTypes.containsKey(clazz))
- {
- processAttributes(clazz);
- }
- return _allAttributeTypes.get(clazz);
- }
-
- private static Map<String, AutomatedField> getAutomatedFields(Class<? extends ConfiguredObject> clazz)
- {
- if(!_allAutomatedFields.containsKey(clazz))
- {
- processAttributes(clazz);
- }
- return _allAutomatedFields.get(clazz);
- }
-
- static <X extends ConfiguredObject<X>> Collection<X> getReachableObjects(final ConfiguredObject<?> object,
- final Class<X> clazz)
- {
- Class<? extends ConfiguredObject> category = Model.getCategory(object.getClass());
- Class<? extends ConfiguredObject> ancestorClass = getAncestorClassWithGivenDescendant(object.getModel(),category, clazz);
- if(ancestorClass != null)
- {
- ConfiguredObject ancestor = getAncestor(ancestorClass, category, object);
- if(ancestor != null)
- {
- return getAllDescendants(ancestor, ancestorClass, clazz);
- }
- }
- return null;
- }
-
- private static <X extends ConfiguredObject<X>> Collection<X> getAllDescendants(final ConfiguredObject ancestor,
- final Class<? extends ConfiguredObject> ancestorClass,
- final Class<X> clazz)
- {
- Set<X> descendants = new HashSet<X>();
- for(Class<? extends ConfiguredObject> childClass : ancestor.getModel().getChildTypes(ancestorClass))
- {
- Collection<? extends ConfiguredObject> children = ancestor.getChildren(childClass);
- if(childClass == clazz)
- {
-
- if(children != null)
- {
- descendants.addAll((Collection<X>)children);
- }
- }
- else
- {
- if(children != null)
- {
- for(ConfiguredObject child : children)
- {
- descendants.addAll(getAllDescendants(child, childClass, clazz));
- }
- }
- }
- }
- return descendants;
- }
-
- private static ConfiguredObject getAncestor(final Class<? extends ConfiguredObject> ancestorClass,
- final Class<? extends ConfiguredObject> category,
- final ConfiguredObject<?> object)
- {
- if(ancestorClass.isInstance(object))
- {
- return object;
- }
- else
- {
- for(Class<? extends ConfiguredObject> parentClass : object.getModel().getParentTypes(category))
- {
- ConfiguredObject parent = object.getParent(parentClass);
- if(parent == null)
- {
- System.err.println(parentClass.getSimpleName());
- }
- ConfiguredObject ancestor = getAncestor(ancestorClass, parentClass, parent);
- if(ancestor != null)
- {
- return ancestor;
- }
- }
- }
- return null;
- }
-
- private static Class<? extends ConfiguredObject> getAncestorClassWithGivenDescendant(
- final Model model, final Class<? extends ConfiguredObject> category,
- final Class<? extends ConfiguredObject> descendantClass)
- {
- Collection<Class<? extends ConfiguredObject>> candidateClasses =
- Collections.<Class<? extends ConfiguredObject>>singleton(category);
- while(!candidateClasses.isEmpty())
- {
- for(Class<? extends ConfiguredObject> candidate : candidateClasses)
- {
- if(hasDescendant(model, candidate, descendantClass))
- {
- return candidate;
- }
- }
- Set<Class<? extends ConfiguredObject>> previous = new HashSet<Class<? extends ConfiguredObject>>(candidateClasses);
- candidateClasses = new HashSet<Class<? extends ConfiguredObject>>();
- for(Class<? extends ConfiguredObject> prev : previous)
- {
- candidateClasses.addAll(model.getParentTypes(prev));
- }
- }
- return null;
- }
-
- private static boolean hasDescendant(final Model model, final Class<? extends ConfiguredObject> candidate,
- final Class<? extends ConfiguredObject> descendantClass)
- {
- int oldSize = 0;
-
- Set<Class<? extends ConfiguredObject>> allDescendants = new HashSet<Class<? extends ConfiguredObject>>(model.getChildTypes(
- candidate));
- while(allDescendants.size() > oldSize)
- {
- oldSize = allDescendants.size();
- Set<Class<? extends ConfiguredObject>> prev = new HashSet<Class<? extends ConfiguredObject>>(allDescendants);
- for(Class<? extends ConfiguredObject> clazz : prev)
- {
- allDescendants.addAll(model.getChildTypes(clazz));
- }
- if(allDescendants.contains(descendantClass))
- {
- break;
- }
- }
- return allDescendants.contains(descendantClass);
- }
private static class OwnAttributeResolver implements Strings.Resolver
{
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 ec8b2d94fe..d0bc1c3436 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
@@ -40,13 +40,13 @@ abstract public class AbstractConfiguredObjectTypeFactory<X extends AbstractConf
@Override
public final String getType()
{
- return Model.getType(_clazz);
+ return ConfiguredObjectTypeRegistry.getType(_clazz);
}
@Override
public final Class<? super X> getCategoryClass()
{
- return (Class<? super X>) Model.getCategory(_clazz);
+ return (Class<? super X>) ConfiguredObjectTypeRegistry.getCategory(_clazz);
}
@Override
@@ -65,7 +65,7 @@ abstract public class AbstractConfiguredObjectTypeFactory<X extends AbstractConf
{
if(!parents[0].getModel().getParentTypes((Class<? extends ConfiguredObject>) getCategoryClass()).contains(
- Model.getCategory(parentClass)))
+ ConfiguredObjectTypeRegistry.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/AbstractUnresolvedObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java
index 617419d828..b9dc1f4071 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java
@@ -50,7 +50,7 @@ public abstract class AbstractUnresolvedObject<C extends ConfiguredObject<C>> im
_parents = parents;
Collection<ConfiguredObjectAttribute<? super C, ?>> attributes =
- AbstractConfiguredObject.getAttributes(clazz);
+ ConfiguredObjectTypeRegistry.getAttributes(clazz);
for(ConfiguredObjectAttribute<? super C, ?> attribute : attributes)
{
final Class<?> attributeType = attribute.getType();
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
index 828643273a..d2f90378cf 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
@@ -620,7 +620,7 @@ abstract class AttributeValueConverter<T>
}
else if(value instanceof UUID)
{
- Collection<X> reachable = AbstractConfiguredObject.getReachableObjects(object, _klazz);
+ Collection<X> reachable = object.getModel().getReachableObjects(object, _klazz);
for(X candidate : reachable)
{
if(candidate.getId().equals(value))
@@ -633,7 +633,7 @@ abstract class AttributeValueConverter<T>
else if(value instanceof String)
{
String valueStr = AbstractConfiguredObject.interpolate(object, (String) value);
- Collection<X> reachable = AbstractConfiguredObject.getReachableObjects(object, _klazz);
+ Collection<X> reachable = object.getModel().getReachableObjects(object, _klazz);
for(X candidate : reachable)
{
if(candidate.getName().equals(valueStr))
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java
index 0c8866fff1..2f80d9fecc 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java
@@ -175,4 +175,6 @@ abstract class ConfiguredObjectAttributeOrStatistic<C extends ConfiguredObject,
{
return _converter;
}
+
+
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
new file mode 100644
index 0000000000..0a99912df1
--- /dev/null
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
@@ -0,0 +1,608 @@
+/*
+ *
+ * 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;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;
+import org.apache.qpid.server.plugin.QpidServiceLoader;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
+import org.apache.qpid.util.Strings;
+
+public class ConfiguredObjectTypeRegistry
+{
+ private static final Comparator<ConfiguredObjectAttributeOrStatistic<?,?>> NAME_COMPARATOR = new Comparator<ConfiguredObjectAttributeOrStatistic<?, ?>>()
+ {
+ @Override
+ public int compare(final ConfiguredObjectAttributeOrStatistic<?, ?> left,
+ final ConfiguredObjectAttributeOrStatistic<?, ?> right)
+ {
+ return left.getName().compareTo(right.getName());
+ }
+ };
+
+
+ private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?,?>>> _allAttributes =
+ Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?, ?>>>());
+
+ private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectStatistic<?,?>>> _allStatistics =
+ Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectStatistic<?, ?>>>());
+
+ private static final Map<Class<? extends ConfiguredObject>, Map<String, ConfiguredObjectAttribute<?,?>>> _allAttributeTypes =
+ Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, ConfiguredObjectAttribute<?, ?>>>());
+
+ private static final Map<Class<? extends ConfiguredObject>, Map<String, AutomatedField>> _allAutomatedFields =
+ Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, AutomatedField>>());
+
+ private static final Map<String, String> _defaultContext =
+ Collections.synchronizedMap(new HashMap<String, String>());
+
+ private static final Map<Class<? extends ConfiguredObject>,Set<Class<? extends ConfiguredObject>>> _knownTypes =
+ Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Set<Class<? extends ConfiguredObject>>>());
+
+ private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?,?>>> _typeSpecificAttributes =
+ Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?, ?>>>());
+
+
+ static
+ {
+ QpidServiceLoader<ConfiguredObjectRegistration> loader = new QpidServiceLoader<>();
+
+ Set<Class<? extends ConfiguredObject>> categories = new HashSet<>();
+ Set<Class<? extends ConfiguredObject>> types = new HashSet<>();
+
+ for (ConfiguredObjectRegistration registration : loader.instancesOf(ConfiguredObjectRegistration.class))
+ {
+ for (Class<? extends ConfiguredObject> configuredObjectClass : registration.getConfiguredObjectClasses())
+ {
+ processAttributes(configuredObjectClass);
+ ManagedObject annotation = configuredObjectClass.getAnnotation(ManagedObject.class);
+ if (annotation.category())
+ {
+ categories.add(configuredObjectClass);
+ }
+ if (!"".equals(annotation.type()))
+ {
+ types.add(configuredObjectClass);
+ }
+ }
+ }
+ for (Class<? extends ConfiguredObject> categoryClass : categories)
+ {
+ _knownTypes.put(categoryClass, new HashSet<Class<? extends ConfiguredObject>>());
+ }
+
+ for (Class<? extends ConfiguredObject> typeClass : types)
+ {
+ for (Class<? extends ConfiguredObject> categoryClass : categories)
+ {
+ if (categoryClass.isAssignableFrom(typeClass))
+ {
+ _knownTypes.get(categoryClass).add(typeClass);
+ }
+ }
+ }
+
+ for (Class<? extends ConfiguredObject> categoryClass : categories)
+ {
+ Set<Class<? extends ConfiguredObject>> typesForCategory = _knownTypes.get(categoryClass);
+ if (typesForCategory.isEmpty())
+ {
+ typesForCategory.add(categoryClass);
+ _typeSpecificAttributes.put(categoryClass, Collections.<ConfiguredObjectAttribute<?, ?>>emptySet());
+ }
+ else
+ {
+ Set<String> commonAttributes = new HashSet<>();
+ for(ConfiguredObjectAttribute<?,?> attribute : _allAttributes.get(categoryClass))
+ {
+ commonAttributes.add(attribute.getName());
+ }
+ for(Class<? extends ConfiguredObject> typeClass : typesForCategory)
+ {
+ Set<ConfiguredObjectAttribute<?,?>> attributes = new HashSet<>();
+ for(ConfiguredObjectAttribute<?,?> attr : _allAttributes.get(typeClass))
+ {
+ if(!commonAttributes.contains(attr.getName()))
+ {
+ attributes.add(attr);
+ }
+ }
+ _typeSpecificAttributes.put(typeClass, attributes);
+ }
+
+ }
+ }
+ }
+
+ public static Class<? extends ConfiguredObject> getCategory(final Class<?> clazz)
+ {
+ ManagedObject annotation = clazz.getAnnotation(ManagedObject.class);
+ if(annotation != null && annotation.category())
+ {
+ return (Class<? extends ConfiguredObject>) clazz;
+ }
+ for(Class<?> iface : clazz.getInterfaces() )
+ {
+ Class<? extends ConfiguredObject> cat = getCategory(iface);
+ if(cat != null)
+ {
+ return cat;
+ }
+ }
+ if(clazz.getSuperclass() != null)
+ {
+ return getCategory(clazz.getSuperclass());
+ }
+ return null;
+ }
+
+ public static Class<? extends ConfiguredObject> getTypeClass(final Class<? extends ConfiguredObject> clazz)
+ {
+ String typeName = getType(clazz);
+ Class<? extends ConfiguredObject> typeClass = null;
+ if(typeName != null)
+ {
+ Class<? extends ConfiguredObject> category = getCategory(clazz);
+ Set<Class<? extends ConfiguredObject>> types = _knownTypes.get(category);
+ for(Class<? extends ConfiguredObject> type : types)
+ {
+ ManagedObject annotation = type.getAnnotation(ManagedObject.class);
+ if(typeName.equals(annotation.type()))
+ {
+ typeClass = type;
+ break;
+ }
+ }
+ if(typeClass == null && typeName.equals(category.getSimpleName()))
+ {
+ typeClass = category;
+ }
+ }
+
+ return typeClass;
+
+ }
+
+ public static Collection<Class<? extends ConfiguredObject>> getTypeSpecialisations(Class<? extends ConfiguredObject> clazz)
+ {
+ Class<? extends ConfiguredObject> categoryClass = getCategory(clazz);
+ if(categoryClass == null)
+ {
+ throw new IllegalArgumentException("Cannot locate ManagedObject information for " + clazz.getName());
+ }
+ return Collections.unmodifiableCollection(_knownTypes.get(categoryClass));
+
+ }
+
+ public static Collection<ConfiguredObjectAttribute<?,?>> getTypeSpecificAttributes(Class<? extends ConfiguredObject> clazz)
+ {
+ Class<? extends ConfiguredObject> typeClass = getTypeClass(clazz);
+ if(typeClass == null)
+ {
+ throw new IllegalArgumentException("Cannot locate ManagedObject information for " + clazz.getName());
+ }
+ return Collections.unmodifiableCollection(_typeSpecificAttributes.get(typeClass));
+ }
+
+ public static String getType(final Class<? extends ConfiguredObject> clazz)
+ {
+ String type = getActualType(clazz);
+
+ if("".equals(type))
+ {
+ Class<? extends ConfiguredObject> category = getCategory(clazz);
+ if (category == null)
+ {
+ throw new IllegalArgumentException("No category for " + clazz.getSimpleName());
+ }
+ ManagedObject annotation = category.getAnnotation(ManagedObject.class);
+ if (annotation == null)
+ {
+ throw new NullPointerException("No definition found for category " + category.getSimpleName());
+ }
+ if (!"".equals(annotation.defaultType()))
+ {
+ type = annotation.defaultType();
+ }
+ else
+ {
+ type = category.getSimpleName();
+ }
+ }
+ return type;
+ }
+
+ private static String getActualType(final Class<? extends ConfiguredObject> clazz)
+ {
+ ManagedObject annotation = clazz.getAnnotation(ManagedObject.class);
+ if(annotation != null)
+ {
+ if(!"".equals(annotation.type()))
+ {
+ return annotation.type();
+ }
+ }
+
+ for(Class<?> iface : clazz.getInterfaces() )
+ {
+ if(ConfiguredObject.class.isAssignableFrom(iface))
+ {
+ String type = getActualType((Class<? extends ConfiguredObject>) iface);
+ if(!"".equals(type))
+ {
+ return type;
+ }
+ }
+ }
+
+ if(clazz.getSuperclass() != null && ConfiguredObject.class.isAssignableFrom(clazz.getSuperclass()))
+ {
+ String type = getActualType((Class<? extends ConfiguredObject>) clazz.getSuperclass());
+ if(!"".equals(type))
+ {
+ return type;
+ }
+ }
+
+ return "";
+ }
+
+ public static Strings.Resolver getDefaultContextResolver()
+ {
+ return new Strings.MapResolver(_defaultContext);
+ }
+
+ static class AutomatedField
+ {
+ private final Field _field;
+ private final Method _preSettingAction;
+ private final Method _postSettingAction;
+
+ private AutomatedField(final Field field, final Method preSettingAction, final Method postSettingAction)
+ {
+ _field = field;
+ _preSettingAction = preSettingAction;
+ _postSettingAction = postSettingAction;
+ }
+
+ public Field getField()
+ {
+ return _field;
+ }
+
+ public Method getPreSettingAction()
+ {
+ return _preSettingAction;
+ }
+
+ public Method getPostSettingAction()
+ {
+ return _postSettingAction;
+ }
+ }
+
+
+
+
+ private static <X extends ConfiguredObject> void processAttributes(final Class<X> clazz)
+ {
+ synchronized (_allAttributes)
+ {
+ if(_allAttributes.containsKey(clazz))
+ {
+ return;
+ }
+
+
+ for(Class<?> parent : clazz.getInterfaces())
+ {
+ if(ConfiguredObject.class.isAssignableFrom(parent))
+ {
+ processAttributes((Class<? extends ConfiguredObject>)parent);
+ }
+ }
+ final Class<? super X> superclass = clazz.getSuperclass();
+ if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass))
+ {
+ processAttributes((Class<? extends ConfiguredObject>) superclass);
+ }
+
+ final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet = new TreeSet<>(NAME_COMPARATOR);
+ final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet = new TreeSet<>(NAME_COMPARATOR);
+
+ _allAttributes.put(clazz, attributeSet);
+ _allStatistics.put(clazz, statisticSet);
+
+ for(Class<?> parent : clazz.getInterfaces())
+ {
+ if(ConfiguredObject.class.isAssignableFrom(parent))
+ {
+ Collection<ConfiguredObjectAttribute<?, ?>> attrs = _allAttributes.get(parent);
+ for(ConfiguredObjectAttribute<?,?> attr : attrs)
+ {
+ if(!attributeSet.contains(attr))
+ {
+ attributeSet.add(attr);
+ }
+ }
+ Collection<ConfiguredObjectStatistic<?, ?>> stats = _allStatistics.get(parent);
+ for(ConfiguredObjectStatistic<?,?> stat : stats)
+ {
+ if(!statisticSet.contains(stat))
+ {
+ statisticSet.add(stat);
+ }
+ }
+ }
+ }
+ if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass))
+ {
+ Collection<ConfiguredObjectAttribute<?, ?>> attrs = _allAttributes.get(superclass);
+ Collection<ConfiguredObjectStatistic<?, ?>> stats = _allStatistics.get(superclass);
+ for(ConfiguredObjectAttribute<?,?> attr : attrs)
+ {
+ if(!attributeSet.contains(attr))
+ {
+ attributeSet.add(attr);
+ }
+ }
+ for(ConfiguredObjectStatistic<?,?> stat : stats)
+ {
+ if(!statisticSet.contains(stat))
+ {
+ statisticSet.add(stat);
+ }
+ }
+ }
+
+
+ for(Method m : clazz.getDeclaredMethods())
+ {
+ ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class);
+ if(annotation != null)
+ {
+ if(!(annotation.automate() || annotation.derived() || annotation.state()))
+ {
+ throw new ServerScopedRuntimeException("ManagedAttributes must be either automated or derived. " + m.getName() + " on " + clazz.getSimpleName() + " does not meet this criterion.");
+ }
+ if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz))
+ {
+ throw new ServerScopedRuntimeException("Can only define ManagedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria.");
+ }
+
+ ConfiguredObjectAttribute<?,?> attribute = new ConfiguredObjectAttribute(clazz, m, annotation);
+ if(attributeSet.contains(attribute))
+ {
+ attributeSet.remove(attribute);
+ }
+ attributeSet.add(attribute);
+ }
+ else
+ {
+ ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class);
+ if(statAnnotation != null)
+ {
+ if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz))
+ {
+ throw new ServerScopedRuntimeException("Can only define ManagedStatistics on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria.");
+ }
+ ConfiguredObjectStatistic statistic = new ConfiguredObjectStatistic(clazz, m);
+ if(statisticSet.contains(statistic))
+ {
+ statisticSet.remove(statistic);
+ }
+ statisticSet.add(statistic);
+ }
+ }
+ }
+
+ Map<String,ConfiguredObjectAttribute<?,?>> attrMap = new HashMap<String, ConfiguredObjectAttribute<?, ?>>();
+ Map<String,AutomatedField> fieldMap = new HashMap<String, AutomatedField>();
+
+
+ Collection<ConfiguredObjectAttribute<?, ?>> attrCol = _allAttributes.get(clazz);
+ for(ConfiguredObjectAttribute<?,?> attr : attrCol)
+ {
+ attrMap.put(attr.getName(), attr);
+ if(attr.getAnnotation().automate())
+ {
+ fieldMap.put(attr.getName(), findField(attr, clazz));
+ }
+
+ }
+ _allAttributeTypes.put(clazz, attrMap);
+ _allAutomatedFields.put(clazz, fieldMap);
+
+ for(Field field : clazz.getDeclaredFields())
+ {
+ if(Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.isAnnotationPresent(ManagedContextDefault.class))
+ {
+ try
+ {
+ String name = field.getAnnotation(ManagedContextDefault.class).name();
+ Object value = field.get(null);
+ if(!_defaultContext.containsKey(name))
+ {
+ _defaultContext.put(name,String.valueOf(value));
+ }
+ else
+ {
+ throw new IllegalArgumentException("Multiple definitions of the default context variable ${"+name+"}");
+ }
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ServerScopedRuntimeException("Unkecpected illegal access exception (only inspecting public static fields)", e);
+ }
+ }
+ }
+ }
+ }
+
+ private static AutomatedField findField(final ConfiguredObjectAttribute<?, ?> attr, Class<?> objClass)
+ {
+ Class<?> clazz = objClass;
+ while(clazz != null)
+ {
+ for(Field field : clazz.getDeclaredFields())
+ {
+ if(field.isAnnotationPresent(ManagedAttributeField.class) && field.getName().equals("_" + attr.getName().replace('.','_')))
+ {
+ try
+ {
+ ManagedAttributeField annotation = field.getAnnotation(ManagedAttributeField.class);
+ field.setAccessible(true);
+ Method beforeSet;
+ if (!"".equals(annotation.beforeSet()))
+ {
+ beforeSet = clazz.getDeclaredMethod(annotation.beforeSet());
+ beforeSet.setAccessible(true);
+ }
+ else
+ {
+ beforeSet = null;
+ }
+ Method afterSet;
+ if (!"".equals(annotation.afterSet()))
+ {
+ afterSet = clazz.getDeclaredMethod(annotation.afterSet());
+ afterSet.setAccessible(true);
+ }
+ else
+ {
+ afterSet = null;
+ }
+ return new AutomatedField(field, beforeSet, afterSet);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new ServerScopedRuntimeException("Cannot find method referenced by annotation for pre/post setting action", e);
+ }
+
+ }
+ }
+ clazz = clazz.getSuperclass();
+ }
+ if(objClass.isInterface() || Modifier.isAbstract(objClass.getModifiers()))
+ {
+ return null;
+ }
+ throw new ServerScopedRuntimeException("Unable to find field definition for automated field " + attr.getName() + " in class " + objClass.getName());
+ }
+
+ public static <X extends ConfiguredObject> Collection<String> getAttributeNames(Class<X> clazz)
+ {
+ final Collection<ConfiguredObjectAttribute<? super X, ?>> attrs = getAttributes(clazz);
+
+ return new AbstractCollection<String>()
+ {
+ @Override
+ public Iterator<String> iterator()
+ {
+ final Iterator<ConfiguredObjectAttribute<? super X, ?>> underlyingIterator = attrs.iterator();
+ return new Iterator<String>()
+ {
+ @Override
+ public boolean hasNext()
+ {
+ return underlyingIterator.hasNext();
+ }
+
+ @Override
+ public String next()
+ {
+ return underlyingIterator.next().getName();
+ }
+
+ @Override
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ @Override
+ public int size()
+ {
+ return attrs.size();
+ }
+ };
+
+ }
+
+ protected static <X extends ConfiguredObject> Collection<ConfiguredObjectAttribute<? super X, ?>> getAttributes(final Class<X> clazz)
+ {
+ if(!_allAttributes.containsKey(clazz))
+ {
+ processAttributes(clazz);
+ }
+ final Collection<ConfiguredObjectAttribute<? super X, ?>> attributes = (Collection) _allAttributes.get(clazz);
+ return attributes;
+ }
+
+
+ protected static Collection<ConfiguredObjectStatistic> getStatistics(final Class<? extends ConfiguredObject> clazz)
+ {
+ if(!_allStatistics.containsKey(clazz))
+ {
+ processAttributes(clazz);
+ }
+ final Collection<ConfiguredObjectStatistic> statistics = (Collection) _allStatistics.get(clazz);
+ return statistics;
+ }
+
+
+ static Map<String, ConfiguredObjectAttribute<?, ?>> getAttributeTypes(final Class<? extends ConfiguredObject> clazz)
+ {
+ if(!_allAttributeTypes.containsKey(clazz))
+ {
+ processAttributes(clazz);
+ }
+ return _allAttributeTypes.get(clazz);
+ }
+
+ static Map<String, AutomatedField> getAutomatedFields(Class<? extends ConfiguredObject> clazz)
+ {
+ if(!_allAutomatedFields.containsKey(clazz))
+ {
+ processAttributes(clazz);
+ }
+ return _allAutomatedFields.get(clazz);
+ }
+
+
+
+}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java
index 54d69fe516..57b06817f7 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java
@@ -22,6 +22,8 @@ package org.apache.qpid.server.model;
public interface ExternalFileBasedAuthenticationManager<X extends ExternalFileBasedAuthenticationManager<X>> extends PasswordCredentialManagingAuthenticationProvider<X>
{
- @ManagedAttribute( automate = true , mandatory = true )
+ String PATH = "path";
+
+ @ManagedAttribute( automate = true , mandatory = true, description = "File location")
public String getPath();
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java
index 53f5fbc0d9..bf42335620 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java
@@ -34,4 +34,5 @@ public @interface ManagedAttribute
boolean mandatory() default false;
boolean persist() default true;
String defaultValue() default "";
+ String description() default "";
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java
index f04ce311b9..790ed74afb 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java
@@ -22,93 +22,127 @@
package org.apache.qpid.server.model;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
public abstract class Model
{
- public static Class<? extends ConfiguredObject> getCategory(final Class<?> clazz)
+ <X extends ConfiguredObject<X>> Collection<X> getReachableObjects(final ConfiguredObject<?> object,
+ final Class<X> clazz)
{
- ManagedObject annotation = clazz.getAnnotation(ManagedObject.class);
- if(annotation != null && annotation.category())
+ Class<? extends ConfiguredObject> category = ConfiguredObjectTypeRegistry.getCategory(object.getClass());
+ Class<? extends ConfiguredObject> ancestorClass = getAncestorClassWithGivenDescendant(category, clazz);
+ if(ancestorClass != null)
{
- return (Class<? extends ConfiguredObject>) clazz;
- }
- for(Class<?> iface : clazz.getInterfaces() )
- {
- Class<? extends ConfiguredObject> cat = getCategory(iface);
- if(cat != null)
+ ConfiguredObject ancestor = getAncestor(ancestorClass, category, object);
+ if(ancestor != null)
{
- return cat;
+ return getAllDescendants(ancestor, ancestorClass, clazz);
}
}
- if(clazz.getSuperclass() != null)
- {
- return getCategory(clazz.getSuperclass());
- }
return null;
}
- public static String getType(final Class<? extends ConfiguredObject> clazz)
+ <X extends ConfiguredObject<X>> Collection<X> getAllDescendants(final ConfiguredObject ancestor,
+ final Class<? extends ConfiguredObject> ancestorClass,
+ final Class<X> clazz)
{
- String type = getActualType(clazz);
-
- if("".equals(type))
+ Set<X> descendants = new HashSet<X>();
+ for(Class<? extends ConfiguredObject> childClass : getChildTypes(ancestorClass))
{
- Class<? extends ConfiguredObject> category = getCategory(clazz);
- if (category == null)
- {
- throw new IllegalArgumentException("No category for " + clazz.getSimpleName());
- }
- ManagedObject annotation = category.getAnnotation(ManagedObject.class);
- if (annotation == null)
+ Collection<? extends ConfiguredObject> children = ancestor.getChildren(childClass);
+ if(childClass == clazz)
{
- throw new NullPointerException("No definition found for category " + category.getSimpleName());
- }
- if (!"".equals(annotation.defaultType()))
- {
- type = annotation.defaultType();
+
+ if(children != null)
+ {
+ descendants.addAll((Collection<X>)children);
+ }
}
else
{
- type = category.getSimpleName();
+ if(children != null)
+ {
+ for(ConfiguredObject child : children)
+ {
+ descendants.addAll(getAllDescendants(child, childClass, clazz));
+ }
+ }
}
}
- return type;
+ return descendants;
}
- private static String getActualType(final Class<? extends ConfiguredObject> clazz)
+ <C extends ConfiguredObject> C getAncestor(final Class<C> ancestorClass,
+ final Class<? extends ConfiguredObject> category,
+ final ConfiguredObject<?> object)
{
- ManagedObject annotation = clazz.getAnnotation(ManagedObject.class);
- if(annotation != null)
+ if(ancestorClass.isInstance(object))
+ {
+ return (C) object;
+ }
+ else
{
- if(!"".equals(annotation.type()))
+ for(Class<? extends ConfiguredObject> parentClass : object.getModel().getParentTypes(category))
{
- return annotation.type();
+ ConfiguredObject<?> parent = object.getParent(parentClass);
+ ConfiguredObject<?> ancestor = getAncestor(ancestorClass, parentClass, parent);
+ if(ancestor != null)
+ {
+ return (C) ancestor;
+ }
}
}
+ return null;
+ }
- for(Class<?> iface : clazz.getInterfaces() )
+ private Class<? extends ConfiguredObject> getAncestorClassWithGivenDescendant(
+ final Class<? extends ConfiguredObject> category,
+ final Class<? extends ConfiguredObject> descendantClass)
+ {
+ Collection<Class<? extends ConfiguredObject>> candidateClasses =
+ Collections.<Class<? extends ConfiguredObject>>singleton(category);
+ while(!candidateClasses.isEmpty())
{
- if(ConfiguredObject.class.isAssignableFrom(iface))
+ for(Class<? extends ConfiguredObject> candidate : candidateClasses)
{
- String type = getActualType((Class<? extends ConfiguredObject>) iface);
- if(!"".equals(type))
+ if(hasDescendant(candidate, descendantClass))
{
- return type;
+ return candidate;
}
}
+ Set<Class<? extends ConfiguredObject>> previous = new HashSet<>(candidateClasses);
+ candidateClasses = new HashSet<>();
+ for(Class<? extends ConfiguredObject> prev : previous)
+ {
+ candidateClasses.addAll(getParentTypes(prev));
+ }
}
+ return null;
+ }
+
+ private boolean hasDescendant(final Class<? extends ConfiguredObject> candidate,
+ final Class<? extends ConfiguredObject> descendantClass)
+ {
+ int oldSize = 0;
- if(clazz.getSuperclass() != null && ConfiguredObject.class.isAssignableFrom(clazz.getSuperclass()))
+ Set<Class<? extends ConfiguredObject>> allDescendants = new HashSet<>(getChildTypes(candidate));
+ while(allDescendants.size() > oldSize)
{
- String type = getActualType((Class<? extends ConfiguredObject>) clazz.getSuperclass());
- if(!"".equals(type))
+ oldSize = allDescendants.size();
+ Set<Class<? extends ConfiguredObject>> prev = new HashSet<>(allDescendants);
+ for(Class<? extends ConfiguredObject> clazz : prev)
{
- return type;
+ allDescendants.addAll(getChildTypes(clazz));
+ }
+ if(allDescendants.contains(descendantClass))
+ {
+ break;
}
}
-
- return "";
+ return allDescendants.contains(descendantClass);
}
public abstract Collection<Class<? extends ConfiguredObject>> getSupportedCategories();
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java
index 047ea4ef97..7ca27f25ea 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java
@@ -29,6 +29,6 @@ public interface FileBasedGroupProvider<X extends FileBasedGroupProvider<X>> ext
{
String PATH="path";
- @ManagedAttribute( automate = true, mandatory = true)
+ @ManagedAttribute( automate = true, mandatory = true, description = "File location" )
String getPath();
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java
deleted file mode 100644
index fd1970f837..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java
+++ /dev/null
@@ -1,37 +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.plugin;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.qpid.server.logging.EventLogger;
-import org.apache.qpid.server.logging.EventLoggerProvider;
-import org.apache.qpid.server.model.AccessControlProvider;
-import org.apache.qpid.server.security.AccessControl;
-
-public interface AccessControlProviderFactory<X extends AccessControlProvider<X>> extends ConfiguredObjectTypeFactory<X>
-{
- public static final String ATTRIBUTE_TYPE = AccessControlProvider.TYPE;
-
- /**
- * @return returns human readable descriptions for the attributes
- */
- Map<String, String> getAttributeDescriptions();
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java
deleted file mode 100644
index 35651b442c..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java
+++ /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.
- */
-package org.apache.qpid.server.plugin;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.qpid.server.model.AuthenticationProvider;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.security.auth.manager.AbstractAuthenticationManager;
-
-public interface AuthenticationManagerFactory<X extends AuthenticationProvider<X>> extends ConfiguredObjectTypeFactory<X>
-{
-
- /**
- * Returns the authentication provider type
- * @return authentication provider type
- */
- String getType();
-
- /**
- * Get the names of attributes the authentication manager
- * authentication manager
- *
- * @return the collection of attribute names
- */
- Collection<String> getAttributeNames();
-
- /**
- * @return returns human readable descriptions for the attributes
- */
- Map<String, String> getAttributeDescriptions();
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectRegistration.java
index f82aaff42b..7e8ce579eb 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectRegistration.java
@@ -20,16 +20,11 @@
*/
package org.apache.qpid.server.plugin;
-import java.util.Map;
+import java.util.Collection;
-import org.apache.qpid.server.exchange.ExchangeImpl;
-import org.apache.qpid.server.virtualhost.VirtualHostImpl;
+import org.apache.qpid.server.model.ConfiguredObject;
-public interface ExchangeType<T extends ExchangeImpl<T>> extends Pluggable
+public interface ConfiguredObjectRegistration extends Pluggable
{
- public String getType();
-
- public T newInstance(final VirtualHostImpl virtualHost, Map<String, Object> attributes);
-
- public String getDefaultExchangeName();
+ Collection<Class<? extends ConfiguredObject>> getConfiguredObjectClasses();
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java
deleted file mode 100644
index 3d7a6323eb..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java
+++ /dev/null
@@ -1,51 +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.plugin;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.qpid.server.model.GroupProvider;
-import org.apache.qpid.server.security.group.GroupManager;
-
-public interface GroupManagerFactory extends Pluggable
-{
- public static final String ATTRIBUTE_TYPE = GroupProvider.TYPE;
-
- GroupManager createInstance(Map<String, Object> attributes);
-
- /**
- * Returns the authentication provider type
- * @return authentication provider type
- */
- String getType();
-
- /**
- * Get the names of attributes the group manager which can be passed into {@link #createInstance(Map)} to create the
- * group manager
- *
- * @return the collection of attribute names
- */
- Collection<String> getAttributeNames();
-
- /**
- * @return returns human readable descriptions for the attributes
- */
- Map<String, String> getAttributeDescriptions();
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java
deleted file mode 100644
index 9665dfffbb..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java
+++ /dev/null
@@ -1,33 +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.plugin;
-
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.qpid.server.model.AuthenticationProvider;
-import org.apache.qpid.server.model.PreferencesProvider;
-
-public interface PreferencesProviderFactory extends Pluggable
-{
- PluggableFactoryLoader<PreferencesProviderFactory> FACTORY_LOADER = new PluggableFactoryLoader<PreferencesProviderFactory>(PreferencesProviderFactory.class);
-
- PreferencesProvider createInstance(UUID id, Map<String, Object> attributes, AuthenticationProvider<? extends AuthenticationProvider> authenticationProvider);
-
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
index 041db03a09..d36f3df37e 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
@@ -171,7 +171,7 @@ public abstract class AbstractQueue<X extends AbstractQueue<X>>
@ManagedAttributeField
private ExclusivityPolicy _exclusive;
- private Object _exclusiveOwner; // could be connection, session, Principal or a String for the container name
+ private Object _exclusiveOwner; // could be connection, session, Principal or a String forset the container name
private final Set<NotificationCheck> _notificationChecks =
Collections.synchronizedSet(EnumSet.noneOf(NotificationCheck.class));
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 08fccda4e8..823f24922e 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
@@ -46,7 +46,7 @@ import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.TrustStore;
import org.apache.qpid.server.security.access.Operation;
-import org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManagerFactory;
+import org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManager;
import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager;
import org.apache.qpid.transport.network.security.ssl.QpidPeersOnlyTrustManager;
import org.apache.qpid.transport.network.security.ssl.SSLUtil;
@@ -122,8 +122,8 @@ public class FileTrustStoreImpl extends AbstractConfiguredObject<FileTrustStoreI
for (AuthenticationProvider authProvider : authenticationProviders)
{
Object attributeType = authProvider.getAttribute(AuthenticationProvider.TYPE);
- Object attributeValue = authProvider.getAttribute(SimpleLDAPAuthenticationManagerFactory.ATTRIBUTE_TRUST_STORE);
- if (SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE.equals(attributeType)
+ Object attributeValue = authProvider.getAttribute(SimpleLDAPAuthenticationManager.TRUST_STORE);
+ if (SimpleLDAPAuthenticationManager.PROVIDER_TYPE.equals(attributeType)
&& storeName.equals(attributeValue))
{
throw new IntegrityViolationException("Trust store '" + storeName + "' can't be deleted as it is in use by an authentication manager: " + authProvider.getName());
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java
index 6122cef5c1..05b3f0d9d1 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java
@@ -196,7 +196,7 @@ public class ObjectProperties
put(Property.AUTO_DELETE, exchange.isAutoDelete());
put(Property.TEMPORARY, exchange.getLifetimePolicy() != LifetimePolicy.PERMANENT);
put(Property.DURABLE, exchange.isDurable());
- put(Property.TYPE, exchange.getTypeName());
+ put(Property.TYPE, exchange.getType());
put(Property.VIRTUALHOST_NAME, exchange.getParent(VirtualHost.class).getName());
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java
index 10753bc1f8..49580ff976 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java
@@ -29,6 +29,7 @@ import javax.security.sasl.SaslServer;
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.security.auth.AuthenticationResult;
import org.apache.qpid.server.security.auth.UsernamePrincipal;
import org.apache.qpid.server.security.auth.sasl.anonymous.AnonymousSaslServer;
@@ -36,6 +37,7 @@ import org.apache.qpid.server.security.auth.sasl.anonymous.AnonymousSaslServer;
@ManagedObject( category = false, type= "Anonymous" )
public class AnonymousAuthenticationManager extends AbstractAuthenticationManager<AnonymousAuthenticationManager>
{
+ public static final String PROVIDER_TYPE = "Anonymous";
private static final String ANONYMOUS = "ANONYMOUS";
public static final String ANONYMOUS_USERNAME = "ANONYMOUS";
@@ -50,6 +52,7 @@ public class AnonymousAuthenticationManager extends AbstractAuthenticationManage
private static final AuthenticationResult ANONYMOUS_AUTHENTICATION = new AuthenticationResult(ANONYMOUS_PRINCIPAL);
+ @ManagedObjectFactoryConstructor
protected AnonymousAuthenticationManager(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
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
deleted file mode 100644
index 7f37c4e39f..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java
+++ /dev/null
@@ -1,63 +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 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;
-
-@PluggableService
-public class AnonymousAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<AnonymousAuthenticationManager> implements AuthenticationManagerFactory<AnonymousAuthenticationManager>
-{
- public static final String PROVIDER_TYPE = "Anonymous";
-
- public AnonymousAuthenticationManagerFactory()
- {
- super(AnonymousAuthenticationManager.class);
- }
-
- @Override
- public Collection<String> getAttributeNames()
- {
- return Collections.singletonList(AuthenticationProvider.TYPE);
- }
-
-
- @Override
- public Map<String, String> getAttributeDescriptions()
- {
- return Collections.emptyMap();
- }
-
- public AnonymousAuthenticationManager createInstance(final Map<String, Object> attributes,
- final ConfiguredObject<?>... parents)
- {
- return new AnonymousAuthenticationManager(attributes, getParent(Broker.class,parents));
- }
-
-
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java
index 2140df545a..6fe649ff04 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java
@@ -24,6 +24,7 @@ import java.util.Map;
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.security.auth.database.Base64MD5PasswordFilePrincipalDatabase;
import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
@@ -33,8 +34,10 @@ public class Base64MD5PasswordDatabaseAuthenticationManager
{
- protected Base64MD5PasswordDatabaseAuthenticationManager(final Broker broker,
- final Map<String, Object> attributes)
+ public static final String PROVIDER_TYPE = "Base64MD5PasswordFile";
+
+ @ManagedObjectFactoryConstructor
+ protected Base64MD5PasswordDatabaseAuthenticationManager(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
}
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
deleted file mode 100644
index 2fb9fd4ac3..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java
+++ /dev/null
@@ -1,93 +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 java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-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.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>
-{
- public static final String PROVIDER_TYPE = "Base64MD5PasswordFile";
- public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.PasswordFileAuthenticationProviderAttributeDescriptions";
- public static final String ATTRIBUTE_PATH = "path";
-
-
- public static final Collection<String> ATTRIBUTES = Collections.unmodifiableList(Arrays.asList(
- AuthenticationProvider.TYPE,
- ATTRIBUTE_PATH));
-
- public Base64MD5PasswordFileAuthenticationManagerFactory()
- {
- super(Base64MD5PasswordDatabaseAuthenticationManager.class);
- }
-
- @Override
- public Map<String, String> getAttributeDescriptions()
- {
- return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
- }
-
- @Override
- public Collection<String> getAttributeNames()
- {
- return ATTRIBUTES;
- }
-
- @Override
- public Base64MD5PasswordDatabaseAuthenticationManager createInstance(final Map<String, Object> attributes,
- final ConfiguredObject<?>... parents)
- {
- return new Base64MD5PasswordDatabaseAuthenticationManager(getParent(Broker.class, parents), attributes);
- }
-
- @Override
- public UnresolvedConfiguredObject<Base64MD5PasswordDatabaseAuthenticationManager> recover(final ConfiguredObjectFactory factory,
- final ConfiguredObjectRecord record,
- final ConfiguredObject<?>... parents)
- {
-
- Map<String, Object> attributes = new HashMap<String, Object>(record.getAttributes());
- attributes.put(ConfiguredObject.ID, record.getId());
- final Base64MD5PasswordDatabaseAuthenticationManager authenticationManager =
- new Base64MD5PasswordDatabaseAuthenticationManager(getParent(Broker.class, parents),
- attributes
- );
- return ResolvedObject.newInstance(authenticationManager);
- }
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java
index ceb6424c3d..28293b5814 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java
@@ -27,6 +27,9 @@ import org.apache.qpid.server.model.ManagedObject;
@ManagedObject( category = false, type = "External" )
public interface ExternalAuthenticationManager<T extends ExternalAuthenticationManager<T>> extends AuthenticationProvider<T>
{
- @ManagedAttribute( automate = true )
+ String PROVIDER_TYPE = "External";
+ String ATTRIBUTE_USE_FULL_DN = "useFullDN";
+
+ @ManagedAttribute( automate = true , description = "Use the full DN as the Username")
boolean getUseFullDN();
}
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
deleted file mode 100644
index 967dbedc36..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java
+++ /dev/null
@@ -1,71 +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 java.util.Arrays;
-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 org.apache.qpid.server.util.ResourceBundleLoader;
-
-@PluggableService
-public class ExternalAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<ExternalAuthenticationManagerImpl>
- implements AuthenticationManagerFactory<ExternalAuthenticationManagerImpl>
-{
- public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.ExternalAuthenticationProviderAttributeDescriptions";
- public static final String PROVIDER_TYPE = "External";
- public static final String ATTRIBUTE_USE_FULL_DN = "useFullDN";
-
- public static final Collection<String> ATTRIBUTES = Collections.<String> unmodifiableList(Arrays.asList(
- AuthenticationProvider.TYPE,
- ATTRIBUTE_USE_FULL_DN));
-
- public ExternalAuthenticationManagerFactory()
- {
- super(ExternalAuthenticationManagerImpl.class);
- }
-
- @Override
- public Collection<String> getAttributeNames()
- {
- return ATTRIBUTES;
- }
-
- @Override
- public Map<String, String> getAttributeDescriptions()
- {
- return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
- }
-
- @Override
- public ExternalAuthenticationManagerImpl createInstance(final Map<String, Object> attributes,
- final ConfiguredObject<?>... parents)
- {
- return new ExternalAuthenticationManagerImpl(attributes, getParent(Broker.class, parents));
- }
-
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java
index 99175bc13c..182200612e 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java
@@ -26,6 +26,7 @@ import javax.security.sasl.SaslServer;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.ManagedAttributeField;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
import org.apache.qpid.server.security.auth.AuthenticationResult;
import org.apache.qpid.server.security.auth.UsernamePrincipal;
import org.apache.qpid.server.security.auth.sasl.external.ExternalSaslServer;
@@ -38,6 +39,7 @@ public class ExternalAuthenticationManagerImpl extends AbstractAuthenticationMan
@ManagedAttributeField
private boolean _useFullDN;
+ @ManagedObjectFactoryConstructor
protected ExternalAuthenticationManagerImpl(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationProviderAttributeDescriptions.properties b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationProviderAttributeDescriptions.properties
deleted file mode 100644
index 263254e9fe..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationProviderAttributeDescriptions.properties
+++ /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.
-
-useFullDN=Use the full DN as the Username \ No newline at end of file
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java
index b344c4f5b4..28646ea5f4 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java
@@ -33,15 +33,18 @@ import javax.security.sasl.SaslServer;
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.security.auth.AuthenticationResult;
import org.apache.qpid.server.security.auth.UsernamePrincipal;
@ManagedObject( category = false, type = "Kerberos" )
public class KerberosAuthenticationManager extends AbstractAuthenticationManager<KerberosAuthenticationManager>
{
+ public static final String PROVIDER_TYPE = "Kerberos";
private static final String GSSAPI_MECHANISM = "GSSAPI";
private final CallbackHandler _callbackHandler = new GssApiCallbackHandler();
+ @ManagedObjectFactoryConstructor
protected KerberosAuthenticationManager(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java
deleted file mode 100644
index 36c389bbdd..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java
+++ /dev/null
@@ -1,64 +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 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;
-
-@PluggableService
-public class KerberosAuthenticationManagerFactory
- extends AbstractConfiguredObjectTypeFactory<KerberosAuthenticationManager>
- implements AuthenticationManagerFactory<KerberosAuthenticationManager>
-{
- public static final String PROVIDER_TYPE = "Kerberos";
-
- public KerberosAuthenticationManagerFactory()
- {
- super(KerberosAuthenticationManager.class);
- }
-
- @Override
- public Collection<String> getAttributeNames()
- {
- return Collections.<String>singletonList(AuthenticationProvider.TYPE);
- }
-
- @Override
- public Map<String, String> getAttributeDescriptions()
- {
- return Collections.emptyMap();
- }
-
- @Override
- public KerberosAuthenticationManager createInstance(final Map<String, Object> attributes,
- final ConfiguredObject<?>... parents)
- {
- return new KerberosAuthenticationManager(attributes, getParent(Broker.class, parents));
- }
-
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PasswordFileAuthenticationProviderAttributeDescriptions.properties b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PasswordFileAuthenticationProviderAttributeDescriptions.properties
deleted file mode 100644
index e847e90f57..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PasswordFileAuthenticationProviderAttributeDescriptions.properties
+++ /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.
-
-path=File location* \ No newline at end of file
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java
index 8c9ec5a3e9..e6d2fcf44c 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java
@@ -24,14 +24,17 @@ import java.util.Map;
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.security.auth.database.PlainPasswordFilePrincipalDatabase;
import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
@ManagedObject( category = false, type = "PlainPasswordFile" )
public class PlainPasswordDatabaseAuthenticationManager extends PrincipalDatabaseAuthenticationManager<PlainPasswordDatabaseAuthenticationManager>
{
- protected PlainPasswordDatabaseAuthenticationManager(final Broker broker,
- final Map<String, Object> attributes)
+ public static final String PROVIDER_TYPE = "PlainPasswordFile";
+
+ @ManagedObjectFactoryConstructor
+ protected PlainPasswordDatabaseAuthenticationManager(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
}
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
deleted file mode 100644
index 5fa054a363..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactory.java
+++ /dev/null
@@ -1,96 +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 java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-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.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>
-{
- public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.PasswordFileAuthenticationProviderAttributeDescriptions";
- public static final String ATTRIBUTE_PATH = "path";
-
-
- public static final Collection<String> ATTRIBUTES = Collections.unmodifiableList(Arrays.asList(
- AuthenticationProvider.TYPE,
- ATTRIBUTE_PATH));
-
- public static final String PROVIDER_TYPE = "PlainPasswordFile";
-
- public PlainPasswordFileAuthenticationManagerFactory()
- {
- super(PlainPasswordDatabaseAuthenticationManager.class);
- }
-
- @Override
- public Map<String, String> getAttributeDescriptions()
- {
- return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
- }
-
-
- @Override
- public Collection<String> getAttributeNames()
- {
- return ATTRIBUTES;
- }
-
- @Override
- public PlainPasswordDatabaseAuthenticationManager createInstance(final Map<String, Object> attributes,
- final ConfiguredObject<?>... parents)
- {
- return new PlainPasswordDatabaseAuthenticationManager(getParent(Broker.class, parents), attributes);
- }
-
- @Override
- public UnresolvedConfiguredObject<PlainPasswordDatabaseAuthenticationManager> recover(final ConfiguredObjectFactory factory,
- final ConfiguredObjectRecord record,
- final ConfiguredObject<?>... parents)
- {
-
- Map<String, Object> attributes = new HashMap<String, Object>(record.getAttributes());
- attributes.put(ConfiguredObject.ID, record.getId());
- PlainPasswordDatabaseAuthenticationManager authManager = new PlainPasswordDatabaseAuthenticationManager(
- getParent(Broker.class, parents),
- attributes
- );
-
- return ResolvedObject.newInstance(authManager);
- }
-}
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 22e34edab1..43a4932022 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
@@ -45,6 +45,7 @@ import org.apache.qpid.server.configuration.updater.VoidTaskWithException;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ManagedObject;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
import org.apache.qpid.server.model.PasswordCredentialManagingAuthenticationProvider;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.User;
@@ -60,6 +61,7 @@ public class ScramSHA1AuthenticationManager
implements PasswordCredentialManagingAuthenticationProvider<ScramSHA1AuthenticationManager>
{
public static final String SCRAM_USER_TYPE = "scram";
+ public static final String PROVIDER_TYPE = "SCRAM-SHA-1";
static final Charset ASCII = Charset.forName("ASCII");
public static final String HMAC_SHA_1 = "HmacSHA1";
private final SecureRandom _random = new SecureRandom();
@@ -67,6 +69,7 @@ public class ScramSHA1AuthenticationManager
private Map<String, ScramAuthUser> _users = new ConcurrentHashMap<String, ScramAuthUser>();
+ @ManagedObjectFactoryConstructor
protected ScramSHA1AuthenticationManager(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
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
deleted file mode 100644
index 30c97dfead..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java
+++ /dev/null
@@ -1,72 +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 java.util.Arrays;
-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;
-
-@PluggableService
-public class ScramSHA1AuthenticationManagerFactory
- extends AbstractConfiguredObjectTypeFactory<ScramSHA1AuthenticationManager>
- implements AuthenticationManagerFactory<ScramSHA1AuthenticationManager>
-{
-
- public static final String PROVIDER_TYPE = "SCRAM-SHA-1";
-
- public static final String ATTRIBUTE_NAME = "name";
-
- public static final Collection<String> ATTRIBUTES = Collections.<String> unmodifiableList(Arrays.asList(
- AuthenticationProvider.TYPE
- ));
-
- public ScramSHA1AuthenticationManagerFactory()
- {
- super(ScramSHA1AuthenticationManager.class);
- }
-
- @Override
- public Collection<String> getAttributeNames()
- {
- return ATTRIBUTES;
- }
-
- @Override
- public Map<String, String> getAttributeDescriptions()
- {
- return Collections.emptyMap();
- }
-
- @Override
- public ScramSHA1AuthenticationManager createInstance(final Map<String, Object> attributes,
- final ConfiguredObject<?>... parents)
- {
- return new ScramSHA1AuthenticationManager(attributes, getParent(Broker.class, parents));
- }
-
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
index 2e3568ff57..883dcd025e 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
@@ -28,21 +28,24 @@ import org.apache.qpid.server.model.TrustStore;
@ManagedObject( category = false, type = "SimpleLDAP" )
public interface SimpleLDAPAuthenticationManager<X extends SimpleLDAPAuthenticationManager<X>> extends AuthenticationProvider<X>
{
- @ManagedAttribute( automate = true )
+ String PROVIDER_TYPE = "SimpleLDAP";
+ String TRUST_STORE = "trustStore";
+
+ @ManagedAttribute( automate = true, description = "LDAP server URL" )
String getProviderUrl();
- @ManagedAttribute( automate = true )
+ @ManagedAttribute( automate = true, description = "LDAP authentication URL")
String getProviderAuthUrl();
- @ManagedAttribute( automate = true )
+ @ManagedAttribute( automate = true, description = "Search context")
String getSearchContext();
- @ManagedAttribute( automate = true )
+ @ManagedAttribute( automate = true, description = "Search filter")
String getSearchFilter();
- @ManagedAttribute( automate = true )
+ @ManagedAttribute( automate = true, description = "LDAP context factory")
String getLdapContextFactory();
- @ManagedAttribute( automate = true )
+ @ManagedAttribute( automate = true, description = "Trust store name")
TrustStore getTrustStore();
}
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
deleted file mode 100644
index cce7864e26..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java
+++ /dev/null
@@ -1,86 +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 java.util.Arrays;
-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 org.apache.qpid.server.util.ResourceBundleLoader;
-
-@PluggableService
-public class SimpleLDAPAuthenticationManagerFactory
- extends AbstractConfiguredObjectTypeFactory<SimpleLDAPAuthenticationManagerImpl>
- implements AuthenticationManagerFactory<SimpleLDAPAuthenticationManagerImpl>
-{
- public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationProviderAttributeDescriptions";
-
- public static final String PROVIDER_TYPE = "SimpleLDAP";
-
- public static final String ATTRIBUTE_NAME = "name";
- public static final String ATTRIBUTE_LDAP_CONTEXT_FACTORY = "ldapContextFactory";
- public static final String ATTRIBUTE_SEARCH_FILTER = "searchFilter";
- public static final String ATTRIBUTE_SEARCH_CONTEXT = "searchContext";
- public static final String ATTRIBUTE_TRUST_STORE = "trustStore";
- public static final String ATTRIBUTE_PROVIDER_AUTH_URL = "providerAuthUrl";
- public static final String ATTRIBUTE_PROVIDER_URL = "providerUrl";
-
- public static final Collection<String> ATTRIBUTES = Collections.<String> unmodifiableList(Arrays.asList(
- AuthenticationProvider.TYPE,
- ATTRIBUTE_PROVIDER_URL,
- ATTRIBUTE_SEARCH_CONTEXT,
- ATTRIBUTE_SEARCH_FILTER,
- ATTRIBUTE_TRUST_STORE,
- ATTRIBUTE_PROVIDER_AUTH_URL,
- ATTRIBUTE_LDAP_CONTEXT_FACTORY
- ));
-
- public SimpleLDAPAuthenticationManagerFactory()
- {
- super(SimpleLDAPAuthenticationManagerImpl.class);
- }
-
- @Override
- public Collection<String> getAttributeNames()
- {
- return ATTRIBUTES;
- }
-
- @Override
- public Map<String, String> getAttributeDescriptions()
- {
- return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
- }
-
- @Override
- public SimpleLDAPAuthenticationManagerImpl createInstance(final Map<String, Object> attributes,
- final ConfiguredObject<?>... parents)
- {
- return new SimpleLDAPAuthenticationManagerImpl(attributes, getParent(Broker.class, parents));
- }
-
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java
index 8227590dfe..c06a06c45e 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java
@@ -48,6 +48,7 @@ import org.apache.log4j.Logger;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.ManagedAttributeField;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
import org.apache.qpid.server.model.TrustStore;
import org.apache.qpid.server.security.auth.AuthenticationResult;
import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
@@ -94,6 +95,7 @@ public class SimpleLDAPAuthenticationManagerImpl extends AbstractAuthenticationM
*/
private Class<? extends SocketFactory> _sslSocketFactoryOverrideClass;
+ @ManagedObjectFactoryConstructor
protected SimpleLDAPAuthenticationManagerImpl(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationProviderAttributeDescriptions.properties b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationProviderAttributeDescriptions.properties
deleted file mode 100644
index 18e6fb8a4c..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationProviderAttributeDescriptions.properties
+++ /dev/null
@@ -1,24 +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.
-
-ldapContextFactory= LDAP context factory
-searchFilter=Search filter*
-searchContext=Search context*
-providerAuthUrl=LDAP authentication URL
-providerUrl=LDAP server URL*
-trustStore=Truststore name
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupProviderAttributeDescriptions.properties b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupProviderAttributeDescriptions.properties
deleted file mode 100644
index 2c2d2ab9e3..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupProviderAttributeDescriptions.properties
+++ /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.
-
-path= File location*
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
index 5723a004d9..8d0ff46cff 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
@@ -31,12 +31,12 @@ import java.util.UUID;
import junit.framework.TestCase;
+import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.binding.BindingImpl;
import org.apache.qpid.server.logging.EventLogger;
import org.apache.qpid.server.message.AMQMessageHeader;
import org.apache.qpid.server.model.Binding;
import org.apache.qpid.server.model.BrokerModel;
-import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.virtualhost.VirtualHostImpl;
@@ -156,7 +156,7 @@ public class HeadersBindingTest extends TestCase
final EventLogger eventLogger = new EventLogger();
when(vhost.getEventLogger()).thenReturn(eventLogger);
_exchange = mock(ExchangeImpl.class);
- when(_exchange.getExchangeType()).thenReturn(mock(ExchangeType.class));
+ when(_exchange.getType()).thenReturn(ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
when(_exchange.getEventLogger()).thenReturn(eventLogger);
when(_exchange.getModel()).thenReturn(BrokerModel.getInstance());
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java
index 4789fa8c47..76a80a3570 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java
@@ -20,11 +20,11 @@
*/
package org.apache.qpid.server.logging.messages;
+import java.util.List;
+
import org.apache.qpid.server.exchange.ExchangeImpl;
import org.apache.qpid.server.util.BrokerTestHelper;
-import java.util.List;
-
/**
* Test EXH Log Messages
*/
@@ -34,7 +34,7 @@ public class ExchangeMessagesTest extends AbstractTestMessages
{
ExchangeImpl exchange = BrokerTestHelper.createExchange("test", false, getEventLogger());
- String type = exchange.getTypeName();
+ String type = exchange.getType();
String name = exchange.getName();
_logMessage = ExchangeMessages.CREATED(type, name, false);
@@ -49,7 +49,7 @@ public class ExchangeMessagesTest extends AbstractTestMessages
{
ExchangeImpl exchange = BrokerTestHelper.createExchange("test", true, getEventLogger());
- String type = exchange.getTypeName();
+ String type = exchange.getType();
String name = exchange.getName();
_logMessage = ExchangeMessages.CREATED(type, name, true);
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
index f2486ff4d8..024ae22966 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
@@ -21,6 +21,8 @@
package org.apache.qpid.server.logging.subjects;
+import java.util.List;
+
import org.apache.qpid.server.exchange.ExchangeImpl;
import org.apache.qpid.server.logging.EventLogger;
import org.apache.qpid.server.logging.LogMessage;
@@ -31,8 +33,6 @@ import org.apache.qpid.server.util.BrokerTestHelper;
import org.apache.qpid.server.virtualhost.VirtualHostImpl;
import org.apache.qpid.test.utils.QpidTestCase;
-import java.util.List;
-
/**
* Abstract Test for LogSubject testing
* Includes common validation code and two common tests.
@@ -181,7 +181,7 @@ public abstract class AbstractTestLogSubject extends QpidTestCase
exchangeParts.length);
assertEquals("Exchange type not correct",
- exchange.getExchangeType().getType(), exchangeParts[0]);
+ exchange.getType(), exchangeParts[0]);
assertEquals("Exchange name not correct",
exchange.getName(), exchangeParts[1]);
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java
index d76734f6b8..c18feb38a7 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java
@@ -228,7 +228,7 @@ public class SecurityManagerTest extends QpidTestCase
ExchangeImpl<?> exchange = mock(ExchangeImpl.class);
when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost);
when(exchange.getName()).thenReturn(TEST_EXCHANGE);
- when(exchange.getTypeName()).thenReturn(TEST_EXCHANGE_TYPE);
+ when(exchange.getType()).thenReturn(TEST_EXCHANGE_TYPE);
ObjectProperties properties = createExpectedExchangeObjectProperties();
@@ -329,7 +329,7 @@ public class SecurityManagerTest extends QpidTestCase
ExchangeImpl<?> exchange = mock(ExchangeImpl.class);
when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost);
when(exchange.getName()).thenReturn(TEST_EXCHANGE);
- when(exchange.getTypeName()).thenReturn(TEST_EXCHANGE_TYPE);
+ when(exchange.getType()).thenReturn(TEST_EXCHANGE_TYPE);
ObjectProperties properties = createExpectedExchangeObjectProperties();
@@ -355,7 +355,7 @@ public class SecurityManagerTest extends QpidTestCase
ExchangeImpl<?> exchange = mock(ExchangeImpl.class);
when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost);
when(exchange.getName()).thenReturn(TEST_EXCHANGE);
- when(exchange.getTypeName()).thenReturn(TEST_EXCHANGE_TYPE);
+ when(exchange.getType()).thenReturn(TEST_EXCHANGE_TYPE);
ObjectProperties properties = createExpectedExchangeObjectProperties();
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java
index 7be60d1049..a1b173c790 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java
@@ -28,13 +28,15 @@ import junit.framework.TestCase;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.BrokerModel;
+import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase;
import org.apache.qpid.server.util.BrokerTestHelper;
public class PlainPasswordFileAuthenticationManagerFactoryTest extends TestCase
{
- PlainPasswordFileAuthenticationManagerFactory _factory = new PlainPasswordFileAuthenticationManagerFactory();
+ ConfiguredObjectFactory _factory = BrokerModel.getInstance().getObjectFactory();
private Map<String, Object> _configuration = new HashMap<String, Object>();
private File _emptyPasswordFile;
private Broker _broker = BrokerTestHelper.createBrokerMock();
@@ -51,10 +53,10 @@ public class PlainPasswordFileAuthenticationManagerFactoryTest extends TestCase
public void testPlainInstanceCreated() throws Exception
{
- _configuration.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE);
+ _configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE);
_configuration.put("path", _emptyPasswordFile.getAbsolutePath());
- AuthenticationManager manager = _factory.create(null, _configuration, _broker);
+ AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
assertNotNull(manager);
assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager);
assertTrue(((PrincipalDatabaseAuthenticationManager)manager).getPrincipalDatabase() instanceof PlainPasswordFilePrincipalDatabase);
@@ -65,11 +67,11 @@ public class PlainPasswordFileAuthenticationManagerFactoryTest extends TestCase
//delete the file
_emptyPasswordFile.delete();
- _configuration.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE);
+ _configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE);
_configuration.put("path", _emptyPasswordFile.getAbsolutePath());
- AuthenticationManager manager = _factory.create(null, _configuration, _broker);
+ AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
assertNotNull(manager);
assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager);
@@ -78,11 +80,11 @@ public class PlainPasswordFileAuthenticationManagerFactoryTest extends TestCase
public void testThrowsExceptionWhenConfigForPlainPDImplementationNoPasswordFileValueSpecified() throws Exception
{
- _configuration.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE);
+ _configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE);
try
{
- AuthenticationManager manager = _factory.create(null, _configuration, _broker);
+ AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
fail("No authentication manager should be created");
}
catch (IllegalArgumentException e)
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
index 6fc28ac136..56283b1392 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
@@ -33,17 +33,17 @@ import junit.framework.TestCase;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.SystemContext;
+import org.apache.qpid.server.model.BrokerModel;
+import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.model.TrustStore;
import org.apache.qpid.server.model.UnknownConfiguredObjectException;
import org.apache.qpid.server.util.BrokerTestHelper;
public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase
{
- private SimpleLDAPAuthenticationManagerFactory _factory = new SimpleLDAPAuthenticationManagerFactory();
+ private ConfiguredObjectFactory _factory = BrokerModel.getInstance().getObjectFactory();
private Map<String, Object> _configuration = new HashMap<String, Object>();
private Broker _broker = BrokerTestHelper.createBrokerMock();
- private SystemContext _systemContext = mock(SystemContext.class);
private TrustStore _trustStore = mock(TrustStore.class);
@@ -60,22 +60,22 @@ public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase
public void testLdapInstanceCreated() throws Exception
{
- _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE);
+ _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManager.PROVIDER_TYPE);
_configuration.put("providerUrl", "ldap://example.com:389/");
_configuration.put("searchContext", "dc=example");
- AuthenticationManager manager = _factory.create(null, _configuration, _broker);
+ AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
assertNotNull(manager);
}
public void testLdapsInstanceCreated() throws Exception
{
- _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE);
+ _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManager.PROVIDER_TYPE);
_configuration.put("providerUrl", "ldaps://example.com:636/");
_configuration.put("searchContext", "dc=example");
- AuthenticationManager manager = _factory.create(null, _configuration, _broker);
+ AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
assertNotNull(manager);
}
@@ -85,12 +85,12 @@ public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase
when(_broker.getChildren(eq(TrustStore.class))).thenReturn(Collections.singletonList(_trustStore));
- _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE);
+ _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManager.PROVIDER_TYPE);
_configuration.put("providerUrl", "ldaps://example.com:636/");
_configuration.put("searchContext", "dc=example");
_configuration.put("trustStore", "mytruststore");
- AuthenticationManager manager = _factory.create(null, _configuration, _broker);
+ AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
assertNotNull(manager);
}
@@ -98,14 +98,14 @@ public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase
{
when(_broker.getChildren(eq(TrustStore.class))).thenReturn(Collections.singletonList(_trustStore));
- _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE);
+ _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManager.PROVIDER_TYPE);
_configuration.put("providerUrl", "ldaps://example.com:636/");
_configuration.put("searchContext", "dc=example");
_configuration.put("trustStore", "notfound");
try
{
- _factory.create(null, _configuration, _broker);
+ _factory.create(AuthenticationProvider.class, _configuration, _broker);
fail("Exception not thrown");
}
catch(UnknownConfiguredObjectException e)
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
index f0838be380..1e10053d90 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
@@ -38,6 +38,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+
import org.apache.qpid.common.AMQPFilterTypes;
import org.apache.qpid.server.binding.BindingImpl;
import org.apache.qpid.server.exchange.ExchangeImpl;
@@ -52,7 +53,6 @@ import org.apache.qpid.server.model.LifetimePolicy;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.security.SecurityManager;
import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler;
@@ -496,7 +496,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
actualAttributes.put("type", getName() + "Type");
actualAttributes.put("lifetimePolicy", LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
when(exchange.getName()).thenReturn(getName());
- when(exchange.getTypeName()).thenReturn(getName() + "Type");
+ when(exchange.getType()).thenReturn(getName() + "Type");
when(exchange.isAutoDelete()).thenReturn(true);
when(exchange.getId()).thenReturn(_exchangeId);
when(exchange.getCategoryClass()).thenReturn(Exchange.class);
@@ -510,7 +510,6 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
when(exchangeRecord.getAttributes()).thenReturn(actualAttributes);
when(exchangeRecord.getParents()).thenReturn(Collections.singletonMap(_rootRecord.getType(), _rootRecord));
when(exchange.asObjectRecord()).thenReturn(exchangeRecord);
- when(exchange.getExchangeType()).thenReturn(mock(ExchangeType.class));
when(exchange.getEventLogger()).thenReturn(new EventLogger());
return exchange;
}