001// Copyright 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 015package org.apache.tapestry5.ioc.services; 016 017import org.apache.tapestry5.commons.ObjectCreator; 018 019/** 020 * A <a href="http://en.wikipedia.org/wiki/Thunk">thunk</a> is a delayed calculation. In Java and Tapestry terms, a 021 * Thunk is a proxy object of a particular interface that delegates all methods to an object of the same type obtained 022 * from an {@link org.apache.tapestry5.commons.ObjectProvider}. This is used by {@link 023 * org.apache.tapestry5.ioc.services.LazyAdvisor} to build lazy thunk proxies. 024 * 025 * @since 5.1.0.1 026 */ 027public interface ThunkCreator 028{ 029 /** 030 * Creates a Thunk of the given proxy type. 031 * 032 * @param proxyType type of object to create (must be an interface) 033 * @param objectCreator provides an instance of the same type on demand (may be invoked multiple times) 034 * @param description to be returned from the thunk's toString() method 035 * @param <T> type of thunk 036 * @return thunk of given type 037 */ 038 <T> T createThunk(Class<T> proxyType, ObjectCreator objectCreator, String description); 039}