parent
06e610218b
commit
35c21d7ced
|
@ -54,6 +54,25 @@ public class ArrayUtil
|
|||
return array;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Add arrays
|
||||
* @param array1 An array to add to (or null)
|
||||
* @param array2 An array to add to (or null)
|
||||
* @return new array with contents of both arrays, or null if both arrays are null
|
||||
* @param <T> the array entry type
|
||||
*/
|
||||
public static<T> T[] add(T[] array1, T[] array2)
|
||||
{
|
||||
if (array1==null || array1.length==0)
|
||||
return array2;
|
||||
if (array2==null || array2.length==0)
|
||||
return array1;
|
||||
|
||||
T[] na = Arrays.copyOf(array1,array1.length+array2.length);
|
||||
System.arraycopy(array2,0,na,array1.length,array2.length);
|
||||
return na;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Add element to an array
|
||||
* @param array The array to add to (or null)
|
||||
|
|
|
@ -647,7 +647,7 @@ public class XmlConfiguration
|
|||
|
||||
/*
|
||||
* Call a get method. Any object returned from the call is passed to the configure method to consume the remaining elements. @param obj @param node
|
||||
*
|
||||
* If class attribute is given and the name is "class", then the class instance itself is returned.
|
||||
* @return @exception Exception
|
||||
*/
|
||||
private Object get(Object obj, XmlParser.Node node) throws Exception
|
||||
|
@ -665,9 +665,15 @@ public class XmlConfiguration
|
|||
|
||||
try
|
||||
{
|
||||
// try calling a getXxx method.
|
||||
Method method = oClass.getMethod("get" + name.substring(0,1).toUpperCase(Locale.ENGLISH) + name.substring(1),(java.lang.Class[])null);
|
||||
obj = method.invoke(obj,(java.lang.Object[])null);
|
||||
// Handle getClass explicitly
|
||||
if ("class".equalsIgnoreCase(name))
|
||||
obj=oClass;
|
||||
else
|
||||
{
|
||||
// try calling a getXxx method.
|
||||
Method method = oClass.getMethod("get" + name.substring(0,1).toUpperCase(Locale.ENGLISH) + name.substring(1),(java.lang.Class[])null);
|
||||
obj = method.invoke(obj,(java.lang.Object[])null);
|
||||
}
|
||||
if (id!=null)
|
||||
_configuration.getIdMap().put(id,obj);
|
||||
configure(obj,node,0);
|
||||
|
|
|
@ -221,6 +221,22 @@ public class XmlConfigurationTest
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetClass() throws Exception
|
||||
{
|
||||
XmlConfiguration configuration =
|
||||
new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Test\"><Get name=\"class\"/></Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
configuration.configure(tc);
|
||||
assertEquals(TestConfiguration.class,tc.testObject);
|
||||
|
||||
configuration =
|
||||
new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Test\"><Get class=\"java.lang.String\" name=\"class\"><Get id=\"simple\" name=\"simpleName\"/></Get></Set></Configure>");
|
||||
configuration.configure(tc);
|
||||
assertEquals(String.class,tc.testObject);
|
||||
assertEquals("String",configuration.getIdMap().get("simple"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringConfiguration() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue