Author: orudyy
Date: Wed Nov 26 16:29:26 2014
New Revision: 1641849
URL: http://svn.apache.org/r1641849
Log:
QPID-6246: Introduce ManagedInterface and ManagedAnnotation and expose the
implemented ManagedInterfaces via meta data servlet
Added:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedInterface.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass0.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass4.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass5.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java
Modified:
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/PasswordCredentialManagingAuthenticationProvider.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java
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=1641849&r1=1641848&r2=1641849&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
Wed Nov 26 16:29:26 2014
@@ -20,6 +20,7 @@
*/
package org.apache.qpid.server.model;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -172,6 +173,9 @@ public class ConfiguredObjectTypeRegistr
private final Map<Class<? extends ConfiguredObject>, Map<State, Map<State,
Method>>> _stateChangeMethods =
Collections.synchronizedMap(new HashMap<Class<? extends
ConfiguredObject>, Map<State, Map<State, Method>>>());
+ private final Map<Class<? extends ConfiguredObject>,Set<Class<? extends
ManagedInterface>>> _allManagedInterfaces =
+ Collections.synchronizedMap(new HashMap<Class<? extends
ConfiguredObject>, Set<Class<? extends ManagedInterface>>>());
+
public ConfiguredObjectTypeRegistry(Iterable<ConfiguredObjectRegistration>
configuredObjectRegistrations, Collection<Class<? extends ConfiguredObject>>
categoriesRestriction)
{
@@ -258,8 +262,8 @@ public class ConfiguredObjectTypeRegistr
}
_typeSpecificAttributes.put(typeClass, attributes);
}
-
}
+
}
}
@@ -545,6 +549,8 @@ public class ConfiguredObjectTypeRegistr
processDefaultContext(clazz);
processStateChangeMethods(clazz);
+
+ processManagedInterfaces(clazz);
}
}
@@ -859,4 +865,60 @@ public class ConfiguredObjectTypeRegistr
return Collections.unmodifiableMap(_defaultContext);
}
+
+ public Set<Class<? extends ManagedInterface>> getManagedInterfaces(final
Class<? extends ConfiguredObject> classObject)
+ {
+ if (!_allManagedInterfaces.containsKey(classObject))
+ {
+ process(classObject);
+ }
+ Set<Class<? extends ManagedInterface>> interfaces =
_allManagedInterfaces.get(classObject);
+ return interfaces == null ? Collections.<Class<? extends
ManagedInterface>>emptySet() : interfaces;
+ }
+
+
+ private <X extends ConfiguredObject> void
processManagedInterfaces(Class<X> clazz)
+ {
+ Set<Class<? extends ManagedInterface>> managedInterfaces = new
HashSet<>();
+ if (checkManagedAnnotationAndFindManagedInterfaces(clazz,
managedInterfaces, false))
+ {
+ _allManagedInterfaces.put(clazz,
Collections.unmodifiableSet(managedInterfaces));
+ }
+ else
+ {
+ _allManagedInterfaces.put(clazz, Collections.<Class<? extends
ManagedInterface>>emptySet());
+ }
+ }
+
+ private boolean checkManagedAnnotationAndFindManagedInterfaces(Class<?>
type, Set<Class<? extends ManagedInterface>> managedInterfaces, boolean
hasManagedAnnotation)
+ {
+ while(type != null && ManagedInterface.class.isAssignableFrom(type))
+ {
+ Annotation[] annotations = type.getAnnotations();
+ for (Annotation annotation : annotations)
+ {
+ if (annotation instanceof ManagedAnnotation)
+ {
+ hasManagedAnnotation = true;
+ }
+ }
+
+ if (hasManagedAnnotation && type.isInterface() &&
ManagedInterface.class.isAssignableFrom(type) && type != ManagedInterface.class)
+ {
+ managedInterfaces.add((Class<? extends ManagedInterface>)type);
+ }
+
+ Class<?>[] interfaceClasses = type.getInterfaces();
+ for (Class<?> interfaceClass : interfaceClasses)
+ {
+ if
(checkManagedAnnotationAndFindManagedInterfaces(interfaceClass,
managedInterfaces, hasManagedAnnotation))
+ {
+ hasManagedAnnotation = true;
+ }
+ }
+ type = type.getSuperclass();
+ }
+ return hasManagedAnnotation;
+ }
+
}
Added:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Inherited
+public @interface ManagedAnnotation
+{
+}
Added:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedInterface.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedInterface.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedInterface.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedInterface.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,25 @@
+/*
+ *
+ * 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;
+
+public interface ManagedInterface
+{
+}
Modified:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/PasswordCredentialManagingAuthenticationProvider.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/PasswordCredentialManagingAuthenticationProvider.java?rev=1641849&r1=1641848&r2=1641849&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/PasswordCredentialManagingAuthenticationProvider.java
(original)
+++
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/PasswordCredentialManagingAuthenticationProvider.java
Wed Nov 26 16:29:26 2014
@@ -25,7 +25,8 @@ import java.util.Map;
import javax.security.auth.login.AccountNotFoundException;
-public interface PasswordCredentialManagingAuthenticationProvider<X extends
PasswordCredentialManagingAuthenticationProvider<X>> extends
AuthenticationProvider<X>
+@ManagedAnnotation
+public interface PasswordCredentialManagingAuthenticationProvider<X extends
PasswordCredentialManagingAuthenticationProvider<X>> extends
AuthenticationProvider<X>, ManagedInterface
{
boolean createUser(String username, String password, Map<String, String>
attributes);
Modified:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java?rev=1641849&r1=1641848&r2=1641849&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java
(original)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java
Wed Nov 26 16:29:26 2014
@@ -22,15 +22,27 @@ package org.apache.qpid.server.model;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
import junit.framework.TestCase;
+import org.apache.qpid.server.model.testmodel.TestManagedClass0;
+import org.apache.qpid.server.model.testmodel.TestManagedClass1;
+import org.apache.qpid.server.model.testmodel.TestManagedClass2;
+import org.apache.qpid.server.model.testmodel.TestManagedClass3;
+import org.apache.qpid.server.model.testmodel.TestManagedClass4;
+import org.apache.qpid.server.model.testmodel.TestManagedClass5;
+import org.apache.qpid.server.model.testmodel.TestManagedInterface1;
+import org.apache.qpid.server.model.testmodel.TestManagedInterface2;
import org.apache.qpid.server.model.testmodel.Test2RootCategory;
import org.apache.qpid.server.model.testmodel.Test2RootCategoryImpl;
import org.apache.qpid.server.model.testmodel.TestChildCategory;
import org.apache.qpid.server.model.testmodel.TestModel;
import org.apache.qpid.server.model.testmodel.TestRootCategory;
import org.apache.qpid.server.model.testmodel.TestRootCategoryImpl;
+import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;
public class ConfigureObjectTypeRegistryTest extends TestCase
{
@@ -93,6 +105,66 @@ public class ConfigureObjectTypeRegistry
}
+ public void
testGetManagedInterfacesForTypeNotImplementingManagedInterfaceAndNotHavingManagedAnnotation()
+ {
+ ConfiguredObjectTypeRegistry typeRegistry =
createConfiguredObjectTypeRegistry(TestRootCategoryImpl.class);
+ assertEquals("Unexpected interfaces from object not implementing
Managed interfaces",
+ Collections.emptySet(),
typeRegistry.getManagedInterfaces(TestRootCategory.class));
+ }
+
+ public void
testGetManagedInterfacesForTypeImplementingManagedInterfaceButNotHavingManagedAnnotation()
+ {
+ ConfiguredObjectTypeRegistry typeRegistry =
createConfiguredObjectTypeRegistry(TestRootCategoryImpl.class,
TestManagedClass5.class);
+ assertEquals("Unexpected interfaces from object not implementing
Managed interfaces",
+ Collections.emptySet(),
typeRegistry.getManagedInterfaces(TestManagedClass5.class));
+ }
+
+ public void
testGetManagedInterfacesForTypesImplementingManagedInterfacesWithManagedAnnotation()
+ {
+ ConfiguredObjectTypeRegistry typeRegistry =
createConfiguredObjectTypeRegistry(TestRootCategoryImpl.class,
TestManagedClass0.class, TestManagedClass1.class, TestManagedClass4.class);
+ Set<Class<?>> expected =
Collections.<Class<?>>singleton(TestManagedInterface1.class);
+ assertEquals("Unexpected interfaces on child class", expected,
typeRegistry.getManagedInterfaces(TestManagedClass1.class));
+ assertEquals("Unexpected interfaces on super class", expected,
typeRegistry.getManagedInterfaces(TestManagedClass0.class));
+ assertEquals("Unexpected interfaces on class implementing interface
with annotation twice",
+ expected,
typeRegistry.getManagedInterfaces(TestManagedClass4.class));
+ }
+
+ public void testGetManagedInterfacesForTypeHavingDirectManagedAnnotation()
+ {
+ ConfiguredObjectTypeRegistry typeRegistry =
createConfiguredObjectTypeRegistry(TestRootCategoryImpl.class,
TestManagedClass2.class, TestManagedClass3.class);
+
+ assertEquals("Unexpected interfaces on class implementing 2 interfaces
with annotation",
+ new HashSet<>(Arrays.asList(TestManagedInterface2.class,
TestManagedInterface1.class)),
typeRegistry.getManagedInterfaces(TestManagedClass2.class));
+ assertEquals("Unexpected interfaces on class implementing 2 direct
interfaces with annotation",
+ new HashSet<>(Arrays.asList(TestManagedInterface2.class,
TestManagedInterface1.class)),
typeRegistry.getManagedInterfaces(TestManagedClass3.class));
+
+ }
+
+ private ConfiguredObjectTypeRegistry
createConfiguredObjectTypeRegistry(Class<? extends ConfiguredObject>...
supportedTypes)
+ {
+ ConfiguredObjectRegistration configuredObjectRegistration =
createConfiguredObjectRegistration(supportedTypes);
+
+ return new
ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration),
Arrays.asList(TestRootCategory.class, TestChildCategory.class));
+ }
+
+ private ConfiguredObjectRegistration
createConfiguredObjectRegistration(final Class<? extends ConfiguredObject>...
supportedTypes)
+ {
+ return new ConfiguredObjectRegistration()
+ {
+ @Override
+ public Collection<Class<? extends ConfiguredObject>>
getConfiguredObjectClasses()
+ {
+ return Arrays.asList(supportedTypes);
+ }
+
+ @Override
+ public String getType()
+ {
+ return "test";
+ }
+ };
+ }
+
private void checkDefaultedValue(final
Collection<ConfiguredObjectAttribute<?, ?>> attrs,
final String defaultedValueDefault)
{
Added:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass0.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass0.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass0.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass0.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.testmodel;
+
+import java.util.Map;
+
+import org.apache.qpid.server.model.ManagedInterface;
+import org.apache.qpid.server.model.ManagedObject;
+
+/**
+ * This is a test managed type implementing TestManagedInterface1 which
extends ManagedInterface.
+ * Because TestManagedInterface1 already has ManagedAnnotation set, the
instances of this class will be managed entities
+ * of type TestManagedInterface1.
+ */
+@ManagedObject( category = false , type = "SuperClass" )
+public class TestManagedClass0 extends TestChildCategoryImpl implements
TestManagedInterface1
+{
+ public TestManagedClass0(final Map<String, Object> attributes,
TestRootCategory<?> parent)
+ {
+ super(attributes, parent);
+ }
+}
Added:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.testmodel;
+
+import java.util.Map;
+
+import org.apache.qpid.server.model.ManagedObject;
+
+/**
+ * This is a test managed type extending TestManagedClass0.
+ * Because TestManagedClass0 implements managed interface
TestManagedInterface1 with ManagedAnnotation set,
+ * the instances of this class will be managed entities of type
TestManagedInterface1.
+ */
+@ManagedObject( category = false , type = "ChildClass" )
+public class TestManagedClass1 extends TestManagedClass0
+{
+ public TestManagedClass1(final Map<String, Object> attributes,
TestRootCategory<?> parent)
+ {
+ super(attributes, parent);
+ }
+}
Added:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.testmodel;
+
+import java.util.Map;
+
+import org.apache.qpid.server.model.ManagedAnnotation;
+import org.apache.qpid.server.model.ManagedObject;
+
+/**
+ * This is a test managed type implementing managed interface
TestManagedInterface2 and having ManagedAnnotation set.
+ * The instances of this class will be managed entities of types
TestManagedInterface1 and TestManagedInterface2
+ */
+@ManagedObject( category = false , type = "ChildClass2" )
+@ManagedAnnotation
+public class TestManagedClass2 extends TestManagedClass0 implements
TestManagedInterface2
+{
+ public TestManagedClass2(final Map<String, Object> attributes,
TestRootCategory<?> parent)
+ {
+ super(attributes, parent);
+ }
+}
Added:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.testmodel;
+
+import java.util.Map;
+
+import org.apache.qpid.server.model.ManagedAnnotation;
+import org.apache.qpid.server.model.ManagedObject;
+
+/**
+ * This is a test managed type implementing managed interface
TestManagedInterface1 and TestManagedInterface2.
+ * The instances of this class will be managed entities of types
TestManagedInterface1 and TestManagedInterface2.
+ */
+@ManagedObject( category = false , type = "ChildClass3" )
+@ManagedAnnotation
+public class TestManagedClass3 extends TestChildCategoryImpl implements
TestManagedInterface1,TestManagedInterface2
+{
+ public TestManagedClass3(final Map<String, Object> attributes,
TestRootCategory<?> parent)
+ {
+ super(attributes, parent);
+ }
+}
Added:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass4.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass4.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass4.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass4.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.testmodel;
+
+import java.util.Map;
+
+import org.apache.qpid.server.model.ManagedObject;
+
+/**
+ * This is a test managed type extending managed type TestManagedClass0 and
implementing TestManagedInterface2
+ * The instances of this class will be managed entities of types
TestManagedInterface1 only
+ * as it has no direct ManagedAnnotation set and no ManagedAnnotation
declared in TestManagedInterface2.
+ */
+@ManagedObject( category = false , type = "ChildClass4" )
+public class TestManagedClass4 extends TestManagedClass0 implements
TestManagedInterface2
+{
+ public TestManagedClass4(final Map<String, Object> attributes,
TestRootCategory<?> parent)
+ {
+ super(attributes, parent);
+ }
+}
Added:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass5.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass5.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass5.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass5.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.testmodel;
+
+import java.util.Map;
+
+import org.apache.qpid.server.model.ManagedObject;
+
+/**
+ * This is a test type which has no ManagedAnnotation set and thus it should
not expose any ManagedInterface
+ */
+@ManagedObject( category = false , type = "ChildClass3" )
+public class TestManagedClass5 extends TestChildCategoryImpl implements
TestManagedInterface2
+{
+ public TestManagedClass5(final Map<String, Object> attributes,
TestRootCategory<?> parent)
+ {
+ super(attributes, parent);
+ }
+}
Added:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,33 @@
+/*
+ *
+ * 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.testmodel;
+
+import org.apache.qpid.server.model.ManagedAnnotation;
+import org.apache.qpid.server.model.ManagedInterface;
+
+/**
+ * This is a test managed interface which has ManagedAnnotation.
+ * All types implementing this interface will inherit the annotation and will
be managed entities of type TestManagedInterface1
+ */
+@ManagedAnnotation
+public interface TestManagedInterface1 extends ManagedInterface
+{
+}
Added:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java?rev=1641849&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java
Wed Nov 26 16:29:26 2014
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.testmodel;
+
+import org.apache.qpid.server.model.ManagedInterface;
+
+/**
+ * This is a test managed interface which has no ManagedAnnotation.
+ * All types implementing this interface would need to have ManagedAnnotation
declared in order to became managed entity.
+ */
+public interface TestManagedInterface2 extends ManagedInterface
+{
+}
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=1641849&r1=1641848&r2=1641849&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
Wed Nov 26 16:29:26 2014
@@ -24,8 +24,10 @@ import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
import javax.servlet.ServletException;
@@ -98,9 +100,20 @@ public class MetaDataServlet extends Abs
{
Map<String,Object> typeDetails = new LinkedHashMap<>();
typeDetails.put("attributes", processAttributes(type));
+ typeDetails.put("managedInterfaces", getManagedInterfaces(type));
return typeDetails;
}
+ private Set<String> getManagedInterfaces(Class<? extends ConfiguredObject>
type)
+ {
+ Set<String> interfaces = new HashSet<>();
+ for(Class<?> classObject:
_instance.getTypeRegistry().getManagedInterfaces(type))
+ {
+ interfaces.add(classObject.getSimpleName());
+ }
+ return interfaces;
+ }
+
private Map<String,Map> processAttributes(final Class<? extends
ConfiguredObject> type)
{
Collection<ConfiguredObjectAttribute<?, ?>> attributes =
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]