diff options
Diffstat (limited to 'qpid/java')
8 files changed, 281 insertions, 173 deletions
diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java new file mode 100644 index 0000000000..b38866147b --- /dev/null +++ b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java @@ -0,0 +1,98 @@ +/* + * + * 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.validation; + +import java.util.Set; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.Elements; +import javax.lang.model.util.Types; +import javax.tools.Diagnostic; + +@SupportedAnnotationTypes(ManagedAnnotationValidator.MANAGED_ANNOTATION_CLASS_NAME) +public class ManagedAnnotationValidator extends AbstractProcessor +{ + public static final String MANAGED_ANNOTATION_CLASS_NAME = "org.apache.qpid.server.model.ManagedAnnotation"; + + + @Override + public SourceVersion getSupportedSourceVersion() + { + return SourceVersion.latest(); + } + + + @Override + public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) + { + Elements elementUtils = processingEnv.getElementUtils(); + Types typeUtils = processingEnv.getTypeUtils(); + + TypeElement annotationElement = elementUtils.getTypeElement(MANAGED_ANNOTATION_CLASS_NAME); + + String className = "org.apache.qpid.server.model.ManagedInterface"; + TypeMirror configuredObjectType = getErasure(className); + + for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement)) + { + if (e.getKind() != ElementKind.INTERFACE) + { + processingEnv.getMessager() + .printMessage(Diagnostic.Kind.ERROR, + "@" + + annotationElement.getSimpleName() + + " can only be applied to an interface", + e + ); + } + + + if(!typeUtils.isAssignable(typeUtils.erasure(e.asType()), configuredObjectType)) + { + + processingEnv.getMessager() + .printMessage(Diagnostic.Kind.ERROR, + "@" + + annotationElement.getSimpleName() + + " can only be applied to an interface which extends " + className, + e + ); + } + } + + return false; + } + + + private TypeMirror getErasure(final String className) + { + final Types typeUtils = processingEnv.getTypeUtils(); + final Elements elementUtils = processingEnv.getElementUtils(); + return typeUtils.erasure(elementUtils.getTypeElement(className).asType()); + } +} diff --git a/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor index 64440bb999..7f88042433 100644 --- a/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor +++ b/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor @@ -22,3 +22,4 @@ org.apache.qpid.server.plugin.PluggableProcessor org.apache.qpid.server.model.ConfiguredObjectRegistrationGenerator org.apache.qpid.server.model.validation.AttributeAnnotationValidator org.apache.qpid.server.model.validation.AttributeFieldValidation +org.apache.qpid.server.model.validation.ManagedAnnotationValidator diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java index 70a64e8130..8ca5ff3d6a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java @@ -20,7 +20,6 @@ */ 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; @@ -41,6 +40,7 @@ import java.util.TreeSet; import org.apache.log4j.Logger; import org.apache.qpid.server.plugin.ConfiguredObjectRegistration; +import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.apache.qpid.util.Strings; @@ -385,6 +385,7 @@ public class ConfiguredObjectTypeRegistry } } + for(Class<?> iface : clazz.getInterfaces() ) { if(ConfiguredObject.class.isAssignableFrom(iface)) @@ -455,94 +456,37 @@ public class ConfiguredObjectTypeRegistry return; } - - for(Class<?> parent : clazz.getInterfaces()) + doWithAllParents(clazz, new Action<Class<? extends ConfiguredObject>>() { - if(ConfiguredObject.class.isAssignableFrom(parent)) + @Override + public void performAction(final Class<? extends ConfiguredObject> parent) { - process((Class<? extends ConfiguredObject>) parent); + process(parent); } - } - final Class<? super X> superclass = clazz.getSuperclass(); - if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass)) - { - process((Class<? extends ConfiguredObject>) superclass); - } + }); final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet = new TreeSet<>(OBJECT_NAME_COMPARATOR); final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet = new TreeSet<>(OBJECT_NAME_COMPARATOR); + final Set<Class<? extends ManagedInterface>> managedInterfaces = new HashSet<>(); _allAttributes.put(clazz, attributeSet); _allStatistics.put(clazz, statisticSet); + _allManagedInterfaces.put(clazz, managedInterfaces); - for(Class<?> parent : clazz.getInterfaces()) + doWithAllParents(clazz, new Action<Class<? extends ConfiguredObject>>() { - if(ConfiguredObject.class.isAssignableFrom(parent)) + @Override + public void performAction(final Class<? extends ConfiguredObject> parent) { initialiseWithParentAttributes(attributeSet, statisticSet, - (Class<? extends ConfiguredObject>) parent); - } - } - if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass)) - { - initialiseWithParentAttributes(attributeSet, - statisticSet, - (Class<? extends ConfiguredObject>) superclass); - } - - - for(Method m : clazz.getDeclaredMethods()) - { - - if(m.isAnnotationPresent(ManagedAttribute.class)) - { - ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class); - - if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) - { - throw new ServerScopedRuntimeException("Can only define ManagedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); - } + managedInterfaces, + parent); - ConfiguredObjectAttribute<?,?> attribute = new ConfiguredAutomatedAttribute<>(clazz, m, annotation); - if(attributeSet.contains(attribute)) - { - attributeSet.remove(attribute); - } - attributeSet.add(attribute); } - else if(m.isAnnotationPresent(DerivedAttribute.class)) - { - DerivedAttribute annotation = m.getAnnotation(DerivedAttribute.class); - - if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) - { - throw new ServerScopedRuntimeException("Can only define DerivedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); - } - - ConfiguredObjectAttribute<?,?> attribute = new ConfiguredDerivedAttribute<>(clazz, m, annotation); - if(attributeSet.contains(attribute)) - { - attributeSet.remove(attribute); - } - attributeSet.add(attribute); + }); - } - else if(m.isAnnotationPresent(ManagedStatistic.class)) - { - ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class); - if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) - { - throw new ServerScopedRuntimeException("Can only define ManagedStatistics on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); - } - ConfiguredObjectStatistic statistic = new ConfiguredObjectStatistic(clazz, m); - if(statisticSet.contains(statistic)) - { - statisticSet.remove(statistic); - } - statisticSet.add(statistic); - } - } + processMethods(clazz, attributeSet, statisticSet); processAttributesTypesAndFields(clazz); @@ -554,28 +498,117 @@ public class ConfiguredObjectTypeRegistry } } - private void initialiseWithParentAttributes(final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet, - final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet, - final Class<? extends ConfiguredObject> parent) + private static void doWithAllParents(Class<?> clazz, Action<Class<? extends ConfiguredObject>> action) { - Collection<ConfiguredObjectAttribute<?, ?>> attrs = _allAttributes.get(parent); - for(ConfiguredObjectAttribute<?,?> attr : attrs) + for(Class<?> parent : clazz.getInterfaces()) { - if(!attributeSet.contains(attr)) + if(ConfiguredObject.class.isAssignableFrom(parent)) { - attributeSet.add(attr); + action.performAction((Class<? extends ConfiguredObject>) parent); } } - Collection<ConfiguredObjectStatistic<?, ?>> stats = _allStatistics.get(parent); - for(ConfiguredObjectStatistic<?,?> stat : stats) + final Class<?> superclass = clazz.getSuperclass(); + if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass)) { - if(!statisticSet.contains(stat)) - { - statisticSet.add(stat); - } + action.performAction((Class<? extends ConfiguredObject>) superclass); + } + } + + private <X extends ConfiguredObject> void processMethods(final Class<X> clazz, + final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet, + final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet) + { + for(Method method : clazz.getDeclaredMethods()) + { + processMethod(clazz, attributeSet, statisticSet, method); + } + } + + private <X extends ConfiguredObject> void processMethod(final Class<X> clazz, + final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet, + final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet, + final Method m) + { + if(m.isAnnotationPresent(ManagedAttribute.class)) + { + processManagedAttribute(clazz, attributeSet, m); + } + else if(m.isAnnotationPresent(DerivedAttribute.class)) + { + processDerivedAttribute(clazz, attributeSet, m); + + } + else if(m.isAnnotationPresent(ManagedStatistic.class)) + { + processManagedStatistic(clazz, statisticSet, m); } } + private <X extends ConfiguredObject> void processManagedStatistic(final Class<X> clazz, + final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet, + final Method m) + { + ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class); + if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) + { + throw new ServerScopedRuntimeException("Can only define ManagedStatistics on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); + } + ConfiguredObjectStatistic statistic = new ConfiguredObjectStatistic(clazz, m); + if(statisticSet.contains(statistic)) + { + statisticSet.remove(statistic); + } + statisticSet.add(statistic); + } + + private <X extends ConfiguredObject> void processDerivedAttribute(final Class<X> clazz, + final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet, + final Method m) + { + DerivedAttribute annotation = m.getAnnotation(DerivedAttribute.class); + + if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) + { + throw new ServerScopedRuntimeException("Can only define DerivedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); + } + + ConfiguredObjectAttribute<?,?> attribute = new ConfiguredDerivedAttribute<>(clazz, m, annotation); + if(attributeSet.contains(attribute)) + { + attributeSet.remove(attribute); + } + attributeSet.add(attribute); + } + + private <X extends ConfiguredObject> void processManagedAttribute(final Class<X> clazz, + final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet, + final Method m) + { + ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class); + + if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) + { + throw new ServerScopedRuntimeException("Can only define ManagedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); + } + + ConfiguredObjectAttribute<?,?> attribute = new ConfiguredAutomatedAttribute<>(clazz, m, annotation); + if(attributeSet.contains(attribute)) + { + attributeSet.remove(attribute); + } + attributeSet.add(attribute); + } + + private void initialiseWithParentAttributes(final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet, + final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet, + final Set<Class<? extends ManagedInterface>> managedInterfaces, + final Class<? extends ConfiguredObject> parent) + { + attributeSet.addAll(_allAttributes.get(parent)); + statisticSet.addAll(_allStatistics.get(parent)); + managedInterfaces.addAll(_allManagedInterfaces.get(parent)); + } + private <X extends ConfiguredObject> void processAttributesTypesAndFields(final Class<X> clazz) { Map<String,ConfiguredObjectAttribute<?,?>> attrMap = new TreeMap<>(NAME_COMPARATOR); @@ -625,25 +658,20 @@ public class ConfiguredObjectTypeRegistry private void processStateChangeMethods(Class<? extends ConfiguredObject> clazz) { - Map<State, Map<State, Method>> map = new HashMap<>(); + final Map<State, Map<State, Method>> map = new HashMap<>(); _stateChangeMethods.put(clazz, map); addStateTransitions(clazz, map); - for(Class<?> parent : clazz.getInterfaces()) + + doWithAllParents(clazz, new Action<Class<? extends ConfiguredObject>>() { - if(ConfiguredObject.class.isAssignableFrom(parent)) + @Override + public void performAction(final Class<? extends ConfiguredObject> parent) { - inheritTransitions((Class<? extends ConfiguredObject>) parent, map); + inheritTransitions(parent, map); } - } - - Class<?> superclass = clazz.getSuperclass(); - - if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass)) - { - inheritTransitions((Class<? extends ConfiguredObject>) superclass, map); - } + }); } private void inheritTransitions(final Class<? extends ConfiguredObject> parent, @@ -811,21 +839,23 @@ public class ConfiguredObjectTypeRegistry protected <X extends ConfiguredObject> Collection<ConfiguredObjectAttribute<? super X, ?>> getAttributes(final Class<X> clazz) { - if(!_allAttributes.containsKey(clazz)) - { - process(clazz); - } + processClassIfNecessary(clazz); final Collection<ConfiguredObjectAttribute<? super X, ?>> attributes = (Collection) _allAttributes.get(clazz); return attributes; } - - protected Collection<ConfiguredObjectStatistic> getStatistics(final Class<? extends ConfiguredObject> clazz) + private <X extends ConfiguredObject> void processClassIfNecessary(final Class<X> clazz) { if(!_allAttributes.containsKey(clazz)) { process(clazz); } + } + + + protected Collection<ConfiguredObjectStatistic> getStatistics(final Class<? extends ConfiguredObject> clazz) + { + processClassIfNecessary(clazz); final Collection<ConfiguredObjectStatistic> statistics = (Collection) _allStatistics.get(clazz); return statistics; } @@ -833,28 +863,19 @@ public class ConfiguredObjectTypeRegistry public Map<String, ConfiguredObjectAttribute<?, ?>> getAttributeTypes(final Class<? extends ConfiguredObject> clazz) { - if(!_allAttributes.containsKey(clazz)) - { - process(clazz); - } + processClassIfNecessary(clazz); return _allAttributeTypes.get(clazz); } Map<String, AutomatedField> getAutomatedFields(Class<? extends ConfiguredObject> clazz) { - if(!_allAttributes.containsKey(clazz)) - { - process(clazz); - } + processClassIfNecessary(clazz); return _allAutomatedFields.get(clazz); } Map<State, Map<State, Method>> getStateChangeMethods(final Class<? extends ConfiguredObject> objectClass) { - if(!_allAttributes.containsKey(objectClass)) - { - process(objectClass); - } + processClassIfNecessary(objectClass); Map<State, Map<State, Method>> map = _stateChangeMethods.get(objectClass); return map != null ? Collections.unmodifiableMap(map) : Collections.<State, Map<State, Method>>emptyMap(); @@ -868,10 +889,7 @@ public class ConfiguredObjectTypeRegistry public Set<Class<? extends ManagedInterface>> getManagedInterfaces(final Class<? extends ConfiguredObject> classObject) { - if (!_allManagedInterfaces.containsKey(classObject)) - { - process(classObject); - } + processClassIfNecessary(classObject); Set<Class<? extends ManagedInterface>> interfaces = _allManagedInterfaces.get(classObject); return interfaces == null ? Collections.<Class<? extends ManagedInterface>>emptySet() : interfaces; } @@ -879,46 +897,14 @@ public class ConfiguredObjectTypeRegistry private <X extends ConfiguredObject> void processManagedInterfaces(Class<X> clazz) { - Set<Class<? extends ManagedInterface>> managedInterfaces = new HashSet<>(); - if (checkManagedAnnotationAndFindManagedInterfaces(clazz, managedInterfaces, false)) + final Set<Class<? extends ManagedInterface>> managedInterfaces = _allManagedInterfaces.get(clazz); + for(Class<?> iface : clazz.getInterfaces()) { - _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 (iface.isAnnotationPresent(ManagedAnnotation.class) && ManagedInterface.class.isAssignableFrom(iface)) { - if (checkManagedAnnotationAndFindManagedInterfaces(interfaceClass, managedInterfaces, hasManagedAnnotation)) - { - hasManagedAnnotation = true; - } + managedInterfaces.add((Class<? extends ManagedInterface>) iface); } - type = type.getSuperclass(); } - return hasManagedAnnotation; } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java index 80b25fd7f8..ddd2396e26 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java @@ -21,14 +21,12 @@ 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 { } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistryTest.java index 68186cc534..426526dbea 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistryTest.java @@ -28,6 +28,9 @@ import java.util.Set; import junit.framework.TestCase; +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.TestManagedClass0; import org.apache.qpid.server.model.testmodel.TestManagedClass1; import org.apache.qpid.server.model.testmodel.TestManagedClass2; @@ -35,16 +38,13 @@ 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.TestManagedInterface3; 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 +public class ConfiguredObjectTypeRegistryTest extends TestCase { private ConfiguredObjectTypeRegistry _typeRegistry; @@ -133,10 +133,10 @@ public class ConfigureObjectTypeRegistryTest extends TestCase { ConfiguredObjectTypeRegistry typeRegistry = createConfiguredObjectTypeRegistry(TestRootCategoryImpl.class, TestManagedClass2.class, TestManagedClass3.class); + assertEquals("Unexpected interfaces on class implementing 1 interface with annotation", + new HashSet<>(Arrays.asList(TestManagedInterface1.class)), typeRegistry.getManagedInterfaces(TestManagedClass2.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)); + new HashSet<>(Arrays.asList(TestManagedInterface3.class, TestManagedInterface1.class)), typeRegistry.getManagedInterfaces(TestManagedClass3.class)); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java index bd1bc6b24c..62cc0c0c01 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java @@ -22,15 +22,13 @@ 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 + * The instances of this class will be managed entities of type TestManagedInterface1 */ @ManagedObject( category = false , type = "ChildClass2" ) -@ManagedAnnotation public class TestManagedClass2 extends TestManagedClass0 implements TestManagedInterface2 { public TestManagedClass2(final Map<String, Object> attributes, TestRootCategory<?> parent) diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java index fbd3c60045..c78f7404a6 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java @@ -22,16 +22,14 @@ 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. + * This is a test managed type implementing managed interface TestManagedInterface1 and TestManagedInterface3. + * The instances of this class will be managed entities of types TestManagedInterface1 and TestManagedInterface3. */ @ManagedObject( category = false , type = "ChildClass3" ) -@ManagedAnnotation -public class TestManagedClass3 extends TestChildCategoryImpl implements TestManagedInterface1,TestManagedInterface2 +public class TestManagedClass3 extends TestChildCategoryImpl implements TestManagedInterface1,TestManagedInterface3 { public TestManagedClass3(final Map<String, Object> attributes, TestRootCategory<?> parent) { diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java new file mode 100644 index 0000000000..d1d0a1b820 --- /dev/null +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java @@ -0,0 +1,29 @@ +/* + * + * 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; + +@ManagedAnnotation +public interface TestManagedInterface3 extends ManagedInterface +{ +} |
