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