You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2012/11/01 10:48:57 UTC

svn commit: r1404521 [3/6] - in /qpid/branches/java-broker-config-qpid-4390/qpid/java: ./ broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/ broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/ bro...

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Port.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Port.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Port.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Port.java Thu Nov  1 09:48:52 2012
@@ -39,6 +39,16 @@ public interface Port extends Configured
     String PORT                                 = "port";
     String PROTOCOLS                            = "protocols";
     String TRANSPORTS                           = "transports";
+    String TCP_NO_DELAY                         = "tcpNoDelay";
+    String SEND_BUFFER_SIZE                     = "sendBufferSize";
+    String RECEIVE_BUFFER_SIZE                  = "receiveBufferSize";
+    String NEED_CLIENT_AUTH                     = "needClientAuth";
+    String WANT_CLIENT_AUTH                     = "wantClientAuth";
+
+    /**
+     * TODO: rename it to AUTHENTICATION_MANAGER_ID or introduce relationships
+     */
+    String AUTHENTICATION_MANAGER               = "authenticationManager";
 
     // Attributes
     public static final Collection<String> AVAILABLE_ATTRIBUTES =
@@ -55,7 +65,13 @@ public interface Port extends Configured
                             BINDING_ADDRESS,
                             PORT,
                             PROTOCOLS,
-                            TRANSPORTS
+                            TRANSPORTS,
+                            TCP_NO_DELAY,
+                            SEND_BUFFER_SIZE,
+                            RECEIVE_BUFFER_SIZE,
+                            NEED_CLIENT_AUTH,
+                            WANT_CLIENT_AUTH,
+                            AUTHENTICATION_MANAGER
                                  ));
 
 
@@ -88,4 +104,19 @@ public interface Port extends Configured
     //children
     Collection<VirtualHostAlias> getVirtualHostBindings();
     Collection<Connection> getConnections();
+
+    boolean isTcpNoDelay();
+
+    int getReceiveBufferSize();
+
+    int getSendBufferSize();
+
+    boolean isNeedClientAuth();
+
+    boolean isWantClientAuth();
+
+    String getAuthenticationManager();
+
+    AuthenticationProvider getAuthenticationProvider();
+
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Protocol.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Protocol.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Protocol.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Protocol.java Thu Nov  1 09:48:52 2012
@@ -20,14 +20,94 @@
  */
 package org.apache.qpid.server.model;
 
