001    // Copyright 2006, 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.tapestry.services;
016    
017    import org.apache.tapestry.ioc.ObjectLocator;
018    import org.apache.tapestry.model.MutableComponentModel;
019    
020    /**
021     * Provides some form of injection when the value for an {@link org.apache.tapestry.ioc.annotations.Inject} annotation
022     * is present. In this case, the provider is responsible for determining the value to be injected from the field name
023     * and field type.
024     * <p/>
025     * This interface will be used as part of a {@link org.apache.tapestry.ioc.services.ChainBuilder chain of command}.
026     */
027    public interface InjectionProvider
028    {
029        /**
030         * Peform the injection, if possible. Most often, this will result in a call to {@link
031         * ClassTransformation#injectField(String, Object)}. The caller is responsible for invoking {@link
032         * ClassTransformation#claimField(String, Object)}.
033         *
034         * @param fieldName      the name of the field requesting injection
035         * @param fieldType      the type of the field
036         * @param locator        allows services to be located
037         * @param transformation allows the code for the class to be transformed
038         * @param componentModel defines the relevant aspects of the component
039         * @return true if an injection has been made (terminates the command chain), false to continue down the chain
040         */
041        boolean provideInjection(String fieldName, Class fieldType, ObjectLocator locator,
042                                 ClassTransformation transformation, MutableComponentModel componentModel);
043    }