java.lang.Object
org.refcodes.decoupling.Reactor
org.refcodes.decoupling.ext.application.ApplicationReactor
All Implemented Interfaces:
org.refcodes.properties.ext.application.ApplicationPropertiesAccessor

public class ApplicationReactor extends org.refcodes.decoupling.Reactor implements org.refcodes.properties.ext.application.ApplicationPropertiesAccessor
The ApplicationReactor enables harnessing the ApplicationProperties alongside the ApplicationProperties profile support (as of ProfileProperties.getRuntimeProfiles()) by automatically placing an accordingly configured ApplicationProperties instance into the container and enabling it for injection. The ApplicationProperties Dependency's alias is set to "applicationProperties" (as of this class's constant APPLICATION_PROPERTIES_ALIAS). Also if declared by a Dependency, an ApplicationBus singleton is provided for synchronous communication between the components.
  • Field Details

    • APPLICATION_CONTEXT_ALIAS

      public static final String APPLICATION_CONTEXT_ALIAS
      The ApplicationContext Dependency's alias to be used.
      See Also:
    • APPLICATION_PROPERTIES_ALIAS

      public static final String APPLICATION_PROPERTIES_ALIAS
      The ApplicationProperties Dependency's alias to be used.
      See Also:
    • APPLICATION_BUS_ALIAS

      public static final String APPLICATION_BUS_ALIAS
      The ApplicationBus Dependency's alias to be used.
      See Also:
    • _properties

      protected org.refcodes.properties.ext.application.ApplicationProperties _properties
  • Constructor Details

    • ApplicationReactor

      public ApplicationReactor()
      Constructs a ApplicationReactor instance.
    • ApplicationReactor

      public ApplicationReactor(org.refcodes.properties.ext.application.ApplicationProperties aProperties)
      Constructs a ApplicationReactor instance.
      Parameters:
      aProperties - The ApplicationProperties to use as initial configuration.
    • ApplicationReactor

      public ApplicationReactor(InputStream aInputStream) throws IOException, ParseException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aInputStream - The InputStream pointing to the properties to be loaded.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • ApplicationReactor

      public ApplicationReactor(InputStream aInputStream, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aInputStream - The InputStream pointing to the properties to be loaded.
      aArgs - The command line arguments to be evaluated.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      org.refcodes.cli.ArgsSyntaxException - thrown in case of a command line arguments mismatch regarding provided and expected args.
    • ApplicationReactor

      public ApplicationReactor(URL aUrl) throws IOException, ParseException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aUrl - The URL pointing to the properties to be loaded.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • ApplicationReactor

      public ApplicationReactor(URL aUrl, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aUrl - The URL pointing to the properties to be loaded.
      aArgs - The command line arguments to be evaluated.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      org.refcodes.cli.ArgsSyntaxException - thrown in case of a command line arguments mismatch regarding provided and expected args.
    • ApplicationReactor

      public ApplicationReactor(File aFile) throws IOException, ParseException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aFile - The File pointing to the properties to be loaded.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • ApplicationReactor

      public ApplicationReactor(File aFile, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aFile - The File pointing to the properties to be loaded.
      aArgs - The command line arguments to be evaluated.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      org.refcodes.cli.ArgsSyntaxException - thrown in case of a command line arguments mismatch regarding provided and expected args.
    • ApplicationReactor

      public ApplicationReactor(File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator) throws IOException, ParseException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aFile - The File pointing to the properties to be loaded.
      aConfigLocator - The ConfigLocator to be used when seeking for the given File.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • ApplicationReactor

      public ApplicationReactor(File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aFile - The File pointing to the properties to be loaded.
      aConfigLocator - The ConfigLocator to be used when seeking for the given File.
      aArgs - the args
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      org.refcodes.cli.ArgsSyntaxException - thrown in case of a command line arguments mismatch regarding provided and expected args.
    • ApplicationReactor

      public ApplicationReactor(String aFilePath) throws IOException, ParseException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aFilePath - The properties' file path pointing to the properties to be loaded.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • ApplicationReactor

      public ApplicationReactor(String aFilePath, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aFilePath - The properties' file path pointing to the properties to be loaded.
      aArgs - The command line arguments to be evaluated.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      org.refcodes.cli.ArgsSyntaxException - thrown in case of a command line arguments mismatch regarding provided and expected args.
    • ApplicationReactor

      public ApplicationReactor(String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator) throws IOException, ParseException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aFilePath - The properties' file path pointing to the properties to be loaded.
      aConfigLocator - The ConfigLocator to be used when seeking for the given String.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • ApplicationReactor

      public ApplicationReactor(String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Create a ApplicationReactor using the provided ApplicationProperties instance.
      Parameters:
      aFilePath - The properties' file path pointing to the properties to be loaded.
      aConfigLocator - The ConfigLocator to be used when seeking for the given String.
      aArgs - the args
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      org.refcodes.cli.ArgsSyntaxException - thrown in case of a command line arguments mismatch regarding provided and expected args.
  • Method Details

    • addConfiguration

      public <T> org.refcodes.decoupling.DependencyBuilder<T> addConfiguration(Class<T> aType)
      Adds a specially fabricated Dependency to the Reactor which's DependencyBuilder is returned for fluently configuring your Dependency: The Dependency will be initialized by default by the ApplicationReactor instance's underlying Properties instance (being instantiated by the ApplicationReactor). This is a shortcut for configuring and applying a FactoryClaim with the according Properties to your Dependency: addDependency( aType ).withFactory( Properties.class, ( p ) -> p.toType( aType ), "applicationProperties" );
      Type Parameters:
      T - The type of the Dependency.
      Parameters:
      aType - The type of the Dependency.
      Returns:
      An instance of the DependencyBuilder class which is used to fluently configure your Dependency.
    • addConfiguration

      public <T> org.refcodes.decoupling.DependencyBuilder<T> addConfiguration(Class<T> aType, String aNamespace)
      Adds a specially fabricated Dependency to the Reactor which's DependencyBuilder is returned for fluently configuring your Dependency: The Dependency will be initialized by default by the ApplicationReactor instance's underlying Properties instance (being instantiated by the ApplicationReactor). This is a shortcut for configuring and applying a FactoryClaim with the according Properties to your Dependency: addDependency( aType ).withFactory( Properties.class, ( p ) -> p.toType( "service.datasource", aType ), "applicationProperties" );
      Type Parameters:
      T - The type of the Dependency.
      Parameters:
      aType - The type of the Dependency.
      aNamespace - The namespace within the Properties managed by the ApplicationReactor. The namespace can be regarded a property key's prefix.
      Returns:
      An instance of the DependencyBuilder class which is used to fluently configure your Dependency.
    • addConfiguration

      public <T> org.refcodes.decoupling.DependencyBuilder<T> addConfiguration(Class<T> aType, Object aNamespace)
      Adds a specially fabricated Dependency to the Reactor which's DependencyBuilder is returned for fluently configuring your Dependency: The Dependency will be initialized by default by the ApplicationReactor instance's underlying Properties instance (being instantiated by the ApplicationReactor). This is a shortcut for configuring and applying a FactoryClaim with the according Properties to your Dependency: addDependency( aType ).withFactory( Properties.class, ( p ) -> p.toType( "service.datasource", aType ), "applicationProperties" );
      Type Parameters:
      T - The type of the Dependency.
      Parameters:
      aType - The type of the Dependency.
      aNamespace - The namespace within the Properties managed by the ApplicationReactor. The namespace can be regarded a property key's prefix.
      Returns:
      An instance of the DependencyBuilder class which is used to fluently configure your Dependency.
    • addConfiguration

      public <T> org.refcodes.decoupling.DependencyBuilder<T> addConfiguration(Class<T> aType, String... aNamespaceElements)
      Adds a specially fabricated Dependency to the Reactor which's DependencyBuilder is returned for fluently configuring your Dependency: The Dependency will be initialized by default by the ApplicationReactor instance's underlying Properties instance (being instantiated by the ApplicationReactor). This is a shortcut for configuring and applying a FactoryClaim with the according Properties to your Dependency: addDependency( aType ).withFactory( Properties.class, ( p ) -> p.toType( aType. "service", "datasource" ), "applicationProperties" );
      Type Parameters:
      T - The type of the Dependency.
      Parameters:
      aType - The type of the Dependency.
      aNamespaceElements - The namespace elements denoting the namespace (not requiring denoting any delimiters separating the namespace elements from each other) within the Properties managed by the ApplicationReactor. The namespace can be regarded a property key's prefix.
      Returns:
      An instance of the DependencyBuilder class which is used to fluently configure your Dependency.
    • addConfiguration

      public <T> org.refcodes.decoupling.DependencyBuilder<T> addConfiguration(Class<T> aType, Object... aNamespaceElements)
      Adds a specially fabricated Dependency to the Reactor which's DependencyBuilder is returned for fluently configuring your Dependency: The Dependency will be initialized by default by the ApplicationReactor instance's underlying Properties instance (being instantiated by the ApplicationReactor). This is a shortcut for configuring and applying a FactoryClaim with the according Properties to your Dependency: addDependency( aType ).withFactory( Properties.class, ( p ) -> p.toType( aType. "service", "datasource" ), "applicationProperties" );
      Type Parameters:
      T - The type of the Dependency.
      Parameters:
      aType - The type of the Dependency.
      aNamespaceElements - The namespace elements denoting the namespace (not requiring denoting any delimiters separating the namespace elements from each other) within the Properties managed by the ApplicationReactor. The namespace can be regarded a property key's prefix.
      Returns:
      An instance of the DependencyBuilder class which is used to fluently configure your Dependency.
    • addConfiguration

      public <T> org.refcodes.decoupling.DependencyBuilder<T> addConfiguration(Class<T> aType, Collection<?> aNamespaceElements)
      Adds a specially fabricated Dependency to the Reactor which's DependencyBuilder is returned for fluently configuring your Dependency: The Dependency will be initialized by default by the ApplicationReactor instance's underlying Properties instance (being instantiated by the ApplicationReactor). This is a shortcut for configuring and applying a FactoryClaim with the according Properties to your Dependency: addDependency( aType ).withFactory( Properties.class, ( p ) -> p.toType( aType. someNameSpaceList ), "applicationProperties" );
      Type Parameters:
      T - The type of the Dependency.
      Parameters:
      aType - The type of the Dependency.
      aNamespaceElements - The namespace elements denoting the namespace (not requiring denoting any delimiters separating the namespace elements from each other) within the Properties managed by the ApplicationReactor. The namespace can be regarded a property key's prefix.
      Returns:
      An instance of the DependencyBuilder class which is used to fluently configure your Dependency.
    • createContext

      public ApplicationContext createContext() throws org.refcodes.decoupling.AmbigousDependencyException, org.refcodes.decoupling.UnsatisfiedDependencyException, org.refcodes.decoupling.CircularDependencyException, org.refcodes.decoupling.DuplicateDependencyException, org.refcodes.decoupling.DuplicateClaimException, org.refcodes.decoupling.UnsatisfiedClaimException, org.refcodes.decoupling.AmbigousClaimException, org.refcodes.decoupling.AmbigousInitializerException, org.refcodes.decoupling.UnsatisfiedInitializerException, org.refcodes.decoupling.AmbigousFactoryException, org.refcodes.decoupling.UnsatisfiedFactoryException, org.refcodes.decoupling.InstallDependencyException
      Uses the profiles as provided by the Properties initialized with as of the according constructors.
      Overrides:
      createContext in class org.refcodes.decoupling.Reactor
      Throws:
      org.refcodes.decoupling.AmbigousDependencyException
      org.refcodes.decoupling.UnsatisfiedDependencyException
      org.refcodes.decoupling.CircularDependencyException
      org.refcodes.decoupling.DuplicateDependencyException
      org.refcodes.decoupling.DuplicateClaimException
      org.refcodes.decoupling.UnsatisfiedClaimException
      org.refcodes.decoupling.AmbigousClaimException
      org.refcodes.decoupling.AmbigousInitializerException
      org.refcodes.decoupling.UnsatisfiedInitializerException
      org.refcodes.decoupling.AmbigousFactoryException
      org.refcodes.decoupling.UnsatisfiedFactoryException
      org.refcodes.decoupling.InstallDependencyException
    • createContext

      public ApplicationContext createContext(String... aProfiles) throws org.refcodes.decoupling.AmbigousDependencyException, org.refcodes.decoupling.UnsatisfiedDependencyException, org.refcodes.decoupling.CircularDependencyException, org.refcodes.decoupling.DuplicateDependencyException, org.refcodes.decoupling.DuplicateClaimException, org.refcodes.decoupling.UnsatisfiedClaimException, org.refcodes.decoupling.AmbigousClaimException, org.refcodes.decoupling.AmbigousInitializerException, org.refcodes.decoupling.UnsatisfiedInitializerException, org.refcodes.decoupling.AmbigousFactoryException, org.refcodes.decoupling.UnsatisfiedFactoryException, org.refcodes.decoupling.InstallDependencyException
      Overrides:
      createContext in class org.refcodes.decoupling.Reactor
      Throws:
      org.refcodes.decoupling.AmbigousDependencyException
      org.refcodes.decoupling.UnsatisfiedDependencyException
      org.refcodes.decoupling.CircularDependencyException
      org.refcodes.decoupling.DuplicateDependencyException
      org.refcodes.decoupling.DuplicateClaimException
      org.refcodes.decoupling.UnsatisfiedClaimException
      org.refcodes.decoupling.AmbigousClaimException
      org.refcodes.decoupling.AmbigousInitializerException
      org.refcodes.decoupling.UnsatisfiedInitializerException
      org.refcodes.decoupling.AmbigousFactoryException
      org.refcodes.decoupling.UnsatisfiedFactoryException
      org.refcodes.decoupling.InstallDependencyException
    • createContext

      public ApplicationContext createContext(ApplicationReactor.ProfilesMode aProfilesMode) throws org.refcodes.decoupling.AmbigousDependencyException, org.refcodes.decoupling.UnsatisfiedDependencyException, org.refcodes.decoupling.CircularDependencyException, org.refcodes.decoupling.DuplicateDependencyException, org.refcodes.decoupling.DuplicateClaimException, org.refcodes.decoupling.UnsatisfiedClaimException, org.refcodes.decoupling.AmbigousClaimException, org.refcodes.decoupling.AmbigousInitializerException, org.refcodes.decoupling.UnsatisfiedInitializerException, org.refcodes.decoupling.AmbigousFactoryException, org.refcodes.decoupling.UnsatisfiedFactoryException, org.refcodes.decoupling.InstallDependencyException
      Creates the ApplicationContext and invokes the Initializable.initialize() methods before invoking the Startable.start() methods on all dependencies' instances. The ApplicationContext returned then is in lifecycle status ApplicationContext.isRunning().
      Parameters:
      aProfilesMode - the ApplicationReactor.ProfilesMode determining on how to handle implicit profiles information as provided by the ApplicationProperties instance (implicitly added as Dependency by the ApplicationReactor).
      Returns:
      The accordingly created ApplicationContext instance.
      Throws:
      org.refcodes.decoupling.AmbigousDependencyException - is thrown in case for a required Dependency there are more than one matching Dependency candidates in the Reactor.
      org.refcodes.decoupling.UnsatisfiedDependencyException - is thrown in case for a required Dependency none matching Dependency candidates in the Reactor have been found (taking the profiles applied into account) for the constructors of the given Dependency.
      org.refcodes.decoupling.CircularDependencyException - is thrown in case there is some (transitive) circular dependency between two Dependency instances.
      org.refcodes.decoupling.DuplicateDependencyException - is thrown in case there are multiple identical dependencies applicable by the Reactor.
      org.refcodes.decoupling.DuplicateClaimException - is thrown in case there are multiple identical claims declared by a Dependency.
      org.refcodes.decoupling.UnsatisfiedClaimException - is thrown in case a Claim instance cannot be satisfied by any known Dependency instance.
      org.refcodes.decoupling.AmbigousClaimException - is thrown in case one Claim can be matched by multiple dependencies.
      org.refcodes.decoupling.AmbigousInitializerException - is thrown in case one InitializerClaim instance can be matched by multiple dependencies.
      org.refcodes.decoupling.UnsatisfiedInitializerException - is thrown in case a InitializerClaim instance cannot be satisfied by any known Dependency instance.
      org.refcodes.decoupling.AmbigousFactoryException - is thrown in case one FactoryClaim instance can be matched by multiple dependencies.
      org.refcodes.decoupling.UnsatisfiedFactoryException - is thrown in case a FactoryClaim instance cannot be satisfied by any known Dependency instance.
      org.refcodes.decoupling.InstallDependencyException - is thrown when trying to install a Dependency into the Context, though installing failed die to the dependency throwing an exception during the process of installing (e.g. instantiation).
    • createContext

      public ApplicationContext createContext(Object... aProfiles) throws org.refcodes.decoupling.AmbigousDependencyException, org.refcodes.decoupling.UnsatisfiedDependencyException, org.refcodes.decoupling.CircularDependencyException, org.refcodes.decoupling.DuplicateDependencyException, org.refcodes.decoupling.DuplicateClaimException, org.refcodes.decoupling.UnsatisfiedClaimException, org.refcodes.decoupling.AmbigousClaimException, org.refcodes.decoupling.AmbigousInitializerException, org.refcodes.decoupling.UnsatisfiedInitializerException, org.refcodes.decoupling.AmbigousFactoryException, org.refcodes.decoupling.UnsatisfiedFactoryException, org.refcodes.decoupling.InstallDependencyException
      Overrides:
      createContext in class org.refcodes.decoupling.Reactor
      Throws:
      org.refcodes.decoupling.AmbigousDependencyException
      org.refcodes.decoupling.UnsatisfiedDependencyException
      org.refcodes.decoupling.CircularDependencyException
      org.refcodes.decoupling.DuplicateDependencyException
      org.refcodes.decoupling.DuplicateClaimException
      org.refcodes.decoupling.UnsatisfiedClaimException
      org.refcodes.decoupling.AmbigousClaimException
      org.refcodes.decoupling.AmbigousInitializerException
      org.refcodes.decoupling.UnsatisfiedInitializerException
      org.refcodes.decoupling.AmbigousFactoryException
      org.refcodes.decoupling.UnsatisfiedFactoryException
      org.refcodes.decoupling.InstallDependencyException
    • getApplicationProperties

      public org.refcodes.properties.ext.application.ApplicationProperties getApplicationProperties()
      Retrieves the initial properties (configuration) represented by this ApplicationProperties instance.
      Specified by:
      getApplicationProperties in interface org.refcodes.properties.ext.application.ApplicationPropertiesAccessor
      Returns:
      The according initial configuration.
    • toContext

      protected ApplicationContext toContext(Object[] aProfiles)
      Overrides:
      toContext in class org.refcodes.decoupling.Reactor