qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1648039 - in /qpid/trunk/qpid/java: bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/ bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/ broker-core/src/main/java/org/apache/qpid/server/model/ bro...
Date Sat, 27 Dec 2014 08:55:29 GMT
Author: kwall
Date: Sat Dec 27 08:55:28 2014
New Revision: 1648039

URL: http://svn.apache.org/r1648039
Log:
QPID-6289: [Java Broker] Extend Java Broker model to encapsulate permitted child types

Work of Robert Godfrey <rgodfrey@apache.org>

Added:
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/NonStandardVirtualHost.java
      - copied, changed from r1647766, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java
Modified:
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAReplicaVirtualHost.java
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAVirtualHost.java
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNodeImpl.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedObject.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java
    qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java
    qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java
    qpid/trunk/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAReplicaVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAReplicaVirtualHost.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAReplicaVirtualHost.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAReplicaVirtualHost.java
Sat Dec 27 08:55:28 2014
@@ -52,6 +52,7 @@ import org.apache.qpid.server.store.Mess
 import org.apache.qpid.server.txn.DtxRegistry;
 import org.apache.qpid.server.virtualhost.ExchangeIsAlternateException;
 import org.apache.qpid.server.virtualhost.HouseKeepingTask;
+import org.apache.qpid.server.virtualhost.NonStandardVirtualHost;
 import org.apache.qpid.server.virtualhost.RequiredExchangeException;
 import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 
@@ -62,7 +63,8 @@ import org.apache.qpid.server.virtualhos
 @ManagedObject( category = false, type = "BDB_HA_REPLICA", register = false )
 public class BDBHAReplicaVirtualHost extends AbstractConfiguredObject<BDBHAReplicaVirtualHost>
     implements VirtualHostImpl<BDBHAReplicaVirtualHost, AMQQueue<?>, ExchangeImpl<?>>,
