public class BeanXMLLoader extends Object
This is the principle means of loading beans, allowing XML files to provide inversion of control.
Modifier and Type | Method and Description |
---|---|
static <T> T |
loadBean(Path path)
Creates a bean by loading an XML description from the filesystem
|
static <T> T |
loadBean(Path path,
String xmlPath)
Creates a bean by loading an XML description from the filesystem.
|
static <T extends AssociateXMLUponLoad> |
loadBeanAssociatedXml(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.
|
public static <T> T loadBean(Path path) throws BeanXMLException
Assumes the bean is embedded in a single element <bean> and </bean>
T
- bean-typepath
- file-path to the file containing the XMLBeanXMLException
- if something goes wrongpublic static <T> T loadBean(Path path, String xmlPath) throws BeanXMLException
Exceptions are summarized and user-friendly
T
- bean-typepath
- file-path to the file containing the XMLxmlPath
- xml-path to where the bean is located within the XMLBeanXMLException
- if something goes wrongpublic static <T> T loadBeanLocalized(Path path, String xmlPath) throws BeanXMLException, LocalisedBeanException
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.
T
- bean-typepath
- file-path to the file containing the XMLxmlPath
- xml-path to where the bean is located within the XMLBeanXMLException
- problem with reading the beanXML from the filesystemLocalisedBeanException
- problem occurs somewhere processing a configurationpublic static <T extends AssociateXMLUponLoad> T loadBeanAssociatedXml(Path path, String xmlPath) throws BeanXMLException
Additionally associated the XmlConfiguration with the created Bean
T
- bean-typepath
- file-path to the file containing the XMLxmlPath
- xml-path to where the bean is located within the XMLBeanXMLException
- if something goes wrongCopyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.