+import java.util.Collection;
+import java.util.EnumSet;
+
+import org.apache.qpid.server.protocol.AmqpProtocolVersion;
+
 public enum Protocol
 {
-    AMQP_0_8,
-    AMQP_0_9,
-    AMQP_0_9_1,
-    AMQP_0_10,
-    AMQP_1_0,
-    JMX,
-    HTTP,
-    HTTPS
+    AMQP_0_8(ProtocolType.AMQP),
+    AMQP_0_9(ProtocolType.AMQP),
+    AMQP_0_9_1(ProtocolType.AMQP),
+    AMQP_0_10(ProtocolType.AMQP),
+    AMQP_1_0(ProtocolType.AMQP),
+    JMX_RMI(ProtocolType.JMX),
+    HTTP(ProtocolType.HTTP),
+    HTTPS(ProtocolType.HTTP);
+
+    private final ProtocolType _protocolType;
+
+    private Protocol(ProtocolType type)
+    {
+        _protocolType =  type;
+    }
+
+    public ProtocolType getProtocolType()
+    {
+        return _protocolType;
+    }
+
+    public boolean isAMQP()
+    {
+        return _protocolType == ProtocolType.AMQP;
+    }
+
+    public AmqpProtocolVersion toAmqpProtocolVersion()
+    {
+        switch(this)
+        {
+            case AMQP_0_8:
+                return AmqpProtocolVersion.v0_8;
+            case AMQP_0_9:
+                return AmqpProtocolVersion.v0_9;
+            case AMQP_0_9_1:
+                return AmqpProtocolVersion.v0_9_1;
+            case AMQP_0_10:
+                return AmqpProtocolVersion.v0_10;
+            case AMQP_1_0:
+                return AmqpProtocolVersion.v1_0_0;
+            default:
+                throw new IllegalArgumentException(this + " is not an known AMQP protocol");
+        }
+    }
+
+    public static Protocol valueOfObject(Object protocolObject)
+    {
+        Protocol protocol;
+        if (protocolObject instanceof Protocol)
+        {
+            protocol = (Protocol) protocolObject;
+        }
+        else
+        {
+            try
+            {
+                protocol = Protocol.valueOf(String.valueOf(protocolObject));
+            }
+            catch (Exception e)
+            {
+                throw new IllegalArgumentException("Can't convert '" + protocolObject
+                        + "' to one of the supported protocols: " + EnumSet.allOf(Protocol.class), e);
+            }
+        }
+        return protocol;
+    }
+
+    public static boolean hasAmqpProtocol(Collection<Protocol> protocols)
+    {
+        for (Protocol protocol : protocols)
+        {
+            if (protocol.isAMQP())
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    static enum ProtocolType
+    {
+        AMQP, HTTP, JMX;
+    }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Transport.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Transport.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Transport.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Transport.java Thu Nov  1 09:48:52 2012
@@ -20,8 +20,32 @@
  */
 package org.apache.qpid.server.model;
 
+import java.util.EnumSet;
+
 public enum Transport
 {
     TCP,
-    SSL
+    SSL;
+
+    public static Transport valueOfObject(Object transportObject)
+    {
+        Transport transport;
+        if (transportObject instanceof Transport)
+        {
+            transport = (Transport) transportObject;
+        }
+        else
+        {
+            try
+            {
+                transport = Transport.valueOf(String.valueOf(transportObject));
+            }
+            catch (Exception e)
+            {
+                throw new IllegalArgumentException("Can't convert '" + transportObject
+                        + "' to one of the supported transports: " + EnumSet.allOf(Transport.class), e);
+            }
+        }
+        return transport;
+    }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java Thu Nov  1 09:48:52 2012
@@ -26,8 +26,10 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
+
 import org.apache.qpid.server.model.ConfigurationChangeListener;
 import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObjectType;
 import org.apache.qpid.server.model.IllegalStateTransitionException;
 import org.apache.qpid.server.model.State;
 
@@ -46,130 +48,43 @@ abstract class AbstractAdapter implement
         _id = id;
     }
 
-    static String getStringAttribute(String name, Map<String,Object> attributes, String defaultVal)
-    {
-        final Object value = attributes.get(name);
-        return value == null ? defaultVal : String.valueOf(value);
-    }
-
-    static Map getMapAttribute(String name, Map<String,Object> attributes, Map defaultVal)
+    public final UUID getId()
     {
-        final Object value = attributes.get(name);
-        if(value == null)
-        {
-            return defaultVal;
-        }
-        else if(value instanceof Map)
-        {
-            return (Map) value;
-        }
-        else
-        {
-            throw new IllegalArgumentException("Value for attribute " + name + " is not of required type Map");
-        }
+        return _id;
     }
 
-
-    static <E extends Enum> E getEnumAttribute(Class<E> clazz, String name, Map<String,Object> attributes, E defaultVal)
+    public State getDesiredState()
     {
-        Object obj = attributes.get(name);
-        if(obj == null)
-        {
-            return defaultVal;
-        }
-        else if(clazz.isInstance(obj))
-        {
-            return (E) obj;
-        }
-        else if(obj instanceof String)
-        {
-            return (E) Enum.valueOf(clazz, (String)obj);
-        }
-        else
-        {
-            throw new IllegalArgumentException("Value for attribute " + name + " is not of required type " + clazz.getSimpleName());
-        }
+        return null;  //TODO
     }
 
-    static Boolean getBooleanAttribute(String name, Map<String,Object> attributes, Boolean defaultValue)
+    @Override
+    public final State setDesiredState(final State currentState, final State desiredState)
+            throws IllegalStateTransitionException, AccessControlException
     {
-        Object obj = attributes.get(name);
-        if(obj == null)
-        {
-            return defaultValue;
-        }
-        else if(obj instanceof Boolean)
+        if (setState(currentState, desiredState))
         {
-            return (Boolean) obj;
-        }
-        else if(obj instanceof String)
-        {
-            return Boolean.parseBoolean((String) obj);
-        }
-        else
-        {
-            throw new IllegalArgumentException("Value for attribute " + name + " is not of required type Boolean");
+            notifyStateChanged(currentState, desiredState);
         }
+        return getActualState();
     }
 
-    static Integer getIntegerAttribute(String name, Map<String,Object> attributes, Integer defaultValue)
-    {
-        Object obj = attributes.get(name);
-        if(obj == null)
-        {
-            return defaultValue;
-        }
-        else if(obj instanceof Number)
-        {
-            return ((Number) obj).intValue();
-        }
-        else if(obj instanceof String)
-        {
-            return Integer.valueOf((String) obj);
-        }
-        else
-        {
-            throw new IllegalArgumentException("Value for attribute " + name + " is not of required type Integer");
-        }
-    }
+    /**
+     * @return true when the state has been successfully updated to desiredState or false otherwise
+     */
+    protected abstract boolean setState(State currentState, State desiredState);
 
-    static Long getLongAttribute(String name, Map<String,Object> attributes, Long defaultValue)
+    protected void notifyStateChanged(final State currentState, final State desiredState)
     {
-        Object obj = attributes.get(name);
-        if(obj == null)
-        {
-            return defaultValue;
-        }
-        else if(obj instanceof Number)
-        {
-            return ((Number) obj).longValue();
-        }
-        else if(obj instanceof String)
-        {
-            return Long.valueOf((String) obj);
-        }
-        else
+        synchronized (this)
         {
-            throw new IllegalArgumentException("Value for attribute " + name + " is not of required type Long");
+            for(ConfigurationChangeListener listener : _changeListeners)
+            {
+                listener.stateChanged(this, currentState, desiredState);
+            }
         }
     }
 
-    public final UUID getId()
-    {
-        return _id;
-    }
-
-    public State getDesiredState()
-    {
-        return null;  //TODO
-    }
-
-    public State setDesiredState(final State currentState, final State desiredState)
-            throws IllegalStateTransitionException, AccessControlException
-    {
-        return null;  //TODO
-    }
-
     public void addChangeListener(final ConfigurationChangeListener listener)
     {
         if(listener == null)
@@ -280,4 +195,15 @@ abstract class AbstractAdapter implement
         }
     }
 
+    @Override
+    public ConfiguredObjectType getConfiguredObjectType()
+    {
+        throw new RuntimeException("Not implemented"); //XXX: implement this method in each concrete adapter class
+    }
+
+    @Override
+    public String toString()
+    {
+        return getClass().getSimpleName() + " [id=" + _id + "]";
+    }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java Thu Nov  1 09:48:52 2012
@@ -29,38 +29,44 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
+
 import javax.security.auth.login.AccountNotFoundException;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.model.*;
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.IllegalStateTransitionException;
+import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.PasswordCredentialManagingAuthenticationProvider;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.model.Statistics;
+import org.apache.qpid.server.model.UUIDGenerator;
+import org.apache.qpid.server.model.User;
+import org.apache.qpid.server.model.VirtualHostAlias;
 import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.security.access.Operation;
+import org.apache.qpid.server.security.auth.UsernamePrincipal;
 import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
 import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
 import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
-import org.apache.qpid.server.security.auth.UsernamePrincipal;
+import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
 
 public abstract class AuthenticationProviderAdapter<T extends AuthenticationManager> extends AbstractAdapter implements AuthenticationProvider
 {
     private static final Logger LOGGER = Logger.getLogger(AuthenticationProviderAdapter.class);
 
-    private final BrokerAdapter _broker;
     private final T _authManager;
 
-    private AuthenticationProviderAdapter(BrokerAdapter brokerAdapter,
-                                          final T authManager)
-    {
-        super(UUIDGenerator.generateRandomUUID());
-        _broker = brokerAdapter;
-        _authManager = authManager;
-    }
+    private GroupPrincipalAccessor _groupAccessor;
 
-    public static AuthenticationProviderAdapter createAuthenticationProviderAdapter(BrokerAdapter brokerAdapter,
-                                                                             final AuthenticationManager authManager)
+    private AuthenticationProviderAdapter(UUID id, Broker broker, final T authManager)
     {
-        return authManager instanceof PrincipalDatabaseAuthenticationManager
-                ? new PrincipalDatabaseAuthenticationManagerAdapter(brokerAdapter, (PrincipalDatabaseAuthenticationManager) authManager)
-                : new SimpleAuthenticationProviderAdapter(brokerAdapter, authManager);
+        super(id);
+        _authManager = authManager;
+        addParent(Broker.class, broker);
     }
 
     T getAuthManager()
@@ -199,23 +205,59 @@ public abstract class AuthenticationProv
                                            " creating children of type: " + childClass);
     }
 
-    private static class SimpleAuthenticationProviderAdapter extends AuthenticationProviderAdapter<AuthenticationManager>
+    @Override
+    public boolean setState(State currentState, State desiredState)
+            throws IllegalStateTransitionException, AccessControlException
+    {
+        if(desiredState == State.DELETED)
+        {
+            return true;
+        }
+        else if(desiredState == State.ACTIVE)
+        {
+            if (_groupAccessor == null)
+            {
+                throw new IllegalStateTransitionException("Cannot transit into ACTIVE state with null group accessor!");
+            }
+            _authManager.initialise();
+            return true;
+        }
+        else if(desiredState == State.STOPPED)
+        {
+            _authManager.close();
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public SubjectCreator getSubjectCreator()
+    {
+        return new SubjectCreator(_authManager, _groupAccessor);
+    }
+
+    public void setGroupAccessor(GroupPrincipalAccessor groupAccessor)
+    {
+        _groupAccessor = groupAccessor;
+    }
+
+    public static class SimpleAuthenticationProviderAdapter extends AuthenticationProviderAdapter<AuthenticationManager>
     {
         public SimpleAuthenticationProviderAdapter(
-                BrokerAdapter brokerAdapter, AuthenticationManager authManager)
+                UUID id, Broker broker, AuthenticationManager authManager)
         {
-            super(brokerAdapter,authManager);
+            super(id, broker,authManager);
         }
     }
 
-    private static class PrincipalDatabaseAuthenticationManagerAdapter
+    public static class PrincipalDatabaseAuthenticationManagerAdapter
             extends AuthenticationProviderAdapter<PrincipalDatabaseAuthenticationManager>
             implements PasswordCredentialManagingAuthenticationProvider
     {
         public PrincipalDatabaseAuthenticationManagerAdapter(
-                BrokerAdapter brokerAdapter, PrincipalDatabaseAuthenticationManager authManager)
+                UUID id, Broker broker, PrincipalDatabaseAuthenticationManager authManager)
         {
-            super(brokerAdapter, authManager);
+            super(id, broker, authManager);
         }
 
         @Override
@@ -275,7 +317,7 @@ public abstract class AuthenticationProv
             Map<String, Map<String,String>> users = new HashMap<String, Map<String, String>>();
             for(Principal principal : getPrincipalDatabase().getUsers())
             {
-                users.put(principal.getName(), Collections.EMPTY_MAP);
+                users.put(principal.getName(), Collections.<String, String>emptyMap());
             }
             return users;
         }
@@ -298,7 +340,9 @@ public abstract class AuthenticationProv
 
                 if(createUser(username, password,null))
                 {
-                    return (C) new PrincipalAdapter(p);
+                    @SuppressWarnings("unchecked")
+                    C pricipalAdapter = (C) new PrincipalAdapter(p);
+                    return pricipalAdapter;
                 }
                 else
                 {
@@ -321,7 +365,9 @@ public abstract class AuthenticationProv
                 {
                     principals.add(new PrincipalAdapter(user));
                 }
-                return (Collection<C>) Collections.unmodifiableCollection(principals);
+                @SuppressWarnings("unchecked")
+                Collection<C> unmodifiablePrincipals = (Collection<C>) Collections.unmodifiableCollection(principals);
+                return unmodifiablePrincipals;
             }
             else
             {
@@ -470,7 +516,7 @@ public abstract class AuthenticationProv
             }
 
             @Override
-            public State setDesiredState(State currentState, State desiredState)
+            protected boolean setState(State currentState, State desiredState)
                     throws IllegalStateTransitionException, AccessControlException
             {
                 if(desiredState == State.DELETED)
@@ -483,9 +529,9 @@ public abstract class AuthenticationProv
                     {
                         LOGGER.warn("Failed to delete user " + _user, e);
                     }
-                    return State.DELETED;
+                    return true;
                 }
-                return super.setDesiredState(currentState, desiredState);
+                return false;
             }
         }
     }

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderFactory.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderFactory.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderFactory.java Thu Nov  1 09:48:52 2012
@@ -0,0 +1,77 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model.adapter;
+
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.plugin.AuthenticationManagerFactory;
+import org.apache.qpid.server.plugin.QpidServiceLoader;
+import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
+import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
+import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
+import org.apache.qpid.server.model.adapter.AuthenticationProviderAdapter.PrincipalDatabaseAuthenticationManagerAdapter;
+import org.apache.qpid.server.model.adapter.AuthenticationProviderAdapter.SimpleAuthenticationProviderAdapter;
+
+public class AuthenticationProviderFactory
+{
+    private final Iterable<AuthenticationManagerFactory> _factories;
+
+    public AuthenticationProviderFactory(QpidServiceLoader<AuthenticationManagerFactory> authManagerFactoryServiceLoader)
+    {
+        _factories = authManagerFactoryServiceLoader.atLeastOneInstanceOf(AuthenticationManagerFactory.class);
+    }
+
+    /**
+     * Creates {@link AuthenticationProvider} for given ID, {@link Broker} and attributes.
+     * <p>
+     * The configured {@link AuthenticationManagerFactory}'s are used to try to create the {@link AuthenticationProvider}.
+     * The first non-null instance is returned. The factories are used in non-deterministic order.
+     * @param groupPrincipalAccessor TODO
+     */
+    public AuthenticationProvider create(UUID id, Broker broker, Map<String, Object> attributes, GroupPrincipalAccessor groupPrincipalAccessor)
+    {
+        for (AuthenticationManagerFactory factory : _factories)
+        {
+            AuthenticationManager manager = factory.createInstance(attributes);
+            if (manager != null)
+            {
+                AuthenticationProviderAdapter<?> authenticationProvider;
+                if (manager instanceof PrincipalDatabaseAuthenticationManager)
+                {
+                    authenticationProvider = new PrincipalDatabaseAuthenticationManagerAdapter(id, broker,
+                            (PrincipalDatabaseAuthenticationManager) manager);
+                }
+                else
+                {
+                    authenticationProvider = new SimpleAuthenticationProviderAdapter(id, broker, manager);
+                }
+                authenticationProvider.setGroupAccessor(groupPrincipalAccessor);
+                return authenticationProvider;
+            }
+        }
+
+        throw new IllegalArgumentException("No factories found for configuration attributes " + attributes);
+    }
+
+}

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BindingAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BindingAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BindingAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BindingAdapter.java Thu Nov  1 09:48:52 2012
@@ -219,14 +219,14 @@ final class BindingAdapter extends Abstr
     }
 
     @Override
