public class ImplementationsReader extends AbstractXMLStreaming
The XML files that this class parses look like this, for some value of foobar:
Example:
<foobar-implementations>
<foobar-implementation class="com.example.MyFoobarImplementation"/>
</foobar-implementations>
| Constructor and Description |
|---|
ImplementationsReader(String name)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<T> List<T> |
findImplementations(Class<T> type,
String resource)
Find all available implementations based on reading all XML files on the classpath at the specified resource name.
|
List<String> |
parse(InputStream input)
Parse the XML input and return the list of class names.
|
void |
setConstructorParameterLists(List<Object[]> list)
Configure constructor parameter lists.
|
expect, expectClose, getAttr, getAttr, getBooleanAttr, getBooleanAttr, getIntAttr, getIntAttr, getLongAttr, writeElementprotected final Logger log
public ImplementationsReader(String name)
name - base name for XML tags (e.g., "foobar")IllegalArgumentException - if name is nullpublic void setConstructorParameterLists(List<Object[]> list)
By default, only default constructors are tried. This method allows configuring a list of possible constructors to try, by supplying corresponding parameter lists. The parameter lists will be tried in order.
If multiple constructors are compatible with a given parameter list, which one gets chosen is indeterminate.
list - list of constructor parameter lists to tryIllegalArgumentException - if list is nullIllegalArgumentException - if list is emptyIllegalArgumentException - if list contains a null entrypublic List<String> parse(InputStream input) throws XMLStreamException
input - XML inputIllegalArgumentException - if input is nullXMLStreamException - if XML parse failspublic <T> List<T> findImplementations(Class<T> type, String resource)
If any errors occur, they are logged but otherwise ignored.
T - implementation typetype - required implementation typeresource - XML file classpath resourceIllegalArgumentException - if either parameter is nullCopyright © 2016. All rights reserved.