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.internal;
016    
017    import org.apache.hivemind.definition.ConstructionContext;
018    
019    /**
020     * Default Implementation of {@link ConstructionContext}.
021     * 
022     * @author Achim Huegen
023     */
024    public abstract class AbstractConstructionContext implements ConstructionContext
025    {
026        private Module _definingModule;
027    
028        public AbstractConstructionContext(Module definingModule)
029        {
030            _definingModule = definingModule;
031        }
032    
033        public Object getConfiguration(String configurationId)
034        {
035            return _definingModule.getConfiguration(configurationId);
036        }
037    
038        /**
039         * @see org.apache.hivemind.definition.ConstructionContext#getDefiningModule()
040         */
041        public Module getDefiningModule()
042        {
043            return _definingModule;
044        }
045    
046        /**
047         * @see org.apache.hivemind.definition.ConstructionContext#getService(java.lang.String, java.lang.Class)
048         */
049        public Object getService(String serviceId, Class serviceInterface)
050        {
051            return _definingModule.getService(serviceId, serviceInterface);
052        }
053    
054        /**
055         * @see org.apache.hivemind.definition.ConstructionContext#getService(java.lang.Class)
056         */
057        public Object getService(Class serviceInterface)
058        {
059            return _definingModule.getService(serviceInterface);
060        }
061        
062        /**
063         * @see org.apache.hivemind.definition.ConstructionContext#containsService(java.lang.Class)
064         */
065        public boolean containsService(Class serviceInterface)
066        {
067            return _definingModule.containsService(serviceInterface);
068        }
069    
070        /**
071         * @see org.apache.hivemind.definition.ConstructionContext#getRegistry()
072         */
073        public RegistryInfrastructure getRegistry()
074        {
075            return getDefiningModule().getRegistry();
076        }
077    
078    }