Class ExoContainer

    • Constructor Detail

      • ExoContainer

        public ExoContainer()
      • ExoContainer

        public ExoContainer​(ExoContainer parent)
    • Method Detail

      • getProfilesFromProperty

        public static Set<String> getProfilesFromProperty()
        Returns an unmodifiable set of profiles defined by the value returned by invoking PropertyManager.getProperty(String) with the PropertyManager.RUNTIME_PROFILES property.
        Returns:
        the set of profiles
      • hasProfileInProperty

        public static boolean hasProfileInProperty​(String profileName)
        Indicates whether or not a given profile exists
        Parameters:
        profileName - the name of the profile to check
        Returns:
        true if the profile exists, false otherwise.
      • hasProfile

        public static boolean hasProfile​(String profileName)
        Indicates whether the current container has a given profile.
        Parameters:
        profileName - profile to check
        Returns:
        true if current ExoContainer retrieved from ExoContainerContext was started with the given profile, false otherwise.
      • initContainerInternal

        protected void initContainerInternal()
      • dispose

        public void dispose()
        Description copied from class: AbstractContainer
        Dispose this component. The component should deallocate all resources. The contract for this method defines a single call at the end of this component's life.
        Specified by:
        dispose in interface Disposable
        Overrides:
        dispose in class AbstractContainer
      • start

        public void start​(boolean init)
        Starts the container
        Parameters:
        init - indicates if the container must be initialized first
      • start

        public void start()
        Description copied from class: AbstractContainer
        Start this component. Called initially at the begin of the lifecycle. It can be called again after a stop.
        Specified by:
        start in interface Startable
        Overrides:
        start in class AbstractContainer
      • stop

        public void stop()
        Description copied from class: AbstractContainer
        Stop this component. Called near the end of the lifecycle. It can be called again after a further start. Implement Disposable if you need a single call at the definite end of the lifecycle.
        Specified by:
        stop in interface Startable
        Overrides:
        stop in class AbstractContainer
      • unregisterAllComponents

        protected void unregisterAllComponents()
        Unregister all components from container to avoid keeping instances in memory.
      • registerComponentImplementation

        public <T> ComponentAdapter<T> registerComponentImplementation​(Class<T> componentImplementation)
                                                                throws ContainerException
        Register a component using the componentImplementation as key. Calling this method is equivalent to calling registerComponentImplementation(componentImplementation, componentImplementation).
        Parameters:
        componentImplementation - the concrete component class.
        Returns:
        the ComponentAdapter that has been associated with this component. In the majority of cases, this return value can be safely ignored, as one of the getXXX() methods of the Container interface can be used to retrieve a reference to the component later on.
        Throws:
        ContainerException - if registration fails.
      • registerComponentInstance

        public <T> ComponentAdapter<T> registerComponentInstance​(T componentInstance)
                                                          throws ContainerException
        Register an arbitrary object. The class of the object will be used as a key. Calling this method is equivalent to calling * registerComponentImplementation(componentImplementation, componentImplementation).
        Parameters:
        componentInstance - the instance of the component to register
        Returns:
        the ComponentAdapter that has been associated with this component. In the majority of cases, this return value can be safely ignored, as one of the getXXX() methods of the Container interface can be used to retrieve a reference to the component later on.
        Throws:
        ContainerException - if registration fails.
      • getComponentAdapter

        public ComponentAdapter<?> getComponentAdapter​(Object componentKey)
        Find a component adapter associated with the specified key. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched.
        Parameters:
        componentKey - the key that the component was registered with.
        Returns:
        the component adapter associated with this key, or null if no component has been registered for the specified key.
      • getComponentInstance

        public Object getComponentInstance​(Object componentKey)
        Retrieve a component instance registered with a specific key. If a component cannot be found in this container, the parent container (if one exists) will be searched.
        Parameters:
        componentKey - the key that the component was registered with.
        Returns:
        an instantiated component, or null if no component has been registered for the specified key.
      • getParent

        public ExoContainer getParent()
        Gives the parent container of this container.
        Returns:
        a ExoContainer instance, or null if this container does not have a parent.
      • canBeStarted

        public boolean canBeStarted()
        Indicates whether or not the container can be started
        Returns:
        true if it can be started, false otherwise.
      • canBeStopped

        public boolean canBeStopped()
        Indicates whether or not the container can be stopped
        Returns:
        true if it can be stopped, false otherwise.
      • canBeDisposed

        public boolean canBeDisposed()
        Indicates whether or not the container can be disposed
        Returns:
        true if it can be disposed, false otherwise.
      • canBeInitialized

        protected boolean canBeInitialized()
        Indicates whether or not the container can be initialized
        Returns:
        true if it can be initialized, false otherwise.
      • isContextManagerLoaded

        public boolean isContextManagerLoaded()
        Indicates whether or not the ContextManager has already been loaded
        Returns:
        true if the ContextManager has been loaded, false otherwise.
      • getComponentInstanceOfType

        public <T> T getComponentInstanceOfType​(Class<T> componentType,
                                                boolean autoRegistration)
        Find a component instance matching the specified type. If none can be found it will try to auto register the component according to the content of the annotation DefinitionByType if the parameter autoRegistration has been set to true.
        Specified by:
        getComponentInstanceOfType in interface Container
        Overrides:
        getComponentInstanceOfType in class AbstractContainer
        Parameters:
        componentType - the type of the component.
        autoRegistration - indicates whether the auto registration should be performed or not
        Returns:
        the adapter matching the class.
      • getComponentAdapterOfType

        public <T> ComponentAdapter<T> getComponentAdapterOfType​(Class<T> componentType)
        This method is equivalent to getComponentAdapterOfType(Class, boolean) with true for the parameter autoRegistration
        Parameters:
        componentType - the type of the component.
        Returns:
        the component adapter associated with this class, or null if no component has been registered for the specified key.
      • getComponentAdapterOfType

        public <T> ComponentAdapter<T> getComponentAdapterOfType​(Class<T> componentType,
                                                                 boolean autoRegistration)
        Find a component adapter associated with the specified type. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched. If none can be found it will try to auto register the component according to the content of the annotation DefinitionByType if the parameter autoRegistration has been set to true.
        Specified by:
        getComponentAdapterOfType in interface Container
        Overrides:
        getComponentAdapterOfType in class AbstractContainer
        Parameters:
        componentType - the type of the component.
        autoRegistration - indicates whether the auto registration should be performed or not
        Returns:
        the component adapter associated with this class, or null if no component has been registered for the specified key.
      • getComponentInstance

        public <T> T getComponentInstance​(Object componentKey,
                                          Class<T> bindType)
        This method is equivalent to getComponentInstance(Object, Class, boolean) with true for the parameter autoRegistration
        Parameters:
        componentKey - the key that the component was registered with.
        bindType - the expected type of the instance if one can be found.
        Returns:
        an instantiated component, or null if no component has been registered for the specified key.
      • getComponentInstance

        public <T> T getComponentInstance​(Object componentKey,
                                          Class<T> bindType,
                                          boolean autoRegistration)
        Retrieve a component instance registered with a specific key. If a component cannot be found in this container, the parent container (if one exists) will be searched. If none can be found and the parameter autoRegistration has been set to true, it will try to auto register the component according to the content of:
        Specified by:
        getComponentInstance in interface Container
        Overrides:
        getComponentInstance in class AbstractContainer
        Parameters:
        componentKey - the key that the component was registered with.
        bindType - the expected type of the instance if one can be found.
        autoRegistration - indicates whether the auto registration should be performed or not
        Returns:
        an instantiated component, or null if no component has been registered for the specified key.
      • getComponentAdapter

        public <T> ComponentAdapter<T> getComponentAdapter​(Object componentKey,
                                                           Class<T> bindType)
        This method is equivalent to getComponentAdapter(Object, Class, boolean) with true for the parameter autoRegistration
        Parameters:
        componentKey - the key that the component was registered with.
        bindType - the expected raw type of the adapter if one can be found.
        Returns:
        the component adapter associated with this key, or null if no component has been registered for the specified key.
      • getComponentAdapter

        public <T> ComponentAdapter<T> getComponentAdapter​(Object componentKey,
                                                           Class<T> bindType,
                                                           boolean autoRegistration)
        Find a component adapter associated with the specified key. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched. If none can be found and the parameter autoRegistration has been set to true, it will try to auto register the component according to the content of:
        Specified by:
        getComponentAdapter in interface Container
        Overrides:
        getComponentAdapter in class AbstractContainer
        Parameters:
        componentKey - the key that the component was registered with.
        bindType - the expected raw type of the adapter if one can be found.
        autoRegistration - indicates whether the auto registration should be performed or not
        Returns:
        the component adapter associated with this key, or null if no component has been registered for the specified key.