-    public State setDesiredState(State currentState, State desiredState) throws IllegalStateTransitionException,
+    protected boolean setState(State currentState, State desiredState) throws IllegalStateTransitionException,
             AccessControlException
     {
         if (desiredState == State.DELETED)
         {
             delete();
-            return State.DELETED;
+            return true;
         }
-        return super.setDesiredState(currentState, desiredState);
+        return false;
     }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java Thu Nov  1 09:48:52 2012
@@ -20,90 +20,64 @@
  */
 package org.apache.qpid.server.model.adapter;
 
-import java.net.InetSocketAddress;
 import java.security.AccessControlException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
 import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.VirtualHostConfiguration;
+import org.apache.qpid.server.logging.actors.BrokerActor;
+import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.model.AuthenticationProvider;
 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.GroupProvider;
 import org.apache.qpid.server.model.LifetimePolicy;
 import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Protocol;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.Statistics;
-import org.apache.qpid.server.model.Transport;
-import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
-import org.apache.qpid.server.security.auth.manager.IAuthenticationManagerRegistry;
-import org.apache.qpid.server.security.group.GroupManager;
-import org.apache.qpid.server.transport.QpidAcceptor;
+import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
+import org.apache.qpid.server.stats.StatisticsGatherer;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 
-public class BrokerAdapter extends AbstractAdapter implements Broker, VirtualHostRegistry.RegistryChangeListener,
-                                                              IApplicationRegistry.PortBindingListener,
-                                                              IAuthenticationManagerRegistry.RegistryChangeListener,
-                                                              IApplicationRegistry.GroupManagerChangeListener
+public class BrokerAdapter extends AbstractAdapter implements Broker, ConfigurationChangeListener
 {
+    private static final Logger LOGGER = Logger.getLogger(BrokerAdapter.class);
 
-
-    private final IApplicationRegistry _applicationRegistry;
+    private IApplicationRegistry _applicationRegistry;
     private String _name;
-    private final Map<org.apache.qpid.server.virtualhost.VirtualHost, VirtualHostAdapter> _vhostAdapters =
-            new HashMap<org.apache.qpid.server.virtualhost.VirtualHost, VirtualHostAdapter>();
-    private final StatisticsAdapter _statistics;
-    private final Map<QpidAcceptor, PortAdapter> _portAdapters = new HashMap<QpidAcceptor, PortAdapter>();
-    private Collection<HTTPPortAdapter> _httpManagementPorts;
+    private StatisticsAdapter _statistics;
+
+    private final Map<String, VirtualHost> _vhostAdapters = new HashMap<String, VirtualHost>();
+    private final Map<Integer, Port> _portAdapters = new HashMap<Integer, Port>();
+    private final Map<String, AuthenticationProvider> _authenticationProviders = new HashMap<String, AuthenticationProvider>();
+    private final Map<String, GroupProvider> _groupProviders = new HashMap<String, GroupProvider>();
 
-    private final Map<AuthenticationManager, AuthenticationProviderAdapter> _authManagerAdapters =
-            new HashMap<AuthenticationManager, AuthenticationProviderAdapter>();
-    private final Map<GroupManager, GroupProviderAdapter> _groupManagerAdapters =
-            new HashMap<GroupManager, GroupProviderAdapter>();
+    private final AuthenticationProviderFactory _authenticationProviderFactory;
+    private AuthenticationProvider _defaultAuthenticationProvider;
 
+    private final PortFactory _portFactory;
 
-    public BrokerAdapter(final IApplicationRegistry instance)
+    public BrokerAdapter(UUID id, IApplicationRegistry instance, AuthenticationProviderFactory authenticationProviderFactory, PortFactory portFactory)
     {
-        super(UUIDGenerator.generateRandomUUID());
+        super(id);
+        _name = "Broker";
         _applicationRegistry = instance;
         _name = "Broker";
         _statistics = new StatisticsAdapter(instance);
-
-        instance.getVirtualHostRegistry().addRegistryChangeListener(this);
-        populateVhosts();
-        instance.addPortBindingListener(this);
-        populatePorts();
-        instance.addAuthenticationManagerRegistryChangeListener(this);
-        populateAuthenticationManagers();
-        instance.addGroupManagerChangeListener(this);
-        populateGroupManagers();
+        _authenticationProviderFactory = authenticationProviderFactory;
+        _portFactory = portFactory;
     }
 
-    private void populateVhosts()
-    {
-        synchronized(_vhostAdapters)
-        {
-            Collection<org.apache.qpid.server.virtualhost.VirtualHost> actualVhosts =
-                    _applicationRegistry.getVirtualHostRegistry().getVirtualHosts();
-            for(org.apache.qpid.server.virtualhost.VirtualHost vh : actualVhosts)
-            {
-                if(!_vhostAdapters.containsKey(vh))
-                {
-                    _vhostAdapters.put(vh, new VirtualHostAdapter(this, vh));
-                }
-            }
-
-        }
-    }
-
-
     public Collection<VirtualHost> getVirtualHosts()
     {
         synchronized(_vhostAdapters)
@@ -112,107 +86,55 @@ public class BrokerAdapter extends Abstr
         }
 
     }
