qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1587682 - in /qpid/trunk/qpid/java/broker-core/src: main/java/org/apache/qpid/server/binding/ main/java/org/apache/qpid/server/model/ main/java/org/apache/qpid/server/model/adapter/ main/java/org/apache/qpid/server/queue/ main/java/org/apa...
Date Tue, 15 Apr 2014 18:47:57 GMT
Author: rgodfrey
Date: Tue Apr 15 18:47:56 2014
New Revision: 1587682

URL: http://svn.apache.org/r1587682
Log:
QPID-5698 : [Java Broker] make attributes automated or derived

Modified:
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java
Tue Apr 15 18:47:56 2014
@@ -122,13 +122,13 @@ public class BindingImpl
     }
 
     @Override
-    public Queue getQueue()
+    public Queue<?> getQueue()
     {
         return _queue;
     }
 
     @Override
-    public ExchangeImpl getExchange()
+    public ExchangeImpl<?> getExchange()
     {
         return _exchange;
     }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
Tue Apr 15 18:47:56 2014
@@ -136,6 +136,9 @@ public abstract class AbstractConfigured
     private boolean _durable;
 
     @ManagedAttributeField
+    private String _description;
+
+    @ManagedAttributeField
     private LifetimePolicy _lifetimePolicy;
 
     private final Map<String, ConfiguredObjectAttribute<?,?>> _attributeTypes;
@@ -342,6 +345,10 @@ public abstract class AbstractConfigured
         }
         catch (InvocationTargetException e)
         {
+            if(e.getCause() instanceof RuntimeException)
+            {
+                throw (RuntimeException) e.getCause();
+            }
             throw new ServerScopedRuntimeException("Unable to set the automated attribute
" + name + " on the configure object type " + getClass().getName(),e);
         }
     }