-               VirtualHost<BDBHAReplicaVirtualHost,AMQQueue<?>, ExchangeImpl<?>>
+               VirtualHost<BDBHAReplicaVirtualHost,AMQQueue<?>, ExchangeImpl<?>>,
+               NonStandardVirtualHost<BDBHAReplicaVirtualHost,AMQQueue<?>,ExchangeImpl<?>>
 {
     private final StatisticsCounter _messagesDelivered, _dataDelivered, _messagesReceived,
_dataReceived;
 

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAVirtualHost.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAVirtualHost.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAVirtualHost.java
Sat Dec 27 08:55:28 2014
@@ -20,16 +20,18 @@
  */
 package org.apache.qpid.server.virtualhost.berkeleydb;
 
-import java.util.List;
-
 import org.apache.qpid.server.exchange.ExchangeImpl;
 import org.apache.qpid.server.model.DerivedAttribute;
 import org.apache.qpid.server.model.ManagedAttribute;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.store.SizeMonitoringSettings;
+import org.apache.qpid.server.virtualhost.NonStandardVirtualHost;
 import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 
-public interface BDBHAVirtualHost<X extends BDBHAVirtualHost<X>> extends VirtualHostImpl<X,
AMQQueue<?>, ExchangeImpl<?>>, SizeMonitoringSettings
+public interface BDBHAVirtualHost<X extends BDBHAVirtualHost<X>>
+        extends VirtualHostImpl<X, AMQQueue<?>, ExchangeImpl<?>>,
+                SizeMonitoringSettings,
+                NonStandardVirtualHost<X,AMQQueue<?>,ExchangeImpl<?>>
 {
     String REMOTE_TRANSACTION_SYNCHRONIZATION_POLICY = "remoteTransactionSynchronizationPolicy";
     String LOCAL_TRANSACTION_SYNCHRONIZATION_POLICY = "localTransactionSynchronizationPolicy";

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
Sat Dec 27 08:55:28 2014
@@ -21,15 +21,14 @@
 package org.apache.qpid.server.virtualhostnode.berkeleydb;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.nio.file.Files;
 import java.security.PrivilegedAction;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -62,7 +61,6 @@ import org.apache.qpid.server.logging.me
 import org.apache.qpid.server.logging.messages.HighAvailabilityMessages;
 import org.apache.qpid.server.logging.subjects.BDBHAVirtualHostNodeLogSubject;
 import org.apache.qpid.server.logging.subjects.GroupLogSubject;
-import org.apache.qpid.server.model.AbstractConfiguredObject;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.BrokerModel;
 import org.apache.qpid.server.model.ConfiguredObject;
@@ -88,7 +86,8 @@ import org.apache.qpid.server.util.Serve
 import org.apache.qpid.server.virtualhost.berkeleydb.BDBHAVirtualHostImpl;
 import org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode;
 
-@ManagedObject( category = false, type = BDBHAVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE
)
+@ManagedObject( category = false, type = BDBHAVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE,
+        validChildTypes = "org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNodeImpl#getSupportedChildTypes()"
)
 public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode<BDBHAVirtualHostNodeImpl>
implements
         BDBHAVirtualHostNode<BDBHAVirtualHostNodeImpl>
 {
@@ -1205,4 +1204,8 @@ public class BDBHAVirtualHostNodeImpl ex
         abstract void perform();
     }
 
+    public static Map<String, Collection<String>> getSupportedChildTypes()
+    {
+        return Collections.singletonMap(VirtualHost.class.getSimpleName(), (Collection<String>)
Collections.singleton(BDBHAVirtualHostImpl.VIRTUAL_HOST_TYPE));
+    }
 }

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNodeImpl.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNodeImpl.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNodeImpl.java
Sat Dec 27 08:55:28 2014
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.server.virtualhostnode.berkeleydb;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 
 import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
@@ -32,7 +34,8 @@ import org.apache.qpid.server.store.Dura
 import org.apache.qpid.server.store.berkeleydb.BDBConfigurationStore;
 import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode;
 
-@ManagedObject(type = BDBVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE, category = false)
+@ManagedObject(type = BDBVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE, category = false,
+               validChildTypes = "org.apache.qpid.server.virtualhostnode.berkeleydb.BDBVirtualHostNodeImpl#getSupportedChildTypes()")
 public class BDBVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<BDBVirtualHostNodeImpl>
implements BDBVirtualHostNode<BDBVirtualHostNodeImpl>
 {
     public static final String VIRTUAL_HOST_NODE_TYPE = "BDB";
@@ -70,4 +73,8 @@ public class BDBVirtualHostNodeImpl exte
         return getClass().getSimpleName() + " [id=" + getId() + ", name=" + getName() + ",
storePath=" + getStorePath() + "]";
     }
 
+    public static Map<String, Collection<String>> getSupportedChildTypes()
+    {
+        return Collections.singletonMap(VirtualHost.class.getSimpleName(), getSupportedVirtualHostTypes(true));
+    }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
Sat Dec 27 08:55:28 2014
@@ -21,8 +21,11 @@
 package org.apache.qpid.server.model;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.util.AbstractCollection;
 import java.util.Arrays;
 import java.util.Collection;
@@ -176,6 +179,9 @@ public class ConfiguredObjectTypeRegistr
     private final Map<Class<? extends ConfiguredObject>,Set<Class<? extends
ManagedInterface>>> _allManagedInterfaces =
             Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>,
Set<Class<? extends ManagedInterface>>>());
 
+    private final Map<Class<? extends ConfiguredObject>, Map<String, Collection<String>>>
_validChildTypes =
+            Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>,
Map<String, Collection<String>>>());
+
     public ConfiguredObjectTypeRegistry(Iterable<ConfiguredObjectRegistration> configuredObjectRegistrations,
Collection<Class<? extends ConfiguredObject>> categoriesRestriction)
     {
 
@@ -265,6 +271,96 @@ public class ConfiguredObjectTypeRegistr
             }
 
         }
