Class SpringBeanFactory

java.lang.Object
org.refcodes.factory.alt.spring.SpringBeanFactory
All Implemented Interfaces:
org.refcodes.factory.BeanFactory<String>, org.refcodes.factory.BeanLookupFactory<String>, org.refcodes.factory.TypeLookupFactory

public class SpringBeanFactory extends Object implements org.refcodes.factory.BeanFactory<String>
This factory looks up beans from a spring context as provided in the constructor.
  • Constructor Details

    • SpringBeanFactory

      public SpringBeanFactory(URI[] aConfigurationFiles) throws MalformedURLException
      Creates a factory with the given Spring configuration files.
      Parameters:
      aConfigurationFiles - The URIs of the configuration files describing the handled Spring application context.
      Throws:
      MalformedURLException - If a given URI is malformed.
    • SpringBeanFactory

      public SpringBeanFactory(URI[] aConfigurationFiles, URI[] aPropertyFiles) throws MalformedURLException
      Creates a factory with the given Spring configuration files. If the configuration files contains placeholders (e.g. ${jdbc.url}), the given property files are used to replace them. The provided property files have to follow the JAVA properties scheme (key=value).
      Parameters:
      aConfigurationFiles - The URIs of the configuration files describing the handled Spring application context.
      aPropertyFiles - The URIs of the property files containing the values for the used placeholders.
      Throws:
      MalformedURLException - If a given URI is malformed
    • SpringBeanFactory

      public SpringBeanFactory(URI[] aConfigurationFiles, Map<String,String> aProperties) throws MalformedURLException
      Creates a factory with the given Spring configuration files and the given properties. If the configuration files contains placeholders (e.g. ${jdbc.url}), the given properties are used to replace them.
      Parameters:
      aConfigurationFiles - The URIs of the configuration files describing the handled Spring application context.
      aProperties - The dynamic properties which are not defined by an configuration file.
      Throws:
      MalformedURLException - If a given URI is malformed
    • SpringBeanFactory

      public SpringBeanFactory(URI[] aConfigurationFiles, URI[] aPropertyFiles, Map<String,String> aProperties) throws MalformedURLException
      Creates a factory with the given Spring configuration files and the given properties. If the configuration files contains placeholders (e.g. ${jdbc.url}), the given property files and properties are used to replace them. The provided property files have to follow the JAVA properties scheme (key=value).
      Parameters:
      aConfigurationFiles - The URIs of the configuration files describing the handled Spring application context.
      aPropertyFiles - The URIs of the property files containing the values for the used placeholders.
      aProperties - The dynamic properties which are not defined by an configuration file.
      Throws:
      MalformedURLException - If a given URI is malformed
  • Method Details

    • createInstance

      public <T> T createInstance(String aIdentifier)
      To instance.
      Specified by:
      createInstance in interface org.refcodes.factory.BeanFactory<String>
      Specified by:
      createInstance in interface org.refcodes.factory.BeanLookupFactory<String>
      Type Parameters:
      T - the generic type
      Parameters:
      aIdentifier - the identifier
      Returns:
      the t
    • createInstance

      public <T> T createInstance(String aIdentifier, Map<String,String> aProperties)
      Specified by:
      createInstance in interface org.refcodes.factory.BeanLookupFactory<String>
    • createInstances

      public <T> Set<T> createInstances(Class<?> aType)
      To instances.
      Specified by:
      createInstances in interface org.refcodes.factory.BeanFactory<String>
      Specified by:
      createInstances in interface org.refcodes.factory.TypeLookupFactory
      Type Parameters:
      T - the generic type
      Parameters:
      aType - the type
      Returns:
      the sets the
    • toInstances

      public <T> Set<T> toInstances(Class<?> aType, Map<String,String> aProperties)
      To instances.
      Specified by:
      toInstances in interface org.refcodes.factory.TypeLookupFactory
      Type Parameters:
      T - the generic type
      Parameters:
      aType - the type
      aProperties - the properties
      Returns:
      the sets the