-    private void populatePorts()
-    {
-        synchronized (_portAdapters)
-        {
-            Map<InetSocketAddress, QpidAcceptor> acceptors = _applicationRegistry.getAcceptors();
-
-            for(Map.Entry<InetSocketAddress, QpidAcceptor> entry : acceptors.entrySet())
-            {
-                if(!_portAdapters.containsKey(entry.getValue()))
-                {
-                    _portAdapters.put(entry.getValue(), new PortAdapter(this, entry.getValue(), entry.getKey()));
-                }
-            }
-            if(_applicationRegistry.useHTTPManagement() || _applicationRegistry.useHTTPSManagement())
-            {
-                ArrayList<HTTPPortAdapter> httpPorts = new ArrayList<HTTPPortAdapter>();
-                if (_applicationRegistry.useHTTPManagement())
-                {
-                    httpPorts.add(new HTTPPortAdapter(this, _applicationRegistry.getHTTPManagementPort()));
-                }
-                if (_applicationRegistry.useHTTPSManagement())
-                {
-                    httpPorts.add(new HTTPPortAdapter(this, _applicationRegistry.getHTTPSManagementPort(), Protocol.HTTPS, Transport.SSL));
-                }
-                _httpManagementPorts = Collections.unmodifiableCollection(httpPorts);
-            }
-        }
-    }
 
     public Collection<Port> getPorts()
     {
         synchronized (_portAdapters)
         {
             final ArrayList<Port> ports = new ArrayList<Port>(_portAdapters.values());
-            if(_httpManagementPorts != null)
-            {
-                ports.addAll(_httpManagementPorts);
-            }
             return ports;
         }
     }
 
-    private void populateAuthenticationManagers()
+    public Collection<AuthenticationProvider> getAuthenticationProviders()
     {
-        synchronized (_authManagerAdapters)
+        synchronized (_authenticationProviders)
         {
-            IAuthenticationManagerRegistry authenticationManagerRegistry =
-                    _applicationRegistry.getAuthenticationManagerRegistry();
-            if(authenticationManagerRegistry != null)
-            {
-                Map<String, AuthenticationManager> authenticationManagers =
-                        authenticationManagerRegistry.getAvailableAuthenticationManagers();
-
-                for(Map.Entry<String, AuthenticationManager> entry : authenticationManagers.entrySet())
-                {
-                    if(!_authManagerAdapters.containsKey(entry.getValue()))
-                    {
-                        _authManagerAdapters.put(entry.getValue(),
-                                                 AuthenticationProviderAdapter.createAuthenticationProviderAdapter(this,
-                                                                                                                   entry.getValue()));
-                    }
-                }
-            }
+            return new ArrayList<AuthenticationProvider>(_authenticationProviders.values());
         }
     }
 
-    private void populateGroupManagers()
+    public AuthenticationProvider getAuthenticationProviderByName(String authenticationProviderName)
     {
-        synchronized (_groupManagerAdapters)
+        Collection<AuthenticationProvider> providers = getAuthenticationProviders();
+        for (AuthenticationProvider authenticationProvider : providers)
         {
-            List<GroupManager> groupManagers = _applicationRegistry.getGroupManagers();
-            if(groupManagers != null)
+            if (authenticationProvider.getName().equals(authenticationProviderName))
             {
-                for (GroupManager groupManager : groupManagers)
-                {
-                    if(!_groupManagerAdapters.containsKey(groupManager))
-                    {
-                        _groupManagerAdapters.put(groupManager,
-                                                 GroupProviderAdapter.createGroupProviderAdapter(this, groupManager));
-                    }
-                }
+                return authenticationProvider;
             }
         }
+        return null;
     }
 
-    public Collection<AuthenticationProvider> getAuthenticationProviders()
+    @Override
+    public AuthenticationProvider getDefaultAuthenticationProvider()
     {
-        synchronized (_authManagerAdapters)
-        {
-            final ArrayList<AuthenticationProvider> authManagers =
-                    new ArrayList<AuthenticationProvider>(_authManagerAdapters.values());
-            return authManagers;
-        }
+        return _defaultAuthenticationProvider;
     }
 
+    public void setDefaultAuthenticationProvider(AuthenticationProvider provider)
+    {
+        _defaultAuthenticationProvider = provider;
+    }
+
+    @Override
     public Collection<GroupProvider> getGroupProviders()
     {
-        synchronized (_groupManagerAdapters)
+        synchronized (_groupProviders)
         {
             final ArrayList<GroupProvider> groupManagers =
-                    new ArrayList<GroupProvider>(_groupManagerAdapters.values());
+                    new ArrayList<GroupProvider>(_groupProviders.values());
             return groupManagers;
         }
     }
@@ -228,16 +150,32 @@ public class BrokerAdapter extends Abstr
         return null;  //TODO
     }
 
-    public VirtualHost createVirtualHost(final Map<String, Object> attributes)
+    private VirtualHost createVirtualHost(final Map<String, Object> attributes)
             throws AccessControlException, IllegalArgumentException
     {
-        return null;  //TODO
+        String virtualHostName = (String) attributes.get(VirtualHost.NAME);
+        VirtualHostConfiguration vhostConfig = _applicationRegistry.getConfiguration().getVirtualHostConfig(virtualHostName);
+
+        VirtualHostRegistry virtualHostRegistry = _applicationRegistry.getVirtualHostRegistry();
+        final VirtualHostAdapter virtualHostAdapter = new VirtualHostAdapter(UUID.randomUUID(), this,
+                attributes, virtualHostRegistry, (StatisticsGatherer)_applicationRegistry,
+                _applicationRegistry.getSecurityManager(), vhostConfig);
+
+        synchronized (_vhostAdapters)
+        {
+            _vhostAdapters.put(virtualHostAdapter.getName(), virtualHostAdapter);
+        }
+
+        virtualHostAdapter.setState(State.INITIALISING, State.ACTIVE);
+        childAdded(virtualHostAdapter);
+
+        return virtualHostAdapter;
     }
 
-    public void deleteVirtualHost(final VirtualHost vhost)
+    private boolean deleteVirtualHost(final VirtualHost vhost)
         throws AccessControlException, IllegalStateException
     {
-        //TODO
+        //TODO implement deleteVirtualHost
         throw new UnsupportedOperationException("Not yet implemented");
     }
 
@@ -297,6 +235,7 @@ public class BrokerAdapter extends Abstr
         return _statistics;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz)
     {
@@ -320,6 +259,7 @@ public class BrokerAdapter extends Abstr
         return Collections.emptySet();
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public <C extends ConfiguredObject> C createChild(Class<C> childClass, Map<String, Object> attributes, ConfiguredObject... otherParents)
     {
@@ -341,111 +281,73 @@ public class BrokerAdapter extends Abstr
         }
     }
 
-    private Port createPort(Map<String, Object> attributes)
-    {
-        // TODO
-        return null;
-    }
-
-    private AuthenticationProvider createAuthenticationProvider(Map<String,Object> attributes)
-    {
-        // TODO
-        return null;
-    }
-
-
-    public void virtualHostRegistered(org.apache.qpid.server.virtualhost.VirtualHost virtualHost)
+    public void addPort(Port port)
     {
-        VirtualHostAdapter adapter = null;
-        synchronized (_vhostAdapters)
+        synchronized (_portAdapters)
         {
-            if(!_vhostAdapters.containsKey(virtualHost))
+            int portNumber = port.getPort();
+            if(_portAdapters.containsKey(portNumber))
             {
-                adapter = new VirtualHostAdapter(this, virtualHost);
-                _vhostAdapters.put(virtualHost, adapter);
+                throw new IllegalArgumentException("Cannot add port " + port + " because port number " + portNumber + " already configured");
             }
+            _portAdapters.put(portNumber, port);
         }
-        if(adapter != null)
-        {
-            childAdded(adapter);
-        }
+        port.addChangeListener(this);
     }
 
-    public void virtualHostUnregistered(org.apache.qpid.server.virtualhost.VirtualHost virtualHost)
+    private Port createPort(Map<String, Object> attributes)
     {
-        VirtualHostAdapter adapter = null;
-
-        synchronized (_vhostAdapters)
-        {
-            adapter = _vhostAdapters.remove(virtualHost);
-        }
-        if(adapter != null)
-        {
-            childRemoved(adapter);
-        }
+        Port port = _portFactory.createPort(UUID.randomUUID(), this, attributes);
+        addPort(port);
+        childAdded(port);
+        return port;
     }
 
