Package org.jboss.as.connector.util
Class Injection
java.lang.Object
org.jboss.as.connector.util.Injection
Injection utility which can inject values into objects. This file is a copy
of the
com.github.fungal.api.util.Injection class.- Author:
- Jesper Pedersen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected FieldFind 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 a value into an object propertyvoidInject a value into an object propertyvoidinject(Object object, String propertyName, Object propertyValue, String propertyType, boolean includeFields) Inject a value into an object property
-
Constructor Details
-
Injection
public Injection()Constructor
-
-
Method Details
-
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
Find a method- Parameters:
clz- The classmethodName- The method namepropertyType- The property type; can benull- Returns:
- The method;
nullif not found
-
findField
Find a field- Parameters:
clz- The classfieldName- The field namefieldType- The field type; can benull- Returns:
- The field;
nullif not found
-
getValue
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
-
getSubstitutionValue
System property substitution- Parameters:
input- The input string- Returns:
- The output
-