Interface ScopeContainer

  • All Known Implementing Classes:
    DefaultScopeContainer

    public interface ScopeContainer
    Defines a scope container.
    Author:
    Darek KaczyƄski
    • Method Detail

      • getObjectNames

        Set<String> getObjectNames()
        Gets the names of all beans within the container.
        Returns:
        the list of contained bean names.
        Throws:
        IllegalStateException - if the scope container is currently in destruction.
      • contains

        boolean contains​(String name)
        Checks if a bean of given name is present within the container.
        Parameters:
        name - the name of the bean to check.
        Returns:
        true if the bean was found, false otherwise.
        Throws:
        IllegalStateException - if the whole container is currently in destruction.
      • getObject

        Object getObject​(String name)
        Gets the given bean by name.
        Parameters:
        name - the name of the bean to retrieve.
        Returns:
        the bean of given name, or null if was not contained.
        Throws:
        IllegalStateException - if object of given name or the whole container is currently in destruction.
      • putObject

        void putObject​(String name,
                       Object obj)
        Puts a bean of given name into the container.
        Parameters:
        name - the bean name to put.
        obj - the bean instance to put.
        Throws:
        IllegalArgumentException - if an object for given name is already present in the container.
        IllegalStateException - if object of given name or the whole container is currently in destruction.
      • removeObject

        Object removeObject​(String name)
        Removes the bean of given name from the container.
        Parameters:
        name - the name of the bean to remove.
        Returns:
        the removed bean, or null if it was not contained.
        Throws:
        IllegalStateException - if object of given name or the whole container is currently in destruction.
      • addDestructionCallback

        void addDestructionCallback​(String name,
                                    Runnable callback)
        Adds a detruction callback for the bean of given name. All added callbacks will be run upon bean removal from the container.
        Parameters:
        name - the name of the bean to register callback for.
        callback - the destrution callback to register.
        Throws:
        IllegalStateException - if object of given name or the whole container is currently in destruction.
      • clear

        void clear()
        Clears the container destroying all contained beans.
        Throws:
        IllegalStateException - if the scope container is already during destruction.