-    @Override
-    public void authenticationManagerRegistered(AuthenticationManager authenticationManager)
+    private AuthenticationProvider createAuthenticationProvider(Map<String, Object> attributes)
     {
-        AuthenticationProviderAdapter adapter = null;
-        synchronized (_authManagerAdapters)
-        {
-            if(!_authManagerAdapters.containsKey(authenticationManager))
-            {
-                adapter =
-                        AuthenticationProviderAdapter.createAuthenticationProviderAdapter(this, authenticationManager);
-                _authManagerAdapters.put(authenticationManager, adapter);
-            }
-        }
-        if(adapter != null)
-        {
-            childAdded(adapter);
-        }
+        // it's cheap to create the groupPrincipalAccessor on the fly
+        GroupPrincipalAccessor groupPrincipalAccessor = new GroupPrincipalAccessor(_groupProviders.values());
+
+        AuthenticationProvider authenticationProvider = _authenticationProviderFactory.create(UUID.randomUUID(), this, attributes, groupPrincipalAccessor);
+        addAuthenticationProvider(authenticationProvider);
+        childAdded(authenticationProvider);
+        return authenticationProvider;
     }
 
-    @Override
-    public void authenticationManagerUnregistered(AuthenticationManager authenticationManager)
+    /**
+     * @throws IllegalConfigurationException if an AuthenticationProvider with the same name already exists
+     */
+    public void addAuthenticationProvider(AuthenticationProvider authenticationProvider)
     {
-        AuthenticationProviderAdapter adapter;
-        synchronized (_authManagerAdapters)
+        String name = authenticationProvider.getName();
+        synchronized (_authenticationProviders)
         {
-            adapter = _authManagerAdapters.remove(authenticationManager);
-        }
-        if(adapter != null)
-        {
-            childRemoved(adapter);
+            if(_authenticationProviders.containsKey(name))
+            {
+                throw new IllegalConfigurationException("Cannot add AuthenticationProvider because one with name " + name + " already exists");
+            }
+            _authenticationProviders.put(name, authenticationProvider);
         }
+        authenticationProvider.addChangeListener(this);
     }
 
-
-    @Override
-    public void bound(QpidAcceptor acceptor, InetSocketAddress bindAddress)
+    public void addGroupProvider(GroupProvider groupProvider)
     {
-        synchronized (_portAdapters)
+        synchronized (_groupProviders)
         {
-            if(!_portAdapters.containsKey(acceptor))
+            String name = groupProvider.getName();
+            if(_groupProviders.containsKey(name))
             {
-                PortAdapter adapter = new PortAdapter(this, acceptor, bindAddress);
-                _portAdapters.put(acceptor, adapter);
-                childAdded(adapter);
+                throw new IllegalConfigurationException("Cannot add GroupProvider because one with name " + name + " already exists");
             }
+            _groupProviders.put(name, groupProvider);
         }
+        groupProvider.addChangeListener(this);
     }
 
-    @Override
-    public void unbound(QpidAcceptor acceptor)
+    private boolean deleteGroupProvider(GroupProvider object)
     {
-        PortAdapter adapter = null;
-
-        synchronized (_portAdapters)
-        {
-            adapter = _portAdapters.remove(acceptor);
-        }
-        if(adapter != null)
-        {
-            childRemoved(adapter);
-        }
+        throw new UnsupportedOperationException("Not implemented yet!");
     }
 
     @Override
@@ -520,7 +422,10 @@ public class BrokerAdapter extends Abstr
         {
             // TODO
         }
-
+        else if (DEFAULT_AUTHENTICATION_PROVIDER.equals(name))
+        {
+            return getDefaultAuthenticationProvider();
+        }
         return super.getAttribute(name);    //TODO - Implement.
     }
 
@@ -531,35 +436,137 @@ public class BrokerAdapter extends Abstr
         return super.setAttribute(name, expected, desired);    //TODO - Implement.
     }
 
+    private boolean deletePort(Port portAdapter)
+    {
+        Port removedPort = null;
+        synchronized (_portAdapters)
+        {
+            removedPort = _portAdapters.remove(portAdapter.getPort());
+        }
+        return removedPort != null;
+    }
+
+    private boolean deleteAuthenticationProvider(AuthenticationProvider authenticationProvider)
+    {
+        AuthenticationProvider removedAuthenticationProvider = null;
+        synchronized (_authenticationProviders)
+        {
+            removedAuthenticationProvider = _authenticationProviders.remove(authenticationProvider.getName());
+        }
+        return removedAuthenticationProvider != null;
+    }
+
+    public void addVirtualHost(VirtualHost virtualHost)
+    {
+        synchronized (_vhostAdapters)
+        {
+            String name = virtualHost.getName();
+            if (_vhostAdapters.containsKey(name))
+            {
+                throw new IllegalConfigurationException("Virtual host with name " + name + " is already specified!");
+            }
+            _vhostAdapters.put(name, virtualHost);
+        }
+        virtualHost.addChangeListener(this);
+    }
+
     @Override
-    public void groupManagerRegistered(GroupManager groupManager)
+    public boolean setState(State currentState, State desiredState)
     {
-        GroupProviderAdapter adapter = null;
-        synchronized (_groupManagerAdapters)
+        if (desiredState == State.ACTIVE)
         {
-            if(!_groupManagerAdapters.containsKey(groupManager))
+            changeState(_groupProviders, currentState, State.ACTIVE, false);
+            changeState(_authenticationProviders, currentState, State.ACTIVE, false);
+
+            CurrentActor.set(new BrokerActor(_applicationRegistry.getRootMessageLogger()));
+            try
             {
-                adapter = GroupProviderAdapter.createGroupProviderAdapter(this, groupManager);
-                _groupManagerAdapters.put(groupManager, adapter);
+                changeState(_vhostAdapters, currentState, State.ACTIVE, false);
             }
+            finally
+            {
+                CurrentActor.remove();
+            }
+
+            changeState(_portAdapters, currentState,State.ACTIVE, false);
+            return true;
         }
-        if(adapter != null)
+        else if (desiredState == State.STOPPED)
         {
-            childAdded(adapter);
+            changeState(_portAdapters, currentState, State.STOPPED, true);
+            changeState(_vhostAdapters,currentState, State.STOPPED, true);
+            changeState(_authenticationProviders, currentState, State.STOPPED, true);
+            changeState(_groupProviders, currentState, State.STOPPED, true);
+            return true;
         }
+        return false;
     }
 
-    @Override
-    public void groupManagerUnregistered(GroupManager groupManager)
+    private void changeState(Map<?, ? extends ConfiguredObject> configuredObjectMap, State currentState, State desiredState, boolean swallowException)
     {
-        GroupProviderAdapter adapter;
-        synchronized (_groupManagerAdapters)
+        synchronized(configuredObjectMap)
         {
-            adapter = _groupManagerAdapters.remove(groupManager);
+            Collection<? extends ConfiguredObject> adapters = configuredObjectMap.values();
+            for (ConfiguredObject configuredObject : adapters)
+            {
+                try
+                {
+                    configuredObject.setDesiredState(currentState, desiredState);
+                }
+                catch(RuntimeException e)
+                {
+                    if (swallowException)
+                    {
+                        LOGGER.error("Failed to stop " + configuredObject, e);
+                    }
+                    else
+                    {
+                        throw e;
+                    }
+                }
+            }
         }
-        if(adapter != null)
+    }
+
+    @Override
+    public void stateChanged(ConfiguredObject object, State oldState, State newState)
+    {
+        if(newState == State.DELETED)
         {
-            childRemoved(adapter);
+            boolean childDeleted = false;
+            if(object instanceof AuthenticationProvider)
+            {
+                childDeleted = deleteAuthenticationProvider((AuthenticationProvider)object);
+            }
+            else if(object instanceof Port)
+            {
+                childDeleted = deletePort((Port)object);
+            }
+            else if(object instanceof VirtualHost)
+            {
+                childDeleted = deleteVirtualHost((VirtualHost)object);
+            }
+            else if(object instanceof GroupProvider)
+            {
+                childDeleted = deleteGroupProvider((GroupProvider)object);
+            }
+            if(childDeleted)
+            {
+                childRemoved(object);
+            }
         }
     }
+
+    @Override
+    public void childAdded(ConfiguredObject object, ConfiguredObject child)
+    {
+        // no-op
+    }
+
+    @Override
+    public void childRemoved(ConfiguredObject object, ConfiguredObject child)
+    {
+        // no-op
+    }
+
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java Thu Nov  1 09:48:52 2012
@@ -310,4 +310,11 @@ final class ConnectionAdapter extends Ab
             return super.getStatistic(name);
         }
     }
