You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2016/02/16 16:09:31 UTC
svn commit: r1730697 -
/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
Author: kwall
Date: Tue Feb 16 15:09:31 2016
New Revision: 1730697
URL: http://svn.apache.org/viewvc?rev=1730697&view=rev
Log:
QPID-7068: Drive AbstractConfiguredObject#validationChange from reflection rather than attribute metadata
Modified:
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1730697&r1=1730696&r2=1730697&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java (original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java Tue Feb 16 15:09:31 2016
@@ -2872,14 +2872,15 @@ public abstract class AbstractConfigured
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable
{
- if(method.isAnnotationPresent(ManagedAttribute.class))
+ ConfiguredObjectAttribute attribute = getAttributeFromMethod(method);
+
+ if(attribute != null && attribute.isAutomated())
{
- ConfiguredObjectAttribute attribute = getAttributeFromMethod(method);
return getValue(attribute);
}
else if(method.getName().equals("getAttribute") && args != null && args.length == 1 && args[0] instanceof String)
{
- ConfiguredObjectAttribute attribute = _attributeTypes.get((String)args[0]);
+ attribute = _attributeTypes.get((String)args[0]);
if(attribute != null)
{
return getValue(attribute);
@@ -2893,6 +2894,10 @@ public abstract class AbstractConfigured
{
return Collections.unmodifiableMap(_attributes);
}
+ else if(method.getName().equals("toString") && (args == null || args.length == 0))
+ {
+ return "ValidationProxy{" + getCategoryClass().getSimpleName() + "/" + getType() + "}";
+ }
else
{
throw new UnsupportedOperationException(
@@ -2926,15 +2931,27 @@ public abstract class AbstractConfigured
private ConfiguredObjectAttribute getAttributeFromMethod(final Method method)
{
- for(ConfiguredObjectAttribute attribute : _attributeTypes.values())
+ if(!Modifier.isStatic(method.getModifiers()) && method.getParameterTypes().length==0)
{
- if((attribute instanceof ConfiguredObjectMethodAttribute) && ((ConfiguredObjectMethodAttribute)attribute).getGetter().getName().equals(method.getName())
- && !Modifier.isStatic(method.getModifiers()))
+ for(ConfiguredObjectAttribute attribute : _attributeTypes.values())
{
- return attribute;
+ if((attribute instanceof ConfiguredObjectMethodAttribute) && ((ConfiguredObjectMethodAttribute)attribute).getGetter().getName().equals(method.getName()))
+ {
+ return attribute;
+ }
}
}
- throw new ServerScopedRuntimeException("Unable to find attribute definition for method " + method.getName());
+ return null;
+ }
+
+ protected String getType()
+ {
+ return _configuredObject.getType();
+ }
+
+ protected Class<? extends ConfiguredObject> getCategoryClass()
+ {
+ return _configuredObject.getCategoryClass();
}
}
@@ -2943,6 +2960,7 @@ public abstract class AbstractConfigured
private final Class<? extends ConfiguredObject> _category;
private final Map<Class<? extends ConfiguredObject>, ConfiguredObject<?>> _parents;
private final ConfiguredObject<?> _parent ;
+ private Map<String, Object> _attributes;
AuthorisationProxyInvocationHandler(Map<String, Object> attributes,
Map<String, ConfiguredObjectAttribute<?, ?>> attributeTypes,
@@ -2954,6 +2972,7 @@ public abstract class AbstractConfigured
_parent = parent;
_category = categoryClass;
_parents = new HashMap<>();
+ _attributes = attributes;
if (parents != null)
{
for (ConfiguredObject<?> parentObject : parents)
@@ -2984,6 +3003,18 @@ public abstract class AbstractConfigured
{
return attribute.convert(value, _parent);
}
+
+ @Override
+ protected Class<? extends ConfiguredObject> getCategoryClass()
+ {
+ return _category;
+ }
+
+ @Override
+ protected String getType()
+ {
+ return String.valueOf(_attributes.get(ConfiguredObject.TYPE));
+ }
}
public final static class DuplicateIdException extends IllegalArgumentException
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org