You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2015/01/27 16:00:16 UTC

svn commit: r1655057 [4/8] - in /qpid/branches/QPID-6262-JavaBrokerNIO: ./ qpid/ qpid/cpp/examples/messaging/ qpid/cpp/src/ qpid/cpp/src/qpid/amqp_0_10/ qpid/cpp/src/qpid/broker/ qpid/cpp/src/qpid/broker/amqp/ qpid/cpp/src/qpid/client/amqp0_10/ qpid/cp...

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemConfig.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemConfig.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemConfig.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemConfig.java Tue Jan 27 15:00:13 2015
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.model;
 
-import org.apache.qpid.server.BrokerOptions;
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.LogRecorder;
 import org.apache.qpid.server.store.DurableConfigurationStore;
@@ -28,9 +27,41 @@ import org.apache.qpid.server.store.Dura
 @ManagedObject (creatable = false)
 public interface SystemConfig<X extends SystemConfig<X>> extends ConfiguredObject<X>
 {
-    EventLogger getEventLogger();
+    String MANAGEMENT_MODE = "managementMode";
+    
+    String MANAGEMENT_MODE_QUIESCE_VIRTUAL_HOSTS = "managementModeQuiesceVirtualHosts";
+    String MANAGEMENT_MODE_RMI_PORT_OVERRIDE = "managementModeRmiPortOverride";
+    String MANAGEMENT_MODE_JMX_PORT_OVERRIDE = "managementModeJmxPortOverride";
+    String MANAGEMENT_MODE_HTTP_PORT_OVERRIDE = "managementModeHttpPortOverride";
+    String MANAGEMENT_MODE_PASSWORD = "managementModePassword";
+    String INITIAL_CONFIGURATION_LOCATION = "initialConfigurationLocation";
+    String STARTUP_LOGGED_TO_SYSTEM_OUT = "startupLoggedToSystemOut";
+
+    @ManagedAttribute(defaultValue = "false")
+    boolean isManagementMode();
+
+    @ManagedAttribute(defaultValue = "0")
+    int getManagementModeRmiPortOverride();
+
+    @ManagedAttribute(defaultValue = "0")
+    int getManagementModeJmxPortOverride();
+
+    @ManagedAttribute(defaultValue = "0")
+    int getManagementModeHttpPortOverride();
+
+    @ManagedAttribute(defaultValue = "false")
+    boolean isManagementModeQuiesceVirtualHosts();
+
+    @ManagedAttribute(secure = true)
+    String getManagementModePassword();
+
+    @ManagedAttribute
+    String getInitialConfigurationLocation();
 
-    BrokerOptions getBrokerOptions();
+    @ManagedAttribute(defaultValue = "true")
+    boolean isStartupLoggedToSystemOut();
+
+    EventLogger getEventLogger();
 
     Broker getBroker();
 
@@ -39,4 +70,5 @@ public interface SystemConfig<X extends
     DurableConfigurationStore getConfigurationStore();
 
     BrokerShutdownProvider getBrokerShutdownProvider();
+
 }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java Tue Jan 27 15:00:13 2015
@@ -40,19 +40,9 @@ public interface VirtualHost<X extends V
     String STORE_TRANSACTION_IDLE_TIMEOUT_WARN  = "storeTransactionIdleTimeoutWarn";
     String STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE = "storeTransactionOpenTimeoutClose";
     String STORE_TRANSACTION_OPEN_TIMEOUT_WARN  = "storeTransactionOpenTimeoutWarn";
-    String SUPPORTED_EXCHANGE_TYPES             = "supportedExchangeTypes";
-    String SUPPORTED_QUEUE_TYPES                = "supportedQueueTypes";
     String HOUSE_KEEPING_THREAD_COUNT           = "houseKeepingThreadCount";
     String MODEL_VERSION                        = "modelVersion";
 
-    // TODO - this isn't really an attribute
-    @DerivedAttribute
-    Collection<String> getSupportedExchangeTypes();
-
-    // TODO - this isn't really an attribute
-    @DerivedAttribute
-    Collection<String> getSupportedQueueTypes();
-
     @ManagedContextDefault( name = "queue.deadLetterQueueEnabled")
     public static final boolean DEFAULT_DEAD_LETTER_QUEUE_ENABLED = false;
 

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java Tue Jan 27 15:00:13 2015
@@ -71,13 +71,13 @@ public class BrokerAdapter extends Abstr
             CONNECTION_HEART_BEAT_DELAY, STATISTICS_REPORTING_PERIOD };
 
 
+    private SystemConfig<?> _parent;
     private EventLogger _eventLogger;
     private final LogRecorder _logRecorder;
 
     private final SecurityManager _securityManager;
 
     private AuthenticationProvider<?> _managementModeAuthenticationProvider;
-    private BrokerOptions _brokerOptions;
 
     private Timer _reportingTimer;
     private final StatisticsCounter _messagesDelivered, _dataDelivered, _messagesReceived, _dataReceived;
@@ -108,18 +108,17 @@ public class BrokerAdapter extends Abstr
                          SystemConfig parent)
     {
         super(parentsMap(parent), attributes);
-
+        _parent = parent;
         _logRecorder = parent.getLogRecorder();
         _eventLogger = parent.getEventLogger();
-        _brokerOptions = parent.getBrokerOptions();
-        _securityManager = new SecurityManager(this, _brokerOptions.isManagementMode());
-        if (_brokerOptions.isManagementMode())
+        _securityManager = new SecurityManager(this, parent.isManagementMode());
+        if (parent.isManagementMode())
         {
             Map<String,Object> authManagerAttrs = new HashMap<String, Object>();
             authManagerAttrs.put(NAME,"MANAGEMENT_MODE_AUTHENTICATION");
             authManagerAttrs.put(ID, UUID.randomUUID());
             SimpleAuthenticationManager authManager = new SimpleAuthenticationManager(authManagerAttrs, this);
-            authManager.addUser(BrokerOptions.MANAGEMENT_MODE_USER_NAME, _brokerOptions.getManagementModePassword());
+            authManager.addUser(BrokerOptions.MANAGEMENT_MODE_USER_NAME, _parent.getManagementModePassword());
             _managementModeAuthenticationProvider = authManager;
         }
         _messagesDelivered = new StatisticsCounter("messages-delivered");
@@ -181,6 +180,14 @@ public class BrokerAdapter extends Abstr
             deleted();
             throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable");
         }
+
+        Collection<AccessControlProvider<?>> accessControlProviders = getAccessControlProviders();
+
+        if(accessControlProviders != null && accessControlProviders.size() > 1)
+        {
+            deleted();
+            throw new IllegalArgumentException("At most one AccessControlProvider can be defined");
+        }
     }
 
     @Override
