private static class XmlConfiguration.JettyXmlConfiguration extends java.lang.Object implements ConfigurationProcessor
| Modifier and Type | Class and Description |
|---|---|
private class |
XmlConfiguration.JettyXmlConfiguration.Args |
private class |
XmlConfiguration.JettyXmlConfiguration.AttrOrElementNode |
| Modifier and Type | Field and Description |
|---|---|
(package private) XmlConfiguration |
_configuration |
(package private) XmlParser.Node |
_root |
| Modifier | Constructor and Description |
|---|---|
private |
JettyXmlConfiguration() |
| Modifier and Type | Method and Description |
|---|---|
private void |
appendDefaultPropertyValues(java.lang.StringBuilder defValues,
XmlParser.Node node) |
private java.lang.Object |
call(java.lang.Class<?> oClass,
java.lang.String methodName,
java.lang.Object obj,
XmlConfiguration.JettyXmlConfiguration.Args args) |
private java.lang.Object |
call(java.lang.Object obj,
XmlParser.Node node)
Calls a method.
|
java.lang.Object |
configure() |
java.lang.Object |
configure(java.lang.Object obj) |
void |
configure(java.lang.Object obj,
XmlParser.Node cfg,
int i)
Recursive configuration routine.
|
private java.lang.Object |
construct(java.lang.Class<?> klass,
XmlConfiguration.JettyXmlConfiguration.Args args) |
private static java.util.ArrayList<java.lang.Object> |
convertArrayToArrayList(java.lang.Object array) |
private static java.util.Collection<?> |
convertArrayToCollection(java.lang.Object array,
java.lang.Class<?> collectionType) |
private java.lang.String |
defaultValue(java.lang.Object obj,
XmlParser.Node node)
Check children for all
<Property> and <SystemProperty> and return
the String representation of any declared default="value" attributes. |
private java.lang.Object |
envObj(XmlParser.Node node)
Returns the value of an environment property.
|
private java.lang.Object |
get(java.lang.Object obj,
XmlParser.Node node)
Calls a getter method.
|
private java.lang.Object |
getField(java.lang.reflect.Field field,
java.lang.Object object) |
void |
init(Resource resource,
XmlParser.Node root,
XmlConfiguration configuration)
Initialize a ConfigurationProcessor from provided Resource and XML
|
void |
init(java.net.URL url,
XmlParser.Node root,
XmlConfiguration configuration) |
private java.lang.Object |
invokeConstructor(java.lang.reflect.Constructor<?> constructor,
java.lang.Object... args) |
private java.lang.Object |
invokeMethod(java.lang.reflect.Method method,
java.lang.Object obj,
java.lang.Object[] args) |
private java.lang.Object |
invokeMethod(java.lang.reflect.Method method,
java.lang.Object obj,
java.lang.Object[] args,
boolean isUsingDefaultValue) |
private static boolean |
isTypeMatchingClass(java.lang.String type,
java.lang.Class<?> classToMatch) |
private java.lang.Object |
itemValue(java.lang.Object obj,
java.lang.Object item)
Returns recursively the value of an element.
|
private java.lang.Object |
newArray(java.lang.Object obj,
XmlParser.Node node)
Creates a new array object.
|
private java.lang.Object |
newMap(java.lang.Object obj,
XmlParser.Node node)
Creates a new map object.
|
private java.lang.Object |
newObj(java.lang.Object obj,
XmlParser.Node node)
Creates a new value object.
|
private static java.lang.Class<?> |
nodeClass(XmlParser.Node node) |
private java.lang.Object |
propertyObj(XmlParser.Node node)
Returns the value of a property.
|
private void |
put(java.lang.Object obj,
XmlParser.Node node)
Calls a put method.
|
private java.lang.Object |
refObj(XmlParser.Node node)
Returns a reference object mapped to an id.
|
private void |
set(java.lang.Object obj,
XmlParser.Node node)
Call a setter method.
|
private void |
setField(java.lang.reflect.Field field,
java.lang.Object obj,
java.lang.Object arg,
boolean isUsingDefaultValue) |
private java.lang.Object |
systemPropertyObj(XmlParser.Node node)
Returns the value of a system property.
|
private java.lang.Object |
value(java.lang.Object obj,
XmlParser.Node node)
Returns the scalar value of an element
|
XmlParser.Node _root
XmlConfiguration _configuration
public void init(java.net.URL url,
XmlParser.Node root,
XmlConfiguration configuration)
init in interface ConfigurationProcessorpublic void init(Resource resource, XmlParser.Node root, XmlConfiguration configuration)
ConfigurationProcessorinit in interface ConfigurationProcessorresource - the resource being readroot - the parsed XML root node for the resourceconfiguration - the configuration being used (typically for ref IDs)public java.lang.Object configure(java.lang.Object obj)
throws java.lang.Exception
configure in interface ConfigurationProcessorjava.lang.Exceptionpublic java.lang.Object configure()
throws java.lang.Exception
configure in interface ConfigurationProcessorjava.lang.Exceptionprivate static java.lang.Class<?> nodeClass(XmlParser.Node node) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionpublic void configure(java.lang.Object obj,
XmlParser.Node cfg,
int i)
throws java.lang.Exception
obj - the object to configurecfg - the XML nodes of the configurationi - the index of the XML nodesjava.lang.Exception - if the configuration failsprivate void set(java.lang.Object obj,
XmlParser.Node node)
throws java.lang.Exception
Call a setter method.
This method makes a best effort to find a matching set method. The type of the value is used to find a suitable set method by:
obj - the enclosing objectnode - the <Set> XML nodejava.lang.Exceptionprivate java.lang.Object invokeConstructor(java.lang.reflect.Constructor<?> constructor,
java.lang.Object... args)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.InstantiationException
java.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetExceptionjava.lang.InstantiationExceptionprivate java.lang.Object invokeMethod(java.lang.reflect.Method method,
java.lang.Object obj,
java.lang.Object[] args)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetExceptionprivate java.lang.Object invokeMethod(java.lang.reflect.Method method,
java.lang.Object obj,
java.lang.Object[] args,
boolean isUsingDefaultValue)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetExceptionprivate java.lang.Object getField(java.lang.reflect.Field field,
java.lang.Object object)
throws java.lang.IllegalAccessException
java.lang.IllegalAccessExceptionprivate void setField(java.lang.reflect.Field field,
java.lang.Object obj,
java.lang.Object arg,
boolean isUsingDefaultValue)
throws java.lang.IllegalAccessException
java.lang.IllegalAccessExceptionprivate static java.util.Collection<?> convertArrayToCollection(java.lang.Object array,
java.lang.Class<?> collectionType)
array - the array to convertcollectionType - the desired collection typeprivate static java.util.ArrayList<java.lang.Object> convertArrayToArrayList(java.lang.Object array)
private void put(java.lang.Object obj,
XmlParser.Node node)
throws java.lang.Exception
Calls a put method.
obj - the enclosing map objectnode - the <Put> XML nodejava.lang.Exceptionprivate java.lang.Object get(java.lang.Object obj,
XmlParser.Node node)
throws java.lang.Exception
Calls a getter method.
Any object returned from the call is passed to the configure method to consume the remaining elements.
If the "class" attribute is present and its value is "class", then the class instance itself is returned.
obj - the enclosing objectnode - the <Get> XML nodejava.lang.Exceptionprivate java.lang.Object call(java.lang.Object obj,
XmlParser.Node node)
throws java.lang.Exception
Calls a method.
A method is selected by trying all methods with matching names and number of arguments. Any object returned from the call is passed to the configure method to consume the remaining elements. Note that if this is a static call we consider only methods declared directly in the given class, i.e. we ignore any static methods in superclasses.
obj - the enclosing objectnode - the <Call> XML nodejava.lang.Exceptionprivate java.lang.Object call(java.lang.Class<?> oClass,
java.lang.String methodName,
java.lang.Object obj,
XmlConfiguration.JettyXmlConfiguration.Args args)
throws java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetExceptionjava.lang.NoSuchMethodExceptionprivate java.lang.Object newObj(java.lang.Object obj,
XmlParser.Node node)
throws java.lang.Exception
Creates a new value object.
obj - the enclosing objectnode - the <New> XML nodejava.lang.Exceptionprivate java.lang.Object construct(java.lang.Class<?> klass,
XmlConfiguration.JettyXmlConfiguration.Args args)
throws java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetExceptionjava.lang.NoSuchMethodExceptionprivate java.lang.Object refObj(XmlParser.Node node) throws java.lang.Exception
Returns a reference object mapped to an id.
node - the <Ref> XML nodejava.lang.Exceptionprivate java.lang.Object newArray(java.lang.Object obj,
XmlParser.Node node)
throws java.lang.Exception
Creates a new array object.
obj - the enclosing objectnode - the <Array> XML nodejava.lang.Exceptionprivate java.lang.Object newMap(java.lang.Object obj,
XmlParser.Node node)
throws java.lang.Exception
Creates a new map object.
obj - the enclosing objectnode - the <Map> XML nodejava.lang.Exceptionprivate java.lang.Object propertyObj(XmlParser.Node node) throws java.lang.Exception
Returns the value of a property.
node - the <Property> XML nodejava.lang.Exceptionprivate java.lang.Object systemPropertyObj(XmlParser.Node node) throws java.lang.Exception
Returns the value of a system property.
node - the <SystemProperty> XML nodejava.lang.Exceptionprivate java.lang.Object envObj(XmlParser.Node node) throws java.lang.Exception
Returns the value of an environment property.
node - the <Env> XML nodejava.lang.Exceptionprivate java.lang.String defaultValue(java.lang.Object obj,
XmlParser.Node node)
throws java.lang.Exception
<Property> and <SystemProperty> and return
the String representation of any declared default="value" attributes.obj - the enclosing objnode - the XML node<Property default="..."> and <SystemProperty default="..."> values appended togetherjava.lang.Exceptionprivate void appendDefaultPropertyValues(java.lang.StringBuilder defValues,
XmlParser.Node node)
throws java.lang.Exception
java.lang.Exceptionprivate java.lang.Object value(java.lang.Object obj,
XmlParser.Node node)
throws java.lang.Exception
Returns the scalar value of an element
.If no value type is specified, then white space is trimmed out of the value. If it contains multiple value elements they are added as strings before being converted to any specified type.
obj - the enclosing objectnode - the XML nodejava.lang.Exceptionprivate static boolean isTypeMatchingClass(java.lang.String type,
java.lang.Class<?> classToMatch)
private java.lang.Object itemValue(java.lang.Object obj,
java.lang.Object item)
throws java.lang.Exception
Returns recursively the value of an element.
obj - the enclosing objectitem - the initial element valuejava.lang.Exception