MentaContainer

Rev

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

Rev 110 Rev 135
Line 28... Line 28...
28
         * The instance will be fully initialized (through constructor and/or setters) and fully wired (all dependencies will be resolved).
28
         * The instance will be fully initialized (through constructor and/or setters) and fully wired (all dependencies will be resolved).
29
         *
29
         *
30
         * @param key The key representing the factory to use. The name of the bean in the container.
30
         * @param key The key representing the factory to use. The name of the bean in the container.
31
         * @return The fully initialized and wired bean.
31
         * @return The fully initialized and wired bean.
32
         */
32
         */
33
        public <T> T get(String key);
-
 
-
 
33
        public <T> T get(Object key);
34
       
34
       
35
        /**
35
        /**
36
         * Get the type of the instances returned by the associated factory.
36
         * Get the type of the instances returned by the associated factory.
37
         *
37
         *
38
         * @param key The factory
38
         * @param key The factory
39
         * @return The type returned by this factory
39
         * @return The type returned by this factory
40
         */
40
         */
41
        public Class<? extends Object> getType(String key);
-
 
-
 
41
        public Class<? extends Object> getType(Object key);
42
       
42
       
43
        /**
43
        /**
44
         * Configure a bean to be returned with the given implementation when {@link #get(String)} is called.
44
         * Configure a bean to be returned with the given implementation when {@link #get(String)} is called.
45
         * An internal factory will be used.
45
         * An internal factory will be used.
46
         *
46
         *
Line 48... Line 48...
48
         * @param klass The class used to instantiate the bean, in other words, its implementation.
48
         * @param klass The class used to instantiate the bean, in other words, its implementation.
49
         * @param scope The scope of the factory.
49
         * @param scope The scope of the factory.
50
         * @return The factory created as a ConfigurableFactory. (Fluent API)
50
         * @return The factory created as a ConfigurableFactory. (Fluent API)
51
         * @see Scope
51
         * @see Scope
52
         */
52
         */
53
        public ConfigurableFactory ioc(String key, Class<? extends Object> klass, Scope scope);
-
 
-
 
53
        public ConfigurableFactory ioc(Object key, Class<? extends Object> klass, Scope scope);
54
       
54
       
55
        /**
55
        /**
56
         * Same as {@link #ioc(String, Class, Scope)} except that it assumes
56
         * Same as {@link #ioc(String, Class, Scope)} except that it assumes
57
         * there is no scope (Scope.NONE).
57
         * there is no scope (Scope.NONE).
58
         *
58
         *
59
         * @param key
59
         * @param key
60
         * @param klass
60
         * @param klass
61
         * @return The factory created as a ConfigurableFactory. (Fluent API)
61
         * @return The factory created as a ConfigurableFactory. (Fluent API)
62
         * @see Scope
62
         * @see Scope
63
         */
63
         */
64
        public ConfigurableFactory ioc(String key, Class<?extends Object> klass);
-
 
-
 
64
        public ConfigurableFactory ioc(Object key, Class<?extends Object> klass);
65
       
65
       
66
        /**
66
        /**
67
         * Set up a factory for the given key. The scope assumed is NONE.
67
         * Set up a factory for the given key. The scope assumed is NONE.
68
         *
68
         *
69
         * @param key The key representing the bean to return. The name of the bean in the container.
69
         * @param key The key representing the bean to return. The name of the bean in the container.
70
         * @param factory The factory for the IoC.
70
         * @param factory The factory for the IoC.
71
         * @return The factory passed as a parameter. (Fluent API)
71
         * @return The factory passed as a parameter. (Fluent API)
72
         * @see Factory
72
         * @see Factory
73
         */
73
         */
74
        public Factory ioc(String key, Factory factory);
-
 
-
 
74
        public Factory ioc(Object key, Factory factory);
75
       
75
       
76
        /**
76
        /**
77
         * Set up a factory for the given key in the given scope.
77
         * Set up a factory for the given key in the given scope.
78
         *
78
         *
79
         * @param key The key representing the bean to return. The name of the bean in the container.
79
         * @param key The key representing the bean to return. The name of the bean in the container.
Line 81... Line 81...
81
         * @param scope The scope used by the factory.
81
         * @param scope The scope used by the factory.
82
         * @return The factory passed as a parameter (Fluent API).
82
         * @return The factory passed as a parameter (Fluent API).
83
         * @see Factory
83
         * @see Factory
84
         * @see Scope
84
         * @see Scope
85
         */
