001    // Copyright 2007 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.hivemind.definition;
016    
017    import java.util.Collection;
018    import java.util.List;
019    
020    import org.apache.hivemind.ApplicationRuntimeException;
021    import org.apache.hivemind.events.RegistryInitializationListener;
022    import org.apache.hivemind.impl.RegistryBuilder;
023    
024    /**
025     * Defines all modules and their service and configuration points 
026     * which build a registry. The definition is a blueprint from which
027     * a registry instance is constructed. 
028     * 
029     * The definition is passed to {@link RegistryBuilder} for the next phase: 
030     * the registry construction. 
031     * From that moment on the definition shouldn't be changed any longer.
032     * 
033     * @author Achim Huegen
034     */
035    public interface RegistryDefinition
036    {
037    
038        /**
039         * Adds a module definition.
040         * @param module  the module 
041         * @throws ApplicationRuntimeException  if another module with the same id already exists.
042         */
043        public void addModule(ModuleDefinition module) throws ApplicationRuntimeException;
044    
045        /**
046         * @return  a collection of all added {@link ModuleDefinition modules}
047         */
048        public Collection getModules();
049    
050        /**
051         * Returns a module that is identified by its module id.
052         * @param id  the module id
053         * @return  the module
054         */
055        public ModuleDefinition getModule(String id);
056    
057        /**
058         * Adds a {@link RegistryDefinitionPostProcessor}. The processor is called after all
059         * module definitions have been processed.
060         * @param postProcessor the processor
061         */
062        public void addPostProcessor(RegistryDefinitionPostProcessor postProcessor);
063    
064        /**
065         * @return  a collection of all registered {@link RegistryDefinitionPostProcessor}s
066         */
067        public List getPostProcessors();
068    
069        /**
070         * Adds a {@link RegistryInitializationListener} which is called after the 
071         * construction of the registry.
072         * @param listener  the listener
073         */
074        public void addRegistryInitializationListener(RegistryInitializationListener listener);
075    
076        /**
077         * @return  a collection of all registered {@link RegistryInitializationListener}s
078         */
079        public List getRegistryInitializationListeners();
080    
081        /**
082         * Returns a service point that is identified by its id.
083         * @param qualifiedServicePointId  the fully qualified service point id
084         * @return the service point definition
085         */
086        public ServicePointDefinition getServicePoint(String qualifiedServicePointId);
087    
088        /**
089         * Returns a configuration point that is identified by its id.
090         * @param qualifiedConfigurationPointId  the fully qualified configuration point id
091         * @return the configuration point definition
092         */
093        public ConfigurationPointDefinition getConfigurationPoint(String qualifiedConfigurationPointId);
094    
095    }