@@ -630,7 +637,7 @@ public abstract class AbstractConfigured
     public Object getAttribute(String name)
     {
         ConfiguredObjectAttribute<X,?> attr = (ConfiguredObjectAttribute<X, ?>)
_attributeTypes.get(name);
-        if(attr != null && attr.getAnnotation().automate())
+        if(attr != null && (attr.getAnnotation().automate() || attr.getAnnotation().derived()))
         {
             Object value = attr.getValue((X)this);
             if(value != null && attr.getAnnotation().secure() &&
@@ -653,7 +660,7 @@ public abstract class AbstractConfigured
     @Override
     public String getDescription()
     {
-        return (String) getAttribute(DESCRIPTION);
+        return _description;
     }
 
     @Override
@@ -926,7 +933,9 @@ public abstract class AbstractConfigured
             {
                 Object desired = attributes.get(name);
                 Object expected = getAttribute(name);
-                if (changeAttribute(name, expected, desired))
+                if(((_attributes.get(name) != null && !_attributes.get(name).equals(attributes.get(name)))
+                     || attributes.get(name) != null)
+                    && changeAttribute(name, expected, desired))
                 {
                     attributeSet(name, expected, desired);
                 }
@@ -1005,19 +1014,19 @@ public abstract class AbstractConfigured
     }
 
     @Override
-    public String getLastUpdatedBy()
+    public final String getLastUpdatedBy()
     {
         return _lastUpdatedBy;
     }
 
     @Override
-    public long getLastUpdatedTime()
+    public final long getLastUpdatedTime()
     {
         return _lastUpdatedTime;
     }
 
     @Override
-    public String getCreatedBy()
+    public final String getCreatedBy()
     {
         return _createdBy;
     }
@@ -1038,7 +1047,7 @@ public abstract class AbstractConfigured
     }
 
     @Override
-    public long getCreatedTime()
+    public final long getCreatedTime()
     {
         return _createdTime;
     }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java
Tue Apr 15 18:47:56 2014
@@ -31,11 +31,13 @@ public interface Binding<X extends Bindi
     public String QUEUE = "queue";
     public String EXCHANGE = "exchange";
 
-    @ManagedAttribute
-    Queue getQueue();
+    // TODO - this is a hack
+    @ManagedAttribute( derived = true )
+    Queue<?> getQueue();
 
-    @ManagedAttribute
-    Exchange getExchange();
+    // TODO - this is a hack
+    @ManagedAttribute( derived = true )
+    Exchange<?> getExchange();
 
     @ManagedAttribute
     Map<String,Object> getArguments();

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
Tue Apr 15 18:47:56 2014
@@ -99,6 +99,9 @@ public interface Broker<X extends Broker
     @ManagedAttribute( derived = true )
     Collection<String> getSupportedPreferencesProviderTypes();
 
+    @ManagedAttribute( derived = true )
+    Collection<String> getSupportedVirtualHostTypes();
+
     @ManagedAttribute( automate = true )
     String getDefaultVirtualHost();
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
Tue Apr 15 18:47:56 2014
@@ -65,7 +65,7 @@ public interface ConfiguredObject<X exte
     String getName();
 
 
-    @ManagedAttribute
+    @ManagedAttribute( automate = true )
     String getDescription();
 
     @ManagedAttribute( automate = true )
@@ -74,16 +74,16 @@ public interface ConfiguredObject<X exte
     @ManagedAttribute(automate = true)
     Map<String, String> getContext();
 
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     String getLastUpdatedBy();
 
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     long getLastUpdatedTime();
 
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     String getCreatedBy();
 
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     long getCreatedTime();
 
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Connection.java
Tue Apr 15 18:47:56 2014
@@ -28,53 +28,52 @@ public interface Connection<X extends Co
 
     // Attributes
 
-    public static final String STATE = "state";
+    String STATE = "state";
 
-    public static final String CLIENT_ID = "clientId";
-    public static final String CLIENT_VERSION = "clientVersion";
-    public static final String INCOMING = "incoming";
-    public static final String LOCAL_ADDRESS = "localAddress";
-    public static final String PRINCIPAL = "principal";
-    public static final String PROPERTIES = "properties";
-    public static final String REMOTE_ADDRESS = "remoteAddress";
-    public static final String REMOTE_PROCESS_NAME = "remoteProcessName";
-    public static final String REMOTE_PROCESS_PID = "remoteProcessPid";
-    public static final String SESSION_COUNT_LIMIT = "sessionCountLimit";
-    public static final String TRANSPORT = "transport";
-    /** Name of port associated with the connection */
-    public static final String PORT = "port";
+    String CLIENT_ID = "clientId";
+    String CLIENT_VERSION = "clientVersion";
+    String INCOMING = "incoming";
+    String LOCAL_ADDRESS = "localAddress";
+    String PRINCIPAL = "principal";
+    String PROPERTIES = "properties";
+    String REMOTE_ADDRESS = "remoteAddress";
+    String REMOTE_PROCESS_NAME = "remoteProcessName";
+    String REMOTE_PROCESS_PID = "remoteProcessPid";
+    String SESSION_COUNT_LIMIT = "sessionCountLimit";
+    String TRANSPORT = "transport";
+    String PORT = "port";
 
-    @ManagedAttribute( automate = true )
+    @ManagedAttribute( derived = true )
     String getClientId();
 
-    @ManagedAttribute( automate = true )
+    @ManagedAttribute( derived = true )
     String getClientVersion();
 
-    @ManagedAttribute( automate = true )
+    @ManagedAttribute( derived = true )
     boolean isIncoming();
 
-    @ManagedAttribute( automate = true )
+    @ManagedAttribute( derived = true )
     String getLocalAddress();
 
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     String getPrincipal();
 
-    @ManagedAttribute( automate = true )
+    @ManagedAttribute( derived = true )
     String getRemoteAddress();
 
-    @ManagedAttribute( automate = true )
+    @ManagedAttribute( derived = true )
     String getRemoteProcessName();
 
-    @ManagedAttribute( automate = true )
+    @ManagedAttribute( derived = true )
     String getRemoteProcessPid();
 
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     long getSessionCountLimit();
 
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     Transport getTransport();
 
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     Port getPort();
 
     @ManagedStatistic

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java
Tue Apr 15 18:47:56 2014
@@ -101,7 +101,7 @@ public interface Queue<X extends Queue<X
 
 
     // TODO - this is not an attribute
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     boolean isQueueFlowStopped();
 
     @ManagedContextDefault( name = "queue.alertThresholdMessageAge")

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Session.java
Tue Apr 15 18:47:56 2014
@@ -32,10 +32,10 @@ public interface Session<X extends Sessi
     // available credit of both producer and consumer sides.
     String PRODUCER_FLOW_BLOCKED = "producerFlowBlocked";
 
-    @ManagedAttribute( automate = true )
+    @ManagedAttribute( derived = true )
     int getChannelId();
 
-    @ManagedAttribute
+    @ManagedAttribute( derived = true )
     boolean isProducerFlowBlocked();
 
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java
Tue Apr 15 18:47:56 2014
@@ -47,10 +47,12 @@ public interface VirtualHost<X extends V
     String CONFIGURATION_STORE_SETTINGS         = "configurationStoreSettings";
     String MESSAGE_STORE_SETTINGS               = "messageStoreSettings";
 
-    @ManagedAttribute
+    // TODO - this isn't really an attribute
+    @ManagedAttribute( derived = true )
     Collection<String> getSupportedExchangeTypes();
 
-    @ManagedAttribute
+    // TODO - this isn't really an attribute
+    @ManagedAttribute( derived = true )
     Collection<String> getSupportedQueueTypes();
 
     @ManagedContextDefault( name = "queue.deadLetterQueueEnabled")
@@ -89,7 +91,7 @@ public interface VirtualHost<X extends V
     @ManagedAttribute( automate = true, defaultValue = "${virtualhost.storeTransactionOpenTimeoutWarn}")
     long getStoreTransactionOpenTimeoutWarn();
 
-    @ManagedAttribute
+    @ManagedAttribute( automate = true )
     String getSecurityAcl();
 
     @ManagedContextDefault( name = "virtualhost.housekeepingThreadCount")

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
Tue Apr 15 18:47:56 2014
@@ -137,7 +137,8 @@ public class BrokerAdapter extends Abstr
                          SystemContext parent)
     {
         super(parentsMap(parent),
-              combineIdWithAttributes(id,MapValueConverter.convert(attributes, ATTRIBUTE_TYPES)),
parent.getTaskExecutor());
+              combineIdWithAttributes(id, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES)),
+              parent.getTaskExecutor());
 
         _objectFactory = parent.getObjectFactory();
         _virtualHostRegistry = new VirtualHostRegistry(parent.getEventLogger());
