001// Copyright 2009 The Apache Software Foundation
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
007//     http://www.apache.org/licenses/LICENSE-2.0
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.
015package org.apache.tapestry5.ioc.services;
017import org.apache.tapestry5.ioc.MethodAdviceReceiver;
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
034 */
035public interface LazyAdvisor
037    void addLazyMethodInvocationAdvice(MethodAdviceReceiver methodAdviceReceiver);