@@ -230,7 +237,7 @@ public class BrokerAdapter extends Abstr
     @StateTransition( currentState = State.UNINITIALIZED, desiredState = State.ACTIVE )
     private void activate()
     {
-        if(_brokerOptions.isManagementMode())
+        if(_parent.isManagementMode())
         {
             _managementModeAuthenticationProvider.open();
         }
@@ -243,14 +250,7 @@ public class BrokerAdapter extends Abstr
             if (children != null) {
                 for (final ConfiguredObject<?> child : children) {
 
-                    if (child instanceof  AccessControlProvider)
-                    {
-                        addAccessControlProvider((AccessControlProvider)child);
-                    }
-                    else
-                    {
-                        child.addChangeListener(this);
-                    }
+                    child.addChangeListener(this);
 
                     if (child.getState() == State.ERRORED )
                     {
@@ -263,7 +263,7 @@ public class BrokerAdapter extends Abstr
         }
 
         final boolean brokerShutdownOnErroredChild = getContextValue(Boolean.class, BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD);
-        if (!_brokerOptions.isManagementMode() && brokerShutdownOnErroredChild && hasBrokerAnyErroredChildren)
+        if (!_parent.isManagementMode() && brokerShutdownOnErroredChild && hasBrokerAnyErroredChildren)
         {
             throw new IllegalStateException(String.format("Broker context variable %s is set and the broker has %s children",
                     BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD, State.ERRORED));
@@ -274,7 +274,7 @@ public class BrokerAdapter extends Abstr
         if (isManagementMode())
         {
             _eventLogger.message(BrokerMessages.MANAGEMENT_MODE(BrokerOptions.MANAGEMENT_MODE_USER_NAME,
-                                                                _brokerOptions.getManagementModePassword()));
+                                                                _parent.getManagementModePassword()));
         }
         setState(State.ACTIVE);
     }
@@ -317,8 +317,7 @@ public class BrokerAdapter extends Abstr
     @Override
     public String getProcessPid()
     {
-        // TODO
-        return null;
+        return SystemUtils.getProcessPid();
     }
 
     @Override
@@ -328,30 +327,6 @@ public class BrokerAdapter extends Abstr
     }
 
     @Override
-    public Collection<String> getSupportedVirtualHostNodeTypes()
-    {
-        return getObjectFactory().getSupportedTypes(VirtualHostNode.class);
-    }
-
-    @Override
-    public Collection<String> getSupportedVirtualHostTypes()
-    {
-        return getObjectFactory().getSupportedTypes(VirtualHost.class);
-    }
-
-    @Override
-    public Collection<String> getSupportedAuthenticationProviders()
-    {
-        return getObjectFactory().getSupportedTypes(AuthenticationProvider.class);
-    }
-
-    @Override
-    public Collection<String> getSupportedPreferencesProviderTypes()
-    {
-        return getObjectFactory().getSupportedTypes(PreferencesProvider.class);
-    }
-
-    @Override
     public String getDefaultVirtualHost()
     {
         return _defaultVirtualHost;
@@ -604,23 +579,18 @@ public class BrokerAdapter extends Abstr
 
     private AccessControlProvider<?> createAccessControlProvider(final Map<String, Object> attributes)
     {
+        final Collection<AccessControlProvider<?>> currentProviders = getAccessControlProviders();
+        if(currentProviders != null && !currentProviders.isEmpty())
+        {
+            throw new IllegalConfigurationException("Cannot add a second AccessControlProvider");
+        }
         AccessControlProvider<?> accessControlProvider = (AccessControlProvider<?>) createChild(AccessControlProvider.class, attributes);
-        addAccessControlProvider(accessControlProvider);
+        accessControlProvider.addChangeListener(this);
 
         return accessControlProvider;
 
     }
 
-    private void addAccessControlProvider(final AccessControlProvider<?> accessControlProvider)
-    {
-        accessControlProvider.addChangeListener(this);
-        accessControlProvider.addChangeListener(_securityManager);
-        if(accessControlProvider.getState() == State.ACTIVE)
-        {
-            _securityManager.addPlugin(accessControlProvider.getAccessControl());
-        }
-    }
-
     private boolean deleteAccessControlProvider(AccessControlProvider<?> accessControlProvider)
     {
         accessControlProvider.removeChangeListener(this);
@@ -939,7 +909,7 @@ public class BrokerAdapter extends Abstr
     @Override
     public boolean isManagementMode()
     {
-        return _brokerOptions.isManagementMode();
+        return _parent.isManagementMode();
     }
 
     @Override

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java Tue Jan 27 15:00:13 2015
@@ -54,7 +54,6 @@ import org.apache.qpid.server.security.g
 public class FileBasedGroupProviderImpl
         extends AbstractConfiguredObject<FileBasedGroupProviderImpl> implements FileBasedGroupProvider<FileBasedGroupProviderImpl>
 {
-    public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.group.FileGroupProviderAttributeDescriptions";
     public static final String GROUP_FILE_PROVIDER_TYPE = "GroupFile";
     private static Logger LOGGER = Logger.getLogger(FileBasedGroupProviderImpl.class);
 
@@ -357,7 +356,7 @@ public class FileBasedGroupProviderImpl
 
     private class GroupAdapter extends AbstractConfiguredObject<GroupAdapter> implements Group<GroupAdapter>
     {
-
+        private GroupPrincipal _groupPrincipal;
         public GroupAdapter(Map<String, Object> attributes)
         {
             super(parentsMap(FileBasedGroupProviderImpl.this), attributes);
@@ -396,6 +395,7 @@ public class FileBasedGroupProviderImpl
                 groupMemberAdapter.open();
                 members.add(groupMemberAdapter);
             }
+            _groupPrincipal = new GroupPrincipal(getName());
         }
 
         @Override
@@ -463,16 +463,30 @@ public class FileBasedGroupProviderImpl
             setState(State.DELETED);
         }
 
+        @Override
+        public GroupPrincipal getGroupPrincipal()
+        {
+            return _groupPrincipal;
+        }
+
         private class GroupMemberAdapter extends AbstractConfiguredObject<GroupMemberAdapter> implements
                 GroupMember<GroupMemberAdapter>
         {
 
+            private Principal _principal;
+
             public GroupMemberAdapter(Map<String, Object> attrMap)
             {
                 // TODO - need to relate to the User object
                 super(parentsMap(GroupAdapter.this),attrMap);
             }
 
+            @Override
+            protected void onOpen()
+            {
+                super.onOpen();
+                _principal = new UsernamePrincipal(getName());
+            }
 
             @Override
             public void onValidate()
@@ -484,6 +498,8 @@ public class FileBasedGroupProviderImpl
                 }
             }
 
+
+
             @Override
             protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes)
             {
@@ -517,6 +533,11 @@ public class FileBasedGroupProviderImpl
                 setState(State.DELETED);
             }
 
+            @Override
+            public Principal getPrincipal()
+            {
+                return _principal;
+            }
         }
     }
 

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/Pluggable.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/Pluggable.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/Pluggable.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/Pluggable.java Tue Jan 27 15:00:13 2015
@@ -1,4 +1,4 @@
-package org.apache.qpid.server.plugin;/*
+/*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,6 +19,8 @@ package org.apache.qpid.server.plugin;/*
  *
  */
 
+package org.apache.qpid.server.plugin;
+
 public interface Pluggable
 {
     String getType();

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java Tue Jan 27 15:00:13 2015
@@ -84,7 +84,8 @@ public class QpidServiceLoader
 
     private boolean isDisabledConfiguredType(final ConfiguredObjectTypeFactory<?> typeFactory)
     {
-        return Boolean.getBoolean("qpid.type.disabled:" + typeFactory.getCategoryClass().getSimpleName().toLowerCase()
+        String simpleName = typeFactory.getCategoryClass().getSimpleName().toLowerCase();
+        return Boolean.getBoolean("qpid.type.disabled:" + simpleName
                                   + "." + typeFactory.getType());
     }
 }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/SystemConfigFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/SystemConfigFactory.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/SystemConfigFactory.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/SystemConfigFactory.java Tue Jan 27 15:00:13 2015
@@ -20,7 +20,8 @@
  */
 package org.apache.qpid.server.plugin;
 
-import org.apache.qpid.server.BrokerOptions;
+import java.util.Map;
+
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.LogRecorder;
@@ -32,6 +33,6 @@ public interface SystemConfigFactory<X e
     public X newInstance(final TaskExecutor taskExecutor,
                          final EventLogger eventLogger,
                          final LogRecorder logRecorder,
-                         final BrokerOptions brokerOptions,
+                         final Map<String,Object> options,
                          final BrokerShutdownProvider brokerShutdownProvider);
 }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java Tue Jan 27 15:00:13 2015
