Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.aop.interceptor;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.springframework.core.Constants;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
/**
* {@code MethodInterceptor} implementation that allows for highly customizable
* method-level tracing, using placeholders.
*
*
Trace messages are written on method entry, and if the method invocation succeeds
* on method exit. If an invocation results in an exception, then an exception message
* is written. The contents of these trace messages is fully customizable and special
* placeholders are available to allow you to include runtime information in your log
* messages. The placeholders available are:
*
*
*
{@code $[methodName]} - replaced with the name of the method being invoked
*
{@code $[targetClassName]} - replaced with the name of the class that is
* the target of the invocation
*
{@code $[targetClassShortName]} - replaced with the short name of the class
* that is the target of the invocation
*
{@code $[returnValue]} - replaced with the value returned by the invocation
*
{@code $[argumentTypes]} - replaced with a comma-separated list of the
* short class names of the method arguments
*
{@code $[arguments]} - replaced with a comma-separated list of the
* {@code String} representation of the method arguments
*
{@code $[exception]} - replaced with the {@code String} representation
* of any {@code Throwable} raised during the invocation
*
{@code $[invocationTime]} - replaced with the time, in milliseconds,
* taken by the method invocation
*
*
*
There are restrictions on which placeholders can be used in which messages:
* see the individual message properties for details on the valid placeholders.
*
* @author Rob Harrop
* @author Juergen Hoeller
* @since 1.2
* @see #setEnterMessage
* @see #setExitMessage
* @see #setExceptionMessage
* @see SimpleTraceInterceptor
*/
@SuppressWarnings("serial")
public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
/**
* The {@code $[methodName]} placeholder.
* Replaced with the name of the method being invoked.
*/
public static final String PLACEHOLDER_METHOD_NAME = "$[methodName]";
/**
* The {@code $[targetClassName]} placeholder.
* Replaced with the fully-qualified name of the {@code Class}
* of the method invocation target.
*/
public static final String PLACEHOLDER_TARGET_CLASS_NAME = "$[targetClassName]";
/**
* The {@code $[targetClassShortName]} placeholder.
* Replaced with the short name of the {@code Class} of the
* method invocation target.
*/
public static final String PLACEHOLDER_TARGET_CLASS_SHORT_NAME = "$[targetClassShortName]";
/**
* The {@code $[returnValue]} placeholder.
* Replaced with the {@code String} representation of the value
* returned by the method invocation.
*/
public static final String PLACEHOLDER_RETURN_VALUE = "$[returnValue]";
/**
* The {@code $[argumentTypes]} placeholder.
* Replaced with a comma-separated list of the argument types for the
* method invocation. Argument types are written as short class names.
*/
public static final String PLACEHOLDER_ARGUMENT_TYPES = "$[argumentTypes]";
/**
* The {@code $[arguments]} placeholder.
* Replaced with a comma separated list of the argument values for the
* method invocation. Relies on the {@code toString()} method of
* each argument type.
*/
public static final String PLACEHOLDER_ARGUMENTS = "$[arguments]";
/**
* The {@code $[exception]} placeholder.
* Replaced with the {@code String} representation of any
* {@code Throwable} raised during method invocation.
*/
public static final String PLACEHOLDER_EXCEPTION = "$[exception]";
/**
* The {@code $[invocationTime]} placeholder.
* Replaced with the time taken by the invocation (in milliseconds).
*/
public static final String PLACEHOLDER_INVOCATION_TIME = "$[invocationTime]";
/**
* The default message used for writing method entry messages.
*/
private static final String DEFAULT_ENTER_MESSAGE = "Entering method '" +
PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
/**
* The default message used for writing method exit messages.
*/
private static final String DEFAULT_EXIT_MESSAGE = "Exiting method '" +
PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
/**
* The default message used for writing exception messages.
*/
private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception thrown in method '" +
PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
/**
* The {@code Pattern} used to match placeholders.
*/
private static final Pattern PATTERN = Pattern.compile("\\$\\[\\p{Alpha}+]");
/**
* The {@code Set} of allowed placeholders.
*/
private static final Set