001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
004//
005//     http://www.apache.org/licenses/LICENSE-2.0
006//
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
012
013package org.apache.tapestry5.ioc.def;
014
015import org.apache.tapestry5.commons.*;
016import org.apache.tapestry5.ioc.ModuleBuilderSource;
017import org.apache.tapestry5.ioc.ServiceResources;
018
019/**
020 * Contribution to a service configuration.
021 *
022 * The toString() method of the ContributionDef will be used for some exception reporting and should clearly identify
023 * where the contribution comes from; the normal behavior is to identify the class and method of the contribution
024 * method.
025 */
026public interface ContributionDef
027{
028    /**
029     * Identifies the service contributed to.
030     */
031    String getServiceId();
032
033    /**
034     * Performs the work needed to contribute into the standard, unordered configuration.
035     *
036     * @param moduleSource  the source, if needed, of the module  instance associated with the contribution
037     * @param resources     allows access to services visible to the module
038     * @param configuration the unordered configuration into which values should be loaded. This instance will
039     *                      encapsulate all related error checks (such as passing of nulls or inappropriate classes).
040     */
041    void contribute(ModuleBuilderSource moduleSource, ServiceResources resources,
042                    Configuration configuration);
043
044    /**
045     * Performs the work needed to contribute into the ordered configuration.
046     *
047     * @param moduleSource  the source, if needed, of the module instance associated with the contribution
048     * @param resources     allows access to services visible to the module
049     * @param configuration the ordered configuration into which values should be loaded. This instance will encapsulate
050     *                      all related error checks (such as passing of nulls or inappropriate classes).
051     */
052    void contribute(ModuleBuilderSource moduleSource, ServiceResources resources,
053                    OrderedConfiguration configuration);
054
055    /**
056     * Performs the work needed to contribute into the mapped configuration.
057     *
058     * @param moduleSource  the source, if needed, of the module instance associated with the contribution
059     * @param resources     allows access to services visible to the module
060     * @param configuration the mapped configuration into which values should be loaded. This instance will encapsulate
061     *                      all related error checks (such as passing of null keys or values or inappropriate classes,
062     *                      or duplicate keys).
063     */
064    void contribute(ModuleBuilderSource moduleSource, ServiceResources resources,
065                    MappedConfiguration configuration);
066}