@@ -71,6 +71,8 @@ public interface AMQQueue<X extends AMQQ
 
     void decrementUnackedMsgCount(QueueEntry queueEntry);
 
+    void incrementUnackedMsgCount(QueueEntry entry);
+
     boolean resend(final QueueEntry entry, final QueueConsumer<?> consumer);
 
     List<? extends QueueEntry> getMessagesOnTheQueue();

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java Tue Jan 27 15:00:13 2015
@@ -1231,7 +1231,6 @@ public abstract class AbstractQueue<X ex
         setLastSeenEntry(sub, entry);
 
         _deliveredMessages.incrementAndGet();
-        incrementUnackedMsgCount(entry);
 
         sub.send(entry, batch);
     }
@@ -2462,13 +2461,15 @@ public abstract class AbstractQueue<X ex
         return _unackedMsgBytes.get();
     }
 
+    @Override
     public void decrementUnackedMsgCount(QueueEntry queueEntry)
     {
         _unackedMsgCount.decrementAndGet();
         _unackedMsgBytes.addAndGet(-queueEntry.getSize());
     }
 
-    private void incrementUnackedMsgCount(QueueEntry entry)
+    @Override
+    public void incrementUnackedMsgCount(QueueEntry entry)
     {
         _unackedMsgCount.incrementAndGet();
         _unackedMsgBytes.addAndGet(entry.getSize());

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java Tue Jan 27 15:00:13 2015
@@ -214,6 +214,7 @@ public abstract class QueueEntryImpl imp
         if(acquired)
         {
             _deliveryCountUpdater.compareAndSet(this,-1,0);
+            getQueue().incrementUnackedMsgCount(this);
         }
         return acquired;
     }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java Tue Jan 27 15:00:13 2015
@@ -20,11 +20,15 @@
  */
 package org.apache.qpid.server.security;
 
+import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.security.AccessControlException;
 import java.security.GeneralSecurityException;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
 import java.security.cert.Certificate;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -48,6 +52,7 @@ import org.apache.qpid.server.model.Stat
 import org.apache.qpid.server.model.StateTransition;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.util.ServerScopedRuntimeException;
+import org.apache.qpid.server.util.urlstreamhandler.data.Handler;
 import org.apache.qpid.transport.network.security.ssl.QpidClientX509KeyManager;
 import org.apache.qpid.transport.network.security.ssl.SSLUtil;
 
@@ -69,7 +74,12 @@ public class FileKeyStoreImpl extends Ab
     private String _password;
 
 
-    private Broker<?> _broker;
+    private final Broker<?> _broker;
+
+    static
+    {
+        Handler.register();
+    }
 
     @ManagedObjectFactoryConstructor
     public FileKeyStoreImpl(Map<String, Object> attributes, Broker<?> broker)
@@ -152,14 +162,25 @@ public class FileKeyStoreImpl extends Ab
         java.security.KeyStore keyStore;
         try
         {
-            String path = fileKeyStore.getPath();
+            URL url = getUrlFromString(fileKeyStore.getPath());
             String password = fileKeyStore.getPassword();
             String keyStoreType = fileKeyStore.getKeyStoreType();
-            keyStore = SSLUtil.getInitializedKeyStore(path, password, keyStoreType);
+            keyStore = SSLUtil.getInitializedKeyStore(url, password, keyStoreType);
         }
+
         catch (Exception e)
         {
-            throw new IllegalConfigurationException("Cannot instantiate key store at " + fileKeyStore.getPath(), e);
+            final String message;
+            if (e instanceof IOException && e.getCause() != null && e.getCause() instanceof UnrecoverableKeyException)
+            {
+                message = "Check key store password. Cannot instantiate key store from '" + fileKeyStore.getPath() + "'.";
+            }
+            else
+            {
+                message = "Cannot instantiate key store from '" + fileKeyStore.getPath() + "'.";
+            }
+
+            throw new IllegalConfigurationException(message, e);
         }
 
         if (fileKeyStore.getCertificateAlias() != null)
@@ -176,8 +197,8 @@ public class FileKeyStoreImpl extends Ab
             }
             if (cert == null)
             {
-                throw new IllegalConfigurationException("Cannot find a certificate with alias " + fileKeyStore.getCertificateAlias()
-                        + "in key store : " + fileKeyStore.getPath());
+                throw new IllegalConfigurationException("Cannot find a certificate with alias '" + fileKeyStore.getCertificateAlias()
+                        + "' in key store : " + fileKeyStore.getPath());
             }
         }
 
@@ -237,17 +258,18 @@ public class FileKeyStoreImpl extends Ab
 
         try
         {
+            URL url = getUrlFromString(_path);
             if (_certificateAlias != null)
             {
                 return new KeyManager[] {
-                        new QpidClientX509KeyManager( _certificateAlias, _path, _keyStoreType, getPassword(),
+                        new QpidClientX509KeyManager( _certificateAlias, url, _keyStoreType, getPassword(),
                                                       _keyManagerFactoryAlgorithm)
                                         };
 
             }
             else
             {
-                final java.security.KeyStore ks = SSLUtil.getInitializedKeyStore(_path, getPassword(), _keyStoreType);
+                final java.security.KeyStore ks = SSLUtil.getInitializedKeyStore(url, getPassword(), _keyStoreType);
 
                 char[] keyStoreCharPassword = getPassword() == null ? null : getPassword().toCharArray();
 
@@ -263,4 +285,20 @@ public class FileKeyStoreImpl extends Ab
             throw new GeneralSecurityException(e);
         }
     }
+
+    private static URL getUrlFromString(String urlString) throws MalformedURLException
+    {
+        URL url;
+        try
+        {
+            url = new URL(urlString);
+        }
+        catch (MalformedURLException e)
+        {
+            File file = new File(urlString);
+            url = file.toURI().toURL();
+
+        }
+        return url;
+    }
 }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java Tue Jan 27 15:00:13 2015
@@ -20,11 +20,15 @@
  */
 package org.apache.qpid.server.security;
 
+import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.security.AccessControlException;
 import java.security.GeneralSecurityException;
 import java.security.KeyStore;
 import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
@@ -48,6 +52,7 @@ import org.apache.qpid.server.model.Stat
 import org.apache.qpid.server.model.TrustStore;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManager;
+import org.apache.qpid.server.util.urlstreamhandler.data.Handler;
 import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager;
 import org.apache.qpid.transport.network.security.ssl.QpidPeersOnlyTrustManager;
 import org.apache.qpid.transport.network.security.ssl.SSLUtil;
@@ -66,7 +71,12 @@ public class FileTrustStoreImpl extends
     @ManagedAttributeField
     private String _password;
 
-    private Broker<?> _broker;
+    private final Broker<?> _broker;
+
+    static
+    {
+        Handler.register();
+    }
 
     @ManagedObjectFactoryConstructor
     public FileTrustStoreImpl(Map<String, Object> attributes, Broker<?> broker)