85
         */
86
        public Factory ioc(String key, Factory factory, Scope scope);
-
 
-
 
86
        public Factory ioc(Object key, Factory factory, Scope scope);
87
       
87
       
88
        /**
88
        /**
89
         * Configure a bean dependency to be auto-wired by the container.
89
         * Configure a bean dependency to be auto-wired by the container.
90
         * It wires by constructor and by setter. By constructor is uses the type of sourceFromContainer. By setter it assumes the property is also named sourceFromContainer.
90
         * It wires by constructor and by setter. By constructor is uses the type of sourceFromContainer. By setter it assumes the property is also named sourceFromContainer.
91
         *
91
         *
92
         * @param sourceFromContainer The bean inside the container that will be wired automatically inside any other bean the depends on it.
92
         * @param sourceFromContainer The bean inside the container that will be wired automatically inside any other bean the depends on it.
93
         */
93
         */
94
        public void autowire(String sourceFromContainer);
-
 
-
 
94
        public void autowire(Object sourceFromContainer);
95
       
95
       
96
        /**
96
        /**
97
         * Configure a bean dependency to be auto-wired by the container.
97
         * Configure a bean dependency to be auto-wired by the container.
98
         * It wires by constructor and by setter. By constructor is uses the type of sourceFromContainer. By setter it looks for a property with the given name and try to inject.
98
         * It wires by constructor and by setter. By constructor is uses the type of sourceFromContainer. By setter it looks for a property with the given name and try to inject.
99
         *
99
         *
100
         * @param sourceFromContainer The bean inside the container that will be wired automatically inside any other bean the depends on it.
100
         * @param sourceFromContainer The bean inside the container that will be wired automatically inside any other bean the depends on it.
101
         * @param property The name of the property to inject, whey trying auto-wiring by setter.
101
         * @param property The name of the property to inject, whey trying auto-wiring by setter.
102
         */
102
         */
103
        public void autowire(String sourceFromContainer, String property);
-
 
-
 
103
        public void autowire(Object sourceFromContainer, String property);
104
       
104
       
105
        /**
105
        /**
106
         * Take a given bean and populate its properties with other beans coming from this container.
106
         * Take a given bean and populate its properties with other beans coming from this container.
107
         * You basically checking properties of the given bean and looking for values inside the container.
107
         * You basically checking properties of the given bean and looking for values inside the container.
108
         * And injecting in the given bean, in other words, populating it.
108
         * And injecting in the given bean, in other words, populating it.
Line 126... Line 126...
126
         * The method is useful to check for an instance without forcing her creation.
126
         * The method is useful to check for an instance without forcing her creation.
127
         *
127
         *
128
         * @param key The key representing the bean inside the container.
128
         * @param key The key representing the bean inside the container.
129
         * @return true if the container has an instance cached in the scope for this key
129
         * @return true if the container has an instance cached in the scope for this key
130
         */
130
         */
131
        public boolean check(String key);
-
 
-
 
131
        public boolean check(Object key);
132
       
132
       
133
        /**
133
        /**
134
         * Clear all cached instances for that scope. If you have a thread-pool for example you will
134
         * Clear all cached instances for that scope. If you have a thread-pool for example you will
135
         * want to clear the THREAD scope when your thread is returned to the pool. Because you have a thread
135
         * want to clear the THREAD scope when your thread is returned to the pool. Because you have a thread
136
         * pool you will have the SAME thread handling different requests and each request will need its own instances
136
         * pool you will have the SAME thread handling different requests and each request will need its own instances
Line 150... Line 150...
150
         * Clear a single key from cache and return the instance that was cached.
150
         * Clear a single key from cache and return the instance that was cached.
151
         *
151
         *
152
         * @param key The key representing the bean inside the container.
152
         * @param key The key representing the bean inside the container.
153
         * @return The value that was cached and it is not anymore (was cleared) or null if nothing was cleared
153
         * @return The value that was cached and it is not anymore (was cleared) or null if nothing was cleared
154
         */
154
         */
155
        public <T> T clear(String key);
-
 
-
 
155
        public <T> T clear(Object key);
156
}
156
}