All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.tsl2.nano.service.util.LoggingInterceptor Maven / Gradle / Ivy

Go to download

TSL2 JEE Service Access (Generic Services for Entity Access, JEE File-System-Connector, Generic Featuring, Job-Scheduling, BeanContainer, Batch, Comfortable Bean Query Definitions, JAAS, Authentification, Authorization, )

The newest version!
/*
 * File: $HeadURL$
 * Id  : $Id$
 * 
 * created by: TS, Thomas Schneider
 * created on: Jan 11, 2010
 * 
 * Copyright: (c) Thomas Schneider 2010, all rights reserved
 */
package de.tsl2.nano.service.util;

import java.util.Arrays;

import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;

import org.apache.commons.logging.Log;

import de.tsl2.nano.core.log.LogFactory;

/**
 * A EJB 3.x interceptor useful for logging.
 * 
 * @author EGU, Thomas Schneider
 * @version $Revision$
 */
public class LoggingInterceptor {
    private static final Log LOG = LogFactory.getLog(LoggingInterceptor.class);

    /**
     * "Around" interceptor method.
     * 
     * @param invocationContext the context.
     * @return whatever the invoked methods returned
     * @throws Exception only exceptions declared by the invoked method
     */
    @AroundInvoke
    public Object around(InvocationContext invocationContext) throws Exception {
        try {
            LOG.info("invoke method=" + invocationContext.getMethod()
                + " params="
                + Arrays.toString(invocationContext.getParameters()));
            return invocationContext.proceed();
        } catch (final Exception e) {
            LOG.error("catch and rethrow", e);
            throw e;
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy