Class BeanXMLLoader

Object
BeanXMLLoader

public class BeanXMLLoader extends Object
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 Details

    • loadBean

      public static <T> T loadBean(Path path) throws BeanXMLException
      Creates a bean by loading an XML description from the filesystem

      Assumes 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

      public static <T> T loadBean(Path path, String xmlPath) throws BeanXMLException
      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 XML
      xmlPath - 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 XML
      xmlPath - xml-path to where the bean is located within the XML
      Returns:
      an initialized bean
      Throws:
      BeanXMLException - problem with reading the beanXML from the filesystem
      LocalisedBeanException - 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 XML
      xmlPath - xml-path to where the bean is located within the XML
      Returns:
      an initialized bean
      Throws:
      BeanXMLException - if something goes wrong