+
+    @Override
+    protected boolean setState(State currentState, State desiredState)
+    {
+        // TODO: add state management
+        return false;
+    }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ConsumerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ConsumerAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ConsumerAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ConsumerAdapter.java Thu Nov  1 09:48:52 2012
@@ -222,4 +222,11 @@ public class ConsumerAdapter extends Abs
             return null;  // TODO - Implement
         }
     }
+
+    @Override
+    protected boolean setState(State currentState, State desiredState)
+    {
+        // TODO : Add state management
+        return false;
+    }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java Thu Nov  1 09:48:52 2012
@@ -35,14 +35,13 @@ import org.apache.qpid.server.binding.Bi
 import org.apache.qpid.server.exchange.ExchangeRegistry;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Exchange;
-import org.apache.qpid.server.model.IllegalStateTransitionException;
 import org.apache.qpid.server.model.LifetimePolicy;
 import org.apache.qpid.server.model.Publisher;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.Statistics;
-import org.apache.qpid.server.plugin.ExchangeType;
 import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.util.MapValueConverter;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
 final class ExchangeAdapter extends AbstractAdapter implements Exchange, org.apache.qpid.server.exchange.Exchange.BindingListener
@@ -113,8 +112,8 @@ final class ExchangeAdapter extends Abst
             throws AccessControlException, IllegalStateException
     {
         attributes = new HashMap<String, Object>(attributes);
-        String bindingKey = getStringAttribute(org.apache.qpid.server.model.Binding.NAME, attributes, "");
-        Map<String, Object> bindingArgs = getMapAttribute(org.apache.qpid.server.model.Binding.ARGUMENTS, attributes, Collections.EMPTY_MAP);
+        String bindingKey = MapValueConverter.getStringAttribute(org.apache.qpid.server.model.Binding.NAME, attributes, "");
+        Map<String, Object> bindingArgs = MapValueConverter.getMapAttribute(org.apache.qpid.server.model.Binding.ARGUMENTS, attributes, Collections.<String,Object>emptyMap());
 
         attributes.remove(org.apache.qpid.server.model.Binding.NAME);
         attributes.remove(org.apache.qpid.server.model.Binding.ARGUMENTS);
@@ -382,15 +381,14 @@ final class ExchangeAdapter extends Abst
     }
 
     @Override
-    public State setDesiredState(State currentState, State desiredState) throws IllegalStateTransitionException,
-            AccessControlException
+    protected boolean setState(State currentState, State desiredState)
     {
         if (desiredState == State.DELETED)
         {
             delete();
-            return State.DELETED;
+            return true;
         }
-        return super.setDesiredState(currentState, desiredState);
+        return false;
     }
 
     private class ExchangeStatistics implements Statistics

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java Thu Nov  1 09:48:52 2012
@@ -26,6 +26,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
@@ -46,24 +47,16 @@ public class GroupProviderAdapter extend
 {
     private final GroupManager _groupManager;
 
-    protected GroupProviderAdapter(GroupManager groupManager)
+    public GroupProviderAdapter(UUID id, GroupManager groupManager, Broker broker)
     {
-        super(UUIDGenerator.generateRandomUUID());
+        super(id);
 
         if (groupManager == null)
         {
             throw new IllegalArgumentException("GroupManager must not be null");
         }
         _groupManager = groupManager;
-    }
-
-    public static GroupProviderAdapter createGroupProviderAdapter(
-            BrokerAdapter brokerAdapter, GroupManager groupManager)
-    {
-        final GroupProviderAdapter groupProviderAdapter = new GroupProviderAdapter(
-                groupManager);
-        groupProviderAdapter.addParent(Broker.class, brokerAdapter);
-        return groupProviderAdapter;
+       addParent(Broker.class, broker);
     }
 
     @Override
@@ -386,7 +379,7 @@ public class GroupProviderAdapter extend
         }
 
         @Override
-        public State setDesiredState(State currentState, State desiredState)
+        protected boolean setState(State currentState, State desiredState)
                 throws IllegalStateTransitionException, AccessControlException
         {
             if (desiredState == State.DELETED)
@@ -394,16 +387,15 @@ public class GroupProviderAdapter extend
                 if (getSecurityManager().authoriseGroupOperation(Operation.DELETE, _group))
                 {
                     _groupManager.removeGroup(_group);
-                    return State.DELETED;
+                    return true;
                 }
                 else
                 {
-                    throw new AccessControlException("Do not have permission" +
-                    " to delete group");
+                    throw new AccessControlException("Do not have permission to delete group");
                 }
             }
 
-            return super.setDesiredState(currentState, desiredState);
+            return false;
         }
 
         private class GroupMemberAdapter extends AbstractAdapter implements
@@ -522,7 +514,7 @@ public class GroupProviderAdapter extend
             }
 
             @Override
-            public State setDesiredState(State currentState, State desiredState)
+            protected boolean setState(State currentState, State desiredState)
                     throws IllegalStateTransitionException,
                     AccessControlException
             {
@@ -531,18 +523,38 @@ public class GroupProviderAdapter extend
                     if (getSecurityManager().authoriseGroupOperation(Operation.UPDATE, _group))
                     {
                         _groupManager.removeUserFromGroup(_memberName, _group);
-                        return State.DELETED;
+                        return true;
                     }
                     else
                     {
-                        throw new AccessControlException("Do not have permission" +
-                        " to remove group member");
+                        throw new AccessControlException("Do not have permission to remove group member");
                     }
                 }
-                
-                return super.setDesiredState(currentState, desiredState);
+                return false;
             }
 
         }
     }
+
+    @Override
+    protected boolean setState(State currentState, State desiredState)
+    {
+        if (desiredState == State.ACTIVE)
+        {
+            return true;
+        }
+        else if (desiredState == State.STOPPED)
+        {
+            return true;
+        }
+        // TODO: DELETE state is ignored for now
+        // in case if we need to delete group provider, then we need AuthenticationProvider to be a change listener of it
+        // in order to remove deleted group provider from its group provider list
+        return false;
+    }
+
+    public Set<Principal> getGroupPrincipalsForUser(String username)
+    {
+        return _groupManager.getGroupPrincipalsForUser(username);
+    }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java Thu Nov  1 09:48:52 2012
@@ -21,7 +21,19 @@
 
 package org.apache.qpid.server.model.adapter;
 
+import java.net.InetSocketAddress;
+import java.security.AccessControlException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
+
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Connection;
 import org.apache.qpid.server.model.LifetimePolicy;
@@ -30,99 +42,86 @@ import org.apache.qpid.server.model.Prot
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.Statistics;
 import org.apache.qpid.server.model.Transport;
