Example usage for org.springframework.aop.interceptor CustomizableTraceInterceptor setEnterMessage

List of usage examples for org.springframework.aop.interceptor CustomizableTraceInterceptor setEnterMessage

Introduction

In this page you can find the example usage for org.springframework.aop.interceptor CustomizableTraceInterceptor setEnterMessage.

Prototype

public void setEnterMessage(String enterMessage) throws IllegalArgumentException 

Source Link

Document

Set the template used for method entry log messages.

Usage

From source file:com.capgemini.boot.trace.TraceLoggerConfigurationUtils.java

/**
 * Creates a trace interceptor for logging entry into and exit from methods.
 * @param settings the settings// w  ww  .ja  v  a2  s . c  o m
 * @return The created trace interceptor
 */
public static AbstractTraceInterceptor createTraceInterceptor(TraceLoggerSettings settings) {
    CustomizableTraceInterceptor customizableTraceInterceptor = new CustomizableTraceInterceptor();
    customizableTraceInterceptor.setUseDynamicLogger(true);
    customizableTraceInterceptor.setEnterMessage(settings.getMessage().getEnter());
    customizableTraceInterceptor.setExitMessage(settings.getMessage().getExit());
    customizableTraceInterceptor.setExceptionMessage(settings.getMessage().getException());
    return customizableTraceInterceptor;
}

From source file:pl.java.scalatech.config.AopPerformanceLogConfig.java

@Bean
public CustomizableTraceInterceptor interceptor() {
    CustomizableTraceInterceptor interceptor = new CustomizableTraceInterceptor();
    interceptor.setEnterMessage("Entering =>  $[methodName]($[arguments]).");
    interceptor.setExitMessage(/* www. j  a v a  2 s  .c  o m*/
            "Leaving => $[methodName](..) with return value $[returnValue], took $[invocationTime]ms.");
    return interceptor;
}

From source file:example.springdata.jpa.interceptors.ApplicationConfiguration.java

public @Bean CustomizableTraceInterceptor interceptor() {

    CustomizableTraceInterceptor interceptor = new CustomizableTraceInterceptor();
    interceptor.setEnterMessage("Entering $[methodName]($[arguments]).");
    interceptor.setExitMessage(//from www.j av  a  2s  .com
            "Leaving $[methodName](..) with return value $[returnValue], took $[invocationTime]ms.");

    return interceptor;
}

From source file:org.spring.data.jpa.sample.interceptors.ApplicationConfiguration.java

@Bean
public CustomizableTraceInterceptor interceptor() {

    CustomizableTraceInterceptor interceptor = new CustomizableTraceInterceptor();
    interceptor.setEnterMessage("Entering $[methodName]($[arguments]).");
    interceptor.setExitMessage(//from   w  w  w .  j ava 2s.com
            "Leaving $[methodName](..) with return value $[returnValue], took $[invocationTime]ms.");

    return interceptor;
}

From source file:br.com.teste.spring.security.config.AppConfig.java

@Bean
public CustomizableTraceInterceptor interceptor() {
    CustomizableTraceInterceptor interceptor = new CustomizableTraceInterceptor();
    interceptor.setEnterMessage(ENTER_METHOD_MESSAGE);
    interceptor.setExceptionMessage(EXCEPTION_MESSAGE);
    interceptor.setExitMessage(EXIT_METHOD_MESSAGE);
    return interceptor;
}

From source file:fr.univlorraine.mondossierweb.config.DebugConfig.java

/**
 * Interceptor permettant de logger les appels aux mthodes
 * @return//from  ww w . j  a v  a  2s .c  o m
 */
@Bean
public CustomizableTraceInterceptor customizableTraceInterceptor() {
    CustomizableTraceInterceptor customizableTraceInterceptor = new CustomizableTraceInterceptor();
    customizableTraceInterceptor.setUseDynamicLogger(true);
    customizableTraceInterceptor.setEnterMessage("Entering $[methodName]($[arguments])");
    customizableTraceInterceptor.setExitMessage("Leaving  $[methodName](), returned $[returnValue]");
    return customizableTraceInterceptor;
}

From source file:org.springframework.aop.interceptor.CustomizableTraceInterceptorTests.java

@Test
public void testSunnyDayPathLogsCorrectlyWithPrettyMuchAllPlaceholdersMatching() throws Throwable {

    MethodInvocation methodInvocation = mock(MethodInvocation.class);

    given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
    given(methodInvocation.getThis()).willReturn(this);
    given(methodInvocation.getArguments()).willReturn(new Object[] { "$ One \\$", new Long(2) });
    given(methodInvocation.proceed()).willReturn("Hello!");

    Log log = mock(Log.class);
    given(log.isTraceEnabled()).willReturn(true);

    CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log);
    interceptor.setEnterMessage(new StringBuffer().append("Entering the '")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_METHOD_NAME).append("' method of the [")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_TARGET_CLASS_NAME)
            .append("] class with the following args (")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_ARGUMENTS).append(") and arg types (")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_ARGUMENT_TYPES).append(").").toString());
    interceptor.setExitMessage(new StringBuffer().append("Exiting the '")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_METHOD_NAME).append("' method of the [")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_TARGET_CLASS_SHORT_NAME)
            .append("] class with the following args (")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_ARGUMENTS).append(") and arg types (")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_ARGUMENT_TYPES).append("), returning '")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_RETURN_VALUE).append("' and taking '")
            .append(CustomizableTraceInterceptor.PLACEHOLDER_INVOCATION_TIME).append("' this long.")
            .toString());//from w  w w. jav a 2s  .c o m
    interceptor.invoke(methodInvocation);

    verify(log, times(2)).trace(anyString());
}