    001// Copyright 2008, 2011 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.AnnotationAccess;
    018
    019/**
    020 * A decorator used to create an interceptor that delegates each method's invocation to an
    021 * {@link org.apache.tapestry5.plastic.MethodAdvice} for advice. Advice can inspect or change method parameters, inspect or
    022 * change the method's return value, and inspect and change thrown exceptions (checked and unchecked).
    023 */
    024public interface AspectDecorator
    025{
    026    /**
    027     * Creates a builder that can be used to create the interceptor. This is used when only some of the methods need to
    028     * be advised, or when different methods need to receive different advice, or when multiple advice is to be
    029     * applied.
    030     *
    031     * @param serviceInterface defines the interface of the interceptor and the delegate
    032     * @param delegate         the object on which methods will be invokes
    033     * @param description      used as the toString() of the interceptor unless toString() is part of the service
    034     *                         interface
    035     * @return a builder that can be used to generate the final interceptor
    036     */
    037    <T> AspectInterceptorBuilder<T> createBuilder(Class<T> serviceInterface, T delegate, String description);
    038
    039    /**
    040     * Creates a builder that can be used to create the interceptor. This is used when only some of the methods need to
    041     * be advised, or when different methods need to receive different advice, or when multiple advice is to be
    042     * applied.
    043     *
    044     * @param serviceInterface defines the interface of the interceptor and the delegate
    045     * @param delegate         the object on which methods will be invokes
    046     * @param annotationAccess provides access to combined annotations of the underlying service
    047     *                         and service interface
    048     * @param description      used as the toString() of the interceptor unless toString() is part of the service
    049     *                         interface
    050     * @return a builder that can be used to generate the final interceptor
    051     */
    052    <T> AspectInterceptorBuilder<T> createBuilder(Class<T> serviceInterface, T delegate,
    053                                                  AnnotationAccess annotationAccess, String description);
    054}