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