Package org.anchoranalysis.bean.xml
Class BeanXMLLoader
Object
BeanXMLLoader
Creates beans based on XML specifying their properties (including nested children).
This is the principle means of loading beans, allowing XML files to provide inversion of control.
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
Creates a bean by loading an XML description from the filesystemstatic <T> T
Creates a bean by loading an XML description from the filesystem.static <T extends AssociateXMLUponLoad>
TloadBeanAssociatedXml
(Path path, String xmlPath) Creates a bean by loading an XML description from the filesystem.static <T> T
loadBeanLocalized
(Path path, String xmlPath) Creates a bean by loading an XML description from the filesystem.
-
Method Details
-
loadBean
Creates a bean by loading an XML description from the filesystemAssumes the bean is embedded in a single element
<bean> and </bean>
- Type Parameters:
T
- bean-type- Parameters:
path
- file-path to the file containing the XML- Returns:
- an initialized bean
- Throws:
BeanXMLException
- if something goes wrong
-
loadBean
Creates a bean by loading an XML description from the filesystem.Exceptions are summarized and user-friendly
- Type Parameters:
T
- bean-type- Parameters:
path
- file-path to the file containing the XMLxmlPath
- xml-path to where the bean is located within the XML- Returns:
- an initialized bean
- Throws:
BeanXMLException
- if something goes wrong
-
loadBeanLocalized
public static <T> T loadBeanLocalized(Path path, String xmlPath) throws BeanXMLException, LocalisedBeanException Creates a bean by loading an XML description from the filesystem.Does not create summarized and user-friendly exception, but throws lots of LocalisedBeanException exceptions.
This should only be called from an IncludeFactory where we deliberately want these LocalisedBeanException exceptions to be thrown, as a way of getting a include-file trace.
- Type Parameters:
T
- bean-type- Parameters:
path
- file-path to the file containing the XMLxmlPath
- xml-path to where the bean is located within the XML- Returns:
- an initialized bean
- Throws:
BeanXMLException
- problem with reading the beanXML from the filesystemLocalisedBeanException
- problem occurs somewhere processing a configuration
-
loadBeanAssociatedXml
public static <T extends AssociateXMLUponLoad> T loadBeanAssociatedXml(Path path, String xmlPath) throws BeanXMLException Creates a bean by loading an XML description from the filesystem.Additionally associated the XmlConfiguration with the created Bean
- Type Parameters:
T
- bean-type- Parameters:
path
- file-path to the file containing the XMLxmlPath
- xml-path to where the bean is located within the XML- Returns:
- an initialized bean
- Throws:
BeanXMLException
- if something goes wrong
-