MentaContainer

Rev

Rev 20 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.mentacontainer;

/**
 * An IoC component that knows how to create instances of itself and accepts init values for its constructor
 * and properties to be injected through its setters.
 *
 * @author sergio.oliveira.jr@gmail.com
 */

public interface Component {
       
        /**
         * Instantiate the bean.
         *
         * @return The instantiated bean based on the container configuration.
         * @throws InstantiationException
         */

        public Object getInstance() throws InstantiationException;
       
        /**
         * Add a constructor parameter to be used when the bean is instantiated. It can be called more than once to
         * use constructors with more than one argument.
         *
         * @param value A parameter value to be used by a constructor.
         * @return The component itself. (Fluent API)
         */

        public Component addInitValue(Object value);
       
        /**
         * Add a property to be injected through a setter when the component is instantiated.
         *
         * @param name The property name.
         * @param value The property value.
         * @return The component itself. (Fluent API)
         */

        public Component addProperty(String name, Object value);
       
        /**
         * Is this component a singleton component, in other words,
         * it always returns the same instance?
         *
         * @return true if it is a singleton component
         */

        public boolean isSingleton();
}