MentaContainer

Rev

Rev 51 | Rev 58 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 51 Rev 57
Line 5... Line 5...
5
 * <ul>
5
 * <ul>
6
 *   <li> Bean instantiation (duh!)</li>
6
 *   <li> Bean instantiation (duh!)</li>
7
 *   <li> Constructor injection for bean setup</li>
7
 *   <li> Constructor injection for bean setup</li>
8
 *   <li> Setter injection for bean setup</li>
8
 *   <li> Setter injection for bean setup</li>
9
 *   <li> Auto-wiring based on name and type</li>
9
 *   <li> Auto-wiring based on name and type</li>
10
 *   <li> Singleton</li>
-
 
-
 
10
 *   <li> Scopes: Singleton and ThreadLocal</li>
11
 *   <li> Wiring of external beans with the beans configured in this container</li>
11
 *   <li> Wiring of external beans with the beans configured in this container</li>
12
 *   <li> Annotation and XML free (programmatic configuration is the way to go!)
12
 *   <li> Annotation and XML free (programmatic configuration is the way to go!)
13
 * </ul>
13
 * </ul>
14
 *
14
 *
15
 * It does not get much simpler than that.
15
 * It does not get much simpler than that.
Line 32... Line 32...
32
        /**
32
        /**
33
         * Configure a bean to be returned with the given implementation when {@link #get(String)} is called.
33
         * Configure a bean to be returned with the given implementation when {@link #get(String)} is called.
34
         *
34
         *
35
         * @param key The key representing the bean to return. The name of the bean in the container.
35
         * @param key The key representing the bean to return. The name of the bean in the container.
36
         * @param klass The class used to instantiate the bean, in other words, its implementation.
36
         * @param klass The class used to instantiate the bean, in other words, its implementation.
37
         * @param singleton A boolean to indicate if this bean will be a singleton.
-
 
-
 
37
         * @param scope The scope of the component.
38
         * @return The component created as a ConfigurableComponent. (Fluent API)
38
         * @return The component created as a ConfigurableComponent. (Fluent API)
-
 
39
         * @see Scope
39
         */
40
         */
40
        public ConfigurableComponent ioc(String key, Class<? extends Object> klass, boolean singleton);
-
 
-
 
41
        public ConfigurableComponent ioc(String key, Class<? extends Object> klass, Scope scope);
41
       
42
       
42
        /**
43
        /**
43
         * Same as {@link #ioc(String, Class, boolean)} except that it assumes
-
 
44
         * singleton is false.
-
 
-
 
44
         * Same as {@link #ioc(String, Class, Scope)} except that it assumes
-
 
45
         * there is no scope (Scope.NONE).
45
         *
46
         *
46
         * @param key
47
         * @param key
47
         * @param klass
48
         * @param klass
48
         * @return The component created as a ConfigurableComponent. (Fluent API)
49
         * @return The component created as a ConfigurableComponent. (Fluent API)
-
 
50
         * @see Scope
49
         */
51
         */
50
        public ConfigurableComponent ioc(String key, Class<?extends Object> klass);
52
        public ConfigurableComponent ioc(String key, Class<?extends Object> klass);
51
       
53
       
52
        /**
54
        /**
53
         * Set up IoC based on the component passed.
-
 
-
 
55
         * Set up IoC based on the component passed. The scope assumed is NONE.
54
         *
56
         *
55
         * @param key The key representing the bean to return. The name of the bean in the container.
57
         * @param key The key representing the bean to return. The name of the bean in the container.
56
         * @param component The component for the IoC.
58
         * @param component The component for the IoC.
57
         * @return The component passed as a parameter.
59
         * @return The component passed as a parameter.
58
         * @see Component
60
         * @see Component
59
         */
61
         */
60
        public Component ioc(String key, Component component);
62
        public Component ioc(String key, Component component);
61
       
63
       
62
        /**
64
        /**
63
         * Set up IoC based on the component passed. Specify whether this will be a singleton component.
-
 
-
 
65
         * Set up IoC based on the component passed. Specify the scope of the component.
64
         *
66
         *
65
         * @param key The key representing the bean to return. The name of the bean in the container.
67
         * @param key The key representing the bean to return. The name of the bean in the container.
66
         * @param component The component for the IoC.
68
         * @param component The component for the IoC.
67
         * @param isSingleton Should this component be treated as a singleton?
-
 
-
 
69
         * @param scope The scope used by the component.
68
         * @return The component passed as a parameter.
70
         * @return The component passed as a parameter.
69
         * @see Component
71
         * @see Component
-
 
72
         * @see Scope
70
         */
73
         */
71
        public Component ioc(String key, Component component, boolean isSingleton);
-
 
-
 
74
        public Component ioc(String key, Component component, Scope scope);
72
       
75
       
73
        /**
76
        /**
74
         * Configure a bean dependency to be auto-wired by the container. In general you want the
77
         * Configure a bean dependency to be auto-wired by the container. In general you want the
75
         * type of the dependency to be an interface, for loosely couple dependencies. It works like that:<br/><br/>
78
         * type of the dependency to be an interface, for loosely couple dependencies. It works like that:<br/><br/>
76
         *
79
         *
Line 121... Line 124...
121
         *
124
         *
122
         * @param key The key representing the bean inside the container.
125
         * @param key The key representing the bean inside the container.
123
         * @return true if the container contains this bean.
126
         * @return true if the container contains this bean.
124
         */
127
         */
125
        public boolean contains(String key);
128
        public boolean contains(String key);
-
 
129
       
-
 
130
        /**
-
 
131
         * Clear all cached instances for that scope. If you have a thread pool for example you will
-
 
132
         * have to clear the THREAD scope when your thread is returned to the pool.
-
 
133
         *
-
 
134
         * @param scope The scope to be cleared.
-
 
135
         */
-
 
136
        public void clear(Scope scope);
126
}
137
}