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.commons;
014
015/**
016 * Object passed into a service contributor method that allows the method provide contributed values to the service's
017 * configuration.
018 *
019 * A service can <em>collect</em> contributions in three different ways:
020 * <ul>
021 * <li>As an un-ordered collection of values</li>
022 * <li>As an ordered list of values (where each value has a unique id, pre-requisites and post-requisites)</li>
023 * <li>As a map of keys and values
024 * </ul>
025 *
026 * This implementation is used for un-ordered configuration data.
027 *
028 * The service defines the <em>type</em> of contribution, in terms of a base class or service interface. Contributions
029 * must be compatible with the type.
030 */
031public interface Configuration<T>
032{
033    /**
034     * Adds an object to the service's contribution.
035     * 
036     * @param object
037     *            to add to the service's configuration
038     */
039    void add(T object);
040
041    /**
042     * Automatically instantiates an instance of the class, with dependencies injected, and adds it to the
043     * configuration. When the configuration type is an interface and the class to be contributed is a local file,
044     * then a reloadable proxy for the class will be created and contributed.
045     * 
046     * @param clazz
047     *            what class to instantiate
048     * @since 5.1.0.0
049     */
050    void addInstance(Class<? extends T> clazz);
051}