@@ -266,31 +267,33 @@ public class BrokerAdapter extends Abstr
     @Override
     public String getBuildVersion()
     {
-        return (String) getAttribute(BUILD_VERSION);
+        return QpidProperties.getBuildVersion();
     }
 
     @Override
     public String getOperatingSystem()
     {
-        return (String) getAttribute(OPERATING_SYSTEM);
+        return SystemUtils.getOSString();
     }
 
     @Override
     public String getPlatform()
     {
-        return (String) getAttribute(PLATFORM);
+        return System.getProperty("java.vendor") + " "
+                      + System.getProperty("java.runtime.version", System.getProperty("java.version"));
     }
 
     @Override
     public String getProcessPid()
     {
-        return (String) getAttribute(PROCESS_PID);
+        // TODO
+        return null;
     }
 
     @Override
     public String getProductVersion()
     {
-        return (String) getAttribute(PRODUCT_VERSION);
+        return QpidProperties.getReleaseVersion();
     }
 
     @Override
@@ -300,6 +303,12 @@ public class BrokerAdapter extends Abstr
     }
 
     @Override
+    public Collection<String> getSupportedVirtualHostTypes()
+    {
+        return _objectFactory.getSupportedTypes(VirtualHost.class);
+    }
+
+    @Override
     public Collection<String> getSupportedAuthenticationProviders()
     {
         return _objectFactory.getSupportedTypes(AuthenticationProvider.class);
@@ -801,47 +810,6 @@ public class BrokerAdapter extends Abstr
         {
             return State.ACTIVE;
         }
-        else if(BUILD_VERSION.equals(name))
-        {
-            return QpidProperties.getBuildVersion();
-        }
-        else if(OPERATING_SYSTEM.equals(name))
-        {
-            return SystemUtils.getOSString();
-        }
-        else if(PLATFORM.equals(name))
-        {
-            return System.getProperty("java.vendor") + " "
-                   + System.getProperty("java.runtime.version", System.getProperty("java.version"));
-        }
-        else if(PROCESS_PID.equals(name))
-        {
-            // TODO
-        }
-        else if(PRODUCT_VERSION.equals(name))
-        {
-            return QpidProperties.getReleaseVersion();
-        }
-        else if(SUPPORTED_VIRTUALHOST_STORE_TYPES.equals(name))
-        {
-            return _supportedVirtualHostStoreTypes;
-        }
-        else if(SUPPORTED_VIRTUALHOST_TYPES.equals(name))
-        {
-            return _objectFactory.getSupportedTypes(VirtualHost.class);
-        }
-        else if(SUPPORTED_AUTHENTICATION_PROVIDERS.equals(name))
-        {
-            return getSupportedAuthenticationProviders();
-        }
-        else if (SUPPORTED_PREFERENCES_PROVIDER_TYPES.equals(name))
-        {
-            return getSupportedPreferencesProviderTypes();
-        }
-        else if (MODEL_VERSION.equals(name))
-        {
-            return Model.MODEL_VERSION;
-        }
         return super.getAttribute(name);
     }
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
Tue Apr 15 18:47:56 2014
@@ -39,25 +39,6 @@ public final class ConnectionAdapter ext
     private final Map<AMQSessionModel, SessionAdapter> _sessionAdapters =
             new HashMap<AMQSessionModel, SessionAdapter>();
 
