Package org.jboss.as.connector.util
Class Injection
- java.lang.Object
-
- org.jboss.as.connector.util.Injection
-
public class Injection extends Object
Injection utility which can inject values into objects. This file is a copy of thecom.github.fungal.api.util.Injectionclass.- Author:
- Jesper Pedersen
-
-
Constructor Summary
Constructors Constructor Description Injection()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected FieldfindField(Class<?> clz, String fieldName, String fieldType)Find a fieldprotected MethodfindMethod(Class<?> clz, String methodName, String propertyType)Find a methodprotected StringgetSubstitutionValue(String input)System property substitutionprotected ObjectgetValue(String name, Class<?> clz, Object v, ClassLoader cl)Get the valuevoidinject(Object object, String propertyName, Object propertyValue)Inject a value into an object propertyvoidinject(Object object, String propertyName, Object propertyValue, String propertyType)Inject a value into an object propertyvoidinject(Object object, String propertyName, Object propertyValue, String propertyType, boolean includeFields)Inject a value into an object property
-
-
-
Method Detail
-
inject
public void inject(Object object, String propertyName, Object propertyValue) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
Inject a value into an object property- Parameters:
object- The objectpropertyName- The property namepropertyValue- The property value- Throws:
NoSuchMethodException- If the property method cannot be foundIllegalAccessException- If the property method cannot be accessedInvocationTargetException- If the property method cannot be executed
-
inject
public void inject(Object object, String propertyName, Object propertyValue, String propertyType) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
Inject a value into an object property- Parameters:
object- The objectpropertyName- The property namepropertyValue- The property valuepropertyType- The property type as a fully quilified class name- Throws:
NoSuchMethodException- If the property method cannot be foundIllegalAccessException- If the property method cannot be accessedInvocationTargetException- If the property method cannot be executed
-
inject
public void inject(Object object, String propertyName, Object propertyValue, String propertyType, boolean includeFields) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
Inject a value into an object property- Parameters:
object- The objectpropertyName- The property namepropertyValue- The property valuepropertyType- The property type as a fully quilified class nameincludeFields- Should fields be included for injection if a method can't be found- Throws:
NoSuchMethodException- If the property method cannot be foundIllegalAccessException- If the property method cannot be accessedInvocationTargetException- If the property method cannot be executed
-
findMethod
protected Method findMethod(Class<?> clz, String methodName, String propertyType)
Find a method- Parameters:
clz- The classmethodName- The method namepropertyType- The property type; can benull- Returns:
- The method;
nullif not found
-
findField
protected Field findField(Class<?> clz, String fieldName, String fieldType)
Find a field- Parameters:
clz- The classfieldName- The field namefieldType- The field type; can benull- Returns:
- The field;
nullif not found
-
getValue
protected Object getValue(String name, Class<?> clz, Object v, ClassLoader cl) throws Exception
Get the value- Parameters:
name- The value nameclz- The value classv- The valuecl- The class loader- Returns:
- The substituted value
- Throws:
Exception- Thrown in case of an error
-
-