/** * Determines whether or not logging is enabled for the particular {@code MethodInvocation}. * If not, the method invocation proceeds as normal, otherwise the method invocation is passed * to the {@code invokeUnderTrace} method for handling. * @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log) */ @Override public Object invoke(MethodInvocation invocation) throws Throwable { Log logger = getLoggerForInvocation(invocation); if (isInterceptorEnabled(invocation, logger)) { return invokeUnderTrace(invocation, logger); } else { return invocation.proceed(); } }
/** * Return the appropriate {@code Log} instance to use for the given * {@code MethodInvocation}. If the {@code useDynamicLogger} flag * is set, the {@code Log} instance will be for the target class of the * {@code MethodInvocation}, otherwise the {@code Log} will be the * default static logger. * @param invocation the {@code MethodInvocation} being traced * @return the {@code Log} instance to use * @see #setUseDynamicLogger */ protected Log getLoggerForInvocation(MethodInvocation invocation) { if (this.defaultLogger != null) { return this.defaultLogger; } else { Object target = invocation.getThis(); return LogFactory.getLog(getClassForLogging(target)); } }
/** * Determine whether the interceptor should kick in, that is, * whether the {@code invokeUnderTrace} method should be called. * <p>Default behavior is to check whether the given {@code Log} * instance is enabled. Subclasses can override this to apply the * interceptor in other cases as well. * @param invocation the {@code MethodInvocation} being traced * @param logger the {@code Log} instance to check * @see #invokeUnderTrace * @see #isLogEnabled */ protected boolean isInterceptorEnabled(MethodInvocation invocation, Log logger) { return isLogEnabled(logger); }
/** * Determines whether or not logging is enabled for the particular <code>MethodInvocation</code>. * If not, the method invocation proceeds as normal, otherwise the method invocation is passed * to the <code>invokeUnderTrace</code> method for handling. * @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log) */ public Object invoke(MethodInvocation invocation) throws Throwable { Log logger = getLoggerForInvocation(invocation); if (logger.isTraceEnabled()) { return invokeUnderTrace(invocation, logger); } else { return invocation.proceed(); } }
/** * Write the supplied trace message to the supplied {@code Log} instance. * <p>To be called by {@link #invokeUnderTrace} for enter/exit messages. * <p>Delegates to {@link #writeToLog(Log, String, Throwable)} as the * ultimate delegate that controls the underlying logger invocation. * @since 4.3.10 * @see #writeToLog(Log, String, Throwable) */ protected void writeToLog(Log logger, String message) { writeToLog(logger, message, null); }
/** * Write the supplied trace message to the supplied {@code Log} instance. * <p>To be called by {@link #invokeUnderTrace} for enter/exit messages. * <p>Delegates to {@link #writeToLog(Log, String, Throwable)} as the * ultimate delegate that controls the underlying logger invocation. * @since 4.3.10 * @see #writeToLog(Log, String, Throwable) */ protected void writeToLog(Log logger, String message) { writeToLog(logger, message, null); }
/** * Determines whether or not logging is enabled for the particular {@code MethodInvocation}. * If not, the method invocation proceeds as normal, otherwise the method invocation is passed * to the {@code invokeUnderTrace} method for handling. * @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log) */ @Override public Object invoke(MethodInvocation invocation) throws Throwable { Log logger = getLoggerForInvocation(invocation); if (isInterceptorEnabled(invocation, logger)) { return invokeUnderTrace(invocation, logger); } else { return invocation.proceed(); } }
/** * Write the supplied trace message to the supplied {@code Log} instance. * <p>To be called by {@link #invokeUnderTrace} for enter/exit messages. * <p>Delegates to {@link #writeToLog(Log, String, Throwable)} as the * ultimate delegate that controls the underlying logger invocation. * @since 4.3.10 * @see #writeToLog(Log, String, Throwable) */ protected void writeToLog(Log logger, String message) { writeToLog(logger, message, null); }
/** * Determine whether the interceptor should kick in, that is, * whether the {@code invokeUnderTrace} method should be called. * <p>Default behavior is to check whether the given {@code Log} * instance is enabled. Subclasses can override this to apply the * interceptor in other cases as well. * @param invocation the {@code MethodInvocation} being traced * @param logger the {@code Log} instance to check * @see #invokeUnderTrace * @see #isLogEnabled */ protected boolean isInterceptorEnabled(MethodInvocation invocation, Log logger) { return isLogEnabled(logger); }
/** * Return the appropriate {@code Log} instance to use for the given * {@code MethodInvocation}. If the {@code useDynamicLogger} flag * is set, the {@code Log} instance will be for the target class of the * {@code MethodInvocation}, otherwise the {@code Log} will be the * default static logger. * @param invocation the {@code MethodInvocation} being traced * @return the {@code Log} instance to use * @see #setUseDynamicLogger */ protected Log getLoggerForInvocation(MethodInvocation invocation) { if (this.defaultLogger != null) { return this.defaultLogger; } else { Object target = invocation.getThis(); return LogFactory.getLog(getClassForLogging(target)); } }
/** * Determines whether or not logging is enabled for the particular {@code MethodInvocation}. * If not, the method invocation proceeds as normal, otherwise the method invocation is passed * to the {@code invokeUnderTrace} method for handling. * @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log) */ @Override public Object invoke(MethodInvocation invocation) throws Throwable { Log logger = getLoggerForInvocation(invocation); if (isInterceptorEnabled(invocation, logger)) { return invokeUnderTrace(invocation, logger); } else { return invocation.proceed(); } }
/** * Determine whether the interceptor should kick in, that is, * whether the {@code invokeUnderTrace} method should be called. * <p>Default behavior is to check whether the given {@code Log} * instance is enabled. Subclasses can override this to apply the * interceptor in other cases as well. * @param invocation the {@code MethodInvocation} being traced * @param logger the {@code Log} instance to check * @see #invokeUnderTrace * @see #isLogEnabled */ protected boolean isInterceptorEnabled(MethodInvocation invocation, Log logger) { return isLogEnabled(logger); }
/** * Return the appropriate {@code Log} instance to use for the given * {@code MethodInvocation}. If the {@code useDynamicLogger} flag * is set, the {@code Log} instance will be for the target class of the * {@code MethodInvocation}, otherwise the {@code Log} will be the * default static logger. * @param invocation the {@code MethodInvocation} being traced * @return the {@code Log} instance to use * @see #setUseDynamicLogger */ protected Log getLoggerForInvocation(MethodInvocation invocation) { if (this.defaultLogger != null) { return this.defaultLogger; } else { Object target = invocation.getThis(); return LogFactory.getLog(getClassForLogging(target)); } }