-    @ManagedAttributeField
-    private String _remoteAddress;
-    @ManagedAttributeField
-    private String _localAddress;
-    @ManagedAttributeField
-    private String _clientId;
-    @ManagedAttributeField
-    private String _clientVersion;
-    @ManagedAttributeField
-    private boolean _incoming;
-    @ManagedAttributeField
-    private Transport _transport;
-    @ManagedAttributeField
-    private Port _port;
-    @ManagedAttributeField
-    private String _remoteProcessName;
-    @ManagedAttributeField
-    private String _remoteProcessPid;
-
     public ConnectionAdapter(final AMQConnectionModel conn, TaskExecutor taskExecutor)
     {
         super(parentsMap(conn.getVirtualHost()),createAttributes(conn), taskExecutor);
@@ -66,17 +47,11 @@ public final class ConnectionAdapter ext
         conn.addSessionListener(this);
     }
 
-    private static Map<String, Object> createAttributes(final AMQConnectionModel conn)
+    private static Map<String, Object> createAttributes(final AMQConnectionModel _connection)
     {
         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());
+        attributes.put(NAME, _connection.getRemoteAddressString().replaceAll("/", ""));
         attributes.put(DURABLE, false);
         return attributes;
     }
@@ -84,25 +59,25 @@ public final class ConnectionAdapter ext
     @Override
     public String getClientId()
     {
-        return _clientId;
+        return _connection.getClientId();
     }
 
     @Override
     public String getClientVersion()
     {
-        return _clientVersion;
+        return _connection.getClientVersion();
     }
 
     @Override
     public boolean isIncoming()
     {
-        return _incoming;
+        return true;
     }
 
     @Override
     public String getLocalAddress()
     {
-        return _localAddress;
+        return null;
     }
 
     @Override
@@ -115,19 +90,19 @@ public final class ConnectionAdapter ext
     @Override
     public String getRemoteAddress()
     {
-        return _remoteAddress;
+        return _connection.getRemoteAddressString();
     }
 
     @Override
     public String getRemoteProcessName()
     {
-        return _remoteProcessName;
+        return null;
     }
 
     @Override
     public String getRemoteProcessPid()
     {
-        return _remoteProcessPid;
+        return null;
     }
 
     @Override
@@ -139,13 +114,13 @@ public final class ConnectionAdapter ext
     @Override
     public Transport getTransport()
     {
-        return _transport;
+        return _connection.getTransport();
     }
 
     @Override
     public Port getPort()
     {
-        return _port;
+        return _connection.getPort();
     }
 
     public Collection<Session> getSessions()
@@ -179,34 +154,6 @@ public final class ConnectionAdapter ext
         return null;  //TODO
     }
 
-    @Override
-    public Object getAttribute(String name)
-    {
-
-        if(name.equals(PRINCIPAL))
-        {
-            final Principal authorizedPrincipal = _connection.getAuthorizedPrincipal();
-            return authorizedPrincipal == null ? null : authorizedPrincipal.getName();
-        }
-        else if(name.equals(PROPERTIES))
-        {
-
-        }
-        else if(name.equals(SESSION_COUNT_LIMIT))
-        {
-            return _connection.getSessionCountLimit();
-        }
-        else if(name.equals(TRANSPORT))
-        {
-            return String.valueOf(_connection.getTransport());
-        }
-        else if(name.equals(PORT))
-        {
-            Port port = _connection.getPort();
-            return String.valueOf(port == null ? null : port.getName());
-        }
-        return super.getAttribute(name);
-    }
 
     @Override
     public <C extends ConfiguredObject> Collection<C> getChildren(Class<C>
clazz)

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
Tue Apr 15 18:47:56 2014
@@ -30,6 +30,6 @@ public interface FileSystemPreferencesPr
     String PATH = "path";
     String PROVIDER_TYPE = "FileSystemPreferences";
 
