You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2014/11/26 20:57:19 UTC
svn commit: r1641910 - in /qpid/trunk/qpid/java:
broker-codegen/src/main/java/org/apache/qpid/server/model/validation/
broker-codegen/src/main/resources/META-INF/services/
broker-core/src/main/java/org/apache/qpid/server/model/
broker-core/src/test/jav...
Author: rgodfrey
Date: Wed Nov 26 19:57:18 2014
New Revision: 1641910
URL: http://svn.apache.org/r1641910
Log:
QPID-6246 : @ManagedAnnotation should only be applied to interfaces which extend ManagedInterface and should not be inherited
Added:
qpid/trunk/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java (with props)
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistryTest.java
- copied, changed from r1641878, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java (with props)
Removed:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java
Modified:
qpid/trunk/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor
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/ManagedAnnotation.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
Added: qpid/trunk/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java?rev=1641910&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java (added)
+++ qpid/trunk/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java Wed Nov 26 19:57:18 2014
@@ -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());
+ }
+}
Propchange: qpid/trunk/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: qpid/trunk/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor?rev=1641910&r1=1641909&r2=1641910&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor (original)
+++ qpid/trunk/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor Wed Nov 26 19:57:18 2014
@@ -22,3 +22,4 @@ org.apache.qpid.server.plugin.PluggableP
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
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=1641910&r1=1641909&r2=1641910&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 19:57:18 2014
@@ -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 ConfiguredObjectTypeRegistr
}
}
+
for(Class<?> iface : clazz.getInterfaces() )
{
if(ConfiguredObject.class.isAssignableFrom(iface))
@@ -455,94 +456,37 @@ public class ConfiguredObjectTypeRegistr
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,26 +498,115 @@ public class ConfiguredObjectTypeRegistr
}
}
- 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)
@@ -625,25 +658,20 @@ public class ConfiguredObjectTypeRegistr
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 ConfiguredObjectTypeRegistr
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 ConfiguredObjectTypeRegistr
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 ConfiguredObjectTypeRegistr
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 ConfiguredObjectTypeRegistr
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;
}
}
Modified: 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=1641910&r1=1641909&r2=1641910&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAnnotation.java Wed Nov 26 19:57:18 2014
@@ -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
{
}
Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistryTest.java (from r1641878, 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/ConfiguredObjectTypeRegistryTest.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistryTest.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfigureObjectTypeRegistryTest.java&r1=1641878&r2=1641910&rev=1641910&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/ConfiguredObjectTypeRegistryTest.java Wed Nov 26 19:57:18 2014
@@ -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.test
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 ConfigureObjectTypeRegistry
{
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));
}
Modified: 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=1641910&r1=1641909&r2=1641910&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java Wed Nov 26 19:57:18 2014
@@ -22,15 +22,13 @@ package org.apache.qpid.server.model.tes
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)
Modified: 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=1641910&r1=1641909&r2=1641910&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java Wed Nov 26 19:57:18 2014
@@ -22,16 +22,14 @@ package org.apache.qpid.server.model.tes
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)
{
Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java?rev=1641910&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java Wed Nov 26 19:57:18 2014
@@ -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
+{
+}
Propchange: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org