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 org.apache.hivemind.internal.ConfigurationPoint;
018    
019    /**
020     * Context for execution of a {@link Contribution}.
021     * 
022     * Allows to manipulate a configuration from a {@link Contribution}.
023     * The new contribution can be merged with the existing configuration data or
024     * the data may be changed or replaced. 
025     * 
026     * @author Huegen
027     */
028    public interface ContributionContext extends ConstructionContext
029    {
030        /**
031         * @return  the configuration point that is currently constructed
032         */
033        public ConfigurationPoint getConfigurationPoint();
034        
035        /**
036         * @return  the configuration data already provided by other contributions that were processed before.
037         *          Null, if no data has be contributed before.
038         */
039        public Object getConfigurationData();
040        
041        /**
042         * Replaces all configuration data with <code>data</code>. Overrides data provided by other contributions
043         * so should only be called when getConfigurationData() returns null.
044         *  
045         * @param data  the data
046         */
047        public void setConfigurationData(Object data);
048        
049        /**
050         * Merges contribution data with the data already provided by other contributions.
051         * Automatic merging works for standard collections only. 
052         * Handles the case that no data has been provided before (getConfigurationData() returns null)
053         * 
054         * @param contributionData  the data to merge. Must be compatible with the type of the configuration.
055         */
056        public void mergeContribution(Object contributionData);
057    }