-    @ManagedAttribute
+    @ManagedAttribute( automate = true )
     String getPath();
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java
Tue Apr 15 18:47:56 2014
@@ -54,6 +54,7 @@ import org.apache.qpid.server.model.Auth
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.IllegalStateTransitionException;
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.util.MapValueConverter;
 
@@ -76,6 +77,11 @@ public class FileSystemPreferencesProvid
 
     private FileSystemPreferencesStore _store;
 
+    @ManagedAttributeField( afterSet = "openNewStore" )
+    private String _path;
+
+    private boolean _open;
+
     public FileSystemPreferencesProviderImpl(UUID id, Map<String, Object> attributes,
                                              AuthenticationProvider<? extends AuthenticationProvider>
authenticationProvider)
     {
@@ -85,8 +91,15 @@ public class FileSystemPreferencesProvid
         State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes,
State.INITIALISING);
         _state = new AtomicReference<State>(state);
         _authenticationProvider = authenticationProvider;
-        _store = new FileSystemPreferencesStore(new File(MapValueConverter.getStringAttribute(PATH,
attributes)));
+    }
+
+    @Override
+    protected void onOpen()
+    {
+        super.onOpen();
+        _store = new FileSystemPreferencesStore(new File(_path));
         createStoreIfNotExist();
+        _open = true;
     }
 
     @Override
@@ -102,7 +115,7 @@ public class FileSystemPreferencesProvid
     @Override
     public String getPath()
     {
-        return (String) getAttribute(PATH);
+        return _path;
     }
 
     @Override
@@ -127,6 +140,11 @@ public class FileSystemPreferencesProvid
         return super.getAttribute(name);
     }
 
+    public void close()
+    {
+        setDesiredState(getState(), State.STOPPED);
+    }
+
     @Override
     public boolean setState(State currentState, State desiredState) throws IllegalStateTransitionException,
