001    // Copyright 2006 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.services;
016    
017    /**
018     * Creates a "shadow" of a property of an object. The shadow has the same type as the property, and delegates all method
019     * invocations to the property. Each method invocation on the shadow re-acquires the value of the property from the
020     * underlying object and delegates to the current value of the property.
021     * <p/>
022     * Typically, the object in question is another service, one with the "perthread" service lifecycle. This allows a
023     * global singleton to shadow a value that is specific to the current thread (and therefore, the current request).
024     */
025    public interface PropertyShadowBuilder
026    {
027        /**
028         * @param <T>
029         * @param source       the object from which a property will be extracted
030         * @param propertyName the name of a property of the object, which must be readable
031         * @param propertyType the expected type of the property, the actual property type must be assignable to this type
032         * @return the shadow
033         */
034        <T> T build(Object source, String propertyName, Class<T> propertyType);
035    }