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.slf4j.Logger;
016
017/**
018 * Service that can create a logging interceptor that wraps around a service implementation (or interceptor). The
019 * interceptor works with the service's log to log, at debug level, method entry (with arguments), method exit (with
020 * return value, if any) as well as any thrown exceptions.
021 *
022 * This represents the Tapestry 5.0 decorator approach; for Tapestry 5.1 you may want to use the {@link
023 * org.apache.tapestry5.ioc.services.LoggingAdvisor} in conjunction with a service advisor method.
024 */
025public interface LoggingDecorator
026{
027    /**
028     * Builds a logging interceptor instance.
029     *
030     * @param <T>
031     * @param serviceInterface interface implemented by the delegate
032     * @param delegate         existing object to be wrapped
033     * @param serviceId        id of service
034     * @param logger           log used for debug level logging messages by the interceptor
035     * @return a new object implementing the interface that can be used in place of the delegate, providing logging
036     *         behavior around each method call on the service interface
037     */
038    <T> T build(Class<T> serviceInterface, T delegate, String serviceId, Logger logger);
039}