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.ioc.*;
016
017/**
018 * Contribution to a service configuration.
019 *
020 * The toString() method of the ContributionDef will be used for some exception reporting and should clearly identify
021 * where the contribution comes from; the normal behavior is to identify the class and method of the contribution
022 * method.
023 */
024public interface ContributionDef
025{
026    /**
027     * Identifies the service contributed to.
028     */
029    String getServiceId();
030
031    /**
032     * Performs the work needed to contribute into the standard, unordered configuration.
033     *
034     * @param moduleSource  the source, if needed, of the module  instance associated with the contribution
035     * @param resources     allows access to services visible to the module
036     * @param configuration the unordered configuration into which values should be loaded. This instance will
037     *                      encapsulate all related error checks (such as passing of nulls or inappropriate classes).
038     */
039    void contribute(ModuleBuilderSource moduleSource, ServiceResources resources,
040                    Configuration configuration);
041
042    /**
043     * Performs the work needed to contribute into the ordered configuration.
044     *
045     * @param moduleSource  the source, if needed, of the module instance associated with the contribution
046     * @param resources     allows access to services visible to the module
047     * @param configuration the ordered configuration into which values should be loaded. This instance will encapsulate
048     *                      all related error checks (such as passing of nulls or inappropriate classes).
049     */
050    void contribute(ModuleBuilderSource moduleSource, ServiceResources resources,
051                    OrderedConfiguration configuration);
052
053    /**
054     * Performs the work needed to contribute into the mapped configuration.
055     *
056     * @param moduleSource  the source, if needed, of the module instance associated with the contribution
057     * @param resources     allows access to services visible to the module
058     * @param configuration the mapped configuration into which values should be loaded. This instance will encapsulate
059     *                      all related error checks (such as passing of null keys or values or inappropriate classes,
060     *                      or duplicate keys).
061     */
062    void contribute(ModuleBuilderSource moduleSource, ServiceResources resources,
063                    MappedConfiguration configuration);
064}