summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-03-02 18:24:27 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-03-02 18:24:27 +0000
commit13f6187748872d19e9cc288c9ec87e1d1fc53a11 (patch)
treeca3d0669934d00ca44ca0e2b7343044682eae6ed /qpid/java
parentfd8cf2e7ffe5839ac9055eae76a9e00a25154bdc (diff)
downloadqpid-python-13f6187748872d19e9cc288c9ec87e1d1fc53a11.tar.gz
QPID-5578 : [Java Broker] allow the base class AbstractConfiguredObject to take responsibility for the management of managed attributes
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1573336 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java5
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java10
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManager.java4
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java7
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java4
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java14
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Consumer.java10
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/KeyStore.java10
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java2
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/TrustStore.java10
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java344
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractKeyStoreAdapter.java35
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java8
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java31
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java5
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java101
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java6
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java92
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java56
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java6
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java35
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java50
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java8
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java17
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java27
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java97
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java1
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java4
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java2
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java7
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java6
33 files changed, 525 insertions, 493 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java
index 18e78eff88..f344d415f0 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java
@@ -234,11 +234,6 @@ public class BindingImpl
}
}
- public String getName()
- {
- return _bindingKey;
- }
-
@Override
public String setName(final String currentName, final String desiredName)
throws IllegalStateException, AccessControlException
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 f7f0d8d26c..7ffcbc635f 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
@@ -72,7 +72,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>>
{
private static final Logger _logger = Logger.getLogger(AbstractExchange.class);
private final LifetimePolicy _lifetimePolicy;
- private String _name;
private final AtomicBoolean _closed = new AtomicBoolean();
private NonDefaultExchange _alternateExchange;
@@ -113,7 +112,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>>
Collections.<String,Object>emptyMap(), attributes, vhost.getTaskExecutor());
_virtualHost = vhost;
- _name = MapValueConverter.getStringAttribute(org.apache.qpid.server.model.Exchange.NAME, attributes);
_durable = MapValueConverter.getBooleanAttribute(org.apache.qpid.server.model.Exchange.DURABLE, attributes);
_lifetimePolicy = MapValueConverter.getEnumAttribute(LifetimePolicy.class,
org.apache.qpid.server.model.Exchange.LIFETIME_POLICY,
@@ -170,7 +168,7 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>>
}
};
// Log Exchange creation
- CurrentActor.get().message(ExchangeMessages.CREATED(getExchangeType().getType(), _name, _durable));
+ CurrentActor.get().message(ExchangeMessages.CREATED(getExchangeType().getType(), getName(), _durable));
}
public abstract ExchangeType<T> getExchangeType();
@@ -415,12 +413,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>>
protected abstract void onUnbind(final BindingImpl binding);
-
- public String getName()
- {
- return _name.toString();
- }
-
public Map<String, Object> getArguments()
{
return Collections.emptyMap();
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManager.java
index 4992b960c4..69fc520a8f 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManager.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManager.java
@@ -23,6 +23,8 @@ package org.apache.qpid.server.filter;
// Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
//
+import java.util.Iterator;
+
public interface FilterManager
{
void add(MessageFilter filter);
@@ -31,5 +33,7 @@ public interface FilterManager
boolean allAllow(Filterable msg);
+ Iterator<MessageFilter> filters();
+
boolean hasFilters();
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java
index ddbee299a1..111fb6a333 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.filter;
import org.apache.log4j.Logger;
+import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;
public class SimpleFilterManager implements FilterManager
@@ -67,6 +68,12 @@ public class SimpleFilterManager implements FilterManager
return true;
}
+ @Override
+ public Iterator<MessageFilter> filters()
+ {
+ return _filters.iterator();
+ }
+
public boolean hasFilters()
{
return !_filters.isEmpty();
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java
index b806ce4328..e1642f8a2b 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java
@@ -36,8 +36,6 @@ public interface AuthenticationProvider<X extends AuthenticationProvider<X>> ext
//children
Collection<VirtualHostAlias> getVirtualHostPortBindings();
- String getName();
-
/**
* A temporary method to create SubjectCreator.
*
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
index 44df5f70ee..b674f1e7db 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
@@ -49,7 +49,7 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>>
*
* @return the objects id
*/
- @ManagedAttribute
+ @ManagedAttribute( automate = true, mandatory = true )
UUID getId();
/**
@@ -57,7 +57,7 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>>
*
* @return the name of the object
*/
- @ManagedAttribute
+ @ManagedAttribute( automate = true, mandatory = true)
String getName();
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java
index f2c0fdb5c0..0c535ba34d 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java
@@ -46,28 +46,28 @@ public interface Connection<X extends Connection<X>> extends ConfiguredObject<X>
/** Name of port associated with the connection */
public static final String PORT = "port";
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
String getClientId();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
String getClientVersion();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
boolean isIncoming();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
String getLocalAddress();
@ManagedAttribute
String getPrincipal();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
String getRemoteAddress();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
String getRemoteProcessName();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
String getRemoteProcessPid();
@ManagedAttribute
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Consumer.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Consumer.java
index 1911eff78b..05a0a0bf64 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Consumer.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Consumer.java
@@ -35,19 +35,19 @@ public interface Consumer<X extends Consumer<X>> extends ConfiguredObject<X>
public String LIFETIME_POLICY = "lifetimePolicy";
public String STATE = "state";
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
String getDistributionMode();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
String getSettlementMode();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
boolean isExclusive();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
boolean isNoLocal();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
String getSelector();
@ManagedStatistic
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/KeyStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/KeyStore.java
index 9fee4f4df7..302bea8344 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/KeyStore.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/KeyStore.java
@@ -39,19 +39,19 @@ public interface KeyStore<X extends KeyStore<X>> extends ConfiguredObject<X>
String CERTIFICATE_ALIAS = "certificateAlias";
String KEY_MANAGER_FACTORY_ALGORITHM = "keyManagerFactoryAlgorithm";
- @ManagedAttribute( secure = true )
+ @ManagedAttribute( secure = true, automate = true, mandatory = true )
public String getPassword();
- @ManagedAttribute
+ @ManagedAttribute( automate = true, mandatory = true)
public String getPath();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
public String getCertificateAlias();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
public String getKeyManagerFactoryAlgorithm();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
public String getKeyStoreType();
public void setPassword(String password);
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 534ff63b86..036453fcbb 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
@@ -29,4 +29,6 @@ public @interface ManagedAttribute
{
boolean secure() default false;
boolean derived() default false;
+ boolean automate() default false;
+ boolean mandatory() default false;
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java
index 8e462883eb..519f96eb1b 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java
@@ -35,7 +35,7 @@ public interface Session<X extends Session<X>> extends ConfiguredObject<X>
// available credit of both producer and consumer sides.
public static final String PRODUCER_FLOW_BLOCKED = "producerFlowBlocked";
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
int getChannelId();
@ManagedAttribute
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/TrustStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/TrustStore.java
index a5abd7b34e..2685a50776 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/TrustStore.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/TrustStore.java
@@ -39,19 +39,19 @@ public interface TrustStore<X extends TrustStore<X>> extends ConfiguredObject<X>
String PEERS_ONLY = "peersOnly";
String TRUST_MANAGER_FACTORY_ALGORITHM = "trustManagerFactoryAlgorithm";
- @ManagedAttribute( secure = true )
+ @ManagedAttribute( secure = true, automate = true, mandatory = true)
public String getPassword();
- @ManagedAttribute
+ @ManagedAttribute( automate = true, mandatory = true )
public String getPath();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
public String getTrustManagerFactoryAlgorithm();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
public String getTrustStoreType();
- @ManagedAttribute
+ @ManagedAttribute( automate = true )
public boolean isPeersOnly();
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
index e61250b455..b82ab55330 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
@@ -20,6 +20,7 @@
*/
package org.apache.qpid.server.model.adapter;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessControlException;
@@ -38,14 +39,17 @@ import org.apache.qpid.server.configuration.updater.ChangeStateTask;
import org.apache.qpid.server.configuration.updater.CreateChildTask;
import org.apache.qpid.server.configuration.updater.SetAttributeTask;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.security.*;
+import org.apache.qpid.server.security.SecurityManager;
import org.apache.qpid.server.security.auth.AuthenticatedPrincipal;
import org.apache.qpid.server.util.MapValueConverter;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import javax.security.auth.Subject;
public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> implements ConfiguredObject<X>
{
- private static final Object ID = "id";
+ private static final String ID = "id";
private static final Map<Class<? extends ConfiguredObject>, Collection<Attribute<?,?>>> _allAttributes =
Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<Attribute<?, ?>>>());
@@ -53,6 +57,27 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
private static final Map<Class<? extends ConfiguredObject>, Collection<Statistic<?,?>>> _allStatistics =
Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<Statistic<?, ?>>>());
+ private static final Map<Class<? extends ConfiguredObject>, Map<String, Attribute<?,?>>> _allAttributeTypes =
+ Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, Attribute<?, ?>>>());
+
+ private static final Map<Class<? extends ConfiguredObject>, Map<String, Field>> _allAutomatedFields =
+ Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, Field>>());
+ private static final Map<Class, Object> SECURE_VALUES;
+ static
+ {
+ Map<Class,Object> secureValues = new HashMap<Class, Object>();
+ secureValues.put(String.class, "********");
+ secureValues.put(Integer.class, 0);
+ secureValues.put(Long.class, 0l);
+ secureValues.put(Byte.class, (byte)0);
+ secureValues.put(Short.class, (short)0);
+ secureValues.put(Double.class, (double)0);
+ secureValues.put(Float.class, (float)0);
+
+ SECURE_VALUES = Collections.unmodifiableMap(secureValues);
+ }
+
+
private final Map<String,Object> _attributes = new HashMap<String, Object>();
private final Map<Class<? extends ConfiguredObject>, ConfiguredObject> _parents =
new HashMap<Class<? extends ConfiguredObject>, ConfiguredObject>();
@@ -65,20 +90,50 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
private final long _createdTime;
private final String _createdBy;
+ private String _name;
+
+ private final Map<String, Attribute<?,?>> _attributeTypes;
+ private final Map<String, Field> _automatedFields;
+
protected AbstractConfiguredObject(UUID id,
Map<String, Object> defaults,
Map<String, Object> attributes,
TaskExecutor taskExecutor)
{
- this(id, defaults, attributes, taskExecutor, true);
+ this(defaults, combineIdWithAttributes(id,attributes), taskExecutor);
}
+ public static Map<String,Object> combineIdWithAttributes(UUID id, Map<String,Object> attributes)
+ {
+ Map<String,Object> combined = new HashMap<String, Object>(attributes);
+ combined.put(ID, id);
+ return combined;
+ }
+
+
protected AbstractConfiguredObject(UUID id, Map<String, Object> defaults, Map<String, Object> attributes,
TaskExecutor taskExecutor, boolean filterAttributes)
{
+ this(defaults, combineIdWithAttributes(id, attributes), taskExecutor, filterAttributes);
+ }
+
+ protected AbstractConfiguredObject(Map<String, Object> defaults,
+ Map<String, Object> attributes,
+ TaskExecutor taskExecutor)
+ {
+ this(defaults, attributes, taskExecutor, true);
+ }
+
+ protected AbstractConfiguredObject(Map<String, Object> defaults,
+ Map<String, Object> attributes,
+ TaskExecutor taskExecutor,
+ boolean filterAttributes)
+ {
_taskExecutor = taskExecutor;
- _id = id;
+ _id = (UUID)attributes.get(ID);
+ _attributeTypes = getAttributeTypes(getClass());
+ _automatedFields = getAutomatedFields(getClass());
if (attributes != null)
{
Collection<String> names = getAttributeNames();
@@ -95,6 +150,10 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
{
_attributes.put(name, value);
}
+ if(_automatedFields.containsKey(name))
+ {
+ automatedSetValue(name, value);
+ }
}
}
}
@@ -105,6 +164,10 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
if(entry.getValue()!=null)
{
_attributes.put(entry.getKey(),entry.getValue());
+ if(_automatedFields.containsKey(entry.getKey()))
+ {
+ automatedSetValue(entry.getKey(), entry.getValue());
+ }
}
}
}
@@ -113,10 +176,35 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
if (defaults != null)
{
_defaultAttributes.putAll(defaults);
+ for(Map.Entry<String,Object> defaultedEntry : defaults.entrySet())
+ {
+ if(_automatedFields.containsKey(defaultedEntry.getKey()) && !attributes.containsKey(defaultedEntry.getKey()))
+ {
+ automatedSetValue(defaultedEntry.getKey(),defaultedEntry.getValue());
+ }
+ }
}
_createdTime = MapValueConverter.getLongAttribute(CREATED_TIME, attributes, System.currentTimeMillis());
_createdBy = MapValueConverter.getStringAttribute(CREATED_BY, attributes, getCurrentUserName());
+ for(Attribute<?,?> attr : _attributeTypes.values())
+ {
+ if(attr.getAnnotation().mandatory() && !(attributes.containsKey(attr.getName())|| defaults.containsKey(attr.getName())))
+ {
+ throw new IllegalArgumentException("Mandatory attribute " + attr.getName() + " not supplied for instance of " + getClass().getName());
+ }
+ }
+ }
+ private void automatedSetValue(final String name, final Object value)
+ {
+ try
+ {
+ _automatedFields.get(name).set(this,_attributeTypes.get(name).convert(value));
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ServerScopedRuntimeException("Unable to set the automated attribute " + name + " on the configure object type " + getClass().getName(),e);
+ }
}
protected AbstractConfiguredObject(UUID id, TaskExecutor taskExecutor)
@@ -129,6 +217,11 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
return _id;
}
+ public final String getName()
+ {
+ return _name;
+ }
+
public State getDesiredState()
{
return null; //TODO
@@ -245,12 +338,29 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
@Override
public Object getAttribute(String name)
{
- Object value = getActualAttribute(name);
- if (value == null)
+ Attribute<?,?> attr = _attributeTypes.get(name);
+ if(attr != null && attr.getAnnotation().automate())
{
- value = getDefaultAttribute(name);
+ Object value = attr.get(this);
+ if(value != null && attr.getAnnotation().secure() &&
+ !SecurityManager.SYSTEM.equals(Subject.getSubject(AccessController.getContext())))
+ {
+ return SECURE_VALUES.get(value.getClass());
+ }
+ else
+ {
+ return value;
+ }
+ }
+ else
+ {
+ Object value = getActualAttribute(name);
+ if (value == null)
+ {
+ value = getDefaultAttribute(name);
+ }
+ return value;
}
- return value;
}
@Override
@@ -325,6 +435,18 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
{
//TODO: don't put nulls
_attributes.put(name, desired);
+ Attribute<?,?> attr = _attributeTypes.get(name);
+ if(attr != null && attr.getAnnotation().automate())
+ {
+ if(desired == null && _defaultAttributes.containsKey(name))
+ {
+ automatedSetValue(name, _defaultAttributes.get(name));
+ }
+ else
+ {
+ automatedSetValue(name, desired);
+ }
+ }
return true;
}
else
@@ -441,7 +563,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
{
UUID id = getId();
Object idAttributeValue = attributes.get(ID);
- if (idAttributeValue != null && !idAttributeValue.equals(id.toString()))
+ if (idAttributeValue != null && !(idAttributeValue.equals(id) || idAttributeValue.equals(id.toString())))
{
throw new IllegalConfigurationException("Cannot change existing configured object id");
}
@@ -632,6 +754,22 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
Object o = attributeMap.get(_name);
return _converter.convert(o);
}
+
+ public T get(final AbstractConfiguredObject<?> object)
+ {
+ try
+ {
+ return (T) _getter.invoke(object);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ServerScopedRuntimeException("Unable to access attribute " + getName() + " on configuredObject type " + object.getClass().getName(), e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new ServerScopedRuntimeException("Unable to access attribute " + getName() + " on configuredObject type " + object.getClass().getName(), e);
+ }
+ }
}
private static final class Statistic<C extends ConfiguredObject, T extends Number> extends AttributeOrStatistic<C,T>
@@ -646,14 +784,28 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
public static final class Attribute<C extends ConfiguredObject, T> extends AttributeOrStatistic<C,T>
{
- private Attribute(Class<C> clazz, String name, Class<T> type, final Method getter)
+ private final ManagedAttribute _annotation;
+
+ private Attribute(Class<C> clazz,
+ String name,
+ Class<T> type,
+ final Method getter,
+ final ManagedAttribute annotation)
{
super(name, getter, type);
+ _annotation = annotation;
addToAttributesSet(clazz, this);
}
+ public ManagedAttribute getAnnotation()
+ {
+ return _annotation;
+ }
-
+ public T convert(final Object value)
+ {
+ return _converter.convert(value);
+ }
}
@@ -1002,36 +1154,59 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
private static <X extends ConfiguredObject> void processAttributes(final Class<X> clazz)
{
- if(_allAttributes.containsKey(clazz))
+ synchronized (_allAttributes)
{
- return;
- }
+ if(_allAttributes.containsKey(clazz))
+ {
+ return;
+ }
- for(Class<?> parent : clazz.getInterfaces())
- {
- if(ConfiguredObject.class.isAssignableFrom(parent))
+ for(Class<?> parent : clazz.getInterfaces())
{
- processAttributes((Class<? extends ConfiguredObject>)parent);
+ 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 Class<? super X> superclass = clazz.getSuperclass();
- if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass))
- {
- processAttributes((Class<? extends ConfiguredObject>) superclass);
- }
- final ArrayList<Attribute<?, ?>> attributeList = new ArrayList<Attribute<?, ?>>();
- final ArrayList<Statistic<?, ?>> statisticList = new ArrayList<Statistic<?, ?>>();
+ final ArrayList<Attribute<?, ?>> attributeList = new ArrayList<Attribute<?, ?>>();
+ final ArrayList<Statistic<?, ?>> statisticList = new ArrayList<Statistic<?, ?>>();
- _allAttributes.put(clazz, attributeList);
- _allStatistics.put(clazz, statisticList);
+ _allAttributes.put(clazz, attributeList);
+ _allStatistics.put(clazz, statisticList);
- for(Class<?> parent : clazz.getInterfaces())
- {
- if(ConfiguredObject.class.isAssignableFrom(parent))
+ for(Class<?> parent : clazz.getInterfaces())
{
- Collection<Attribute<?, ?>> attrs = _allAttributes.get(parent);
+ if(ConfiguredObject.class.isAssignableFrom(parent))
+ {
+ Collection<Attribute<?, ?>> attrs = _allAttributes.get(parent);
+ for(Attribute<?,?> attr : attrs)
+ {
+ if(!attributeList.contains(attr))
+ {
+ attributeList.add(attr);
+ }
+ }
+ Collection<Statistic<?, ?>> stats = _allStatistics.get(parent);
+ for(Statistic<?,?> stat : stats)
+ {
+ if(!statisticList.contains(stat))
+ {
+ statisticList.add(stat);
+ }
+ }
+ }
+ }
+ if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass))
+ {
+ Collection<Attribute<?, ?>> attrs = _allAttributes.get(superclass);
+ Collection<Statistic<?, ?>> stats = _allStatistics.get(superclass);
for(Attribute<?,?> attr : attrs)
{
if(!attributeList.contains(attr))
@@ -1039,7 +1214,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
attributeList.add(attr);
}
}
- Collection<Statistic<?, ?>> stats = _allStatistics.get(parent);
for(Statistic<?,?> stat : stats)
{
if(!statisticList.contains(stat))
@@ -1048,61 +1222,76 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
}
}
}
- }
- if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass))
- {
- Collection<Attribute<?, ?>> attrs = _allAttributes.get(superclass);
- Collection<Statistic<?, ?>> stats = _allStatistics.get(superclass);
- for(Attribute<?,?> attr : attrs)
+
+
+ for(Method m : clazz.getDeclaredMethods())
{
- if(!attributeList.contains(attr))
+ ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class);
+ if(annotation != null)
{
- attributeList.add(attr);
+ if(m.getParameterTypes().length != 0)
+ {
+ throw new IllegalArgumentException("ManagedAttribute annotation should only be added to no-arg getters");
+ }
+ Class<?> type = getType(m);
+ String name = getName(m, type);
+ Attribute<X,?> newAttr = new Attribute(clazz,name,type,m, annotation);
+
}
- }
- for(Statistic<?,?> stat : stats)
- {
- if(!statisticList.contains(stat))
+ else
{
- statisticList.add(stat);
+ ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class);
+ if(statAnnotation != null)
+ {
+ if(m.getParameterTypes().length != 0)
+ {
+ throw new IllegalArgumentException("ManagedStatistic annotation should only be added to no-arg getters");
+ }
+ Class<?> type = getType(m);
+ if(!Number.class.isAssignableFrom(type))
+ {
+ throw new IllegalArgumentException("ManagedStatistic annotation should only be added to getters returning a Number type");
+ }
+ String name = getName(m, type);
+ Statistic<X,?> newStat = new Statistic(clazz,name,type,m);
+ }
}
}
- }
+ Map<String,Attribute<?,?>> attrMap = new HashMap<String, Attribute<?, ?>>();
+ Map<String,Field> fieldMap = new HashMap<String, Field>();
- for(Method m : clazz.getDeclaredMethods())
- {
- ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class);
- if(annotation != null)
+
+ Collection<Attribute<?, ?>> attrCol = _allAttributes.get(clazz);
+ for(Attribute<?,?> attr : attrCol)
{
- if(m.getParameterTypes().length != 0)
+ attrMap.put(attr.getName(), attr);
+ if(attr.getAnnotation().automate())
{
- throw new IllegalArgumentException("ManagedAttribute annotation should only be added to no-arg getters");
+ fieldMap.put(attr.getName(), findField(attr, clazz));
}
- Class<?> type = getType(m);
- String name = getName(m, type);
- Attribute<X,?> newAttr = new Attribute(clazz,name,type,m);
}
- else
+ _allAttributeTypes.put(clazz, attrMap);
+ _allAutomatedFields.put(clazz, fieldMap);
+ }
+ }
+
+ private static Field findField(final Attribute<?, ?> attr, Class<?> clazz)
+ {
+ while(clazz != null)
+ {
+ for(Field field : clazz.getDeclaredFields())
{
- ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class);
- if(statAnnotation != null)
+ if(field.getName().equals("_" + attr.getName()))
{
- if(m.getParameterTypes().length != 0)
- {
- throw new IllegalArgumentException("ManagedStatistic annotation should only be added to no-arg getters");
- }
- Class<?> type = getType(m);
- if(!Number.class.isAssignableFrom(type))
- {
- throw new IllegalArgumentException("ManagedStatistic annotation should only be added to getters returning a Number type");
- }
- String name = getName(m, type);
- Statistic<X,?> newStat = new Statistic(clazz,name,type,m);
+ field.setAccessible(true);
+ return field;
}
}
+ clazz = clazz.getSuperclass();
}
+ return null;
}
private static String getName(final Method m, final Class<?> type)
@@ -1246,6 +1435,21 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
}
+ private static Map<String, Attribute<?, ?>> getAttributeTypes(final Class<? extends ConfiguredObject> clazz)
+ {
+ if(!_allAttributeTypes.containsKey(clazz))
+ {
+ processAttributes(clazz);
+ }
+ return _allAttributeTypes.get(clazz);
+ }
-
+ private static Map<String, Field> 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/adapter/AbstractKeyStoreAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractKeyStoreAdapter.java
index 1cf5ddf02a..794687b9c7 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractKeyStoreAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractKeyStoreAdapter.java
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.UUID;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.KeyStore;
@@ -43,25 +44,19 @@ public abstract class AbstractKeyStoreAdapter<X extends ConfiguredObject<X>> ext
public static final String DUMMY_PASSWORD_MASK = "********";
public static final String DEFAULT_KEYSTORE_TYPE = java.security.KeyStore.getDefaultType();
- private String _name;
private String _password;
+
protected AbstractKeyStoreAdapter(UUID id, Broker broker, Map<String, Object> defaults,
Map<String, Object> attributes)
{
super(id, defaults, attributes, broker.getTaskExecutor());
+
addParent(Broker.class, broker);
- _name = MapValueConverter.getStringAttribute(TrustStore.NAME, attributes);
- _password = MapValueConverter.getStringAttribute(TrustStore.PASSWORD, attributes);
MapValueConverter.assertMandatoryAttribute(KeyStore.PATH, attributes);
}
- @Override
- public String getName()
- {
- return _name;
- }
@Override
public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException
@@ -115,15 +110,7 @@ public abstract class AbstractKeyStoreAdapter<X extends ConfiguredObject<X>> ext
@Override
public Object getAttribute(String name)
{
- if(KeyStore.ID.equals(name))
- {
- return getId();
- }
- else if(KeyStore.NAME.equals(name))
- {
- return getName();
- }
- else if(KeyStore.STATE.equals(name))
+ if(KeyStore.STATE.equals(name))
{
return getState();
}
@@ -135,25 +122,13 @@ public abstract class AbstractKeyStoreAdapter<X extends ConfiguredObject<X>> ext
{
return getLifetimePolicy();
}
- else if(KeyStore.PASSWORD.equals(name))
- {
- return getPassword();
- }
return super.getAttribute(name);
}
public String getPassword()
{
- // For security reasons we don't expose the password unless running as the system user
- if(SecurityManager.SYSTEM.equals(Subject.getSubject(AccessController.getContext())))
- {
- return _password;
- }
- else
- {
- return DUMMY_PASSWORD_MASK;
- }
+ return _password;
}
public void setPassword(String password)
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java
index f3c8d52286..ee6a5b5607 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java
@@ -49,7 +49,7 @@ public class AccessControlProviderAdapter extends AbstractConfiguredObject<Acces
public AccessControlProviderAdapter(UUID id, Broker broker, AccessControl accessControl, Map<String, Object> attributes, Collection<String> attributeNames)
{
- super(id, Collections.<String,Object>emptyMap(), Collections.<String,Object>emptyMap(), broker.getTaskExecutor());
+ super(id, Collections.<String,Object>emptyMap(), Collections.singletonMap(NAME,attributes.get(NAME)), broker.getTaskExecutor());
if (accessControl == null)
{
@@ -89,12 +89,6 @@ public class AccessControlProviderAdapter extends AbstractConfiguredObject<Acces
}
@Override
- public String getName()
- {
- return (String)getAttribute(AccessControlProvider.NAME);
- }
-
- @Override
public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException
{
return null;
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
index c8e056855b..f24acb7eb5 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
@@ -66,7 +66,7 @@ public abstract class AuthenticationProviderAdapter<X extends AuthenticationProv
private AuthenticationProviderAdapter(UUID id, Broker broker, final T authManager, Map<String, Object> attributes, Collection<String> attributeNames)
{
- super(id, Collections.<String,Object>emptyMap(), Collections.<String,Object>emptyMap(), broker.getTaskExecutor());
+ super(createAttributes(id, attributes), Collections.<String,Object>emptyMap(), broker.getTaskExecutor());
_authManager = authManager;
_broker = broker;
_supportedAttributes = createSupportedAttributes(attributeNames);
@@ -89,6 +89,14 @@ public abstract class AuthenticationProviderAdapter<X extends AuthenticationProv
}
}
+ private static Map<String, Object> createAttributes(final UUID id, final Map<String, Object> attributes)
+ {
+ Map<String, Object> initialAttributes = new HashMap<String, Object>();
+ initialAttributes.put(ID, id);
+ initialAttributes.put(NAME, attributes.get(NAME));
+ return initialAttributes;
+ }
+
T getAuthManager()
{
return _authManager;
@@ -101,12 +109,6 @@ public abstract class AuthenticationProviderAdapter<X extends AuthenticationProv
}
@Override
- public String getName()
- {
- return (String)getAttribute(AuthenticationProvider.NAME);
- }
-
- @Override
public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException
{
return null;
@@ -556,7 +558,7 @@ public abstract class AuthenticationProviderAdapter<X extends AuthenticationProv
public PrincipalAdapter(Principal user)
{
- super(UUIDGenerator.generateUserUUID(PrincipalDatabaseAuthenticationManagerAdapter.this.getName(), user.getName()),
+ super(Collections.<String,Object>emptyMap(), createPrincipalAttributes(PrincipalDatabaseAuthenticationManagerAdapter.this, user),
PrincipalDatabaseAuthenticationManagerAdapter.this.getTaskExecutor());
_user = user;
@@ -581,11 +583,6 @@ public abstract class AuthenticationProviderAdapter<X extends AuthenticationProv
}
}
- @Override
- public String getName()
- {
- return _user.getName();
- }
@Override
public String setName(String currentName, String desiredName)
@@ -753,6 +750,14 @@ public abstract class AuthenticationProviderAdapter<X extends AuthenticationProv
}
+ private static Map<String, Object> createPrincipalAttributes(PrincipalDatabaseAuthenticationManagerAdapter manager, final Principal user)
+ {
+ final Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(ID, UUIDGenerator.generateUserUUID(manager.getName(), user.getName()));
+ attributes.put(NAME, user.getName());
+ return attributes;
+ }
+
}
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
index e12191e9ba..d1f083deed 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
@@ -499,11 +499,6 @@ public class BrokerAdapter<X extends Broker<X>> extends AbstractConfiguredObject
return true;
}
- public String getName()
- {
- return (String)getAttribute(NAME);
- }
-
public String setName(final String currentName, final String desiredName)
throws IllegalStateException, AccessControlException
{
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
index f51fb30584..16b1d0092b 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
@@ -22,14 +22,7 @@ package org.apache.qpid.server.model.adapter;
import java.security.AccessControlException;
import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.model.*;
@@ -45,34 +38,58 @@ final class ConnectionAdapter extends AbstractConfiguredObject<ConnectionAdapter
private final Map<AMQSessionModel, SessionAdapter> _sessionAdapters =
new HashMap<AMQSessionModel, SessionAdapter>();
+ private String _remoteAddress;
+ private String _localAddress;
+ private String _clientId;
+ private String _clientVersion;
+ private boolean _incoming;
+ private Transport _transport;
+ private Port _port;
+ private String _remoteProcessName;
+ private String _remoteProcessPid;
+
public ConnectionAdapter(final AMQConnectionModel conn, TaskExecutor taskExecutor)
{
- super(UUIDGenerator.generateRandomUUID(), taskExecutor);
+ super(Collections.<String,Object>emptyMap(), createAttributes(conn), taskExecutor);
_connection = conn;
}
+ private static Map<String, Object> createAttributes(final AMQConnectionModel conn)
+ {
+ Map<String,Object> attributes = new HashMap<String, Object>();
+ attributes.put(ID, UUID.randomUUID());
+ attributes.put(NAME, conn.getRemoteAddressString().replaceAll("/", ""));
+ attributes.put(CLIENT_ID, conn.getClientId() );
+ attributes.put(CLIENT_VERSION, conn.getClientVersion());
+ attributes.put(TRANSPORT, conn.getTransport());
+ attributes.put(PORT, conn.getPort());
+ attributes.put(INCOMING, true);
+ attributes.put(REMOTE_ADDRESS, conn.getRemoteAddressString());
+ return attributes;
+ }
+
@Override
public String getClientId()
{
- return (String) getAttribute(CLIENT_ID);
+ return _clientId;
}
@Override
public String getClientVersion()
{
- return (String) getAttribute(CLIENT_VERSION);
+ return _clientVersion;
}
@Override
public boolean isIncoming()
{
- return true;
+ return _incoming;
}
@Override
public String getLocalAddress()
{
- return (String)getAttribute(LOCAL_ADDRESS);
+ return _localAddress;
}
@Override
@@ -85,19 +102,19 @@ final class ConnectionAdapter extends AbstractConfiguredObject<ConnectionAdapter
@Override
public String getRemoteAddress()
{
- return _connection.getRemoteAddressString();
+ return _remoteAddress;
}
@Override
public String getRemoteProcessName()
{
- return null;
+ return _remoteProcessName;
}
@Override
public String getRemoteProcessPid()
{
- return null;
+ return _remoteProcessPid;
}
@Override
@@ -109,13 +126,13 @@ final class ConnectionAdapter extends AbstractConfiguredObject<ConnectionAdapter
@Override
public Transport getTransport()
{
- return _connection.getTransport();
+ return _transport;
}
@Override
public Port getPort()
{
- return _connection.getPort();
+ return _port;
}
public Collection<Session> getSessions()
@@ -170,12 +187,6 @@ final class ConnectionAdapter extends AbstractConfiguredObject<ConnectionAdapter
_connection.close(AMQConstant.CONNECTION_FORCED, "Connection closed by external action");
}
- public String getName()
- {
- final String remoteAddressString = _connection.getRemoteAddressString();
- return remoteAddressString.replaceAll("/","");
- }
-
public String setName(final String currentName, final String desiredName)
throws IllegalStateException, AccessControlException
{
@@ -224,31 +235,7 @@ final class ConnectionAdapter extends AbstractConfiguredObject<ConnectionAdapter
public Object getAttribute(String name)
{
- if(name.equals(ID))
- {
- return getId();
- }
- else if (name.equals(NAME))
- {
- return getName();
- }
- else if(name.equals(CLIENT_ID))
- {
- return _connection.getClientId();
- }
- else if(name.equals(CLIENT_VERSION))
- {
- return _connection.getClientVersion();
- }
- else if(name.equals(INCOMING))
- {
- return true;
- }
- else if(name.equals(LOCAL_ADDRESS))
- {
-
- }
- else if(name.equals(PRINCIPAL))
+ if(name.equals(PRINCIPAL))
{
final Principal authorizedPrincipal = _connection.getAuthorizedPrincipal();
return authorizedPrincipal == null ? null : authorizedPrincipal.getName();
@@ -257,18 +244,6 @@ final class ConnectionAdapter extends AbstractConfiguredObject<ConnectionAdapter
{
}
- else if(name.equals(REMOTE_ADDRESS))
- {
- return _connection.getRemoteAddressString();
- }
- else if(name.equals(REMOTE_PROCESS_NAME))
- {
-
- }
- else if(name.equals(REMOTE_PROCESS_PID))
- {
-
- }
else if(name.equals(SESSION_COUNT_LIMIT))
{
return _connection.getSessionCountLimit();
@@ -288,9 +263,7 @@ final class ConnectionAdapter extends AbstractConfiguredObject<ConnectionAdapter
@Override
public Collection<String> getAttributeNames()
{
- final HashSet<String> attrNames = new HashSet<String>(getAttributeNames(Connection.class));
-
- return Collections.unmodifiableCollection(attrNames);
+ return getAttributeNames(Connection.class);
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
index f1ba45dd09..5e3a3061d0 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
@@ -95,12 +95,6 @@ public class FileSystemPreferencesProvider extends AbstractConfiguredObject<File
return getAttributeNames(FileSystemPreferencesProvider.class);
}
- @Override
- public String getName()
- {
- return (String) getAttribute(AuthenticationProvider.NAME);
- }
-
@ManagedAttribute
public String getPath()
{
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java
index 09ab758271..4c2d2ac4e0 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java
@@ -21,13 +21,7 @@ package org.apache.qpid.server.model.adapter;
import java.security.AccessControlException;
import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.log4j.Logger;
@@ -49,7 +43,7 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
public GroupProviderAdapter(UUID id, Broker broker, GroupManager groupManager, Map<String, Object> attributes, Collection<String> attributeNames)
{
- super(id, Collections.<String,Object>emptyMap(), Collections.<String,Object>emptyMap(), broker.getTaskExecutor());
+ super(id, Collections.singletonMap(NAME, attributes.get(NAME)), Collections.<String,Object>emptyMap(), broker.getTaskExecutor());
if (groupManager == null)
{
@@ -87,12 +81,6 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
}
@Override
- public String getName()
- {
- return (String)getAttribute(NAME);
- }
-
- @Override
public String setName(String currentName, String desiredName)
throws IllegalStateException, AccessControlException
{
@@ -170,7 +158,11 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
getSecurityManager().authoriseGroupOperation(Operation.CREATE, groupName);
_groupManager.createGroup(groupName);
- return (C) new GroupAdapter(groupName, getTaskExecutor());
+ Map<String,Object> attrMap = new HashMap<String, Object>();
+ UUID id = UUIDGenerator.generateGroupUUID(getName(),groupName);
+ attrMap.put(Group.ID, id);
+ attrMap.put(Group.NAME, groupName);
+ return (C) new GroupAdapter(attrMap, getTaskExecutor());
}
@@ -189,7 +181,11 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
Collection<Group> principals = new ArrayList<Group>(groups.size());
for (Principal group : groups)
{
- principals.add(new GroupAdapter(group.getName(), getTaskExecutor()));
+ Map<String,Object> attrMap = new HashMap<String, Object>();
+ UUID id = UUIDGenerator.generateGroupUUID(getName(),group.getName());
+ attrMap.put(Group.ID, id);
+ attrMap.put(Group.NAME, group.getName());
+ principals.add(new GroupAdapter(attrMap, getTaskExecutor()));
}
return (Collection<C>) Collections
.unmodifiableCollection(principals);
@@ -331,22 +327,15 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
throw new UnsupportedOperationException("Changing attributes on group providers is not supported.");
}
+
private class GroupAdapter extends AbstractConfiguredObject<GroupAdapter> implements Group<GroupAdapter>
{
- private final String _group;
- public GroupAdapter(String group, TaskExecutor taskExecutor)
+ public GroupAdapter(Map<String,Object> attributes, TaskExecutor taskExecutor)
{
- super(UUIDGenerator.generateGroupUUID(GroupProviderAdapter.this.getName(), group), taskExecutor);
- _group = group;
-
+ super(Collections.<String,Object>emptyMap(),attributes, taskExecutor);
}
- @Override
- public String getName()
- {
- return _group;
- }
@Override
public String setName(String currentName, String desiredName)
@@ -395,11 +384,15 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
if (clazz == GroupMember.class)
{
Set<Principal> usersInGroup = _groupManager
- .getUserPrincipalsForGroup(_group);
+ .getUserPrincipalsForGroup(getName());
Collection<GroupMember> members = new ArrayList<GroupMember>();
for (Principal principal : usersInGroup)
{
- members.add(new GroupMemberAdapter(principal.getName(), getTaskExecutor()));
+ UUID id = UUIDGenerator.generateGroupMemberUUID(GroupProviderAdapter.this.getName(), getName(), principal.getName());
+ Map<String,Object> attrMap = new HashMap<String, Object>();
+ attrMap.put(GroupMember.ID,id);
+ attrMap.put(GroupMember.NAME, principal.getName());
+ members.add(new GroupMemberAdapter(attrMap, getTaskExecutor()));
}
return (Collection<C>) Collections
.unmodifiableCollection(members);
@@ -420,10 +413,14 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
{
String memberName = (String) attributes.get(GroupMember.NAME);
- getSecurityManager().authoriseGroupOperation(Operation.UPDATE, _group);
+ getSecurityManager().authoriseGroupOperation(Operation.UPDATE, getName());
- _groupManager.addUserToGroup(memberName, _group);
- return (C) new GroupMemberAdapter(memberName, getTaskExecutor());
+ _groupManager.addUserToGroup(memberName, getName());
+ UUID id = UUIDGenerator.generateGroupMemberUUID(GroupProviderAdapter.this.getName(), getName(), memberName);
+ Map<String,Object> attrMap = new HashMap<String, Object>();
+ attrMap.put(GroupMember.ID,id);
+ attrMap.put(GroupMember.NAME, memberName);
+ return (C) new GroupMemberAdapter(attrMap, getTaskExecutor());
}
@@ -458,8 +455,8 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
{
if (desiredState == State.DELETED)
{
- getSecurityManager().authoriseGroupOperation(Operation.DELETE, _group);
- _groupManager.removeGroup(_group);
+ getSecurityManager().authoriseGroupOperation(Operation.DELETE, getName());
+ _groupManager.removeGroup(getName());
return true;
}
@@ -483,12 +480,10 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
private class GroupMemberAdapter extends AbstractConfiguredObject<GroupMemberAdapter> implements
GroupMember<GroupMemberAdapter>
{
- private String _memberName;
- public GroupMemberAdapter(String memberName, TaskExecutor taskExecutor)
+ public GroupMemberAdapter(Map<String,Object> attrMap, TaskExecutor taskExecutor)
{
- super(UUIDGenerator.generateGroupMemberUUID(GroupProviderAdapter.this.getName(), _group, memberName), taskExecutor);
- _memberName = memberName;
+ super(Collections.<String,Object>emptyMap(), attrMap, taskExecutor);
}
@Override
@@ -497,25 +492,6 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
return getAttributeNames(GroupMember.class);
}
- @Override
- public Object getAttribute(String name)
- {
- if (ID.equals(name))
- {
- return getId();
- }
- else if (NAME.equals(name))
- {
- return getName();
- }
- return super.getAttribute(name);
- }
-
- @Override
- public String getName()
- {
- return _memberName;
- }
@Override
public String setName(String currentName, String desiredName)
@@ -579,9 +555,9 @@ public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProvider
{
if (desiredState == State.DELETED)
{
- getSecurityManager().authoriseGroupOperation(Operation.UPDATE, _group);
+ getSecurityManager().authoriseGroupOperation(Operation.UPDATE, GroupAdapter.this.getName());
- _groupManager.removeUserFromGroup(_memberName, _group);
+ _groupManager.removeUserFromGroup(getName(), GroupAdapter.this.getName());
return true;
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
index 5b9e9c89f6..cdffe2f36b 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
@@ -64,6 +64,11 @@ public class KeyStoreAdapter extends AbstractKeyStoreAdapter<KeyStoreAdapter> im
put(KEY_MANAGER_FACTORY_ALGORITHM, String.class);
}});
+ private String _keyStoreType;
+ private String _certificateAlias;
+ private String _keyManagerFactoryAlgorithm;
+ private String _path;
+
@SuppressWarnings("serial")
public static final Map<String, Object> DEFAULTS = Collections.unmodifiableMap(new HashMap<String, Object>(){{
put(KeyStore.KEY_STORE_TYPE, DEFAULT_KEYSTORE_TYPE);
@@ -74,24 +79,11 @@ public class KeyStoreAdapter extends AbstractKeyStoreAdapter<KeyStoreAdapter> im
public KeyStoreAdapter(UUID id, Broker<?> broker, Map<String, Object> attributes)
{
- super(id, broker, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES));
+ super(id, broker, DEFAULTS, attributes);
_broker = broker;
- String keyStorePath = (String)getAttribute(KeyStore.PATH);
- String keyStorePassword = Subject.doAs(SecurityManager.SYSTEM, new PrivilegedAction<String>()
- {
- @Override
- public String run()
- {
- return getPassword();
- }
- });
- String keyStoreType = (String)getAttribute(KeyStore.KEY_STORE_TYPE);
- String keyManagerFactoryAlgorithm = (String)getAttribute(KeyStore.KEY_MANAGER_FACTORY_ALGORITHM);
- String certAlias = (String)getAttribute(KeyStore.CERTIFICATE_ALIAS);
-
- validateKeyStoreAttributes(keyStoreType, keyStorePath, keyStorePassword,
- certAlias, keyManagerFactoryAlgorithm);
+ validateKeyStoreAttributes(_keyStoreType, _path, getPassword(),
+ _certificateAlias, _keyManagerFactoryAlgorithm);
}
@Override
@@ -235,59 +227,47 @@ public class KeyStoreAdapter extends AbstractKeyStoreAdapter<KeyStoreAdapter> im
@Override
public String getPath()
{
- return (String) getAttribute(PATH);
+ return _path;
}
@Override
public String getCertificateAlias()
{
- return (String) getAttribute(CERTIFICATE_ALIAS);
+ return _certificateAlias;
}
@Override
public String getKeyManagerFactoryAlgorithm()
{
- return (String) getAttribute(KEY_MANAGER_FACTORY_ALGORITHM);
+ return _keyManagerFactoryAlgorithm;
}
@Override
public String getKeyStoreType()
{
- return (String) getAttribute(KEY_STORE_TYPE);
+ return _keyStoreType;
}
public KeyManager[] getKeyManagers() throws GeneralSecurityException
{
- String keyStorePath = (String)getAttribute(KeyStore.PATH);
- String keyStorePassword = Subject.doAs(SecurityManager.SYSTEM, new PrivilegedAction<String>()
- {
- @Override
- public String run()
- {
- return getPassword();
- }
- });
- String keyStoreType = (String)getAttribute(KeyStore.KEY_STORE_TYPE);
- String keyManagerFactoryAlgorithm = (String)getAttribute(KeyStore.KEY_MANAGER_FACTORY_ALGORITHM);
- String certAlias = (String)getAttribute(KeyStore.CERTIFICATE_ALIAS);
try
{
- if (certAlias != null)
+ if (_certificateAlias != null)
{
return new KeyManager[] {
- new QpidClientX509KeyManager( certAlias, keyStorePath, keyStoreType, keyStorePassword,
- keyManagerFactoryAlgorithm)
+ new QpidClientX509KeyManager( _certificateAlias, _path, _keyStoreType, getPassword(),
+ _keyManagerFactoryAlgorithm)
};
}
else
{
- final java.security.KeyStore ks = SSLUtil.getInitializedKeyStore(keyStorePath, keyStorePassword, keyStoreType);
+ final java.security.KeyStore ks = SSLUtil.getInitializedKeyStore(_path, getPassword(), _keyStoreType);
- char[] keyStoreCharPassword = keyStorePassword == null ? null : keyStorePassword.toCharArray();
+ char[] keyStoreCharPassword = getPassword() == null ? null : getPassword().toCharArray();
- final KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithm);
+ final KeyManagerFactory kmf = KeyManagerFactory.getInstance(_keyManagerFactoryAlgorithm);
kmf.init(ks, keyStoreCharPassword);
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java
index 54a9a44bf3..aa7550b510 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java
@@ -169,12 +169,6 @@ abstract public class PortAdapter<X extends PortAdapter<X>> extends AbstractConf
}
@Override
- public String getName()
- {
- return (String)getAttribute(NAME);
- }
-
- @Override
public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException
{
throw new IllegalStateException();
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
index 92e409e103..669bf19874 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import org.apache.qpid.server.model.*;
import org.apache.qpid.server.consumer.Consumer;
@@ -42,16 +43,27 @@ final class SessionAdapter extends AbstractConfiguredObject<SessionAdapter> impl
private AMQSessionModel _session;
private Map<Consumer, QueueConsumer> _consumerAdapters = new HashMap<Consumer, QueueConsumer>();
+ private int _channelId;
+
public SessionAdapter(final AMQSessionModel session, TaskExecutor taskExecutor)
{
- super(UUIDGenerator.generateRandomUUID(), taskExecutor);
+ super(Collections.<String,Object>emptyMap(),createAttributes(session), taskExecutor);
_session = session;
}
+ private static Map<String, Object> createAttributes(final AMQSessionModel session)
+ {
+ Map<String,Object> attributes = new HashMap<String, Object>();
+ attributes.put(ID, UUID.randomUUID());
+ attributes.put(NAME, String.valueOf(session.getChannelId()));
+ attributes.put(CHANNEL_ID, session.getChannelId());
+ return attributes;
+ }
+
@Override
public int getChannelId()
{
- return _session.getChannelId();
+ return _channelId;
}
@Override
@@ -73,11 +85,6 @@ final class SessionAdapter extends AbstractConfiguredObject<SessionAdapter> impl
return null; //TODO
}
- public String getName()
- {
- return String.valueOf(_session.getChannelId());
- }
-
public String setName(final String currentName, final String desiredName)
throws IllegalStateException, AccessControlException
{
@@ -121,19 +128,7 @@ final class SessionAdapter extends AbstractConfiguredObject<SessionAdapter> impl
@Override
public Object getAttribute(String name)
{
- if(name.equals(ID))
- {
- return getId();
- }
- else if (name.equals(NAME))
- {
- return getName();
- }
- else if(name.equals(CHANNEL_ID))
- {
- return _session.getChannelId();
- }
- else if(name.equals(PRODUCER_FLOW_BLOCKED))
+ if(name.equals(PRODUCER_FLOW_BLOCKED))
{
return _session.getBlocking();
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java
index c1e9c1de0e..03fac7d54d 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java
@@ -74,27 +74,21 @@ public class TrustStoreAdapter extends AbstractKeyStoreAdapter<TrustStoreAdapter
put(TrustStore.TRUST_MANAGER_FACTORY_ALGORITHM, TrustManagerFactory.getDefaultAlgorithm());
}});
+
+ private String _trustStoreType;
+ private String _trustManagerFactoryAlgorithm;
+ private String _path;
+ private boolean _peersOnly;
+
+
private Broker<?> _broker;
public TrustStoreAdapter(UUID id, Broker<?> broker, Map<String, Object> attributes)
{
- super(id, broker, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES));
+ super(id, broker, DEFAULTS, attributes);
_broker = broker;
- String trustStorePath = (String) getAttribute(TrustStore.PATH);
- String trustStorePassword = Subject.doAs(SecurityManager.SYSTEM, new PrivilegedAction<String>()
- {
- @Override
- public String run()
- {
- return getPassword();
- }
- });
- String trustStoreType = (String) getAttribute(TrustStore.TRUST_STORE_TYPE);
- String trustManagerFactoryAlgorithm = (String) getAttribute(TrustStore.TRUST_MANAGER_FACTORY_ALGORITHM);
-
- validateTrustStoreAttributes(trustStoreType, trustStorePath,
- trustStorePassword, trustManagerFactoryAlgorithm);
+ validateTrustStoreAttributes(_trustStoreType, _path, getPassword(), _trustManagerFactoryAlgorithm);
}
@Override
@@ -224,41 +218,33 @@ public class TrustStoreAdapter extends AbstractKeyStoreAdapter<TrustStoreAdapter
@Override
public String getPath()
{
- return (String) getAttribute(PATH);
+ return _path;
}
@Override
public String getTrustManagerFactoryAlgorithm()
{
- return (String) getAttribute(TRUST_MANAGER_FACTORY_ALGORITHM);
+ return _trustManagerFactoryAlgorithm;
}
@Override
public String getTrustStoreType()
{
- return (String) getAttribute(TRUST_STORE_TYPE);
+ return _trustStoreType;
}
@Override
public boolean isPeersOnly()
{
- return (Boolean) getAttribute(PEERS_ONLY);
+ return _peersOnly;
}
public TrustManager[] getTrustManagers() throws GeneralSecurityException
{
- String trustStorePath = (String)getAttribute(TrustStore.PATH);
- String trustStorePassword = Subject.doAs(org.apache.qpid.server.security.SecurityManager.SYSTEM,
- new PrivilegedAction<String>()
- {
- @Override
- public String run()
- {
- return getPassword();
- }
- });
- String trustStoreType = (String)getAttribute(TrustStore.TRUST_STORE_TYPE);
- String trustManagerFactoryAlgorithm = (String)getAttribute(TrustStore.TRUST_MANAGER_FACTORY_ALGORITHM);
+ String trustStorePath = _path;
+ String trustStorePassword = getPassword();
+ String trustStoreType = _trustStoreType;
+ String trustManagerFactoryAlgorithm = _trustManagerFactoryAlgorithm;
try
{
@@ -273,7 +259,7 @@ public class TrustStoreAdapter extends AbstractKeyStoreAdapter<TrustStoreAdapter
{
if (tm instanceof X509TrustManager)
{
- if (Boolean.TRUE.equals(getAttribute(PEERS_ONLY)))
+ if (_peersOnly)
{
// truststore is supposed to trust only clients which peers certificates
// are directly in the store. CA signing will not be considered.
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
index 36d8ebde43..97b6744f1b 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
@@ -92,7 +92,7 @@ public final class VirtualHostAdapter extends AbstractConfiguredObject<VirtualHo
public VirtualHostAdapter(UUID id, Map<String, Object> attributes, Broker<?> broker, StatisticsGatherer brokerStatisticsGatherer, TaskExecutor taskExecutor)
{
- super(id, null, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES, false), taskExecutor, false);
+ super(id, Collections.<String,Object>emptyMap(), MapValueConverter.convert(attributes, ATTRIBUTE_TYPES, false), taskExecutor, false);
_broker = broker;
_brokerStatisticsGatherer = brokerStatisticsGatherer;
validateAttributes();
@@ -361,12 +361,6 @@ public final class VirtualHostAdapter extends AbstractConfiguredObject<VirtualHo
}
}
-
- public String getName()
- {
- return (String)getAttribute(NAME);
- }
-
public String setName(final String currentName, final String desiredName)
throws IllegalStateException, AccessControlException
{
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java
index 8520884fd6..8c715c3519 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.model.adapter;
+import java.util.HashMap;
import java.util.Map;
import org.apache.qpid.server.model.AuthenticationMethod;
import org.apache.qpid.server.model.ConfiguredObject;
@@ -42,11 +43,19 @@ public class VirtualHostAliasAdapter extends AbstractConfiguredObject<VirtualHos
public VirtualHostAliasAdapter(VirtualHostAdapter virtualHostAdapter, Port port)
{
- super(UUIDGenerator.generateVhostAliasUUID(virtualHostAdapter.getName(), port.getName()), virtualHostAdapter.getTaskExecutor());
+ super(Collections.<String,Object>emptyMap(), createAttributes(virtualHostAdapter, port), virtualHostAdapter.getTaskExecutor());
_vhost = virtualHostAdapter;
_port = port;
}
+ private static Map<String, Object> createAttributes(final VirtualHostAdapter virtualHostAdapter, final Port port)
+ {
+ final Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(ID, UUIDGenerator.generateVhostAliasUUID(virtualHostAdapter.getName(), port.getName()));
+ attributes.put(NAME, virtualHostAdapter.getName());
+ return attributes;
+ }
+
@Override
public Port getPort()
{
@@ -66,12 +75,6 @@ public class VirtualHostAliasAdapter extends AbstractConfiguredObject<VirtualHos
}
@Override
- public String getName()
- {
- return _vhost.getName();
- }
-
- @Override
public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException
{
throw new IllegalStateException(); // TODO - Implement
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 516fc7750c..a1ccfc0d41 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
@@ -101,8 +101,6 @@ public abstract class AbstractQueue
private final VirtualHost _virtualHost;
- private final String _name;
-
/** null means shared */
private String _description;
@@ -189,7 +187,6 @@ public abstract class AbstractQueue
private final AtomicBoolean _overfull = new AtomicBoolean(false);
private final CopyOnWriteArrayList<BindingImpl> _bindings = new CopyOnWriteArrayList<BindingImpl>();
- private UUID _id;
private final Map<String, Object> _arguments;
//TODO : persist creation time
@@ -216,10 +213,7 @@ public abstract class AbstractQueue
throw new IllegalArgumentException("Virtual Host must not be null");
}
- UUID id = MapValueConverter.getUUIDAttribute(Queue.ID, attributes);
- String name = MapValueConverter.getStringAttribute(Queue.NAME, attributes);
-
- if (name == null)
+ if (getName() == null)
{
throw new IllegalArgumentException("Queue name must not be null");
}
@@ -236,8 +230,6 @@ public abstract class AbstractQueue
attributes,
LifetimePolicy.PERMANENT);
-
- _name = name;
_durable = durable;
_virtualHost = virtualHost;
_entries = entryListFactory.createQueueEntryList(this);
@@ -251,8 +243,6 @@ public abstract class AbstractQueue
_noLocal = MapValueConverter.getBooleanAttribute(Queue.NO_LOCAL, attributes, false);
-
- _id = id;
_asyncDelivery = ReferenceCountingExecutorService.getInstance().acquireExecutorService();
_logSubject = new QueueLogSubject(this);
@@ -562,10 +552,6 @@ public abstract class AbstractQueue
{
return getOwner();
}
- else if(NAME.equals(name))
- {
- return getName();
- }
if(ALERT_REPEAT_GAP.equals(name))
{
return getAlertRepeatGap();
@@ -641,10 +627,6 @@ public abstract class AbstractQueue
{
return isDurable();
}
- else if(ID.equals(name))
- {
- return getId();
- }
else if(LIFETIME_POLICY.equals(name))
{
return getLifetimePolicy();
@@ -694,11 +676,6 @@ public abstract class AbstractQueue
return _virtualHost;
}
- public String getName()
- {
- return _name;
- }
-
// ------ Manage Consumers
@@ -1408,7 +1385,7 @@ public abstract class AbstractQueue
public int compareTo(final AMQQueue o)
{
- return _name.compareTo(o.getName());
+ return getName().compareTo(o.getName());
}
public AtomicInteger getAtomicQueueCount()
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
index f0a8f239a8..57e4eff230 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
@@ -22,6 +22,8 @@ package org.apache.qpid.server.queue;
import org.apache.log4j.Logger;
import org.apache.qpid.server.filter.FilterManager;
+import org.apache.qpid.server.filter.JMSSelectorFilter;
+import org.apache.qpid.server.filter.MessageFilter;
import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -43,11 +45,7 @@ import org.apache.qpid.server.util.StateChangeListener;
import java.security.AccessControlException;
import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.UUID;
+import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
@@ -70,7 +68,6 @@ class QueueConsumerImpl
private final MessageInstance.ConsumerAcquiredState<QueueConsumerImpl> _owningState = new MessageInstance.ConsumerAcquiredState<QueueConsumerImpl>(this);
private final boolean _acquires;
private final boolean _seesRequeues;
- private final String _consumerName;
private final boolean _isTransient;
private final AtomicLong _deliveredCount = new AtomicLong(0);
private final AtomicLong _deliveredBytes = new AtomicLong(0);
@@ -78,7 +75,6 @@ class QueueConsumerImpl
private final Class<? extends ServerMessage> _messageClass;
private final Object _sessionReference;
private final AbstractQueue _queue;
- private final boolean _exclusive;
private GenericActor _logActor = new GenericActor("[" + MessageFormat.format(SUBSCRIPTION_FORMAT, getConsumerNumber())
+ "(UNKNOWN)"
+ "] ");
@@ -103,7 +99,12 @@ class QueueConsumerImpl
CurrentActor.get().message(SubscriptionMessages.STATE(newState.toString()));
}
};
- private final boolean _noLocal;
+ private boolean _durable;
+ private boolean _exclusive;
+ private boolean _noLocal;
+ private String _distributionMode;
+ private String _settlementMode;
+ private String _selector;
QueueConsumerImpl(final AbstractQueue queue,
ConsumerTarget target, final String consumerName,
@@ -111,8 +112,8 @@ class QueueConsumerImpl
final Class<? extends ServerMessage> messageClass,
EnumSet<Option> optionSet)
{
- super(UUID.randomUUID(), Collections.<String,Object>emptyMap(),
- Collections.<String,Object>emptyMap(),
+ super(Collections.<String,Object>emptyMap(),
+ createAttributeMap(consumerName,filters,optionSet),
queue.getVirtualHost().getTaskExecutor());
_messageClass = messageClass;
_sessionReference = target.getSessionModel().getConnectionReference();
@@ -120,13 +121,10 @@ class QueueConsumerImpl
_filters = filters;
_acquires = optionSet.contains(Option.ACQUIRES);
_seesRequeues = optionSet.contains(Option.SEES_REQUEUES);
- _consumerName = consumerName;
_isTransient = optionSet.contains(Option.TRANSIENT);
_target = target;
_queue = queue;
- _noLocal = optionSet.contains(Option.NO_LOCAL);
- _exclusive = optionSet.contains(Option.EXCLUSIVE);
- setupLogging(optionSet.contains(Option.EXCLUSIVE));
+ setupLogging();
// Access control
_queue.getVirtualHost().getSecurityManager().authoriseCreateConsumer(this);
@@ -145,6 +143,32 @@ class QueueConsumerImpl
});
}
+ private static Map<String, Object> createAttributeMap(String name, FilterManager filters, EnumSet<Option> optionSet)
+ {
+ Map<String,Object> attributes = new HashMap<String, Object>();
+ attributes.put(ID, UUID.randomUUID());
+ attributes.put(NAME, name);
+ attributes.put(EXCLUSIVE, optionSet.contains(Option.EXCLUSIVE));
+ attributes.put(NO_LOCAL, optionSet.contains(Option.NO_LOCAL));
+ attributes.put(DISTRIBUTION_MODE, optionSet.contains(Option.ACQUIRES) ? "MOVE" : "COPY");
+ attributes.put(DURABLE,false);
+ if(filters != null)
+ {
+ Iterator<MessageFilter> iter = filters.filters();
+ while(iter.hasNext())
+ {
+ MessageFilter filter = iter.next();
+ if(filter instanceof JMSSelectorFilter)
+ {
+ attributes.put(SELECTOR, ((JMSSelectorFilter) filter).getSelector());
+ break;
+ }
+ }
+ }
+
+ return attributes;
+ }
+
private void targetStateChanged(final ConsumerTarget.State oldState, final ConsumerTarget.State newState)
{
if(oldState != newState)
@@ -269,7 +293,7 @@ class QueueConsumerImpl
return _queue;
}
- private void setupLogging(final boolean exclusive)
+ private void setupLogging()
{
String queueString = new QueueLogSubject(_queue).toLogString();
@@ -285,7 +309,7 @@ class QueueConsumerImpl
if (CurrentActor.get().getRootMessageLogger().isMessageEnabled(_logActor, _logActor.getLogSubject(), SubscriptionMessages.CREATE_LOG_HIERARCHY))
{
final String filterLogString = getFilterLogString();
- CurrentActor.get().message(_logActor.getLogSubject(), SubscriptionMessages.CREATE(filterLogString, _queue.isDurable() && exclusive,
+ CurrentActor.get().message(_logActor.getLogSubject(), SubscriptionMessages.CREATE(filterLogString, _queue.isDurable() && _exclusive,
filterLogString.length() > 0));
}
}
@@ -442,11 +466,6 @@ class QueueConsumerImpl
return _seesRequeues;
}
- public final String getName()
- {
- return _consumerName;
- }
-
public final boolean isTransient()
{
return _isTransient;
@@ -479,13 +498,13 @@ class QueueConsumerImpl
@Override
public String getDistributionMode()
{
- return acquires() ? "MOVE" : "COPY";
+ return _distributionMode;
}
@Override
public String getSettlementMode()
{
- return null;
+ return _settlementMode;
}
@Override
@@ -497,13 +516,13 @@ class QueueConsumerImpl
@Override
public boolean isNoLocal()
{
- return isNoLocal();
+ return _noLocal;
}
@Override
public String getSelector()
{
- return null;
+ return _selector;
}
@Override
@@ -516,7 +535,7 @@ class QueueConsumerImpl
@Override
public boolean isDurable()
{
- return false;
+ return _durable;
}
@Override
@@ -548,34 +567,10 @@ class QueueConsumerImpl
@Override
public Object getAttribute(final String name)
{
- if(ID.equals(name))
- {
- return getId();
- }
- else if(NAME.equals(name))
- {
- return getName();
- }
- else if(DURABLE.equals(name))
- {
- return isDurable();
- }
- else if(DISTRIBUTION_MODE.equals(name))
- {
- return getDistributionMode();
- }
- else if(SETTLEMENT_MODE.equals(name))
- {
- return getSettlementMode();
- }
- else if(LIFETIME_POLICY.equals(name))
+ if(LIFETIME_POLICY.equals(name))
{
return getLifetimePolicy();
}
- else if(EXCLUSIVE.equals(name))
- {
- return isExclusive();
- }
return super.getAttribute(name);
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java
index b774f4a478..1a204292b7 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java
@@ -34,6 +34,7 @@ import javax.security.auth.Subject;
import junit.framework.TestCase;
import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.KeyStore;
import org.apache.qpid.server.model.adapter.AbstractKeyStoreAdapter;
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java
index 422a266efb..9649838b00 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java
@@ -127,6 +127,10 @@ public class VirtualHostRecovererTest extends TestCase
{
// pass
}
+ catch(IllegalArgumentException e)
+ {
+ // pass
+ }
}
}
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
index 1d942705c7..3b8ab12384 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
@@ -96,6 +96,7 @@ public class FileSystemPreferencesProviderTest extends QpidTestCase
{
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(FileSystemPreferencesProvider.PATH, nonExistingFile.getAbsolutePath());
+ attributes.put(FileSystemPreferencesProvider.NAME, getTestName());
_preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes, _authenticationProvider, _broker.getTaskExecutor());
_preferencesProvider.createStoreIfNotExist();
assertEquals(State.INITIALISING, _preferencesProvider.getState());
@@ -115,6 +116,7 @@ public class FileSystemPreferencesProviderTest extends QpidTestCase
try
{
Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(FileSystemPreferencesProvider.NAME, getTestName());
attributes.put(FileSystemPreferencesProvider.PATH, emptyPrefsFile.getAbsolutePath());
_preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes, _authenticationProvider, _broker.getTaskExecutor());
assertEquals(State.INITIALISING, _preferencesProvider.getState());
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
index 047cdfc29b..d11b1e029c 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
@@ -420,13 +420,6 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem
return httpPorts;
}
-
- @Override
- public String getName()
- {
- return (String)getAttribute(NAME);
- }
-
@Override
public Collection<String> getAttributeNames()
{
diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
index b1999b1292..64667dc96c 100644
--- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
+++ b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
@@ -310,12 +310,6 @@ public class JMXManagement extends AbstractPluginAdapter<JMXManagement> implemen
}
@Override
- public String getName()
- {
- return (String)getAttribute(NAME);
- }
-
- @Override
public Collection<String> getAttributeNames()
{
return getAttributeNames(JMXManagement.class);