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