Search in sources :

Example 1 with MethodValue

use of org.jboss.msc.value.MethodValue in project wildfly by wildfly.

the class ParsedServiceDeploymentProcessor method getValue.

private static Value<?> getValue(final ValueFactory valueFactory, final ClassLoader classLoader) throws DeploymentUnitProcessingException {
    final String methodName = valueFactory.getMethodName();
    final ValueFactoryParameter[] parameters = valueFactory.getParameters();
    final List<Class<?>> paramTypes = new ArrayList<Class<?>>(parameters.length);
    final List<Value<?>> paramValues = new ArrayList<Value<?>>(parameters.length);
    for (ValueFactoryParameter parameter : parameters) {
        final Class<?> attributeTypeValue = ReflectionUtils.getClass(parameter.getType(), classLoader);
        paramTypes.add(attributeTypeValue);
        paramValues.add(new ImmediateValue<Object>(newValue(attributeTypeValue, parameter.getValue())));
    }
    final Value<Method> methodValue = new InjectedBeanMethodValue(Values.injectedValue(), new InjectedBeanMethodValue.MethodFinder() {

        @Override
        public Method find(Class<?> clazz) {
            return ReflectionUtils.getMethod(clazz, methodName, paramTypes.toArray(new Class<?>[0]));
        }
    });
    return cached(new MethodValue<Object>(methodValue, Values.injectedValue(), paramValues));
}
Also used : ValueFactoryParameter(org.jboss.as.service.descriptor.JBossServiceAttributeConfig.ValueFactoryParameter) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) Value(org.jboss.msc.value.Value) ImmediateValue(org.jboss.msc.value.ImmediateValue) MethodValue(org.jboss.msc.value.MethodValue)

Aggregations

Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 ValueFactoryParameter (org.jboss.as.service.descriptor.JBossServiceAttributeConfig.ValueFactoryParameter)1 ImmediateValue (org.jboss.msc.value.ImmediateValue)1 MethodValue (org.jboss.msc.value.MethodValue)1 Value (org.jboss.msc.value.Value)1