Java tutorial
/* * Copyright 2015 JAXIO http://www.jaxio.com * * 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 * * http://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 com.jaxio.celerio.aspects; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE; @Service @Scope(SCOPE_PROTOTYPE) @Slf4j public class GraphPredicateAspect { private static int depth = 0; @Around("com.jaxio.celerio.aspects.PredicatesAspect.methods()") public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable { depth++; StringBuilder sb = new StringBuilder(); for (int i = 0; i < depth; i++) { sb.append(' '); } sb.append(pjp.getSignature()); log.info(sb.toString()); Object retVal = pjp.proceed(); depth--; return retVal; } }