AccessControlException
     {
@@ -136,15 +154,18 @@ public class FileSystemPreferencesProvid
             if ((state == State.INITIALISING || state == State.ACTIVE || state == State.STOPPED
|| state == State.QUIESCED || state == State.ERRORED)
                     && _state.compareAndSet(state, State.DELETED))
             {
-                try
-                {
-                    _store.close();
-                }
-                finally
+                if(_store != null)
                 {
-                    _store.delete();
-                    deleted();
-                    _authenticationProvider.setPreferencesProvider(null);
+                    try
+                    {
+                        _store.close();
+                    }
+                    finally
+                    {
+                        _store.delete();
+                        deleted();
+                        _authenticationProvider.setPreferencesProvider(null);
+                    }
                 }
                 return true;
             }
@@ -194,7 +215,10 @@ public class FileSystemPreferencesProvid
         {
             if (_state.compareAndSet(state, State.STOPPED))
             {
-                _store.close();
+                if(_store != null)
+                {
+                    _store.close();
+                }
                 return true;
             }
             else
@@ -235,47 +259,38 @@ public class FileSystemPreferencesProvid
         return _authenticationProvider;
     }
 
+
+
     @Override
     protected void changeAttributes(Map<String, Object> attributes)
     {
-        Map<String, Object> effectiveAttributes = MapValueConverter.convert(super.generateEffectiveAttributes(attributes),
-                ATTRIBUTE_TYPES);
 
-        String effectivePath = (String) effectiveAttributes.get(PATH);
-        String currentPath = (String) getAttribute(PATH);
+        super.changeAttributes(attributes);
 
-        File storeFile = new File(effectivePath);
-        FileSystemPreferencesStore newStore = null;
-        if (!effectivePath.equals(currentPath))
+        // if provider was previously in ERRORED state then set its state to ACTIVE
+        _state.compareAndSet(State.ERRORED, State.ACTIVE);
+    }
+
+    private void openNewStore()
+    {
+        if(_open)
         {
-            if (!storeFile.exists())
+            if (_store != null)
             {
-                throw new IllegalConfigurationException("Path to preferences file does not
exist!");
+                _store.close();
             }
-            newStore = new FileSystemPreferencesStore(storeFile);
-            newStore.open();
-        }
 
-        try
-        {
-            super.changeAttributes(attributes);
-
-            if (newStore != null)
+            if (_path == null)
             {
-                _store.close();
-                _store = newStore;
-                newStore = null;
+                _store = null;
             }
-        }
-        finally
-        {
-            if (newStore != null)
+            else
             {
-                newStore.close();
+                _store = new FileSystemPreferencesStore(new File(_path));
+                createStoreIfNotExist();
+                _store.open();
             }
         }
-        // if provider was previously in ERRORED state then set its state to ACTIVE
-        _state.compareAndSet(State.ERRORED, State.ACTIVE);
     }
 
     @Override
@@ -294,9 +309,22 @@ public class FileSystemPreferencesProvid
             throw new IllegalConfigurationException("Changing the type of preferences provider
is not supported");
         }
 
-        if (changedAttributes.contains(PATH) && (updated.getPath() == null || updated.getPath().equals("")))
+        if (changedAttributes.contains(PATH))
         {
-            throw new IllegalConfigurationException("Path to preferences file is not specified");
+            if(updated.getPath() == null || updated.getPath().equals(""))
+            {
+                throw new IllegalConfigurationException("Path to preferences file is not
specified");
+            }
+            else if(!updated.getPath().equals(getPath()))
+            {
+                File storeFile = new File(updated.getPath());
+
+                if (!storeFile.exists())
+                {
+                    throw new IllegalConfigurationException("Path to preferences file does
not exist!");
+                }
+
+            }
         }
 
         if(changedAttributes.contains(DURABLE) && !updated.isDurable())
@@ -304,6 +332,8 @@ public class FileSystemPreferencesProvid
             throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable");
         }
 
+
+
     }
 
     public void createStoreIfNotExist()

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
Tue Apr 15 18:47:56 2014
@@ -40,8 +40,6 @@ final class SessionAdapter extends Abstr
 
     private AMQSessionModel _session;
 
-    @ManagedAttributeField
-    private int _channelId;
 
     public SessionAdapter(final ConnectionAdapter connectionAdapter,
                           final AMQSessionModel session,
@@ -71,7 +69,6 @@ final class SessionAdapter extends Abstr
         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());
         attributes.put(DURABLE, false);
         attributes.put(LIFETIME_POLICY, LifetimePolicy.DELETE_ON_SESSION_END);
         return attributes;
@@ -80,7 +77,7 @@ final class SessionAdapter extends Abstr
     @Override
     public int getChannelId()
     {
-        return _channelId;
+        return _session.getChannelId();
     }
 
     @Override

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
Tue Apr 15 18:47:56 2014
@@ -194,19 +194,6 @@ public interface AMQQueue<X extends AMQQ
 
     void setNotificationListener(QueueNotificationListener listener);
 
-    /**
-     * Sets the free text description of this queue.
-     *
-     * @param description
-     *
-     */
-    void setDescription(String description);
-
-    /**
-     * Gets the free text description of this queue.
-     */
-    String getDescription();
-
     long getPersistentDequeuedBytes();
 
     long getPersistentDequeuedMessages();

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
Tue Apr 15 18:47:56 2014
@@ -118,8 +118,6 @@ public abstract class AbstractQueue
     private final VirtualHostImpl _virtualHost;
     private final DeletedChildListener _deletedChildListener = new DeletedChildListener();
 
-    private String _description;
-
     private ExchangeImpl _alternateExchange;
 
 
@@ -309,7 +307,6 @@ public abstract class AbstractQueue
         arguments.put(Queue.LIFETIME_POLICY, getLifetimePolicy());
 
         _arguments = Collections.synchronizedMap(arguments);
-        _description = MapValueConverter.getStringAttribute(Queue.DESCRIPTION, attributes,
null);
 
         _noLocal = MapValueConverter.getBooleanAttribute(Queue.NO_LOCAL, attributes, false);
 
@@ -2406,18 +2403,6 @@ public abstract class AbstractQueue
         _notificationListener = listener;
     }
 
-    @Override
-    public void setDescription(String description)
-    {
-        _description = description;
-    }
-
-    @Override
-    public String getDescription()
-    {
-        return _description;
-    }
-
     public final  <M extends ServerMessage<? extends StorableMessageMetaData>>
int send(final M message,
                                                                                         final
String routingAddress,
                                                                                         final
InstanceProperties instanceProperties,
@@ -2824,11 +2809,6 @@ public abstract class AbstractQueue
                 }
                 return false;
             }
