001    package biz.hammurapi.registry;
002    
003    import java.awt.Component;
004    import java.util.List;
005    import java.util.Map;
006    
007    /**
008     * Implementations of this interface are used to configure and instantiate
009     * component factories.
010     * @author Pavel
011     */
012    public interface FactoryConfigurator<T> {
013            
014            /**
015             * Configures factory. 
016             * @param context Configuration context. Some configuration parameters can be
017             * taken from the context to pre-populate or hide property pages if information
018             * is already available.
019             * @return If conifguration requires user interaction then a list of property 
020             * pages is returned. These pages are then present to the user in a wizard.
021             */
022            List<Component> configure(Map<?, ?> context);
023            
024            // TODO - Means to make factory configurator generic, i.e. not dependent on 
025            // Swing. It can be web-based for example, configured component will result 
026            // in a jar file download. The jar file will have required classes plus
027            // configuration stored in META-INF/config/...
028            
029            /**
030             * Instantiates factory for component/service. Factories aren't supposed to 
031             * implement any particular interface. E.g. CodeSnippet 'factory' creates 
032             * a fragment of code for component instantiation/configuration. 
033             * @return Configured component factory.
034             */
035            T createFactory();
036    }