-import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.model.VirtualHostAlias;
-import org.apache.qpid.server.protocol.AmqpProtocolVersion;
-import org.apache.qpid.server.transport.QpidAcceptor;
-
-import java.net.InetSocketAddress;
-import java.security.AccessControlException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import org.apache.qpid.server.util.MapValueConverter;
 
 public class PortAdapter extends AbstractAdapter implements Port
 {
-    private final BrokerAdapter _broker;
-    private final QpidAcceptor _acceptor;
-    private final InetSocketAddress _address;
-    private final Collection<Protocol> _protocols;
-
-    public PortAdapter(BrokerAdapter brokerAdapter, QpidAcceptor acceptor, InetSocketAddress address)
-    {
-        super(UUIDGenerator.generateRandomUUID());
-        _broker = brokerAdapter;
-        _acceptor = acceptor;
-        _address = address;
-
-        List<Protocol> protocols = new ArrayList<Protocol>();
-
-        for(AmqpProtocolVersion pv : _acceptor.getSupported())
-        {
-             switch(pv)
-             {
-                 case v0_8:
-                     protocols.add(Protocol.AMQP_0_8);
-                     break;
-                 case v0_9:
-                     protocols.add(Protocol.AMQP_0_9);
-                     break;
-                 case v0_9_1:
-                     protocols.add(Protocol.AMQP_0_9_1);
-                     break;
-                 case v0_10:
-                     protocols.add(Protocol.AMQP_0_10);
-                     break;
-                 case v1_0_0:
-                     protocols.add(Protocol.AMQP_1_0);
-                     break;
-             }
-        }
-
-        _protocols = Collections.unmodifiableCollection(protocols);
 
+    private final String _name;
+    private final Broker _broker;
+    private final Set<Protocol> _protocols;
+    private final Set<Transport> _transports;
+    private final InetSocketAddress _bindingSocketAddress;
+    private final boolean _tcpNoDelay;
+    private final int _receiveBufferSize;
+    private final int _sendBufferSize;
+    private final boolean _needClientAuth;
+    private final boolean _wantClientAuth;
+    private final String _authenticationManager;
+    private AuthenticationProvider _authenticationProvider;
+
+    /*
+     * TODO register PortAceptor as a listener. For supporting multiple
+     * protocols on the same port we need to introduce a special entity like
+     * PortAceptor which will be responsible for port binding/unbinding
+     */
+    public PortAdapter(UUID id, Broker broker, Map<String, Object> attributes)
+    {
+        super(id);
+        _broker = broker;
+
+        addParent(Broker.class, broker);
+
+        String bindingAddress = MapValueConverter.getStringAttribute(BINDING_ADDRESS, attributes, null);
+        int portNumber = MapValueConverter.getIntegerAttribute(PORT, attributes, null);
+
+        final Set<Protocol> protocolSet = MapValueConverter.getSetAttribute(PROTOCOLS, attributes);
+        final Set<Transport> transportSet = MapValueConverter.getSetAttribute(TRANSPORTS, attributes);
+
+        _bindingSocketAddress = determineBindingAddress(bindingAddress, portNumber);
+        _name = MapValueConverter.getStringAttribute(NAME, attributes, _bindingSocketAddress.getHostName() + ":" + portNumber);
+        _protocols = Collections.unmodifiableSet(new TreeSet<Protocol>(protocolSet));
+        _transports = Collections.unmodifiableSet(new TreeSet<Transport>(transportSet));
+        _tcpNoDelay = MapValueConverter.getBooleanAttribute(TCP_NO_DELAY, attributes);
+        _receiveBufferSize = MapValueConverter.getIntegerAttribute(RECEIVE_BUFFER_SIZE, attributes);
+        _sendBufferSize = MapValueConverter.getIntegerAttribute(SEND_BUFFER_SIZE, attributes);
+        _needClientAuth = MapValueConverter.getBooleanAttribute(NEED_CLIENT_AUTH, attributes);
+        _wantClientAuth = MapValueConverter.getBooleanAttribute(WANT_CLIENT_AUTH, attributes);
+        _authenticationManager = MapValueConverter.getStringAttribute(AUTHENTICATION_MANAGER, attributes, null);
     }
 
     @Override
     public String getBindingAddress()
     {
-        return _address.getHostName();
+        return _bindingSocketAddress.getAddress().getHostAddress();
     }
 
     @Override
     public int getPort()
     {
-        return _address.getPort();
+        return _bindingSocketAddress.getPort();
     }
 
     @Override
     public Collection<Transport> getTransports()
     {
-        switch (_acceptor.getTransport())
-        {
-            case TCP:
-                return Collections.singleton(Transport.TCP);
-            case SSL:
-                return Collections.singleton(Transport.SSL);
-        }
-
-        return null;  // TODO - Implement
+        return _transports;
     }
 
     @Override
     public void addTransport(Transport transport)
             throws IllegalStateException, AccessControlException, IllegalArgumentException
     {
-        throw new IllegalStateException(); // TODO - Implement
+        throw new IllegalStateException();
     }
 
     @Override
     public Transport removeTransport(Transport transport)
             throws IllegalStateException, AccessControlException, IllegalArgumentException
     {
-        throw new IllegalStateException();   // TODO - Implement
+        throw new IllegalStateException();
     }
 
     @Override
@@ -135,14 +134,14 @@ public class PortAdapter extends Abstrac
     public void addProtocol(Protocol protocol)
             throws IllegalStateException, AccessControlException, IllegalArgumentException
     {
-        throw new IllegalStateException(); // TODO - Implement
+        throw new IllegalStateException();
     }
 
     @Override
     public Protocol removeProtocol(Protocol protocol)
             throws IllegalStateException, AccessControlException, IllegalArgumentException
     {
-        throw new IllegalStateException();   // TODO - Implement
+        throw new IllegalStateException();
     }
 
     @Override
@@ -165,19 +164,19 @@ public class PortAdapter extends Abstrac
     @Override
     public Collection<Connection> getConnections()
     {
-        return null;  // TODO - Implement
+        return null;
     }
 
     @Override
     public String getName()
     {
-        return getBindingAddress() + ":" + getPort();  // TODO - Implement
+        return _name;
     }
 
     @Override
     public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException
     {
-        throw new IllegalStateException();  // TODO - Implement
+        throw new IllegalStateException();
     }
 
     @Override
@@ -189,7 +188,7 @@ public class PortAdapter extends Abstrac
     @Override
     public boolean isDurable()
     {
-        return false;  // TODO - Implement
+        return false;
     }
 
     @Override
@@ -209,20 +208,20 @@ public class PortAdapter extends Abstrac
     public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired)
             throws IllegalStateException, AccessControlException, IllegalArgumentException
     {
-        throw new IllegalStateException();   // TODO - Implement
+        throw new IllegalStateException();
     }
 
     @Override
     public long getTimeToLive()
     {
-        return 0;  // TODO - Implement
+        return 0;
     }
 
     @Override
     public long setTimeToLive(long expected, long desired)
             throws IllegalStateException, AccessControlException, IllegalArgumentException
     {
-        throw new IllegalStateException();  // TODO - Implement
+        throw new IllegalStateException();
     }
 
     @Override
@@ -301,8 +300,31 @@ public class PortAdapter extends Abstrac
         {
             return getTransports();
         }
-
-        return super.getAttribute(name);    //TODO - Implement
+        else if(TCP_NO_DELAY.equals(name))
+        {
+            return isTcpNoDelay();
+        }
+        else if(SEND_BUFFER_SIZE.equals(name))
+        {
+            return getSendBufferSize();
+        }
+        else if(RECEIVE_BUFFER_SIZE.equals(name))
+        {
+            return getReceiveBufferSize();
+        }
+        else if(NEED_CLIENT_AUTH.equals(name))
+        {
+            return isNeedClientAuth();
+        }
+        else if(WANT_CLIENT_AUTH.equals(name))
+        {
+            return isWantClientAuth();
+        }
+        else if(AUTHENTICATION_MANAGER.equals(name))
+        {
+            return getAuthenticationManager();
+        }
+        return super.getAttribute(name);
     }
 
     @Override
@@ -315,6 +337,89 @@ public class PortAdapter extends Abstrac
     public Object setAttribute(String name, Object expected, Object desired)
             throws IllegalStateException, AccessControlException, IllegalArgumentException
     {
-        return super.setAttribute(name, expected, desired);    //TODO - Implement
+        return super.setAttribute(name, expected, desired);
+    }
+
+    @Override
+    public boolean setState(State currentState, State desiredState)
+    {
+        if (desiredState == State.DELETED)
+        {
+            return true;
+        }
+        else if (desiredState == State.ACTIVE)
+        {
+            onActivate();
+            return true;
+        }
+        else if (desiredState == State.STOPPED)
+        {
+            onStop();
+            return true;
+        }
+        return false;
+    }
+
+    protected void onActivate()
+    {
+        // no-op: expected to be overridden by subclass
+    }
+
+    protected void onStop()
+    {
+        // no-op: expected to be overridden by subclass
     }
