001    package com.hammurapi.config.bootstrap;
002    
003    
004    
005    /**
006     * Factory closure to create objects without additional configuration information. 
007     * @author Pavel Vlasov
008     *
009     */
010    public interface FactoryClosure<T> {
011            
012            // TODO If lifecycle executor is available, then initialization
013            // should be performed in multiple threads in parallel, child (injected) objects are guaranteed to be initialized before the parent object in
014            // which they are injected (leaf to root direction).
015            
016            /**
017             * Performs initialization of already
018             * configured objects and returns the root object.
019             * @param args Optional constructor arguments. If arguments are provided,
020             * the closure finds a compatible constructor and invokes it. The rest of 
021             * configuration - property injection, etc. happens in the same way as if 
022             * no argument were provided.    
023             * @return Configured and initialized object.    
024             */
025            T create(Object... args) throws ConfigurationException;
026            
027            /**
028             * @return Destroyable if factory result has resource cleanup logic, or null.
029             */
030            Destroyable getDestroyable() throws ConfigurationException;
031            
032    }