You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2016/02/09 13:05:59 UTC
svn commit: r1729365 - in /qpid/java/branches/6.0.x: ./
broker-core/src/main/java/org/apache/qpid/server/model/
broker-core/src/main/java/org/apache/qpid/server/plugin/
broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/
broker...
Author: orudyy
Date: Tue Feb 9 12:05:58 2016
New Revision: 1729365
URL: http://svn.apache.org/viewvc?rev=1729365&view=rev
Log:
QPID-7049 : Provide a mechanism for injecting attributes/statistics/operations at run time
merged from trunk
svn merge -c 1728497,1728524,1728639 https://svn.apache.org/repos/asf/qpid/java/trunk
Added:
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedInjectedAttribute.java
- copied, changed from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedInjectedAttribute.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedMethodAttribute.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedMethodAttribute.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedAttribute.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedAttribute.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedAttributeOrStatistic.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedAttributeOrStatistic.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedOperation.java
- copied, changed from r1728524, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedOperation.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedStatistic.java
- copied, changed from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedStatistic.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectMethodAttribute.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectMethodAttribute.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectMethodAttributeOrStatistic.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectMethodAttributeOrStatistic.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectMethodOperation.java
- copied unchanged from r1728524, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectMethodOperation.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectMethodStatistic.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectMethodStatistic.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectOperation.java
- copied unchanged from r1728524, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectOperation.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectStatistic.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectStatistic.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredSettableAttribute.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredSettableAttribute.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredSettableInjectedAttribute.java
- copied unchanged from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredSettableInjectedAttribute.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeOrStatistic.java
- copied, changed from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeOrStatistic.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeStatisticOrOperation.java
- copied unchanged from r1728524, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeStatisticOrOperation.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/OperationParameter.java
- copied unchanged from r1728524, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/OperationParameter.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/OperationParameterFromAnnotation.java
- copied unchanged from r1728524, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/OperationParameterFromAnnotation.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/OperationParameterFromInjection.java
- copied unchanged from r1728524, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/OperationParameterFromInjection.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectAttributeInjector.java
- copied, changed from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectAttributeInjector.java
qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/InjectedAttributeTest.java
- copied, changed from r1728497, qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/InjectedAttributeTest.java
Removed:
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedAttribute.java
Modified:
qpid/java/branches/6.0.x/ (props changed)
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java
qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java
qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java
qpid/java/branches/6.0.x/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
Propchange: qpid/java/branches/6.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 9 12:05:58 2016
@@ -9,5 +9,5 @@
/qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
/qpid/branches/java-network-refactor/qpid/java:805429-821809
/qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720340,1720664,1721151,1721198,1722019-1722020,1722246,1722339,1722416,1722674,1722678,1722683,1722711,1723064,1723194,1723563,1724216,1724251,1724257,1724292,1724375,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1725760,1726176,1726244-1726246,1726249,1726358,1726436,1726449,1726456,1726646,1726653,1726755,1726778,1727532,1727555,1727608,1727951,1728089,1728167,1728302
+/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720340,1720664,1721151,1721198,1722019-1722020,1722246,1722339,1722416,1722674,1722678,1722683,1722711,1723064,1723194,1723563,1724216,1724251,1724257,1724292,1724375,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1725760,1726176,1726244-1726246,1726249,1726358,1726436,1726449,1726456,1726646,1726653,1726755,1726778,1727532,1727555,1727608,1727951,1728089,1728167,1728302,1728497,1728524,1728639
/qpid/trunk/qpid:796646-796653
Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java Tue Feb 9 12:05:58 2016
@@ -283,7 +283,7 @@ public abstract class AbstractConfigured
Object durableObj = attributes.get(DURABLE);
_durable = AttributeValueConverter.BOOLEAN_CONVERTER.convert(durableObj == null
- ? ((ConfiguredAutomatedAttribute) (_attributeTypes
+ ? ((ConfiguredSettableAttribute) (_attributeTypes
.get(DURABLE))).defaultValue()
: durableObj, this);
@@ -313,9 +313,9 @@ public abstract class AbstractConfigured
}
for(ConfiguredObjectAttribute<?,?> attr : _attributeTypes.values())
{
- if(attr.isAutomated())
+ if(!attr.isDerived())
{
- ConfiguredAutomatedAttribute<?,?> autoAttr = (ConfiguredAutomatedAttribute<?,?>)attr;
+ ConfiguredSettableAttribute<?,?> autoAttr = (ConfiguredSettableAttribute<?,?>)attr;
if (autoAttr.isMandatory() && !(_attributes.containsKey(attr.getName())
|| !"".equals(autoAttr.defaultValue())))
{
@@ -431,7 +431,7 @@ public abstract class AbstractConfigured
}
}
- private boolean checkValidValues(final ConfiguredAutomatedAttribute attribute, final Object desiredValue)
+ private boolean checkValidValues(final ConfiguredSettableAttribute attribute, final Object desiredValue)
{
for (Object validValue : attribute.validValues())
{
@@ -1065,9 +1065,9 @@ public abstract class AbstractConfigured
{
for(ConfiguredObjectAttribute<?,?> attr : _attributeTypes.values())
{
- if (attr.isAutomated())
+ if (!attr.isDerived())
{
- ConfiguredAutomatedAttribute autoAttr = (ConfiguredAutomatedAttribute) attr;
+ ConfiguredSettableAttribute autoAttr = (ConfiguredSettableAttribute) attr;
if (autoAttr.hasValidValues())
{
Object desiredValueOrDefault = autoAttr.getValue(this);
@@ -1111,22 +1111,25 @@ public abstract class AbstractConfigured
for (ConfiguredObjectAttribute<?, ?> attr : _attributeTypes.values())
{
- if (attr.isAutomated())
+ if(attr.isDerived())
{
- unresolved.add(attr);
+ derived.add(attr);
}
- else if(attr.isDerived())
+ else
{
- derived.add(attr);
+ unresolved.add(attr);
}
}
// If there is a context attribute, resolve it first, so that other attribute values
// may support values containing references to context keys.
ConfiguredObjectAttribute<?, ?> contextAttribute = _attributeTypes.get("context");
- if (contextAttribute != null && contextAttribute.isAutomated())
+ if (contextAttribute != null && !contextAttribute.isDerived())
{
- resolveAutomatedAttribute((ConfiguredAutomatedAttribute<?, ?>) contextAttribute);
+ if(contextAttribute.isAutomated())
+ {
+ resolveAutomatedAttribute((ConfiguredSettableAttribute<?, ?>) contextAttribute);
+ }
unresolved.remove(contextAttribute);
}
@@ -1142,7 +1145,10 @@ public abstract class AbstractConfigured
if(!(dependsOn(attr, unresolved) || (!derived.isEmpty() && dependsOn(attr, derived))))
{
- resolveAutomatedAttribute((ConfiguredAutomatedAttribute<?, ?>) attr);
+ if(attr.isAutomated())
+ {
+ resolveAutomatedAttribute((ConfiguredSettableAttribute<?, ?>) attr);
+ }
attrIter.remove();
changed = true;
}
@@ -1161,9 +1167,9 @@ public abstract class AbstractConfigured
final Set<ConfiguredObjectAttribute<?, ?>> unresolved)
{
Object value = _attributes.get(attr.getName());
- if(value == null && !"".equals(((ConfiguredAutomatedAttribute)attr).defaultValue()))
+ if(value == null && !"".equals(((ConfiguredSettableAttribute)attr).defaultValue()))
{
- value = ((ConfiguredAutomatedAttribute)attr).defaultValue();
+ value = ((ConfiguredSettableAttribute)attr).defaultValue();
}
if(value instanceof String)
{
@@ -1182,7 +1188,7 @@ public abstract class AbstractConfigured
return false;
}
- private void resolveAutomatedAttribute(final ConfiguredAutomatedAttribute<?, ?> autoAttr)
+ private void resolveAutomatedAttribute(final ConfiguredSettableAttribute<?, ?> autoAttr)
{
String attrName = autoAttr.getName();
if (_attributes.containsKey(attrName))
@@ -1580,7 +1586,7 @@ public abstract class AbstractConfigured
public final Object getAttribute(String name)
{
ConfiguredObjectAttribute<X,?> attr = (ConfiguredObjectAttribute<X, ?>) _attributeTypes.get(name);
- if(attr != null && (attr.isAutomated() || attr.isDerived()))
+ if(attr != null)
{
Object value = attr.getValue((X)this);
if(value != null && !SecurityManager.isSystemProcess() && attr.isSecureValue(value))
@@ -1592,11 +1598,6 @@ public abstract class AbstractConfigured
return value;
}
}
- else if(attr != null)
- {
- Object value = getActualAttribute(name);
- return value;
- }
else
{
throw new IllegalArgumentException("Unknown attribute: '" + name + "'");
@@ -2523,9 +2524,9 @@ public abstract class AbstractConfigured
{
for(ConfiguredObjectAttribute<?,?> attr : _attributeTypes.values())
{
- if (attr.isAutomated() && changedAttributes.contains(attr.getName()))
+ if (!attr.isDerived() && changedAttributes.contains(attr.getName()))
{
- ConfiguredAutomatedAttribute autoAttr = (ConfiguredAutomatedAttribute) attr;
+ ConfiguredSettableAttribute autoAttr = (ConfiguredSettableAttribute) attr;
if (autoAttr.isImmutable() && !Objects.equals(autoAttr.getValue(this), autoAttr.getValue(proxyForValidation)))
{
@@ -2839,15 +2840,23 @@ public abstract class AbstractConfigured
return null;
}
}
- throw new UnsupportedOperationException("This class is only intended for value validation, and only getters on managed attributes are permitted.");
+ else if(method.getName().equals("getActualAttributes") && (args == null || args.length == 0))
+ {
+ return Collections.unmodifiableMap(_attributes);
+ }
+ else
+ {
+ throw new UnsupportedOperationException(
+ "This class is only intended for value validation, and only getters on managed attributes are permitted.");
+ }
}
protected Object getValue(final ConfiguredObjectAttribute attribute)
{
Object value;
- if(attribute.isAutomated())
+ if(!attribute.isDerived())
{
- ConfiguredAutomatedAttribute autoAttr = (ConfiguredAutomatedAttribute) attribute;
+ ConfiguredSettableAttribute autoAttr = (ConfiguredSettableAttribute) attribute;
value = _attributes.get(attribute.getName());
if (value == null && !"".equals(autoAttr.defaultValue()))
{
@@ -2870,7 +2879,7 @@ public abstract class AbstractConfigured
{
for(ConfiguredObjectAttribute attribute : _attributeTypes.values())
{
- if(attribute.getGetter().getName().equals(method.getName())
+ if((attribute instanceof ConfiguredObjectMethodAttribute) && ((ConfiguredObjectMethodAttribute)attribute).getGetter().getName().equals(method.getName())
&& !Modifier.isStatic(method.getModifiers()))
{
return attribute;
Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java Tue Feb 9 12:05:58 2016
@@ -60,11 +60,11 @@ public abstract class AbstractUnresolved
{
addUnresolvedObject((Class<? extends ConfiguredObject>) attributeType,
attribute.getName(),
- attribute.isAutomated() && ((ConfiguredAutomatedAttribute<? super C,?>)attribute).isMandatory());
+ attribute.isAutomated() && ((ConfiguredSettableAttribute<? super C,?>)attribute).isMandatory());
}
else if (Collection.class.isAssignableFrom(attributeType))
{
- Type returnType = attribute.getGetter().getGenericReturnType();
+ Type returnType = attribute.getGenericType();
Class<? extends ConfiguredObject> attrClass = getMemberType(returnType);
if (attrClass != null)
{
Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java Tue Feb 9 12:05:58 2016
@@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.apache.qpid.server.plugin.ConfiguredObjectAttributeInjector;
import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;
import org.apache.qpid.server.plugin.QpidServiceLoader;
@@ -116,7 +117,9 @@ public final class BrokerModel extends M
addRelationship(Session.class, Publisher.class);
_objectFactory = new ConfiguredObjectFactoryImpl(this);
- _typeRegistry = new ConfiguredObjectTypeRegistry((new QpidServiceLoader()).instancesOf(ConfiguredObjectRegistration.class), getSupportedCategories(),
+ _typeRegistry = new ConfiguredObjectTypeRegistry((new QpidServiceLoader()).instancesOf(ConfiguredObjectRegistration.class),
+ (new QpidServiceLoader()).instancesOf(ConfiguredObjectAttributeInjector.class),
+ getSupportedCategories(),
_objectFactory);
}
Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java Tue Feb 9 12:05:58 2016
@@ -33,7 +33,8 @@ import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ConfiguredAutomatedAttribute<C extends ConfiguredObject, T> extends ConfiguredObjectAttribute<C,T>
+public class ConfiguredAutomatedAttribute<C extends ConfiguredObject, T> extends ConfiguredObjectMethodAttribute<C,T>
+ implements ConfiguredSettableAttribute<C, T>
{
private static final Logger LOGGER = LoggerFactory.getLogger(ConfiguredAutomatedAttribute.class);
@@ -116,6 +117,7 @@ public class ConfiguredAutomatedAttribut
return false;
}
+ @Override
public String defaultValue()
{
return _annotation.defaultValue();
@@ -126,11 +128,13 @@ public class ConfiguredAutomatedAttribut
return _annotation.secure();
}
+ @Override
public boolean isMandatory()
{
return _annotation.mandatory();
}
+ @Override
public boolean isImmutable()
{
return _annotation.immutable();
@@ -169,6 +173,7 @@ public class ConfiguredAutomatedAttribut
return _secureValuePattern;
}
+ @Override
public Collection<String> validValues()
{
if(_validValuesMethod != null)
@@ -190,6 +195,7 @@ public class ConfiguredAutomatedAttribut
}
/** Returns true iff this attribute has valid values defined */
+ @Override
public boolean hasValidValues()
{
return validValues() != null && validValues().size() > 0;
Copied: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedInjectedAttribute.java (from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedInjectedAttribute.java)
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedInjectedAttribute.java?p2=qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedInjectedAttribute.java&p1=qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedInjectedAttribute.java&r1=1728497&r2=1729365&rev=1729365&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedInjectedAttribute.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedInjectedAttribute.java Tue Feb 9 12:05:58 2016
@@ -43,9 +43,11 @@ public class ConfiguredDerivedInjectedAt
private final String _oversizedAltText;
private final String _description;
private final Method _method;
+ private final Object[] _staticParams;
public ConfiguredDerivedInjectedAttribute(final String name,
final Method method,
+ final Object[] staticParams,
final boolean secure,
final boolean persisted,
final String secureValueFilter,
@@ -57,14 +59,31 @@ public class ConfiguredDerivedInjectedAt
super(name, (Class<T>) AttributeValueConverter.getTypeFromMethod(method),
method.getGenericReturnType(), typeValidator);
- if(!(method.getParameterTypes().length == 1
+ _staticParams = staticParams == null ? new Object[0] : staticParams;
+
+ if(!(method.getParameterTypes().length == 1 + _staticParams.length
&& ConfiguredObject.class.isAssignableFrom(method.getParameterTypes()[0])
&& Modifier.isStatic(method.getModifiers())))
{
- throw new IllegalArgumentException("Injected derived attribute method must be static, and have a single argument which inherits from ConfiguredObject");
+ throw new IllegalArgumentException("Injected derived attribute method must be static, and have an initial argument which inherits from ConfiguredObject");
}
_method = method;
method.setAccessible(true);
+
+ final Class<?>[] methodParamTypes = method.getParameterTypes();
+ for(int i = 0; i < _staticParams.length; i++)
+ {
+ if(methodParamTypes[i+1].isPrimitive() && _staticParams[i] == null)
+ {
+ throw new IllegalArgumentException("Static parameter has null value, but the " + methodParamTypes[i+1].getSimpleName() + " type is a primitive");
+ }
+ if(!AttributeValueConverter.convertPrimitiveToBoxed(methodParamTypes[i+1]).isAssignableFrom(_staticParams[i].getClass()))
+ {
+ throw new IllegalArgumentException("Static parameter cannot be assigned value as it is of incompatible type");
+ }
+ }
+
+
_secure = secure;
_persisted = persisted;
_oversized = oversized;
@@ -144,7 +163,14 @@ public class ConfiguredDerivedInjectedAt
{
try
{
- return (T) _method.invoke(null, configuredObject);
+ Object[] params = new Object[1+_staticParams.length];
+ params[0] = configuredObject;
+ for(int i = 0; i < _staticParams.length; i++)
+ {
+ params[i+1] = _staticParams[i];
+ }
+
+ return (T) _method.invoke(null, params);
}
catch (IllegalAccessException e)
{
Copied: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedOperation.java (from r1728524, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedOperation.java)
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedOperation.java?p2=qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedOperation.java&p1=qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedOperation.java&r1=1728524&r2=1729365&rev=1729365&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedOperation.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedOperation.java Tue Feb 9 12:05:58 2016
@@ -43,12 +43,14 @@ public class ConfiguredObjectInjectedOpe
private final String _name;
private final String _description;
private final boolean _nonModifying;
+ private final Object[] _staticParams;
public ConfiguredObjectInjectedOperation(final String name,
final String description,
final boolean nonModifying,
final OperationParameter[] parameters,
final Method operation,
+ final Object[] staticParams,
final TypeValidator validator)
{
_operation = operation;
@@ -56,6 +58,7 @@ public class ConfiguredObjectInjectedOpe
_description = description;
_nonModifying = nonModifying;
_validator = validator;
+ _staticParams = staticParams == null ? new Object[0] : staticParams;
_params = parameters == null ? Collections.<OperationParameter>emptyList() : Arrays.asList(parameters);
@@ -67,16 +70,29 @@ public class ConfiguredObjectInjectedOpe
_validNames = Collections.unmodifiableSet(validNames);
- Class<?>[] opParameterTypes = operation.getParameterTypes();
+ final Class<?>[] opParameterTypes = operation.getParameterTypes();
+
if(!(Modifier.isStatic(operation.getModifiers())
&& Modifier.isPublic(operation.getModifiers())
- && opParameterTypes.length == _params.size() + 1
+ && opParameterTypes.length == _params.size() + _staticParams.length + 1
&& ConfiguredObject.class.isAssignableFrom(opParameterTypes[0])))
{
throw new IllegalArgumentException("Passed method must be public and static. The first parameter must derive from ConfiguredObject, and the rest of the parameters must match the passed in specifications");
}
- int paramId = 1;
+ for(int i = 0; i < _staticParams.length; i++)
+ {
+ if(opParameterTypes[i+1].isPrimitive() && _staticParams[i] == null)
+ {
+ throw new IllegalArgumentException("Static parameter has null value, but the " + opParameterTypes[i+1].getSimpleName() + " type is a primitive");
+ }
+ if(!AttributeValueConverter.convertPrimitiveToBoxed(opParameterTypes[i+1]).isAssignableFrom(_staticParams[i].getClass()))
+ {
+ throw new IllegalArgumentException("Static parameter cannot be assigned value as it is of incompatible type");
+ }
+ }
+
+ int paramId = 1+_staticParams.length;
for(OperationParameter parameter : _params)
{
if(!opParameterTypes[paramId].isAssignableFrom(parameter.getType()))
@@ -119,8 +135,15 @@ public class ConfiguredObjectInjectedOpe
{
throw new IllegalArgumentException("Parameters " + providedNames + " are not accepted by " + getName());
}
- Object[] paramValues = new Object[1+_params.size()];
+ Object[] paramValues = new Object[1+_staticParams.length+_params.size()];
paramValues[0] = subject;
+
+
+ for(int i = 0; i < _staticParams.length; i++)
+ {
+ paramValues[i+1] = _staticParams[i];
+ }
+
for (int i = 0; i < _params.size(); i++)
{
OperationParameter param = _params.get(i);
@@ -143,7 +166,7 @@ public class ConfiguredObjectInjectedOpe
try
{
final Object convertedVal = converter.convert(providedVal, subject);
- paramValues[i+1] = convertedVal;
+ paramValues[i+1+_staticParams.length] = convertedVal;
}
catch (IllegalArgumentException e)
{
Copied: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedStatistic.java (from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedStatistic.java)
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedStatistic.java?p2=qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedStatistic.java&p1=qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedStatistic.java&r1=1728497&r2=1729365&rev=1729365&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedStatistic.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectInjectedStatistic.java Tue Feb 9 12:05:58 2016
@@ -40,27 +40,43 @@ final public class ConfiguredObjectInjec
private final StatisticUnit _units;
private final StatisticType _type;
private final String _label;
+ private final Object[] _staticParams;
public ConfiguredObjectInjectedStatistic(final String name,
- final Method method,
- final String description,
- final TypeValidator typeValidator,
- final StatisticUnit units,
- final StatisticType type,
- final String label)
+ final Method method,
+ final Object[] staticParams,
+ final String description,
+ final TypeValidator typeValidator,
+ final StatisticUnit units,
+ final StatisticType type,
+ final String label)
{
super(name,
(Class<T>) AttributeValueConverter.getTypeFromMethod(method), method.getGenericReturnType(), typeValidator);
_units = units;
_type = type;
_label = label;
- if(!(method.getParameterTypes().length == 1
+ _staticParams = staticParams == null ? new Object[0] : staticParams;
+ if(!(method.getParameterTypes().length == 1 + _staticParams.length
&& ConfiguredObject.class.isAssignableFrom(method.getParameterTypes()[0])
&& Modifier.isStatic(method.getModifiers())
&& Number.class.isAssignableFrom(AttributeValueConverter.getTypeFromMethod(method))))
{
- throw new IllegalArgumentException("Injected statistic method must be static, have a single argument which inherits from ConfiguredObject, and return a Number");
+ throw new IllegalArgumentException("Injected statistic method must be static, have first argument which inherits from ConfiguredObject, and return a Number");
}
+ final Class<?>[] methodParamTypes = method.getParameterTypes();
+ for(int i = 0; i < _staticParams.length; i++)
+ {
+ if(methodParamTypes[i+1].isPrimitive() && _staticParams[i] == null)
+ {
+ throw new IllegalArgumentException("Static parameter has null value, but the " + methodParamTypes[i+1].getSimpleName() + " type is a primitive");
+ }
+ if(!AttributeValueConverter.convertPrimitiveToBoxed(methodParamTypes[i+1]).isAssignableFrom(_staticParams[i].getClass()))
+ {
+ throw new IllegalArgumentException("Static parameter cannot be assigned value as it is of incompatible type");
+ }
+ }
+
_method = method;
method.setAccessible(true);
_description = description;
@@ -95,7 +111,13 @@ final public class ConfiguredObjectInjec
{
try
{
- return (T) _method.invoke(null, configuredObject);
+ Object[] params = new Object[1+_staticParams.length];
+ params[0] = configuredObject;
+ for(int i = 0; i < _staticParams.length; i++)
+ {
+ params[i+1] = _staticParams[i];
+ }
+ return (T) _method.invoke(null, params);
}
catch (IllegalAccessException e)
{
Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java Tue Feb 9 12:05:58 2016
@@ -48,6 +48,7 @@ import com.google.common.util.concurrent
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.qpid.server.plugin.ConfiguredObjectAttributeInjector;
import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;
import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory;
import org.apache.qpid.server.util.Action;
@@ -197,12 +198,15 @@ public class ConfiguredObjectTypeRegistr
Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, Collection<String>>>());
private final ConfiguredObjectFactory _objectFactory;
+ private final Iterable<ConfiguredObjectAttributeInjector> _attributeInjectors;
public ConfiguredObjectTypeRegistry(Iterable<ConfiguredObjectRegistration> configuredObjectRegistrations,
+ final Iterable<ConfiguredObjectAttributeInjector> attributeInjectors,
Collection<Class<? extends ConfiguredObject>> categoriesRestriction,
final ConfiguredObjectFactory objectFactory)
{
_objectFactory = objectFactory;
+ _attributeInjectors = attributeInjectors;
Set<Class<? extends ConfiguredObject>> categories = new HashSet<>();
Set<Class<? extends ConfiguredObject>> types = new HashSet<>();
@@ -671,6 +675,33 @@ public class ConfiguredObjectTypeRegistr
{
processMethod(clazz, attributeSet, statisticSet, operationsSet, method);
}
+
+ for(ConfiguredObjectAttributeInjector injector : _attributeInjectors)
+ {
+ for(ConfiguredObjectInjectedAttribute<?,?> attr : injector.getInjectedAttributes())
+ {
+ if(attr.appliesToConfiguredObjectType((Class<? extends ConfiguredObject<?>>) clazz))
+ {
+ attributeSet.add(attr);
+ }
+ }
+
+ for(ConfiguredObjectInjectedStatistic<?,?> attr : injector.getInjectedStatistics())
+ {
+ if(attr.appliesToConfiguredObjectType((Class<? extends ConfiguredObject<?>>) clazz))
+ {
+ statisticSet.add(attr);
+ }
+ }
+
+ for(ConfiguredObjectInjectedOperation<?> operation : injector.getInjectedOperations())
+ {
+ if(operation.appliesToConfiguredObjectType((Class<? extends ConfiguredObject<?>>) clazz))
+ {
+ operationsSet.add(operation);
+ }
+ }
+ }
}
private <X extends ConfiguredObject> void processMethod(final Class<X> clazz,
@@ -707,7 +738,7 @@ public class ConfiguredObjectTypeRegistr
{
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, statAnnotation);
+ ConfiguredObjectStatistic statistic = new ConfiguredObjectMethodStatistic(clazz, m, statAnnotation);
if(statisticSet.contains(statistic))
{
statisticSet.remove(statistic);
@@ -726,7 +757,7 @@ public class ConfiguredObjectTypeRegistr
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);
+ ConfiguredObjectAttribute<?,?> attribute = new ConfiguredDerivedMethodAttribute<>(clazz, m, annotation);
if(attributeSet.contains(attribute))
{
attributeSet.remove(attribute);
@@ -764,7 +795,7 @@ public class ConfiguredObjectTypeRegistr
throw new ServerScopedRuntimeException("Can only define ManagedOperations on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria.");
}
- ConfiguredObjectOperation<?> operation = new ConfiguredObjectOperation<>(clazz, m, this);
+ ConfiguredObjectOperation<?> operation = new ConfiguredObjectMethodOperation<>(clazz, m, this);
Iterator<ConfiguredObjectOperation<?>> iter = operationSet.iterator();
while(iter.hasNext())
{
@@ -812,6 +843,16 @@ public class ConfiguredObjectTypeRegistr
}
}
+ for(ConfiguredObjectAttributeInjector injector : _attributeInjectors)
+ {
+ for(ConfiguredObjectInjectedAttribute<?,?> attr : injector.getInjectedAttributes())
+ {
+ if(!attrMap.containsKey(attr.getName()) && attr.appliesToConfiguredObjectType((Class<? extends ConfiguredObject<?>>) clazz))
+ {
+ attrMap.put(attr.getName(), attr);
+ }
+ }
+ }
_allAttributeTypes.put(clazz, attrMap);
_allAutomatedFields.put(clazz, fieldMap);
}
Copied: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeOrStatistic.java (from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeOrStatistic.java)
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeOrStatistic.java?p2=qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeOrStatistic.java&p1=qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeOrStatistic.java&r1=1728497&r2=1729365&rev=1729365&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeOrStatistic.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/InjectedAttributeOrStatistic.java Tue Feb 9 12:05:58 2016
@@ -20,12 +20,7 @@
*/
package org.apache.qpid.server.model;
-public interface InjectedAttributeOrStatistic<C extends ConfiguredObject, T> extends ConfiguredObjectAttributeOrStatistic<C, T>
+public interface InjectedAttributeOrStatistic<C extends ConfiguredObject, T> extends InjectedAttributeStatisticOrOperation<C>, ConfiguredObjectAttributeOrStatistic<C, T>
{
- boolean appliesToConfiguredObjectType(Class<? extends ConfiguredObject<?>> type);
- interface TypeValidator
- {
- boolean appliesToType(Class<? extends ConfiguredObject<?>> type);
- }
}
Copied: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectAttributeInjector.java (from r1728497, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectAttributeInjector.java)
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectAttributeInjector.java?p2=qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectAttributeInjector.java&p1=qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectAttributeInjector.java&r1=1728497&r2=1729365&rev=1729365&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectAttributeInjector.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectAttributeInjector.java Tue Feb 9 12:05:58 2016
@@ -23,10 +23,12 @@ package org.apache.qpid.server.plugin;
import java.util.Collection;
import org.apache.qpid.server.model.ConfiguredObjectInjectedAttribute;
+import org.apache.qpid.server.model.ConfiguredObjectInjectedOperation;
import org.apache.qpid.server.model.ConfiguredObjectInjectedStatistic;
public interface ConfiguredObjectAttributeInjector extends Pluggable
{
Collection<ConfiguredObjectInjectedAttribute<?,?>> getInjectedAttributes();
Collection<ConfiguredObjectInjectedStatistic<?,?>> getInjectedStatistics();
+ Collection<ConfiguredObjectInjectedOperation<?>> getInjectedOperations();
}
Copied: qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/InjectedAttributeTest.java (from r1728497, qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/InjectedAttributeTest.java)
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/InjectedAttributeTest.java?p2=qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/InjectedAttributeTest.java&p1=qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/InjectedAttributeTest.java&r1=1728497&r2=1729365&rev=1729365&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/InjectedAttributeTest.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/InjectedAttributeTest.java Tue Feb 9 12:05:58 2016
@@ -21,22 +21,17 @@
package org.apache.qpid.server.model.testmodels.hierarchy;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.security.AccessControlException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import com.google.common.util.concurrent.ListenableFuture;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.model.*;
import org.apache.qpid.server.plugin.ConfiguredObjectAttributeInjector;
-import org.apache.qpid.server.store.ConfiguredObjectRecord;
import org.apache.qpid.test.utils.QpidTestCase;
public class InjectedAttributeTest extends QpidTestCase
@@ -47,12 +42,36 @@ public class InjectedAttributeTest exten
private Collection<ConfiguredObjectInjectedAttribute<?, ?>> _injectedAttributes;
private Collection<ConfiguredObjectInjectedStatistic<?, ?>> _injectedStatistics;
+ private Collection<ConfiguredObjectInjectedOperation<?>> _injectedOperations;
+
+ private TestInjector(ConfiguredObjectInjectedAttribute<?, ?>... attributes)
+ {
+ this(Arrays.asList(attributes),
+ Collections.<ConfiguredObjectInjectedStatistic<?, ?>>emptyList(),
+ Collections.<ConfiguredObjectInjectedOperation<?>>emptyList());
+ }
+
+ private TestInjector(ConfiguredObjectInjectedStatistic<?, ?>... statistics)
+ {
+ this(Collections.<ConfiguredObjectInjectedAttribute<?, ?>>emptyList(),
+ Arrays.asList(statistics),
+ Collections.<ConfiguredObjectInjectedOperation<?>>emptyList());
+ }
+
+ private TestInjector(ConfiguredObjectInjectedOperation<?>... operations)
+ {
+ this(Collections.<ConfiguredObjectInjectedAttribute<?, ?>>emptyList(),
+ Collections.<ConfiguredObjectInjectedStatistic<?, ?>>emptyList(),
+ Arrays.asList(operations));
+ }
private TestInjector(final Collection<ConfiguredObjectInjectedAttribute<?, ?>> injectedAttributes,
- final Collection<ConfiguredObjectInjectedStatistic<?, ?>> injectedStatistics)
+ final Collection<ConfiguredObjectInjectedStatistic<?, ?>> injectedStatistics,
+ final Collection<ConfiguredObjectInjectedOperation<?>> injectedOperations)
{
_injectedAttributes = injectedAttributes;
_injectedStatistics = injectedStatistics;
+ _injectedOperations = injectedOperations;
}
@Override
@@ -68,6 +87,12 @@ public class InjectedAttributeTest exten
}
@Override
+ public Collection<ConfiguredObjectInjectedOperation<?>> getInjectedOperations()
+ {
+ return _injectedOperations;
+ }
+
+ @Override
public String getType()
{
return "TEST";
@@ -101,8 +126,7 @@ public class InjectedAttributeTest exten
null,
validator);
- TestModel model = new TestModel(null, Collections.<ConfiguredObjectAttributeInjector>singleton(new TestInjector(Collections.<ConfiguredObjectInjectedAttribute<?, ?>>singletonList(
- attrInjector), Collections.<ConfiguredObjectInjectedStatistic<?, ?>>emptySet())));
+ TestModel model = new TestModel(null, new TestInjector(attrInjector));
TestCar<?> testCar = new TestStandardCarImpl(Collections.<String,Object>singletonMap("name", "Arthur"), model);
@@ -150,8 +174,7 @@ public class InjectedAttributeTest exten
new String[] { "42", "49" },
validator);
- TestModel model = new TestModel(null, Collections.<ConfiguredObjectAttributeInjector>singleton(new TestInjector(Collections.<ConfiguredObjectInjectedAttribute<?, ?>>singletonList(
- attrInjector), Collections.<ConfiguredObjectInjectedStatistic<?, ?>>emptySet())));
+ TestModel model = new TestModel(null, new TestInjector(attrInjector));
TestCar<?> testCar = new TestStandardCarImpl(Collections.<String,Object>singletonMap("name", "Arthur"), model);
@@ -191,7 +214,7 @@ public class InjectedAttributeTest exten
final ConfiguredDerivedInjectedAttribute<?, ?> attrInjector =
new ConfiguredDerivedInjectedAttribute<TestCar<?>, Integer>("meaningOfLife",
method,
- false,
+ null, false,
false,
"",
false,
@@ -199,8 +222,7 @@ public class InjectedAttributeTest exten
"",
validator);
- TestModel model = new TestModel(null, Collections.<ConfiguredObjectAttributeInjector>singleton(new TestInjector(Collections.<ConfiguredObjectInjectedAttribute<?, ?>>singletonList(
- attrInjector), Collections.<ConfiguredObjectInjectedStatistic<?, ?>>emptySet())));
+ TestModel model = new TestModel(null, new TestInjector(attrInjector));
TestCar<?> testCar = new TestStandardCarImpl(Collections.<String,Object>singletonMap("name", "Arthur"), model);
@@ -227,13 +249,13 @@ public class InjectedAttributeTest exten
final ConfiguredObjectInjectedStatistic<?, ?> statInjector =
new ConfiguredObjectInjectedStatistic<TestCar<?>, Integer>("meaningOfLife",
method,
- "",
+ null, "",
validator,
StatisticUnit.COUNT,
StatisticType.POINT_IN_TIME,
"What is 6 x 9?");
- TestModel model = new TestModel(null, Collections.<ConfiguredObjectAttributeInjector>singleton(new TestInjector(Collections.<ConfiguredObjectInjectedAttribute<?, ?>>emptyList(), Collections.<ConfiguredObjectInjectedStatistic<?, ?>>singletonList(statInjector))));
+ TestModel model = new TestModel(null, new TestInjector(statInjector));
TestCar<?> testCar = new TestStandardCarImpl(Collections.<String,Object>singletonMap("name", "Arthur"), model);
@@ -243,8 +265,154 @@ public class InjectedAttributeTest exten
}
+ public void testInjectedStatisticWithParameters() throws Exception
+ {
+
+ Method method = InjectedAttributeTest.class.getDeclaredMethod("getWhatISent", TestCar.class, Integer.TYPE);
+ InjectedAttributeOrStatistic.TypeValidator validator =
+ new InjectedAttributeOrStatistic.TypeValidator()
+ {
+ @Override
+ public boolean appliesToType(final Class<? extends ConfiguredObject<?>> type)
+ {
+ return TestCar.class.isAssignableFrom(type);
+ }
+ };
+
+ final ConfiguredObjectInjectedStatistic<?, ?> statInjector1 =
+ new ConfiguredObjectInjectedStatistic<TestCar<?>, Integer>("whatISent1",
+ method,
+ new Object[] { 1 }, "",
+ validator,
+ StatisticUnit.COUNT,
+ StatisticType.POINT_IN_TIME,
+ "One");
+ final ConfiguredObjectInjectedStatistic<?, ?> statInjector2 =
+ new ConfiguredObjectInjectedStatistic<TestCar<?>, Integer>("whatISent2",
+ method,
+ new Object[] { 2 }, "",
+ validator,
+ StatisticUnit.COUNT,
+ StatisticType.POINT_IN_TIME,
+ "Two");
+ TestModel model = new TestModel(null, new TestInjector(statInjector1, statInjector2));
+
+ TestCar<?> testCar = new TestStandardCarImpl(Collections.<String,Object>singletonMap("name", "Arthur"), model);
+
+ final Map<String, Number> statistics = testCar.getStatistics();
+ assertEquals("incorrect number of statistics", 2, statistics.size());
+ assertEquals("incorrect statistic value", 1, statistics.get("whatISent1"));
+ assertEquals("incorrect statistic value", 2, statistics.get("whatISent2"));
+ }
+
+
+ public void testInjectedOperation() throws Exception
+ {
+
+ Method method = InjectedAttributeTest.class.getDeclaredMethod("fly", TestCar.class, Integer.TYPE);
+ InjectedAttributeOrStatistic.TypeValidator validator =
+ new InjectedAttributeOrStatistic.TypeValidator()
+ {
+ @Override
+ public boolean appliesToType(final Class<? extends ConfiguredObject<?>> type)
+ {
+ return TestCar.class.isAssignableFrom(type);
+ }
+ };
+
+ final OperationParameter[] params = new OperationParameter[1];
+ params[0] = new OperationParameterFromInjection("height", Integer.TYPE, Integer.TYPE, "", "", new String[0]);
+ final ConfiguredObjectInjectedOperation<?> operationInjector =
+ new ConfiguredObjectInjectedOperation<TestCar<?>>("fly", "", true, params, method, null, validator);
+
+ TestModel model = new TestModel(null, new TestInjector(operationInjector));
+
+ TestCar testCar = new TestStandardCarImpl(Collections.<String,Object>singletonMap("name", "Arthur"), model);
+
+ final Map<String, ConfiguredObjectOperation<?>> allOperations =
+ model.getTypeRegistry().getOperations(testCar.getClass());
+
+ assertTrue("Operation fly(int height) is missing", allOperations.containsKey("fly"));
+
+ final ConfiguredObjectOperation foundOperation = allOperations.get("fly");
+
+ Object result = foundOperation.perform(testCar, Collections.<String, Object>singletonMap("height", 0));
+
+ assertEquals("Car should be able to fly at 0m", Boolean.TRUE, result);
+
+ result = foundOperation.perform(testCar, Collections.<String, Object>singletonMap("height", 5000));
+
+ assertEquals("Car should not be able to fly at 5000m", Boolean.FALSE, result);
+ }
+
+ public void testInjectedOperationWithStaticParams() throws Exception
+ {
+
+ Method method = InjectedAttributeTest.class.getDeclaredMethod("saySomething", TestCar.class, String.class, Integer.TYPE);
+ InjectedAttributeOrStatistic.TypeValidator validator =
+ new InjectedAttributeOrStatistic.TypeValidator()
+ {
+ @Override
+ public boolean appliesToType(final Class<? extends ConfiguredObject<?>> type)
+ {
+ return TestCar.class.isAssignableFrom(type);
+ }
+ };
+
+ final OperationParameter[] params = new OperationParameter[1];
+ params[0] = new OperationParameterFromInjection("count", Integer.TYPE, Integer.TYPE, "", "", new String[0]);
+
+ final ConfiguredObjectInjectedOperation<?> hello =
+ new ConfiguredObjectInjectedOperation<TestCar<?>>("sayHello", "", true, params, method, new String[] { "Hello"}, validator);
+ final ConfiguredObjectInjectedOperation<?> goodbye =
+ new ConfiguredObjectInjectedOperation<TestCar<?>>("sayGoodbye", "", true, params, method, new String[] { "Goodbye"}, validator);
+
+ TestModel model = new TestModel(null, new TestInjector(hello, goodbye));
+
+ TestCar testCar = new TestStandardCarImpl(Collections.<String,Object>singletonMap("name", "Arthur"), model);
+
+ final Map<String, ConfiguredObjectOperation<?>> allOperations =
+ model.getTypeRegistry().getOperations(testCar.getClass());
+
+ assertTrue("Operation sayHello(int count) is missing", allOperations.containsKey("sayHello"));
+ assertTrue("Operation sayGoodbye(int count) is missing", allOperations.containsKey("sayGoodbye"));
+
+ final ConfiguredObjectOperation helloOperation = allOperations.get("sayHello");
+ final ConfiguredObjectOperation goodbyeOperation = allOperations.get("sayGoodbye");
+
+ Object result = helloOperation.perform(testCar, Collections.<String, Object>singletonMap("count", 3));
+
+ assertEquals("Car should say 'Hello' 3 times", Arrays.asList("Hello", "Hello", "Hello"), result);
+
+ result = goodbyeOperation.perform(testCar, Collections.<String, Object>singletonMap("count", 1));
+
+ assertEquals("Car say 'Goodbye' once", Collections.singletonList("Goodbye"), result);
+ }
+
+
public static int getMeaningOfLife(TestCar<?> car)
{
return 42;
}
+
+
+ public static int getWhatISent(TestCar<?> car, int whatIsent)
+ {
+ return whatIsent;
+ }
+
+ public static boolean fly(TestCar<?> car, int height)
+ {
+ return height == 0;
+ }
+
+ public static List<String> saySomething(TestCar<?> car, String whatToSay, int count)
+ {
+ List<String> list = new ArrayList<>();
+ for(int i = 0; i < count; i++)
+ {
+ list.add(whatToSay);
+ }
+ return list;
+ }
}
Modified: qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java Tue Feb 9 12:05:58 2016
@@ -23,12 +23,14 @@ package org.apache.qpid.server.model.tes
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Set;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry;
import org.apache.qpid.server.model.Model;
+import org.apache.qpid.server.plugin.ConfiguredObjectAttributeInjector;
import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;
public class TestModel extends Model
@@ -50,11 +52,23 @@ public class TestModel extends Model
public TestModel(final ConfiguredObjectFactory objectFactory)
{
+ this(objectFactory, Collections.<ConfiguredObjectAttributeInjector>emptySet());
+ }
+
+ public TestModel(final ConfiguredObjectFactory objectFactory, ConfiguredObjectAttributeInjector injector)
+ {
+ this(objectFactory, Collections.singleton(injector));
+ }
+
+ public TestModel(final ConfiguredObjectFactory objectFactory, Set<ConfiguredObjectAttributeInjector> attributeInjectors)
+ {
_objectFactory = objectFactory == null ? new ConfiguredObjectFactoryImpl(this) : objectFactory;
ConfiguredObjectRegistration configuredObjectRegistration = new ConfiguredObjectRegistrationImpl();
- _registry = new ConfiguredObjectTypeRegistry(Collections.singletonList(configuredObjectRegistration), Collections.EMPTY_LIST, _objectFactory);
+ _registry = new ConfiguredObjectTypeRegistry(Collections.singletonList(configuredObjectRegistration),
+ attributeInjectors,
+ Collections.EMPTY_LIST, _objectFactory);
}
Modified: qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java Tue Feb 9 12:05:58 2016
@@ -51,6 +51,13 @@ public class TestStandardCarImpl extends
_securityManager = new TestSecurityManager(this);
}
+ public TestStandardCarImpl(final Map<String, Object> attributes, TestModel model)
+ {
+ super(parentsMap(), attributes, newTaskExecutor(), model);
+ _securityManager = new TestSecurityManager(this);
+ }
+
+
private static CurrentThreadTaskExecutor newTaskExecutor()
{
CurrentThreadTaskExecutor currentThreadTaskExecutor = new CurrentThreadTaskExecutor();
Modified: qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java Tue Feb 9 12:05:58 2016
@@ -42,6 +42,7 @@ import org.apache.qpid.server.model.Mode
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.StateTransition;
import org.apache.qpid.server.model.testmodels.TestSecurityManager;
+import org.apache.qpid.server.plugin.ConfiguredObjectAttributeInjector;
import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;
import org.apache.qpid.server.security.SecurityManager;
@@ -219,7 +220,9 @@ public class TestConfiguredObject extend
return TestConfiguredObjectModel.class.getSimpleName();
}
};
- _configuredObjectTypeRegistry = new ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration), CATEGORIES,
+ _configuredObjectTypeRegistry = new ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration),
+ Collections.<ConfiguredObjectAttributeInjector>emptySet(),
+ CATEGORIES,
_configuredObjectFactory);
}
Modified: qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java Tue Feb 9 12:05:58 2016
@@ -27,6 +27,7 @@ import org.apache.qpid.server.model.Conf
import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry;
import org.apache.qpid.server.model.Model;
+import org.apache.qpid.server.plugin.ConfiguredObjectAttributeInjector;
import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;
public class TestModel extends Model
@@ -62,7 +63,9 @@ public class TestModel extends Model
return "org.apache.qpid.server.model.testmodels.attribute";
}
};
- _registry = new ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration), getSupportedCategories(), _objectFactory);
+ _registry = new ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration),
+ Collections.<ConfiguredObjectAttributeInjector>emptySet(),
+ getSupportedCategories(), _objectFactory);
}
Modified: qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java (original)
+++ qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java Tue Feb 9 12:05:58 2016
@@ -28,10 +28,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.ConfiguredAutomatedAttribute;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectAttribute;
import org.apache.qpid.server.model.ConfiguredObjectOperation;
+import org.apache.qpid.server.model.ConfiguredSettableAttribute;
import org.apache.qpid.server.model.ManagedObject;
import org.apache.qpid.server.model.Model;
import org.apache.qpid.server.model.OperationParameter;
@@ -395,8 +395,8 @@ public class ApiDocsServlet extends Abst
{
final Class type = attribute.getType();
return renderType(type,
- attribute instanceof ConfiguredAutomatedAttribute && ((ConfiguredAutomatedAttribute)attribute).hasValidValues()
- ? ((ConfiguredAutomatedAttribute)attribute).validValues() : null);
+ attribute instanceof ConfiguredSettableAttribute && ((ConfiguredSettableAttribute)attribute).hasValidValues()
+ ? ((ConfiguredSettableAttribute)attribute).validValues() : null);
}
Modified: qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java (original)
+++ qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java Tue Feb 9 12:05:58 2016
@@ -39,12 +39,12 @@ import javax.servlet.http.HttpServletRes
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
-import org.apache.qpid.server.model.ConfiguredAutomatedAttribute;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectAttribute;
import org.apache.qpid.server.model.ConfiguredObjectOperation;
import org.apache.qpid.server.model.ConfiguredObjectStatistic;
import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry;
+import org.apache.qpid.server.model.ConfiguredSettableAttribute;
import org.apache.qpid.server.model.ManagedObject;
import org.apache.qpid.server.model.Model;
import org.apache.qpid.server.model.OperationParameter;
@@ -167,9 +167,9 @@ public class MetaDataServlet extends Abs
{
attrDetails.put("derived", attribute.isDerived());
}
- if (attribute.isAutomated())
+ if (!attribute.isDerived())
{
- ConfiguredAutomatedAttribute automatedAttribute = (ConfiguredAutomatedAttribute) attribute;
+ ConfiguredSettableAttribute automatedAttribute = (ConfiguredSettableAttribute) attribute;
if (!"".equals(automatedAttribute.defaultValue()))
{
attrDetails.put("defaultValue", automatedAttribute.defaultValue());
@@ -184,7 +184,7 @@ public class MetaDataServlet extends Abs
}
if (!(automatedAttribute.validValues()).isEmpty())
{
- Collection<String> validValues = ((ConfiguredAutomatedAttribute<?, ?>) attribute).validValues();
+ Collection<String> validValues = ((ConfiguredSettableAttribute<?, ?>) attribute).validValues();
Collection<Object> convertedValues = new ArrayList<>(validValues.size());
for (String value : validValues)
Modified: qpid/java/branches/6.0.x/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java?rev=1729365&r1=1729364&r2=1729365&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java (original)
+++ qpid/java/branches/6.0.x/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java Tue Feb 9 12:05:58 2016
@@ -38,6 +38,7 @@ import java.util.Set;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectAttribute;
+import org.apache.qpid.server.model.ConfiguredObjectMethodAttribute;
import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry;
import org.apache.qpid.server.model.Model;
import org.apache.qpid.test.utils.QpidTestCase;
@@ -229,7 +230,7 @@ public class ConfiguredObjectToMapConver
ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry();
final Map<String, ConfiguredObjectAttribute<?, ?>> attributeTypes =
typeRegistry.getAttributeTypes(TestChild.class);
- final ConfiguredObjectAttribute longAttr = mock(ConfiguredObjectAttribute.class);
+ final ConfiguredObjectAttribute longAttr = mock(ConfiguredObjectMethodAttribute.class);
when(longAttr.isOversized()).thenReturn(true);
when(longAttr.getOversizedAltText()).thenReturn("");
when(attributeTypes.get(eq("longAttr"))).thenReturn(longAttr);
@@ -310,7 +311,7 @@ public class ConfiguredObjectToMapConver
Model model = createTestModel();
ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry();
Map<String, ConfiguredObjectAttribute<?, ?>> attributeTypes = typeRegistry.getAttributeTypes(TestChild.class);
- ConfiguredObjectAttribute secureAttribute = mock(ConfiguredObjectAttribute.class);
+ ConfiguredObjectAttribute secureAttribute = mock(ConfiguredObjectMethodAttribute.class);
when(secureAttribute.isSecure()).thenReturn(true);
when(secureAttribute.isSecureValue(any())).thenReturn(true);
when(attributeTypes.get(eq("secureAttribute"))).thenReturn(secureAttribute);
@@ -391,7 +392,7 @@ public class ConfiguredObjectToMapConver
when(model.getChildTypes(ConfiguredObject.class)).thenReturn(list);
final ConfiguredObjectTypeRegistry typeRegistry = mock(ConfiguredObjectTypeRegistry.class);
final Map<String, ConfiguredObjectAttribute<?, ?>> attrTypes = mock(Map.class);
- when(attrTypes.get(any(String.class))).thenReturn(mock(ConfiguredObjectAttribute.class));
+ when(attrTypes.get(any(String.class))).thenReturn(mock(ConfiguredObjectMethodAttribute.class));
when(typeRegistry.getAttributeTypes(any(Class.class))).thenReturn(attrTypes);
when(model.getTypeRegistry()).thenReturn(typeRegistry);
return model;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org