@@ -114,12 +124,10 @@ public class FileTrustStoreImpl extends
         Collection<AuthenticationProvider> authenticationProviders = new ArrayList<AuthenticationProvider>(_broker.getAuthenticationProviders());
         for (AuthenticationProvider authProvider : authenticationProviders)
         {
-            if(authProvider.getAttributeNames().contains(SimpleLDAPAuthenticationManager.TRUST_STORE))
+            if (authProvider instanceof SimpleLDAPAuthenticationManager)
             {
-                Object attributeType = authProvider.getAttribute(AuthenticationProvider.TYPE);
-                Object attributeValue = authProvider.getAttribute(SimpleLDAPAuthenticationManager.TRUST_STORE);
-                if (SimpleLDAPAuthenticationManager.PROVIDER_TYPE.equals(attributeType)
-                        && storeName.equals(attributeValue))
+                SimpleLDAPAuthenticationManager simpleLdap = (SimpleLDAPAuthenticationManager) authProvider;
+                if (simpleLdap.getTrustStore() == this)
                 {
                     throw new IntegrityViolationException("Trust store '"
                             + storeName
@@ -185,11 +193,22 @@ public class FileTrustStoreImpl extends
     {
         try
         {
-            SSLUtil.getInitializedKeyStore(trustStore.getPath(), trustStore.getPassword(), trustStore.getTrustStoreType());
+            URL trustStoreUrl = getUrlFromString(trustStore.getPath());
+            SSLUtil.getInitializedKeyStore(trustStoreUrl, trustStore.getPassword(), trustStore.getTrustStoreType());
         }
         catch (Exception e)
         {
-            throw new IllegalConfigurationException("Cannot instantiate trust store at " + trustStore.getPath(), e);
+            final String message;
+            if (e instanceof IOException && e.getCause() != null && e.getCause() instanceof UnrecoverableKeyException)
+            {
+                message = "Check trust store password. Cannot instantiate trust store from '" + trustStore.getPath() + "'.";
+            }
+            else
+            {
+                message = "Cannot instantiate trust store from '" + trustStore.getPath() + "'.";
+            }
+
+            throw new IllegalConfigurationException(message, e);
         }
 
         try
@@ -238,14 +257,15 @@ public class FileTrustStoreImpl extends
     }
     public TrustManager[] getTrustManagers() throws GeneralSecurityException
     {
-        String trustStorePath = _path;
         String trustStorePassword = getPassword();
         String trustStoreType = _trustStoreType;
         String trustManagerFactoryAlgorithm = _trustManagerFactoryAlgorithm;
 
         try
         {
-            KeyStore ts = SSLUtil.getInitializedKeyStore(trustStorePath, trustStorePassword, trustStoreType);
+            URL trustStoreUrl = getUrlFromString(_path);
+
+            KeyStore ts = SSLUtil.getInitializedKeyStore(trustStoreUrl, trustStorePassword, trustStoreType);
             final TrustManagerFactory tmf = TrustManagerFactory
                     .getInstance(trustManagerFactoryAlgorithm);
             tmf.init(ts);
@@ -291,4 +311,21 @@ public class FileTrustStoreImpl extends
             throw new GeneralSecurityException(e);
         }
     }
+
+    private static URL getUrlFromString(String urlString) throws MalformedURLException
+    {
+        URL url;
+        try
+        {
+            url = new URL(urlString);
+        }
+        catch (MalformedURLException e)
+        {
+            File file = new File(urlString);
+            url = file.toURI().toURL();
+
+        }
+        return url;
+    }
+
 }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java Tue Jan 27 15:00:13 2015
@@ -44,7 +44,6 @@ import org.apache.qpid.server.consumer.C
 import org.apache.qpid.server.exchange.ExchangeImpl;
 import org.apache.qpid.server.model.AccessControlProvider;
 import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.ConfigurationChangeListener;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
@@ -57,18 +56,17 @@ import org.apache.qpid.server.security.a
 import org.apache.qpid.server.security.auth.AuthenticatedPrincipal;
 import org.apache.qpid.server.security.auth.TaskPrincipal;
 
-public class SecurityManager implements ConfigurationChangeListener
+public class SecurityManager
 {
     private static final Subject SYSTEM = new Subject(true,
                                                      Collections.singleton(new SystemPrincipal()),
                                                      Collections.emptySet(),
                                                      Collections.emptySet());
 
-    private final ConcurrentMap<String, AccessControl> _plugins = new ConcurrentHashMap<String, AccessControl>();
     private final boolean _managementMode;
     private final Broker<?> _broker;
 
-    private final ConcurrentMap<PublishAccessCheckCacheEntry, PublishAccessCheck> _publishAccessCheckCache = new ConcurrentHashMap<SecurityManager.PublishAccessCheckCacheEntry, SecurityManager.PublishAccessCheck>();
+    private final ConcurrentMap<PublishAccessCheckCacheEntry, PublishAccessCheck> _publishAccessCheckCache = new ConcurrentHashMap<PublishAccessCheckCacheEntry, SecurityManager.PublishAccessCheck>();
 
     public SecurityManager(Broker<?> broker, boolean managementMode)
     {
@@ -135,16 +133,6 @@ public class SecurityManager implements
         return user;
     }
 
-    public void addPlugin(final AccessControl accessControl)
-    {
-
-        synchronized (_plugins)
-        {
-            String pluginTypeName = getPluginTypeName(accessControl);
-
-            _plugins.put(pluginTypeName, accessControl);
-        }
-    }
 
     private static final class SystemPrincipal implements Principal
     {
@@ -167,24 +155,31 @@ public class SecurityManager implements
     private boolean checkAllPlugins(AccessCheck checker)
     {
         // If we are running as SYSTEM then no ACL checking
-        if(isSystemProcess())
+        if(isSystemProcess() || _managementMode)
         {
             return true;
         }
 
-        for (AccessControl plugin : _plugins.values())
+
+        Collection<AccessControlProvider<?>> accessControlProviders = _broker.getAccessControlProviders();
+        if(accessControlProviders != null && !accessControlProviders.isEmpty())
         {
-            Result remaining = checker.allowed(plugin);
-            if (remaining == Result.DEFER)
-            {
-                remaining = plugin.getDefault();
-            }
-            if (remaining == Result.DENIED)
+            AccessControlProvider<?> accessControlProvider = accessControlProviders.iterator().next();
+            if (accessControlProvider != null
+                && accessControlProvider.getState() == State.ACTIVE
+                && accessControlProvider.getAccessControl() != null)
             {
-                return false;
+                Result remaining = checker.allowed(accessControlProvider.getAccessControl());
+                if (remaining == Result.DEFER)
+                {
+                    remaining = accessControlProvider.getAccessControl().getDefault();
+                }
+                if (remaining == Result.DENIED)
+                {
+                    return false;
+                }
             }
         }
-
         // getting here means either allowed or abstained from all plugins
         return true;
     }
@@ -486,92 +481,6 @@ public class SecurityManager implements
         }
     }
 
-    @Override
-    public void stateChanged(ConfiguredObject object, State oldState, State newState)
-    {
-        if(_managementMode)
-        {
-            //AccessControl is disabled in ManagementMode
-            return;
-        }
-
-        if(object instanceof AccessControlProvider)
-        {
-            if(newState == State.ACTIVE)
-            {
-                synchronized (_plugins)
-                {
-                    AccessControl accessControl = ((AccessControlProvider)object).getAccessControl();
-                    String pluginTypeName = getPluginTypeName(accessControl);
-
-                    _plugins.put(pluginTypeName, accessControl);
-                }
-            }
-            else if(newState == State.DELETED)
-            {
-                synchronized (_plugins)
-                {
-                    AccessControl control = ((AccessControlProvider)object).getAccessControl();
-                    String pluginTypeName = getPluginTypeName(control);
-
-                    // Remove the type->control mapping for this type key only if the
-                    // given control is actually referred to.
-                    if(_plugins.containsValue(control))
-                    {
-                        // If we are removing this control, check if another of the same
-                        // type already exists on the broker and use it in instead.
-                        AccessControl other = null;
-                        Collection<AccessControlProvider<?>> providers = _broker.getAccessControlProviders();
-                        for(AccessControlProvider p : providers)
-                        {
-                            if(p == object || p.getState() != State.ACTIVE)
-                            {
-                                //we don't count ourself as another
-                                continue;
-                            }
-
-                            AccessControl ac = p.getAccessControl();
-                            if(pluginTypeName.equals(getPluginTypeName(ac)))
-                            {
-                                other = ac;
-                                break;
-                            }
-                        }
-
-                        if(other != null)
-                        {
-                            //Another control of this type was found, use it instead
-                            _plugins.replace(pluginTypeName, control, other);
-                        }
-                        else
-                        {
-                            //No other was found, remove the type entirely
-                            _plugins.remove(pluginTypeName);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    @Override
-    public void childAdded(ConfiguredObject object, ConfiguredObject child)
-    {
-        // no op
-    }
-
-    @Override
-    public void childRemoved(ConfiguredObject object, ConfiguredObject child)
-    {
-        // no op
-    }
-
-    @Override
-    public void attributeSet(ConfiguredObject object, String attributeName, Object oldAttributeValue, Object newAttributeValue)
-    {
-        // no op
-    }
-
     public boolean authoriseConfiguringBroker(String configuredObjectName, Class<? extends ConfiguredObject> configuredObjectType, Operation configuredObjectOperation)
     {
         String description = String.format("%s %s '%s'",

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java Tue Jan 27 15:00:13 2015
@@ -604,8 +604,9 @@ public class BrokerStoreUpgraderAndRecov
         return brokerRecord;
     }
 
-    public Broker<?> perform(final DurableConfigurationStore store)
+    public Broker<?> perform()
     {
+        final DurableConfigurationStore store = _systemConfig.getConfigurationStore();
         List<ConfiguredObjectRecord> upgradedRecords = upgrade(store);
         new GenericRecoverer(_systemConfig).recover(upgradedRecords);
 

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java Tue Jan 27 15:00:13 2015
@@ -1087,18 +1087,6 @@ public abstract class AbstractVirtualHos
     }
 
     @Override
-    public Collection<String> getSupportedExchangeTypes()
-    {
-        return getObjectFactory().getSupportedTypes(Exchange.class);
-    }
-
-    @Override
-    public Collection<String> getSupportedQueueTypes()
-    {
-        return getObjectFactory().getSupportedTypes(Queue.class);
-    }
-
-    @Override
     public boolean isQueue_deadLetterQueueEnabled()
     {
         return _queue_deadLetterQueueEnabled;

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java Tue Jan 27 15:00:13 2015
@@ -24,7 +24,10 @@ import org.apache.qpid.server.model.Mana
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.store.SizeMonitoringSettings;
 
-public interface ProvidedStoreVirtualHost<X extends ProvidedStoreVirtualHost<X>> extends VirtualHostImpl<X,AMQQueue<?>,ExchangeImpl<?>>, SizeMonitoringSettings
+public interface ProvidedStoreVirtualHost<X extends ProvidedStoreVirtualHost<X>>
+        extends VirtualHostImpl<X,AMQQueue<?>,ExchangeImpl<?>>,
+                SizeMonitoringSettings,
+                NonStandardVirtualHost<X,AMQQueue<?>,ExchangeImpl<?>>
 {
     @ManagedAttribute(mandatory = true, defaultValue = "0")
     Long getStoreUnderfullSize();

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java Tue Jan 27 15:00:13 2015
@@ -31,6 +31,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -47,14 +48,18 @@ import org.apache.qpid.server.logging.su
 import org.apache.qpid.server.model.AbstractConfiguredObject;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry;
 import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.LifetimePolicy;
 import org.apache.qpid.server.model.ManagedAttributeField;
+import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.StateTransition;
 import org.apache.qpid.server.model.SystemConfig;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.model.VirtualHostNode;
+import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;
+import org.apache.qpid.server.plugin.QpidServiceLoader;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.security.auth.AuthenticatedPrincipal;
 import org.apache.qpid.server.store.ConfiguredObjectRecord;
@@ -62,6 +67,8 @@ import org.apache.qpid.server.store.Conf
 import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.util.urlstreamhandler.data.Handler;
+import org.apache.qpid.server.virtualhost.NonStandardVirtualHost;
+import org.apache.qpid.server.virtualhost.ProvidedStoreVirtualHostImpl;
 
 public abstract class AbstractVirtualHostNode<X extends AbstractVirtualHostNode<X>> extends AbstractConfiguredObject<X> implements VirtualHostNode<X>
 {
@@ -442,4 +449,34 @@ public abstract class AbstractVirtualHos
         return initialConfigReader;
     }
 
+    protected static Collection<String> getSupportedVirtualHostTypes(boolean includeProvided)
+    {
+
+        final Iterable<ConfiguredObjectRegistration> registrations =
+                (new QpidServiceLoader()).instancesOf(ConfiguredObjectRegistration.class);
+
+        Set<String> supportedTypes = new HashSet<>();
+
+        for(ConfiguredObjectRegistration registration : registrations)
+        {
+            for(Class<? extends ConfiguredObject> typeClass : registration.getConfiguredObjectClasses())
+            {
+                if(VirtualHost.class.isAssignableFrom(typeClass))
+                {
+                    ManagedObject annotation = typeClass.getAnnotation(ManagedObject.class);
+
+                    if (annotation.creatable() && annotation.defaultType().equals("") && !NonStandardVirtualHost.class.isAssignableFrom(typeClass))
+                    {
+                        supportedTypes.add(ConfiguredObjectTypeRegistry.getType(typeClass));
+                    }
+                }
+            }
+        }
+        if(includeProvided)
+        {
+            supportedTypes.add(ProvidedStoreVirtualHostImpl.VIRTUAL_HOST_TYPE);
+        }
+        return Collections.unmodifiableCollection(supportedTypes);
+    }
+
 }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java Tue Jan 27 15:00:13 2015
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.server.virtualhostnode;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 
 import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
@@ -31,7 +33,7 @@ import org.apache.qpid.server.model.Virt
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.JsonFileConfigStore;
 
-@ManagedObject(type=JsonVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE, category=false)
+@ManagedObject(type=JsonVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE, category=false, validChildTypes = "org.apache.qpid.server.virtualhostnode.JsonVirtualHostNodeImpl#getSupportedChildTypes()")
 public class JsonVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<JsonVirtualHostNodeImpl> implements JsonVirtualHostNode<JsonVirtualHostNodeImpl>
 {
     public static final String VIRTUAL_HOST_NODE_TYPE = "JSON";
@@ -68,4 +70,9 @@ public class JsonVirtualHostNodeImpl ext
     {
         return getClass().getSimpleName() + " [id=" + getId() + ", name=" + getName() + ", storePath=" + getStorePath() + "]";
     }
+
+    public static Map<String, Collection<String>> getSupportedChildTypes()
+    {
+        return Collections.singletonMap(VirtualHost.class.getSimpleName(), getSupportedVirtualHostTypes(false));
+    }
 }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java Tue Jan 27 15:00:13 2015
@@ -34,7 +34,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.server.model.BrokerShutdownProvider;
 import org.mockito.ArgumentCaptor;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
@@ -45,7 +44,10 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.LogRecorder;
+import org.apache.qpid.server.model.AbstractSystemConfig;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.BrokerShutdownProvider;
+import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.JsonSystemConfigImpl;
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.Protocol;
@@ -79,7 +81,7 @@ public class ManagementModeStoreHandlerT
         _taskExecutor.start();
 
         _systemConfig = new JsonSystemConfigImpl(_taskExecutor, mock(EventLogger.class),
-                                               mock(LogRecorder.class), new BrokerOptions(),
+                                               mock(LogRecorder.class), new BrokerOptions().convertToSystemConfigAttributes(),
                                                mock(BrokerShutdownProvider.class));
 
 
@@ -87,7 +89,8 @@ public class ManagementModeStoreHandlerT
 
 
 
-        _root = new ConfiguredObjectRecordImpl(_rootId, Broker.class.getSimpleName(), Collections.<String,Object>emptyMap(), Collections.singletonMap(SystemConfig.class.getSimpleName(), systemContextRecord.getId()));
+        _root = new ConfiguredObjectRecordImpl(_rootId, Broker.class.getSimpleName(), Collections.singletonMap(Broker.NAME,
+                                                                                                               (Object) "broker"), Collections.singletonMap(SystemConfig.class.getSimpleName(), systemContextRecord.getId()));
 
         _portEntry = mock(ConfiguredObjectRecord.class);
         when(_portEntry.getId()).thenReturn(_portEntryId);
@@ -111,15 +114,48 @@ public class ManagementModeStoreHandlerT
                 }
                 ).when(_store).visitConfiguredObjectRecords(recovererArgumentCaptor.capture());
         _options = new BrokerOptions();
-        _handler = new ManagementModeStoreHandler(_store, _options);
+
+        _handler = new ManagementModeStoreHandler(_store, _systemConfig);;
 
         _handler.openConfigurationStore(_systemConfig, false);
     }
 
+    private ManagementModeStoreHandler createManagementModeStoreHandler()
+    {
+        _systemConfig.close();
+        Map<String, Object> attributes = new HashMap<>(_options.convertToSystemConfigAttributes());
+        attributes.put(ConfiguredObject.DESIRED_STATE, State.QUIESCED);
+        _systemConfig = new AbstractSystemConfig(_taskExecutor,
+                                                 mock(EventLogger.class),
+                                                 mock(LogRecorder.class),
+                                                 attributes,
+                                                 mock(BrokerShutdownProvider.class))
+        {
+            @Override
+            protected void onOpen()
+            {
+            }
+
+            @Override
+            protected DurableConfigurationStore createStoreObject()
+            {
+                return _store;
+            }
+
+            @Override
+            protected void onClose()
+            {
+            }
+        };
+        _systemConfig.open();
+        return new ManagementModeStoreHandler(_store, _systemConfig);
+    }
+
     @Override
     public void tearDown() throws Exception
     {
         _taskExecutor.stop();
+        _systemConfig.close();
         super.tearDown();
     }
 
@@ -154,7 +190,7 @@ public class ManagementModeStoreHandlerT
     public void testGetRootEntryWithHttpPortOverriden()
     {
         _options.setManagementModeHttpPortOverride(9090);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
         ConfiguredObjectRecord root = getRootEntry();
         assertEquals("Unexpected root id", _rootId, root.getId());
@@ -166,7 +202,7 @@ public class ManagementModeStoreHandlerT
     public void testGetRootEntryWithRmiPortOverriden()
     {
         _options.setManagementModeRmiPortOverride(9090);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord root = getRootEntry();
@@ -179,7 +215,7 @@ public class ManagementModeStoreHandlerT
     public void testGetRootEntryWithConnectorPortOverriden()
     {
         _options.setManagementModeJmxPortOverride(9090);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord root = getRootEntry();
@@ -194,7 +230,7 @@ public class ManagementModeStoreHandlerT
         _options.setManagementModeHttpPortOverride(1000);
         _options.setManagementModeRmiPortOverride(2000);
         _options.setManagementModeJmxPortOverride(3000);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord root = getRootEntry();
@@ -222,7 +258,7 @@ public class ManagementModeStoreHandlerT
     public void testGetEntryByCLIConnectorPortId()
     {
         _options.setManagementModeJmxPortOverride(9090);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
 
@@ -234,7 +270,7 @@ public class ManagementModeStoreHandlerT
     public void testGetEntryByCLIHttpPortId()
     {
         _options.setManagementModeHttpPortOverride(9090);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
 
@@ -249,7 +285,7 @@ public class ManagementModeStoreHandlerT
         attributes.put(Port.PROTOCOLS, Collections.singleton(Protocol.HTTP));
         when(_portEntry.getAttributes()).thenReturn(attributes);
         _options.setManagementModeHttpPortOverride(9090);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
 
@@ -263,7 +299,7 @@ public class ManagementModeStoreHandlerT
         attributes.put(Port.PROTOCOLS, Collections.singleton(Protocol.RMI));
         when(_portEntry.getAttributes()).thenReturn(attributes);
         _options.setManagementModeRmiPortOverride(9090);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
 
@@ -277,7 +313,7 @@ public class ManagementModeStoreHandlerT
         attributes.put(Port.PROTOCOLS, Collections.singleton(Protocol.JMX_RMI));
         when(_portEntry.getAttributes()).thenReturn(attributes);
         _options.setManagementModeRmiPortOverride(9090);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
 
@@ -328,7 +364,7 @@ public class ManagementModeStoreHandlerT
             _options.setManagementModeQuiesceVirtualHosts(mmQuiesceVhosts);
         }
 
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord hostEntry = getEntry(virtualHostId);
@@ -354,7 +390,7 @@ public class ManagementModeStoreHandlerT
         _options.setManagementModeHttpPortOverride(1000);
         _options.setManagementModeRmiPortOverride(2000);
         _options.setManagementModeJmxPortOverride(3000);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
         Map<String, Object> attributes = new HashMap<String, Object>();
@@ -371,7 +407,7 @@ public class ManagementModeStoreHandlerT
         _options.setManagementModeHttpPortOverride(1000);
         _options.setManagementModeRmiPortOverride(2000);
         _options.setManagementModeJmxPortOverride(3000);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord root = getRootEntry();
@@ -386,7 +422,7 @@ public class ManagementModeStoreHandlerT
     public void testSaveCLIHttpPort()
     {
         _options.setManagementModeHttpPortOverride(1000);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
         UUID portId = getOptionsPortId();
@@ -410,7 +446,7 @@ public class ManagementModeStoreHandlerT
     public void testRemove()
     {
         _options.setManagementModeHttpPortOverride(1000);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord record = new ConfiguredObjectRecord()
@@ -446,7 +482,7 @@ public class ManagementModeStoreHandlerT
     public void testRemoveCLIPort()
     {
         _options.setManagementModeHttpPortOverride(1000);
-        _handler = new ManagementModeStoreHandler(_store, _options);
+        _handler = createManagementModeStoreHandler();
         _handler.openConfigurationStore(_systemConfig, false);
 
         UUID portId = getOptionsPortId();

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java Tue Jan 27 15:00:13 2015
@@ -37,8 +37,8 @@ import java.util.Set;
 
 import junit.framework.TestCase;
 
-import org.apache.qpid.server.model.testmodel.TestModel;
-import org.apache.qpid.server.model.testmodel.TestRootCategory;
+import org.apache.qpid.server.model.testmodels.hierarchy.TestModel;
+import org.apache.qpid.server.model.testmodels.hierarchy.TestCar;
 
 public class AttributeValueConverterTest extends TestCase
 {
@@ -61,7 +61,7 @@ public class AttributeValueConverterTest
         _context.put("mapWithInterpolatedContents", "{\"${mykey}\" : \"b\"}");
         _context.put("mykey", "mykey1");
 
-        ConfiguredObject object = _objectFactory.create(TestRootCategory.class, _attributes);
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
 
         AttributeValueConverter<Map> mapConverter = getConverter(Map.class, Map.class);
 
@@ -96,7 +96,7 @@ public class AttributeValueConverterTest
     {
         _context.put("simpleCollection", "[\"a\", \"b\"]");
 
-        ConfiguredObject object = _objectFactory.create(TestRootCategory.class, _attributes);
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
 
         AttributeValueConverter<Collection> collectionConverter = getConverter(Collection.class, Collection.class);
 
@@ -131,7 +131,7 @@ public class AttributeValueConverterTest
     {
         _context.put("simpleList", "[\"a\", \"b\"]");
 
-        ConfiguredObject object = _objectFactory.create(TestRootCategory.class, _attributes);
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
 
         AttributeValueConverter<List> listConverter = getConverter(List.class, List.class);
 
@@ -164,7 +164,7 @@ public class AttributeValueConverterTest
     {
         _context.put("simpleSet", "[\"a\", \"b\"]");
 
-        ConfiguredObject object = _objectFactory.create(TestRootCategory.class, _attributes);
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
 
         AttributeValueConverter<Set> setConverter = getConverter(Set.class, Set.class);;
 

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java Tue Jan 27 15:00:13 2015
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.verify
 import static org.mockito.Mockito.when;
 
 import java.security.AccessControlException;
+import java.util.Collections;
 
 import org.apache.qpid.server.binding.BindingImpl;
 import org.apache.qpid.server.consumer.ConsumerImpl;
@@ -68,11 +69,13 @@ public class SecurityManagerTest extends
 
         AccessControlProvider<?> aclProvider = mock(AccessControlProvider.class);
         when(aclProvider.getAccessControl()).thenReturn(_accessControl);
+        when(aclProvider.getState()).thenReturn(State.ACTIVE);
 
         when(_virtualHost.getName()).thenReturn(TEST_VIRTUAL_HOST);
 
-        _securityManager = new SecurityManager(mock(Broker.class), false);
-        _securityManager.stateChanged(aclProvider, State.UNINITIALIZED, State.ACTIVE);
+        Broker broker = mock(Broker.class);
+        when(broker.getAccessControlProviders()).thenReturn(Collections.singleton(aclProvider));
+        _securityManager = new SecurityManager(broker, false);
     }
 
     public void testAuthoriseCreateBinding()

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java Tue Jan 27 15:00:13 2015
@@ -69,7 +69,7 @@ public class BrokerRecovererTest extends
         _brokerShutdownProvider = mock(BrokerShutdownProvider.class);
         _systemConfig = new JsonSystemConfigImpl(_taskExecutor,
                                                mock(EventLogger.class), mock(LogRecorder.class),
-                                               new BrokerOptions(),
+                                               new BrokerOptions().convertToSystemConfigAttributes(),
                                                _brokerShutdownProvider);
 
         when(_brokerEntry.getId()).thenReturn(_brokerId);

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java Tue Jan 27 15:00:13 2015
@@ -81,7 +81,7 @@ public class BrokerStoreUpgraderAndRecov
         _systemConfig = new JsonSystemConfigImpl(_taskExecutor,
                                                mock(EventLogger.class),
                                                mock(LogRecorder.class),
-                                               new BrokerOptions(),
+                                               new BrokerOptions().convertToSystemConfigAttributes(),
                                                mock(BrokerShutdownProvider.class));
     }
 

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/ConfigurationFile.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/ConfigurationFile.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/ConfigurationFile.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/ConfigurationFile.java Tue Jan 27 15:00:13 2015
@@ -20,35 +20,20 @@
  */
 package org.apache.qpid.server.security.access.config;
 
-import java.io.File;
+import java.io.Reader;
 
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 
 public interface ConfigurationFile
 {
     /**
-     * Return the actual {@link File}  object containing the configuration.
-     */
-    File getFile();
-    
-    /**
      * Load this configuration file's contents into a {@link RuleSet}.
      * @throws IllegalConfigurationException if the configuration file has errors.
      * @throws IllegalArgumentException if individual tokens cannot be parsed.
+     * @param configReader
      */
-    RuleSet load() throws IllegalConfigurationException;
-    
-    /**
-     * Reload this configuration file's contents.
-     * @throws IllegalConfigurationException if the configuration file has errors.
-     * @throws IllegalArgumentException if individual tokens cannot be parsed.
-     */
-    RuleSet reload() throws IllegalConfigurationException;
-        
+    RuleSet load(final Reader configReader) throws IllegalConfigurationException;
+
     RuleSet getConfiguration();
-    
-    /**
-     * TODO document me.
-     */
-    boolean save(RuleSet configuration);
+
 }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/PlainConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/PlainConfiguration.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/PlainConfiguration.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/PlainConfiguration.java Tue Jan 27 15:00:13 2015
@@ -21,10 +21,9 @@
 package org.apache.qpid.server.security.access.config;
 
 import java.io.BufferedReader;
-import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.FileReader;
 import java.io.IOException;
+import java.io.Reader;
 import java.io.StreamTokenizer;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -34,14 +33,14 @@ import java.util.Stack;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.EventLoggerProvider;
 import org.apache.qpid.server.security.access.ObjectType;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.security.access.Permission;
 
-public class PlainConfiguration extends AbstractConfiguration
+public class PlainConfiguration implements ConfigurationFile
 {
     private static final Logger _logger = Logger.getLogger(PlainConfiguration.class);
 
@@ -66,30 +65,30 @@ public class PlainConfiguration extends
     static final String PROPERTY_KEY_ONLY_MSG = "Incomplete property (key only) at line %d";
     static final String PROPERTY_NO_EQUALS_MSG = "Incomplete property (no equals) at line %d";
     static final String PROPERTY_NO_VALUE_MSG = "Incomplete property (no value) at line %d";
+    private final EventLoggerProvider _eventLogger;
+    private final String _name;
 
     private StreamTokenizer _st;
+    private RuleSet _config;
 
-    public PlainConfiguration(File file, final EventLoggerProvider eventLogger)
+    public PlainConfiguration(String name, final EventLoggerProvider eventLogger)
     {
-        super(file, eventLogger);
+        _eventLogger = eventLogger;
+        _name = name;
     }
 
     @Override
-    public RuleSet load()
+    public RuleSet load(final Reader configReader)
     {
-        RuleSet ruleSet = super.load();
-
-        File file = getFile();
-        FileReader fileReader = null;
+        _config = new RuleSet(_eventLogger);
 
-        try
+        try(Reader fileReader = configReader)
         {
             if(_logger.isDebugEnabled())
             {
-                _logger.debug("About to load ACL file " + file);
+                _logger.debug("About to load ACL file");
             }
 
-            fileReader = new FileReader(file);
             _st = new StreamTokenizer(new BufferedReader(fileReader));
             _st.resetSyntax(); // setup the tokenizer
 
@@ -209,29 +208,14 @@ public class PlainConfiguration extends
         }
         catch (FileNotFoundException fnfe)
         {
-            throw new IllegalConfigurationException(String.format(CONFIG_NOT_FOUND_MSG, file.getName()), fnfe);
+            throw new IllegalConfigurationException(String.format(CONFIG_NOT_FOUND_MSG, _name), fnfe);
         }
         catch (IOException ioe)
         {
-            throw new IllegalConfigurationException(String.format(CANNOT_LOAD_MSG, file.getName()), ioe);
-        }
-        finally
-        {
-            if(fileReader != null)
-            {
-                try
-                {
-                    fileReader.close();
-                }
-                catch (IOException e)
-                {
-                    throw new IllegalConfigurationException(String.format(CANNOT_CLOSE_MSG, file.getName()), e);
-                }
-            }
+            throw new IllegalConfigurationException(String.format(CANNOT_LOAD_MSG, _name), ioe);
         }
 
-
-        return ruleSet;
+        return _config;
     }
 
     private void parseAcl(Integer number, List<String> args)
@@ -333,4 +317,10 @@ public class PlainConfiguration extends
     {
         return _st.lineno() - 1;
     }
+
+    public RuleSet getConfiguration()
+    {
+        return _config;
+    }
+
 }

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java Tue Jan 27 15:00:13 2015
@@ -39,6 +39,7 @@ import org.apache.qpid.server.model.Stat
 import org.apache.qpid.server.model.StateTransition;
 import org.apache.qpid.server.security.AccessControl;
 import org.apache.qpid.server.security.access.Operation;
+import org.apache.qpid.server.util.urlstreamhandler.data.Handler;
 
 public class ACLFileAccessControlProviderImpl
         extends AbstractConfiguredObject<ACLFileAccessControlProviderImpl>
@@ -46,10 +47,15 @@ public class ACLFileAccessControlProvide
 {
     private static final Logger LOGGER = Logger.getLogger(ACLFileAccessControlProviderImpl.class);
 
+    static
+    {
+        Handler.register();
+    }
+
     protected DefaultAccessControl _accessControl;
     protected final Broker _broker;
 
-    @ManagedAttributeField
+    @ManagedAttributeField( afterSet = "reloadAclFile")
     private String _path;
 
     @ManagedObjectFactoryConstructor
@@ -112,6 +118,26 @@ public class ACLFileAccessControlProvide
         _accessControl = new DefaultAccessControl(getPath(), _broker);
     }
 
+    @SuppressWarnings("unused")
+    private void reloadAclFile()
+    {
+        try
+        {
+            DefaultAccessControl accessControl = new DefaultAccessControl(getPath(), _broker);
+            accessControl.open();
+            DefaultAccessControl oldAccessControl = _accessControl;
+            _accessControl = accessControl;
+            if(oldAccessControl != null)
+            {
+                oldAccessControl.close();
+            }
+        }
+        catch(RuntimeException e)
+        {
+            throw new IllegalConfigurationException(e.getMessage(), e);
+        }
+    }
+
     @Override
     public String getPath()
     {

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java Tue Jan 27 15:00:13 2015
@@ -21,9 +21,14 @@
 package org.apache.qpid.server.security.access.plugins;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
 import java.net.SocketAddress;
+import java.net.URL;
 import java.security.AccessController;
 import java.util.Set;
 
@@ -47,46 +52,81 @@ import org.apache.qpid.server.security.a
 public class DefaultAccessControl implements AccessControl
 {
     private static final Logger _logger = Logger.getLogger(DefaultAccessControl.class);
+    private final String _fileName;
 
     private RuleSet _ruleSet;
-    private File _aclFile;
     private final EventLoggerProvider _eventLogger;
 
-    public DefaultAccessControl(String fileName, final EventLoggerProvider eventLogger)
+    public DefaultAccessControl(String name, final EventLoggerProvider eventLogger)
     {
+        _fileName = name;
         _eventLogger = eventLogger;
         if (_logger.isDebugEnabled())
         {
-            _logger.debug("Creating AccessControl instance using file: " + fileName);
+            _logger.debug("Creating AccessControl instance");
         }
-
-        _aclFile = new File(fileName);
     }
 
     DefaultAccessControl(RuleSet rs)
     {
+        _fileName = null;
         _ruleSet = rs;
         _eventLogger = rs;
     }
 
     public void open()
     {
-        if(_aclFile != null)
+        if(_fileName != null)
         {
-            if (!validate())
-            {
-                throw new IllegalConfigurationException("ACL file '" + _aclFile + "' is not found");
-            }
-
-            ConfigurationFile configFile = new PlainConfiguration(_aclFile, _eventLogger);
-            _ruleSet = configFile.load();
+            ConfigurationFile configFile = new PlainConfiguration(_fileName, _eventLogger);
+            _ruleSet = configFile.load(getReaderFromURLString(_fileName));
         }
     }
 
     @Override
     public boolean validate()
     {
-        return _aclFile.exists();
+        try
+        {
+            getReaderFromURLString(_fileName);
+            return true;
+        }
+        catch(IllegalConfigurationException e)
+        {
+            return false;
+        }
+    }
+
+
+    private static Reader getReaderFromURLString(String urlString)
+    {
+        try
+        {
+            URL url;
+
+            try
+            {
+                url = new URL(urlString);
+            }
+            catch (MalformedURLException e)
+            {
+                File file = new File(urlString);
+                try
+                {
+                    url = file.toURI().toURL();
+                }
+                catch (MalformedURLException notAFile)
+                {
+                    throw new IllegalConfigurationException("Cannot convert " + urlString + " to a readable resource");
+                }
+
+            }
+            return new InputStreamReader(url.openStream());
+        }
+        catch (IOException e)
+        {
+            throw new IllegalConfigurationException("Cannot convert " + urlString + " to a readable resource");
+        }
     }
 
     @Override
@@ -104,16 +144,10 @@ public class DefaultAccessControl implem
     @Override
     public void onCreate()
     {
-        if(_aclFile != null)
+        if(_fileName != null)
         {
-            //verify it exists
-            if (!validate())
-            {
-                throw new IllegalConfigurationException("ACL file '" + _aclFile + "' is not found");
-            }
-
             //verify it is parsable
-            new PlainConfiguration(_aclFile, _eventLogger).load();
+            new PlainConfiguration(_fileName, _eventLogger).load(getReaderFromURLString(_fileName));
         }
     }
 

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java Tue Jan 27 15:00:13 2015
@@ -18,8 +18,10 @@
  */
 package org.apache.qpid.server.security.access.config;
 
+import static org.mockito.Mockito.mock;
+
 import java.io.File;
-import java.io.FileNotFoundException;
+import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.PrintWriter;
 import java.util.Map;
@@ -27,15 +29,12 @@ import java.util.Map;
 import junit.framework.TestCase;
 
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.EventLoggerProvider;
 import org.apache.qpid.server.security.access.ObjectProperties;
 import org.apache.qpid.server.security.access.ObjectProperties.Property;
 import org.apache.qpid.server.security.access.ObjectType;
 import org.apache.qpid.server.security.access.Operation;
 
-import static org.mockito.Mockito.mock;
-
 public class PlainConfigurationTest extends TestCase
 {
     private PlainConfiguration writeACLConfig(String...aclData) throws Exception
@@ -52,28 +51,11 @@ public class PlainConfigurationTest exte
         aclWriter.close();
 
         // Load ruleset
-        PlainConfiguration configFile = new PlainConfiguration(acl, mock(EventLoggerProvider.class));
-        configFile.load();
+        PlainConfiguration configFile = new PlainConfiguration(acl.getName(), mock(EventLoggerProvider.class));
+        configFile.load(new FileReader(acl));
         return configFile;
     }
 
-    public void testMissingACLConfig() throws Exception
-    {
-        try
-        {
-            // Load ruleset
-            ConfigurationFile configFile = new PlainConfiguration(new File("doesnotexist"), mock(EventLoggerProvider.class));
-            configFile.load();
-
-            fail("fail");
-        }
-        catch (IllegalConfigurationException ce)
-        {
-            assertEquals(String.format(PlainConfiguration.CONFIG_NOT_FOUND_MSG, "doesnotexist"), ce.getMessage());
-            assertTrue(ce.getCause() instanceof FileNotFoundException);
-        }
-    }
-
     public void testACLFileSyntaxContinuation() throws Exception
     {
         try

Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java?rev=1655057&r1=1655056&r2=1655057&view=diff
==============================================================================
--- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java (original)
+++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java Tue Jan 27 15:00:13 2015
@@ -107,7 +107,7 @@ public class ACLFileAccessControlProvide
         }
         catch (IllegalConfigurationException e)
         {
-            assertTrue("Unexpected exception message: " + e.getMessage(), Pattern.matches("ACL file '.*' is not found", e.getMessage()));
+            assertTrue("Unexpected exception message: " + e.getMessage(), Pattern.matches("Cannot convert .* to a readable resource", e.getMessage()));
         }
     }
 }



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