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.ioc.MethodAdviceReceiver; 018 019/** 020 * An advisor that identifies methods which can be evaluated lazily and advises them. A method can be evaluated lazily 021 * if it returns an interface type and if it throws no checked exceptions. Lazy evaluation should be handled carefully, 022 * as if any of the parameters to a method are mutable, or the internal state of the invoked service changes, the lazily 023 * evaluated results may not match the immediately evaluated result. This effect is greatly exaggerated if the lazy 024 * return object is evaluated in a different thread than when it was generated. 025 * <p/> 026 * Another consideration is that exceptions that would occur immediately in the non-lazy case are also deferred, often 027 * losing much context in the process. 028 * <p/> 029 * Use laziness with great care. 030 * <p/> 031 * Use the {@link org.apache.tapestry5.ioc.annotations.NotLazy} annotation on methods that should not be advised. 032 * 033 * @since 5.1.0.0 034 */ 035public interface LazyAdvisor 036{ 037 void addLazyMethodInvocationAdvice(MethodAdviceReceiver methodAdviceReceiver); 038 039}