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