List of usage examples for org.aspectj.lang JoinPoint getSourceLocation
SourceLocation getSourceLocation();
If there is no source location available, returns null.
Returns the SourceLocation of the defining class for default constructors.
getStaticPart().getSourceLocation() returns the same object.
From source file:TrivialTestAspect.java
License:Open Source License
@Before("execution (* AnotherClass.print(..))") public void trivialBeforeAspect(final JoinPoint joinPoint) { System.out.println("Intercepted [" + joinPoint.getSourceLocation().getWithinType().getSimpleName() + "]"); }
From source file:TrivialAspect.java
License:Open Source License
@Before("execution (* Clazz.print(..))") public void trivialBeforeAspect(final JoinPoint joinPoint) { System.out.println("Intercepted [" + joinPoint.getSourceLocation().getWithinType().getSimpleName() + "]"); }
From source file:com.arpnetworking.steno.aspect.LogBuilderAspect.java
License:Apache License
/** * Before outputting the message inject additional context. * * @param joinPoint The <code>JoinPoint</code>. *///from w ww . ja v a 2 s . c om @Before("call(* com.arpnetworking.steno.LogBuilder.log())") public void addToContextLineAndMethod(final JoinPoint joinPoint) { final SourceLocation sourceLocation = joinPoint.getSourceLocation(); final LogBuilder targetLogBuilder = (LogBuilder) joinPoint.getTarget(); targetLogBuilder.addContext("line", String.valueOf(sourceLocation.getLine())); targetLogBuilder.addContext("file", sourceLocation.getFileName()); targetLogBuilder.addContext("class", sourceLocation.getWithinType()); }
From source file:com.github.woozoo73.ht.JoinPointInfo.java
License:Apache License
public JoinPointInfo(JoinPoint joinPoint) { if (joinPoint == null) { return;//from www . j a va 2 s . c om } target = new ObjectInfo(joinPoint.getTarget()); args = joinPoint.getArgs(); if (args != null && args.length > 0) { argsInfo = new ObjectInfo[args.length]; for (int i = 0; i < argsInfo.length; i++) { argsInfo[i] = new ObjectInfo(args[i]); } } sourceLocation = new SourceLocationInfo(joinPoint.getSourceLocation()); Signature signature = joinPoint.getSignature(); if (signature == null) { return; } signatureInfo = new SignatureInfo(signature); }
From source file:com.nestedbird.util.JoinPointToStringHelper.java
License:Open Source License
private static Class<?> getType(JoinPoint jp) { return Optional.ofNullable(jp.getSourceLocation()).map(SourceLocation::getWithinType) .orElse(jp.getSignature().getDeclaringType()); }
From source file:com.qs.aop.HelloWorldAspect.java
public void beforeAdvice(JoinPoint jp) { System.out.println("================beforeAdvice================="); System.out.println(jp);/* w w w . j a v a 2 s. co m*/ System.out.println("getTarge" + jp.getTarget()); System.out.println("getSourceLocation" + jp.getSourceLocation()); System.out.println("getSignature" + jp.getSignature()); System.out.println("getStaticPart" + jp.getStaticPart()); System.out.println("================beforeAdvice================="); }
From source file:com.qycloud.oatos.license.monitor.AopMonitor.java
@Before("execution(* com.qycloud.oatos.license.web.*Controller.*(..))") public void forbidAccess(JoinPoint joinPoint) { System.out.println("--aspect----before---"); System.out.println("Completed: " + joinPoint.getSignature()); System.out.println("Completed: " + joinPoint.getTarget()); System.out.println("Completed: " + joinPoint.getArgs()); System.out.println("Completed: " + joinPoint.getSourceLocation()); }
From source file:hello.ServiceMonitor.java
License:Apache License
@After("execution(* hello..*Controller.*(..))") public void logServiceAfter(JoinPoint joinPoint) { System.out.println("After: " + joinPoint.toLongString()); System.out.println("After: " + joinPoint.toShortString()); System.out.println("After: " + joinPoint.getArgs()[0].toString()); System.out.println("After: " + joinPoint.getKind()); System.out.println("After: " + joinPoint.getClass()); System.out.println("After: " + joinPoint.getSignature()); System.out.println("After: " + joinPoint.getSourceLocation()); System.out.println("After: " + joinPoint.getStaticPart()); System.out.println("After: " + joinPoint.getTarget()); }
From source file:org.apache.tuscany.sca.aspectj.LoggingAspect.java
License:Apache License
@Before("anyStatic()") public void beforeStatic(JoinPoint jp) { System.out.println("Logging Before anyStatic before jp=" + jp); System.out.println("Logging anyMethodCall before jp.getSourceLocation=" + jp.getSourceLocation()); }
From source file:org.codelabor.system.sniffer.aspect.SniffingAspect.java
License:Apache License
/** * ./*w w w. j av a 2 s . c o m*/ * * @param joinPoint * ? ?? * @param exception * */ public void dumpException(JoinPoint joinPoint, Exception exception) { if (logger.isErrorEnabled()) { String message = exception.getMessage(); SourceLocation sourceLocation = joinPoint.getSourceLocation(); logger.debug("sourceLocation: {}", sourceLocation); // UnsupportedOperationException occurs. // String fileName = sourceLocation.getFileName(); // int line = sourceLocation.getLine(); logger.error("target: {}", joinPoint.getTarget().getClass().getName()); logger.error("signature: {}", joinPoint.getSignature().getName()); // logger.debug("file name: {}, line: {}", fileName, line); logger.error("exception class: {}", exception.getClass()); logger.error("exception message: {}", message); logger.error("cause: {}", exception.getCause()); StackTraceElement[] stackTraceElements = exception.getStackTrace(); logger.error("stack trace:"); int i = 0; for (StackTraceElement stackTraceElement : stackTraceElements) { logger.error("{} {}", i++, stackTraceElement); /* * logger.error("index: {}", i++); logger.error("class: {}", * stackTraceElement.getClassName()); logger.error("method: {}", * stackTraceElement.getMethodName()); * logger.error("is native method: {}", * stackTraceElement.isNativeMethod()); * logger.error("file name: {}, line: {}", * stackTraceElement.getFileName(), * stackTraceElement.getLineNumber()); */ } } }