Class XmlConfiguration.JettyXmlConfiguration
- java.lang.Object
-
- org.eclipse.jetty.xml.XmlConfiguration.JettyXmlConfiguration
-
- All Implemented Interfaces:
ConfigurationProcessor
- Enclosing class:
- XmlConfiguration
private static class XmlConfiguration.JettyXmlConfiguration extends java.lang.Object implements ConfigurationProcessor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classXmlConfiguration.JettyXmlConfiguration.Argsprivate classXmlConfiguration.JettyXmlConfiguration.AttrOrElementNode
-
Field Summary
Fields Modifier and Type Field Description (package private) XmlConfiguration_configuration(package private) XmlParser.Node_root
-
Constructor Summary
Constructors Modifier Constructor Description privateJettyXmlConfiguration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappendDefaultPropertyValues(java.lang.StringBuilder defValues, XmlParser.Node node)private java.lang.Objectcall(java.lang.Class<?> oClass, java.lang.String methodName, java.lang.Object obj, XmlConfiguration.JettyXmlConfiguration.Args args)private java.lang.Objectcall(java.lang.Object obj, XmlParser.Node node)Calls a method.java.lang.Objectconfigure()java.lang.Objectconfigure(java.lang.Object obj)voidconfigure(java.lang.Object obj, XmlParser.Node cfg, int i)Recursive configuration routine.private java.lang.Objectconstruct(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.StringdefaultValue(java.lang.Object obj, XmlParser.Node node)Check children for all<Property>and<SystemProperty>and return the String representation of any declareddefault="value"attributes.private java.lang.ObjectenvObj(XmlParser.Node node)Returns the value of an environment property.private java.lang.Objectget(java.lang.Object obj, XmlParser.Node node)Calls a getter method.private java.lang.ObjectgetField(java.lang.reflect.Field field, java.lang.Object object)voidinit(java.net.URL url, XmlParser.Node root, XmlConfiguration configuration)voidinit(Resource resource, XmlParser.Node root, XmlConfiguration configuration)Initialize a ConfigurationProcessor from provided Resource and XMLprivate java.lang.ObjectinvokeConstructor(java.lang.reflect.Constructor<?> constructor, java.lang.Object... args)private java.lang.ObjectinvokeMethod(java.lang.reflect.Method method, java.lang.Object obj, java.lang.Object[] args)private java.lang.ObjectinvokeMethod(java.lang.reflect.Method method, java.lang.Object obj, java.lang.Object[] args, boolean isUsingDefaultValue)private static booleanisTypeMatchingClass(java.lang.String type, java.lang.Class<?> classToMatch)private java.lang.ObjectitemValue(java.lang.Object obj, java.lang.Object item)Returns recursively the value of an element.private java.lang.ObjectnewArray(java.lang.Object obj, XmlParser.Node node)Creates a new array object.private java.lang.ObjectnewMap(java.lang.Object obj, XmlParser.Node node)Creates a new map object.private java.lang.ObjectnewObj(java.lang.Object obj, XmlParser.Node node)Creates a new value object.private static java.lang.Class<?>nodeClass(XmlParser.Node node)private java.lang.ObjectpropertyObj(XmlParser.Node node)Returns the value of a property.private voidput(java.lang.Object obj, XmlParser.Node node)Calls a put method.private java.lang.ObjectrefObj(XmlParser.Node node)Returns a reference object mapped to an id.private voidset(java.lang.Object obj, XmlParser.Node node)Call a setter method.private voidsetField(java.lang.reflect.Field field, java.lang.Object obj, java.lang.Object arg, boolean isUsingDefaultValue)private java.lang.ObjectsystemPropertyObj(XmlParser.Node node)Returns the value of a system property.private java.lang.Objectvalue(java.lang.Object obj, XmlParser.Node node)Returns the scalar value of an element
-
-
-
Field Detail
-
_root
XmlParser.Node _root
-
_configuration
XmlConfiguration _configuration
-
-
Method Detail
-
init
public void init(java.net.URL url, XmlParser.Node root, XmlConfiguration configuration)- Specified by:
initin interfaceConfigurationProcessor
-
init
public void init(Resource resource, XmlParser.Node root, XmlConfiguration configuration)
Description copied from interface:ConfigurationProcessorInitialize a ConfigurationProcessor from provided Resource and XML- Specified by:
initin interfaceConfigurationProcessor- Parameters:
resource- the resource being readroot- the parsed XML root node for the resourceconfiguration- the configuration being used (typically for ref IDs)
-
configure
public java.lang.Object configure(java.lang.Object obj) throws java.lang.Exception- Specified by:
configurein interfaceConfigurationProcessor- Throws:
java.lang.Exception
-
configure
public java.lang.Object configure() throws java.lang.Exception- Specified by:
configurein interfaceConfigurationProcessor- Throws:
java.lang.Exception
-
nodeClass
private static java.lang.Class<?> nodeClass(XmlParser.Node node) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
configure
public void configure(java.lang.Object obj, XmlParser.Node cfg, int i) throws java.lang.ExceptionRecursive configuration routine. This method applies the nested Set, Put, Call, etc. elements to the given object.- Parameters:
obj- the object to configurecfg- the XML nodes of the configurationi- the index of the XML nodes- Throws:
java.lang.Exception- if the configuration fails
-
set
private void set(java.lang.Object obj, XmlParser.Node node) throws java.lang.ExceptionCall 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:
- Trying for a trivial type match
- Looking for a native type match
- Trying all correctly named methods for an auto conversion
- Attempting to construct a suitable value from original value
- Parameters:
obj- the enclosing objectnode- the <Set> XML node- Throws:
java.lang.Exception
-
invokeConstructor
private java.lang.Object invokeConstructor(java.lang.reflect.Constructor<?> constructor, java.lang.Object... args) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException- Throws:
java.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetExceptionjava.lang.InstantiationException
-
invokeMethod
private 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- Throws:
java.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException
-
invokeMethod
private 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- Throws:
java.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException
-
getField
private java.lang.Object getField(java.lang.reflect.Field field, java.lang.Object object) throws java.lang.IllegalAccessException- Throws:
java.lang.IllegalAccessException
-
setField
private void setField(java.lang.reflect.Field field, java.lang.Object obj, java.lang.Object arg, boolean isUsingDefaultValue) throws java.lang.IllegalAccessException- Throws:
java.lang.IllegalAccessException
-
convertArrayToCollection
private static java.util.Collection<?> convertArrayToCollection(java.lang.Object array, java.lang.Class<?> collectionType)- Parameters:
array- the array to convertcollectionType- the desired collection type- Returns:
- a collection of the desired type if the array can be converted
-
convertArrayToArrayList
private static java.util.ArrayList<java.lang.Object> convertArrayToArrayList(java.lang.Object array)
-
put
private void put(java.lang.Object obj, XmlParser.Node node) throws java.lang.ExceptionCalls a put method.
- Parameters:
obj- the enclosing map objectnode- the <Put> XML node- Throws:
java.lang.Exception
-
get
private java.lang.Object get(java.lang.Object obj, XmlParser.Node node) throws java.lang.ExceptionCalls 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.
- Parameters:
obj- the enclosing objectnode- the <Get> XML node- Returns:
- the result of the getter invocation
- Throws:
java.lang.Exception
-
call
private java.lang.Object call(java.lang.Object obj, XmlParser.Node node) throws java.lang.ExceptionCalls 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.
- Parameters:
obj- the enclosing objectnode- the <Call> XML node- Returns:
- the result of the method invocation
- Throws:
java.lang.Exception
-
call
private 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- Throws:
java.lang.reflect.InvocationTargetExceptionjava.lang.NoSuchMethodException
-
newObj
private java.lang.Object newObj(java.lang.Object obj, XmlParser.Node node) throws java.lang.ExceptionCreates a new value object.
- Parameters:
obj- the enclosing objectnode- the <New> XML node- Returns:
- the result of the constructor invocation
- Throws:
java.lang.Exception
-
construct
private java.lang.Object construct(java.lang.Class<?> klass, XmlConfiguration.JettyXmlConfiguration.Args args) throws java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException- Throws:
java.lang.reflect.InvocationTargetExceptionjava.lang.NoSuchMethodException
-
refObj
private java.lang.Object refObj(XmlParser.Node node) throws java.lang.Exception
Returns a reference object mapped to an id.
- Parameters:
node- the <Ref> XML node- Returns:
- the result of the reference invocation
- Throws:
java.lang.Exception
-
newArray
private java.lang.Object newArray(java.lang.Object obj, XmlParser.Node node) throws java.lang.ExceptionCreates a new array object.
- Parameters:
obj- the enclosing objectnode- the <Array> XML node- Returns:
- the newly created array
- Throws:
java.lang.Exception
-
newMap
private java.lang.Object newMap(java.lang.Object obj, XmlParser.Node node) throws java.lang.ExceptionCreates a new map object.
- Parameters:
obj- the enclosing objectnode- the <Map> XML node- Returns:
- the newly created map
- Throws:
java.lang.Exception
-
propertyObj
private java.lang.Object propertyObj(XmlParser.Node node) throws java.lang.Exception
Returns the value of a property.
- Parameters:
node- the <Property> XML node- Returns:
- the property value
- Throws:
java.lang.Exception
-
systemPropertyObj
private java.lang.Object systemPropertyObj(XmlParser.Node node) throws java.lang.Exception
Returns the value of a system property.
- Parameters:
node- the <SystemProperty> XML node- Returns:
- the property value
- Throws:
java.lang.Exception
-
envObj
private java.lang.Object envObj(XmlParser.Node node) throws java.lang.Exception
Returns the value of an environment property.
- Parameters:
node- the <Env> XML node- Returns:
- the environment property value
- Throws:
java.lang.Exception
-
defaultValue
private java.lang.String defaultValue(java.lang.Object obj, XmlParser.Node node) throws java.lang.ExceptionCheck children for all<Property>and<SystemProperty>and return the String representation of any declareddefault="value"attributes.- Parameters:
obj- the enclosing objnode- the XML node- Returns:
- a String representing all
<Property default="...">and<SystemProperty default="...">values appended together - Throws:
java.lang.Exception
-
appendDefaultPropertyValues
private void appendDefaultPropertyValues(java.lang.StringBuilder defValues, XmlParser.Node node) throws java.lang.Exception- Throws:
java.lang.Exception
-
value
private java.lang.Object value(java.lang.Object obj, XmlParser.Node node) throws java.lang.ExceptionReturns 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.
- Parameters:
obj- the enclosing objectnode- the XML node- Returns:
- the value of the XML node
- Throws:
java.lang.Exception
-
isTypeMatchingClass
private static boolean isTypeMatchingClass(java.lang.String type, java.lang.Class<?> classToMatch)
-
itemValue
private java.lang.Object itemValue(java.lang.Object obj, java.lang.Object item) throws java.lang.ExceptionReturns recursively the value of an element.
- Parameters:
obj- the enclosing objectitem- the initial element value- Returns:
- the recursive value of the element
- Throws:
java.lang.Exception
-
-