|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.xml.Instantiator
public abstract class Instantiator
Utilities to use an XML to instantiate Java objects, using reflection. This is used by various configuration-read code, which all perform similar tasks of instantiating and configurating certain objects. Supported are schemes like
<class name="class name">
<param name="parameter name">parameter value</param>
...
</class>
and
<anyelement class="class name">
<param name="parameter name">parameter value</param>
...
</anyname>
Param subtags are matched with 'setters' on the created object.
| Constructor Summary | |
|---|---|
Instantiator()
|
|
| Method Summary | |
|---|---|
static Object |
getInstance(Element classElement,
Object... args)
Instantiates any object using an Dom Element and constructor arguments. |
static Object |
getInstanceWithSubElement(Element element,
Object... args)
Instantiates on object with the first child with name 'class'. |
static void |
setParameters(Element element,
Object o)
|
static void |
setProperty(String name,
Class claz,
Object o,
String value)
Given the name of a property, a clazz, an object and a value, set the property on the object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Instantiator()
| Method Detail |
|---|
public static Object getInstance(Element classElement,
Object... args)
throws SAXException,
ClassNotFoundException,
NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException
classElement - a 'class' element with a 'name' attribute,
or any element with a 'class' attribute. Finally if this any element has no 'class' attribute, it will try 'name' too.args - Constructor arguments.
null.
NoSuchMethodError - If not matching constructor could be found
ClassNotFoundException - If the specified class does not exist.
SAXException
NoSuchMethodException
InstantiationException
IllegalAccessException
InvocationTargetException
public static void setParameters(Element element,
Object o)
public static void setProperty(String name,
Class claz,
Object o,
String value)
Casting.toType(Class, Object).
value - The value as a String
public static Object getInstanceWithSubElement(Element element,
Object... args)
throws SAXException,
ClassNotFoundException,
NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException
getInstance(Element, Object...).
element - Element in which a child specifying a java object must be searched.
null if no matching child found.
SAXException
ClassNotFoundException
NoSuchMethodException
InstantiationException
IllegalAccessException
InvocationTargetException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||