-            else if (DESCRIPTION.equals(name))
-            {
-                setDescription((String) desired);
-                return true;
-            }
 
             return super.changeAttribute(name, expected, desired);
         }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
Tue Apr 15 18:47:56 2014
@@ -164,6 +164,9 @@ public abstract class AbstractVirtualHos
     @ManagedAttributeField
     private int _housekeepingThreadCount;
 
+    @ManagedAttributeField
+    private String _securityAcl;
+
 
     public AbstractVirtualHost(final Map<String, Object> attributes, Broker<?>
broker)
     {
@@ -1550,7 +1553,7 @@ public abstract class AbstractVirtualHos
     @Override
     public String getSecurityAcl()
     {
-        return (String)getAttribute(SECURITY_ACL);
+        return _securityAcl;
     }
 
     @Override

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java
Tue Apr 15 18:47:56 2014
@@ -21,6 +21,14 @@
 
 package org.apache.qpid.server.configuration.startup;
 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.PreferencesProvider;
@@ -30,14 +38,6 @@ import org.apache.qpid.server.util.Broke
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.test.utils.TestFileUtils;
 
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 /*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
@@ -98,6 +98,7 @@ public class PreferencesProviderCreation
         {
             attributes.put(FileSystemPreferencesProvider.PATH, file.getAbsolutePath());
             PreferencesProvider provider = new FileSystemPreferencesProviderImpl(id,attributes,_authenticationProvider);
+            provider.open();
             assertNotNull("Preferences provider was not recovered", provider);
             assertEquals("Unexpected name", "test-provider", provider.getName());
             assertEquals("Unexpected id", id, provider.getId());

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
Tue Apr 15 18:47:56 2014
@@ -99,7 +99,8 @@ public class FileSystemPreferencesProvid
             attributes.put(FileSystemPreferencesProvider.PATH, nonExistingFile.getAbsolutePath());
             attributes.put(ConfiguredObject.NAME, getTestName());
             _preferencesProvider = new FileSystemPreferencesProviderImpl(UUID.randomUUID(),
attributes, _authenticationProvider);
-            _preferencesProvider.createStoreIfNotExist();
+            _preferencesProvider.open();
+
             assertEquals(State.INITIALISING, _preferencesProvider.getState());
             assertTrue("Preferences file was not created", nonExistingFile.exists());
         }
@@ -121,6 +122,7 @@ public class FileSystemPreferencesProvid
             attributes.put(FileSystemPreferencesProvider.PATH, emptyPrefsFile.getAbsolutePath());
             _preferencesProvider = new FileSystemPreferencesProviderImpl(UUID.randomUUID(),
attributes, _authenticationProvider);
             assertEquals(State.INITIALISING, _preferencesProvider.getState());
+            _preferencesProvider.close();
         }
         finally
         {
@@ -279,7 +281,9 @@ public class FileSystemPreferencesProvid
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(FileSystemPreferencesProvider.PATH, _preferencesFile.getAbsolutePath());
         attributes.put(ConfiguredObject.NAME, "test");
-        return _preferencesProvider = new FileSystemPreferencesProviderImpl(UUID.randomUUID(),
attributes, _authenticationProvider);
+        _preferencesProvider = new FileSystemPreferencesProviderImpl(UUID.randomUUID(), attributes,
_authenticationProvider);
+        _preferencesProvider.open();
+        return _preferencesProvider;
     }
 
     private void assertUser1Preferences(Map<String, Object> preferences1)

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java?rev=1587682&r1=1587681&r2=1587682&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java
Tue Apr 15 18:47:56 2014
@@ -77,7 +77,7 @@ public class SecurityManagerTest extends
 
     public void testAuthoriseCreateBinding()
     {
-        ExchangeImpl<?> exchange = mock(ExchangeImpl.class);
+        ExchangeImpl exchange = mock(ExchangeImpl.class);
         when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost);
         when(exchange.getName()).thenReturn(TEST_EXCHANGE);
 
@@ -470,7 +470,7 @@ public class SecurityManagerTest extends
 
     public void testAuthoriseUnbind()
     {
-        ExchangeImpl<?> exchange = mock(ExchangeImpl.class);
+        ExchangeImpl exchange = mock(ExchangeImpl.class);
         when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost);
         when(exchange.getName()).thenReturn(TEST_EXCHANGE);
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message