+
+    private InetSocketAddress determineBindingAddress(String bindingAddress, int portNumber)
+    {
+        return bindingAddress == null ? new InetSocketAddress(portNumber) : new InetSocketAddress(bindingAddress, portNumber);
+    }
+
+    @Override
+    public boolean isTcpNoDelay()
+    {
+        return _tcpNoDelay;
+    }
+
+    @Override
+    public int getReceiveBufferSize()
+    {
+        return _receiveBufferSize;
+    }
+
+    @Override
+    public int getSendBufferSize()
+    {
+        return _sendBufferSize;
+    }
+
+    @Override
+    public boolean isNeedClientAuth()
+    {
+        return _needClientAuth;
+    }
+
+    @Override
+    public boolean isWantClientAuth()
+    {
+        return _wantClientAuth;
+    }
+
+    @Override
+    public String getAuthenticationManager()
+    {
+        return _authenticationManager;
+    }
+
+    @Override
+    public AuthenticationProvider getAuthenticationProvider()
+    {
+        return _authenticationProvider;
+    }
+
+    public void setAuthenticationProvider(AuthenticationProvider authenticationProvider)
+    {
+        _authenticationProvider = authenticationProvider;
+    }
+
 }

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAttributeDestringifier.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAttributeDestringifier.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAttributeDestringifier.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAttributeDestringifier.java Thu Nov  1 09:48:52 2012
@@ -0,0 +1,82 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model.adapter;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.Protocol;
+import org.apache.qpid.server.model.Transport;
+import org.apache.qpid.server.util.MapValueConverter;
+
+public class PortAttributeDestringifier
+{
+    private static final int DEFAULT_BUFFER_SIZE = 262144;
+    private static final boolean DEFAULT_TCP_NO_DELAY = true;
+    private static final boolean DEFAULT_WANT_CLIENT_AUTH = false;
+    private static final boolean DEFAULT_NEED_CLIENT_AUTH = false;
+
+    // TODO : implement a generic functionality to convert string attribute  values into corresponding java types
+    public Map<String, Object> destringify(Map<String, Object> attributes)
+    {
+        Map<String, Object> destringifiedAttributes = new HashMap<String, Object>(attributes);
+
+        final Set<Object> protocolObjectSet = MapValueConverter.getSetAttribute(Port.PROTOCOLS, attributes);
+        final Set<Protocol> protocolSet = new HashSet<Protocol>();
+        for (Object object : protocolObjectSet)
+        {
+            Protocol protocol = Protocol.valueOfObject(object);
+            protocolSet.add(protocol);
+        }
+        destringifiedAttributes.put(Port.PROTOCOLS, protocolSet);
+
+        final Set<Object> transportObjectSet = MapValueConverter.getSetAttribute(Port.TRANSPORTS, attributes);
+        final Set<Transport> transportSet = new HashSet<Transport>();
+        for (Object transportObject : transportObjectSet)
+        {
+            Transport transport = Transport.valueOfObject(transportObject);
+            transportSet.add(transport);
+        }
+        destringifiedAttributes.put(Port.TRANSPORTS, transportSet);
+
+        Integer port = MapValueConverter.getIntegerAttribute(Port.PORT, attributes);
+        destringifiedAttributes.put(Port.PORT, port);
+
+        boolean tcpNoDelay = MapValueConverter.getBooleanAttribute(Port.TCP_NO_DELAY, attributes, DEFAULT_TCP_NO_DELAY);
+        int receiveBufferSize = MapValueConverter.getIntegerAttribute(Port.RECEIVE_BUFFER_SIZE, attributes,
+                DEFAULT_BUFFER_SIZE);
+        int sendBufferSize = MapValueConverter.getIntegerAttribute(Port.SEND_BUFFER_SIZE, attributes, DEFAULT_BUFFER_SIZE);
+        boolean needClientAuth = MapValueConverter.getBooleanAttribute(Port.NEED_CLIENT_AUTH, attributes,
+                DEFAULT_NEED_CLIENT_AUTH);
+        boolean wantClientAuth = MapValueConverter.getBooleanAttribute(Port.WANT_CLIENT_AUTH, attributes,
+                DEFAULT_WANT_CLIENT_AUTH);
+
+        destringifiedAttributes.put(Port.TCP_NO_DELAY, tcpNoDelay);
+        destringifiedAttributes.put(Port.RECEIVE_BUFFER_SIZE, receiveBufferSize);
+        destringifiedAttributes.put(Port.SEND_BUFFER_SIZE, sendBufferSize);
+        destringifiedAttributes.put(Port.NEED_CLIENT_AUTH, needClientAuth);
+        destringifiedAttributes.put(Port.WANT_CLIENT_AUTH, wantClientAuth);
+        return destringifiedAttributes;
+    }
+}

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java Thu Nov  1 09:48:52 2012
@@ -0,0 +1,95 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model.adapter;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.Protocol;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.transport.AmqpPortAdapter;
+import org.apache.qpid.server.util.MapValueConverter;
+
+public class PortFactory
+{
+    private final IApplicationRegistry _applicationRegistry;
+    private final PortAttributeDestringifier _portAttributeDestringifier = new PortAttributeDestringifier();
+
+    public PortFactory(IApplicationRegistry applicationRegistry)
+    {
+        _applicationRegistry = applicationRegistry;
+    }
+
+    /**
+     * @param attributes the port attributes, where the values are strings, either singly or in collections.
+     */
+    public Port createPort(UUID id, Broker broker, Map<String, Object> attributesAsStrings)
+    {
+        Map<String, Object> attributes = _portAttributeDestringifier.destringify(attributesAsStrings);
+        final Port port;
+        if (isAmqpProtocol(attributes))
+        {
+            port = new AmqpPortAdapter(id, broker, attributes, _applicationRegistry);
+        }
+        else
+        {
+            port = new PortAdapter(id, broker, attributes);
+        }
+        return port;
+    }
+
+    private boolean isAmqpProtocol(Map<String, Object> portAttributes)
+    {
+        Set<Object> protocolStrings = MapValueConverter.getSetAttribute(Port.PROTOCOLS, portAttributes);
+        int amqpProtocolsFound = 0;
+        int nonAmqpProtocolsFound = 0;
+        for (Object protocolObject : protocolStrings)
+        {
+            Protocol protocol = Protocol.valueOfObject(protocolObject);
+            if (protocol.isAMQP())
+            {
+                amqpProtocolsFound++;
+            }
+            else
+            {
+                nonAmqpProtocolsFound++;
+            }
+        }
+
+        if (amqpProtocolsFound > 0)
+        {
+            if (nonAmqpProtocolsFound > 0)
+            {
+                throw new IllegalConfigurationException("Found AMQP and non-AMQP protocols on port configuration: "
+                        + portAttributes);
+            }
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+}

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java Thu Nov  1 09:48:52 2012
@@ -43,6 +43,7 @@ import org.apache.qpid.server.model.Stat
 import org.apache.qpid.server.model.Statistics;
 import org.apache.qpid.server.queue.*;
 import org.apache.qpid.server.subscription.Subscription;
+import org.apache.qpid.server.util.MapValueConverter;
 
 final class QueueAdapter extends AbstractAdapter implements Queue, AMQQueue.SubscriptionRegistrationListener, AMQQueue.NotificationListener
 {
@@ -495,8 +496,8 @@ final class QueueAdapter extends Abstrac
             throws AccessControlException, IllegalStateException
     {
         attributes = new HashMap<String, Object>(attributes);
-        String bindingKey = getStringAttribute(org.apache.qpid.server.model.Binding.NAME, attributes, "");
-        Map<String, Object> bindingArgs = getMapAttribute(org.apache.qpid.server.model.Binding.ARGUMENTS, attributes, Collections.EMPTY_MAP);
+        String bindingKey = MapValueConverter.getStringAttribute(org.apache.qpid.server.model.Binding.NAME, attributes, "");
+        Map<String, Object> bindingArgs = MapValueConverter.getMapAttribute(org.apache.qpid.server.model.Binding.ARGUMENTS, attributes, Collections.<String,Object>emptyMap());
 
         attributes.remove(org.apache.qpid.server.model.Binding.NAME);
         attributes.remove(org.apache.qpid.server.model.Binding.ARGUMENTS);
@@ -712,15 +713,15 @@ final class QueueAdapter extends Abstrac
     }
 
     @Override
-    public State setDesiredState(State currentState, State desiredState) throws IllegalStateTransitionException,
+    protected boolean setState(State currentState, State desiredState) throws IllegalStateTransitionException,
             AccessControlException
     {
         if (desiredState == State.DELETED)
         {
             delete();
-            return State.DELETED;
+            return true;
         }
-        return super.setDesiredState(currentState, desiredState);
+        return false;
     }
 
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java Thu Nov  1 09:48:52 2012
@@ -237,4 +237,11 @@ final class SessionAdapter extends Abstr
             return null;  // TODO - Implement
         }
     }
+
+    @Override
+    protected boolean setState(State currentState, State desiredState)
+    {
+        // TODO : add state management
+        return false;
+    }
 }



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