+
+        for(Class<? extends ConfiguredObject> type : types)
+        {
+            final ManagedObject annotation = type.getAnnotation(ManagedObject.class);
+            String validChildren = annotation.validChildTypes();
+            if(!"".equals(validChildren))
+            {
+                Method validChildTypesMethod = getValidChildTypesFunction(validChildren,
type);
+                if(validChildTypesMethod != null)
+                {
+                    try
+                    {
+                        _validChildTypes.put(type, (Map<String, Collection<String>>)
validChildTypesMethod.invoke(null));
+                    }
+                    catch (IllegalAccessException | InvocationTargetException e)
+                    {
+                        throw new IllegalArgumentException("Exception while evaluating valid
child types for " + type.getName(), e);
+                    }
+                }
+
+            }
+        }
+    }
+
+    private static Method getValidChildTypesFunction(final String validValue, final Class<?
extends ConfiguredObject> clazz)
+    {
+        if (validValue.matches("([\\w][\\w\\d_]+\\.)+[\\w][\\w\\d_\\$]*#[\\w\\d_]+\\s*\\(\\s*\\)"))
+        {
+            String function = validValue;
+            try
+            {
+                String className = function.split("#")[0].trim();
+                String methodName = function.split("#")[1].split("\\(")[0].trim();
+                Class<?> validValueCalculatingClass = Class.forName(className);
+                Method method = validValueCalculatingClass.getMethod(methodName);
+                if (Modifier.isStatic(method.getModifiers()) && Modifier.isPublic(method.getModifiers()))
+                {
+                    if (Map.class.isAssignableFrom(method.getReturnType()))
+                    {
+                        if (method.getGenericReturnType() instanceof ParameterizedType)
+                        {
+                            Type keyType =
+                                    ((ParameterizedType) method.getGenericReturnType()).getActualTypeArguments()[0];
+                            if (keyType == String.class)
+                            {
+                                Type valueType =
+                                        ((ParameterizedType) method.getGenericReturnType()).getActualTypeArguments()[1];
+                                if (valueType instanceof ParameterizedType)
+                                {
+                                    ParameterizedType paramType = (ParameterizedType) valueType;
+                                    final Type rawType = paramType.getRawType();
+                                    final Type[] args = paramType.getActualTypeArguments();
+                                    if (Collection.class.isAssignableFrom((Class<?>)
rawType)
+                                        && args.length == 1
+                                        && args[0] == String.class)
+                                    {
+                                        return method;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+
+
+                throw new IllegalArgumentException("The validChildTypes of the class "
+                                                   + clazz.getSimpleName()
+                                                   + " has value '"
+                                                   + validValue
+                                                   + "' but the method does not meet the
requirements - is it public and static");
+
+            }
+            catch (ClassNotFoundException | NoSuchMethodException e)
+            {
+                throw new IllegalArgumentException("The validChildTypes of the class "
+                                                   + clazz.getSimpleName()
+                                                   + " has value '"
+                                                   + validValue
+                                                   + "' which looks like it should be a method,"
+                                                   + " but no such method could be used.",
e);
+            }
+        }
+        else
+        {
+            throw new IllegalArgumentException("The validChildTypes of the class "
+                                               + clazz.getSimpleName()
+                                               + " has value '"
+                                               + validValue
+                                               + "' which does not match the required <package>.<class>#<method>()
format.");
+        }
     }
 
     public static Class<? extends ConfiguredObject> getCategory(final Class<?>
clazz)
@@ -907,4 +1003,18 @@ public class ConfiguredObjectTypeRegistr
         }
     }
 
+    public Collection<String> getValidChildTypes(Class<? extends ConfiguredObject>
type, Class<? extends ConfiguredObject> childType)
+    {
+        final Map<String, Collection<String>> allValidChildTypes = _validChildTypes.get(getTypeClass(type));
+        if(allValidChildTypes != null)
+        {
+            final Collection<String> validTypesForSpecificChild = allValidChildTypes.get(getCategory(childType).getSimpleName());
+            return validTypesForSpecificChild == null ? null : Collections.unmodifiableCollection(validTypesForSpecificChild);
+        }
+        else
+        {
+            return null;
+        }
+    }
+
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedObject.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedObject.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedObject.java
Sat Dec 27 08:55:28 2014
@@ -35,5 +35,6 @@ public @interface ManagedObject
     boolean creatable() default true;
     String defaultType() default ""; // in this case the class/interface itself is to be
used
     String type() default "";
+    String validChildTypes() default "";
     boolean register() default true;
 }

Copied: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/NonStandardVirtualHost.java
(from r1647766, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/NonStandardVirtualHost.java?p2=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/NonStandardVirtualHost.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java&r1=1647766&r2=1648039&rev=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/NonStandardVirtualHost.java
Sat Dec 27 08:55:28 2014
@@ -1,4 +1,5 @@
 /*
+ *
  * 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
@@ -15,21 +16,14 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-
 package org.apache.qpid.server.virtualhost;
 
-import org.apache.qpid.server.exchange.ExchangeImpl;
-import org.apache.qpid.server.model.ManagedAttribute;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.store.SizeMonitoringSettings;
+import org.apache.qpid.server.model.Exchange;
+import org.apache.qpid.server.model.Queue;
+import org.apache.qpid.server.model.VirtualHost;
 
-public interface ProvidedStoreVirtualHost<X extends ProvidedStoreVirtualHost<X>>
extends VirtualHostImpl<X,AMQQueue<?>,ExchangeImpl<?>>, SizeMonitoringSettings
+public interface NonStandardVirtualHost<X extends NonStandardVirtualHost<X, Q, E>,
Q extends Queue<?>, E extends Exchange<?> > extends VirtualHost<X, Q, E>
 {
-    @ManagedAttribute(mandatory = true, defaultValue = "0")
-    Long getStoreUnderfullSize();
-
-    @ManagedAttribute(mandatory = true, defaultValue = "0")
-    Long getStoreOverfullSize();
-
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java
Sat Dec 27 08:55:28 2014
@@ -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/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
Sat Dec 27 08:55:28 2014
@@ -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/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java
Sat Dec 27 08:55:28 2014
@@ -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/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java
Sat Dec 27 08:55:28 2014
@@ -21,6 +21,8 @@
 
 package org.apache.qpid.server.virtualhostnode.derby;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 
 import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
@@ -33,7 +35,9 @@ import org.apache.qpid.server.store.Dura
 import org.apache.qpid.server.store.derby.DerbyConfigurationStore;
 import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode;
 
-@ManagedObject( category = false, type = DerbyVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE
)
+@ManagedObject( category = false,
+                type = DerbyVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE,
+                validChildTypes = "org.apache.qpid.server.virtualhostnode.derby.DerbyVirtualHostNodeImpl#getSupportedChildTypes()"
)
 public class DerbyVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<DerbyVirtualHostNodeImpl>
implements DerbyVirtualHostNode<DerbyVirtualHostNodeImpl>
 {
     public static final String VIRTUAL_HOST_NODE_TYPE = "DERBY";
@@ -70,4 +74,10 @@ public class DerbyVirtualHostNodeImpl ex
     {
         return getClass().getSimpleName() + " [id=" + getId() + ", name=" + getName() + ",
storePath=" + getStorePath() + "]";
     }
+
+
+    public static Map<String, Collection<String>> getSupportedChildTypes()
+    {
+        return Collections.singletonMap(VirtualHost.class.getSimpleName(), getSupportedVirtualHostTypes(true));
+    }
 }

Modified: qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java
Sat Dec 27 08:55:28 2014
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.server.virtualhostnode.jdbc;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 
 import org.apache.qpid.server.model.Broker;
@@ -31,7 +33,8 @@ import org.apache.qpid.server.store.Dura
 import org.apache.qpid.server.store.jdbc.GenericJDBCConfigurationStore;
 import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode;
 
-@ManagedObject(type = JDBCVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE, category = false )
+@ManagedObject(type = JDBCVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE, category = false ,
+               validChildTypes = "org.apache.qpid.server.virtualhostnode.jdbc.JDBCVirtualHostNodeImpl#getSupportedChildTypes()")
 public class JDBCVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<JDBCVirtualHostNodeImpl>
implements JDBCVirtualHostNode<JDBCVirtualHostNodeImpl>
 {
     public static final String VIRTUAL_HOST_NODE_TYPE = "JDBC";
@@ -97,4 +100,10 @@ public class JDBCVirtualHostNodeImpl ext
                                         ", connectionPoolType=" + getConnectionPoolType()
+
                                         ", username=" + getUsername() + "]";
     }
+
+
+    public static Map<String, Collection<String>> getSupportedChildTypes()
+    {
+        return Collections.singletonMap(VirtualHost.class.getSimpleName(), getSupportedVirtualHostTypes(true));
+    }
 }

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java
Sat Dec 27 08:55:28 2014
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -101,9 +102,24 @@ public class MetaDataServlet extends Abs
         Map<String,Object> typeDetails = new LinkedHashMap<>();
         typeDetails.put("attributes", processAttributes(type));
         typeDetails.put("managedInterfaces", getManagedInterfaces(type));
+        typeDetails.put("validChildTypes", getValidChildTypes(type));
         return typeDetails;
     }
 
+    private Map<String, Collection<String>> getValidChildTypes(final Class<?
extends ConfiguredObject> type)
+    {
+        Map<String, Collection<String>> validChildTypes = new HashMap<>();
+        for(Class<? extends ConfiguredObject> childType : _instance.getChildTypes(ConfiguredObjectTypeRegistry.getCategory(type)))
+        {
+            Collection<String> validValues = _instance.getTypeRegistry().getValidChildTypes(type,
childType);
+            if(validValues != null)
+            {
+                validChildTypes.put(childType.getSimpleName(), validValues);
+            }
+        }
+        return validChildTypes;
+    }
+
     private Set<String> getManagedInterfaces(Class<? extends ConfiguredObject>
type)
     {
         Set<String> interfaces = new HashSet<>();

Modified: qpid/trunk/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java?rev=1648039&r1=1648038&r2=1648039&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java
Sat Dec 27 08:55:28 2014
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.server.virtualhostnode.memory;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 
 import org.apache.qpid.server.model.Broker;
@@ -30,7 +32,7 @@ import org.apache.qpid.server.store.Dura
 import org.apache.qpid.server.store.MemoryConfigurationStore;
 import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode;
 
-@ManagedObject(type=MemoryVirtualHostNode.VIRTUAL_HOST_NODE_TYPE, category=false)
+@ManagedObject(type=MemoryVirtualHostNode.VIRTUAL_HOST_NODE_TYPE, category=false, validChildTypes
= "org.apache.qpid.server.virtualhostnode.memory.MemoryVirtualHostNode#getSupportedChildTypes()")
 public class MemoryVirtualHostNode extends AbstractStandardVirtualHostNode<MemoryVirtualHostNode>
 {
    public static final String VIRTUAL_HOST_NODE_TYPE = "Memory";
@@ -51,4 +53,9 @@ public class MemoryVirtualHostNode exten
     {
         return new MemoryConfigurationStore(VirtualHost.class);
     }
+
+    public static Map<String, Collection<String>> getSupportedChildTypes()
+    {
+        return Collections.singletonMap(VirtualHost.class.getSimpleName(), getSupportedVirtualHostTypes(true));
+    }
 }



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


Mime
View raw message