001    package biz.hammurapi.registry;
002    
003    import java.util.List;
004    import java.util.Set;
005    
006    /**
007     * Entry in Java Service/Component Registry.
008     * @author Tatyana Konukova
009     *
010     */
011    public interface RegistryEntry {
012            
013            /**
014             * @return Component/service name
015             */
016            String getName();
017            
018            /**
019             * @return Short description to display in component selection tree control.
020             */
021            String getTooltip();
022    
023            /**
024             * @return Long description to display in component details panel.
025             */
026            String getDescription();
027            
028            /**
029             * One entry may produce different types of objects. This method returns
030             * types supported by the entry. 
031             * @return Classes/interfaces implemented by this entry.
032             */
033            Class<?>[] getComponentTypes();
034            
035            /**
036             * One entry may support different factory types, e.g. CodeSnippet factory 
037             * creates a code snippet. That code snippet instantiates and configures component.
038             * XML document factory creates an XML element/document for instantiating/configuring
039             * component.
040             * @return
041             */
042            Class<?>[] getFactoryTypes();     
043    
044            /**
045             * @param componentTypes If this parameter is not null then only entries which
046             * support one of component types are displayed.
047             * @param componentTypes If this parameter is not null then only entries which
048             * support one of factory types are displayed.
049             * @param filterTokens Filter tokens
050             * @return True if entry itself matches (i.e. it can be selected in the browser). 
051             */
052            boolean match(Class<?>[] componentTypes, Class<?> factoryTypes, Set<String> filterTokens);
053            
054            /**
055             * @param componentTypes If this parameter is not null then only entries which
056             * support one of component types are displayed.
057             * @param componentTypes If this parameter is not null then only entries which
058             * support one of factory types are displayed.
059             * @param filterTokens Filter tokens
060             * @return True if entry has children matching tokens.
061             */
062            boolean hasChildren(Class<?>[] componentTypes, Class<?> factoryTypes, Set<String> filterTokens);
063            
064            /**
065             * @param componentTypes If this parameter is not null then only entries which
066             * support one of component types are returned.
067             * @param componentTypes If this parameter is not null then only entries which
068             * support one of factory types are returned.
069             * @param filterTokens
070             * @return Children matching tokens.
071             */
072            List<RegistryEntry> getChildren(Class<?>[] componentTypes, Class<?> factoryTypes, Set<String> filterTokens);
073    
074             /**
075              * Creates new factory for configuring and instantiating registry entry of given type.
076              * @param <T> Factory class.
077              * @return Configurator for the factory.
078              */
079             <T> FactoryConfigurator<T> newFactory(Class<T> factoryClass);
080    }