MentaContainer

Rev

Rev 139 | Rev 143 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
45 soliveira 1
package org.mentacontainer;
2
 
3
/**
108 soliveira 4
 * An IoC factory that knows how to create instances and
45 soliveira 5
 * can be configured by accepting values for its constructor
107 soliveira 6
 * and properties (setters). It can also be intercepted right
110 soliveira 7
 * after it creates an instance and right before it releases an instance
107 soliveira 8
 * through the Interceptor interface.
45 soliveira 9
 *
107 soliveira 10
 * It also supports constructor and property values that are dependencies, in other words, they come from the container itself.
11
 *
45 soliveira 12
 * @author sergio.oliveira.jr@gmail.com
107 soliveira 13
 * @see Interceptor
45 soliveira 14
 */
141 soliveira 15
public interface ConfigurableFactory<E> extends Creator<E> {
45 soliveira 16
 
17
        /**
18
         * Add a constructor parameter to be used when the bean is instantiated. It can be called more than once to
19
         * use constructors with more than one argument.
20
         *
21
         * @param value A parameter value to be used by a constructor.
95 soliveira 22
         * @return The factory itself. (Fluent API)
45 soliveira 23
         */
141 soliveira 24
        public ConfigurableFactory<E> addInitValue(Object value);
45 soliveira 25
 
107 soliveira 26
        /**
27
         * Add a constructor parameter that is a primitive to be used when the bean is instantiated. It can be called more than once to
28
         * use constructors with more than one argument.<br/>
29
         * <br/>
30
         * Note: This method is seldom necessary and should be used if and only if you have a constructor that mixes Wrappers and primitives, like below:<br/>
31
         * <br/><pre>
32
         * public AObject(int x, Integer i, Boolean b, boolean f) { ... }
33
         * </pre>
34
         *
35
         * @param value A parameter value to be used by a constructor. Must be a primitive that will be autoboxed.
36
         * @return The factory itself. (Fluent API)
37
         */
141 soliveira 38
        public ConfigurableFactory<E> addInitPrimitive(Object value);
92 soliveira 39
 
107 soliveira 40
 
41
        /**
42
         * Add a constructor parameter that is a dependency, in other words, it gets its value from the container.
43
         * When the object is created the dependency will be obtained from the container.
44
         *
45
         * @param key The key used to get an instance from the container
46
         * @return The factory itself. (Fluent API)
47
         */
141 soliveira 48
        public ConfigurableFactory<E> addConstructorDependency(Object key);
96 soliveira 49
 
107 soliveira 50
        /**
51
         * In case you want to force the use of a zero argument constructor and avoid any ambiguity when choosing the constructor to use.
52
         *
53
         * This method is seldom necessary and should be used in the rare cases that the container cannot correctly determine the constructor you
54
         * want to use due to auto-wiring.
55
         *
56
         * @return The factory itself. (Fluent API)
57
         */
141 soliveira 58
        public ConfigurableFactory<E> useZeroArgumentConstructor();
96 soliveira 59
 
45 soliveira 60
        /**
107 soliveira 61
         * Add a property to be injected through a setter when the factory instantiates an object.
45 soliveira 62
         *
63
         * @param name The property name.
64
         * @param value The property value.
95 soliveira 65
         * @return The factory itself. (Fluent API)
45 soliveira 66
         */
141 soliveira 67
        public ConfigurableFactory<E> addPropertyValue(String name, Object value);
91 soliveira 68
 
107 soliveira 69
        /**
70
         * Add a setter property that is a dependency, in other words, its value will be obtained from the container.
71
         *
72
         * The property name and the dependency name are the same. If they are different you can use the other version of addPropertyDependency that accepts both values.
73
         *
74
         * @param property The dependency name which is equal to the property name.
75
         * @return The factory itself. (Fluent API)
76
         */
141 soliveira 77
        public ConfigurableFactory<E> addPropertyDependency(String property);
99 soliveira 78
 
107 soliveira 79
        /**
80
         * Add a setter property that is a dependency, in other words, its value will be obtained from the container.
81
         *
82
         * The property name and the dependency name are different.
83
         *
84
         * @param property The property that will be injected by the container.
85
         * @param key The dependency name, in other words, the key used to get a bean from the container.
86
         * @return The factory itself. (Fluent API)
87
         */
141 soliveira 88
        public ConfigurableFactory<E> addPropertyDependency(String property, Object key);
45 soliveira 89
}