List of usage examples for org.aspectj.lang ProceedingJoinPoint 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:com.qmetry.qaf.automation.step.JavaStepReporter.java
License:Open Source License
@Around("execution(@QAFTestStep * *.*(..))") public Object javaTestStep(ProceedingJoinPoint jp, JoinPoint.StaticPart thisJoinPointStaticPart) throws Throwable { JavaStep testStep = null;// ww w. jav a 2s .c om Signature sig = null; try { sig = thisJoinPointStaticPart.getSignature(); if ((sig instanceof MethodSignature) && TestBaseProvider.instance().get().getContext().getBoolean(JavaStep.ATTACH_LISTENER, true)) { // this must be a call or execution join point Method method = ((MethodSignature) sig).getMethod(); testStep = new MockJavaStep(method, jp); if (null != jp.getArgs()) { testStep.setActualArgs(jp.getArgs()); } } } catch (Exception e) { // ignore it... } if (ConfigurationManager.getBundle().getBoolean("method.recording.mode", false)) { ConfigurationManager.getBundle().setProperty("method.param.names", ((MethodSignature) sig).getParameterNames()); return null; } else { // unblock for sub-steps TestBaseProvider.instance().get().getContext().setProperty(JavaStep.ATTACH_LISTENER, true); if (null != testStep) { try { return testStep.execute(); } catch (JPThrowable e) { throw e.getCause(); } } else { // this call is from text client (bdd/kwd/excel) testStep = (JavaStep) TestBaseProvider.instance().get().getContext() .getProperty("current.teststep"); testStep.setFileName(jp.getSourceLocation().getFileName()); testStep.setLineNumber(jp.getSourceLocation().getLine()); testStep.signature = jp.getSignature().toLongString(); return jp.proceed(); } } }
From source file:org.grazy.experimental.graspectj.MethodLogger.java
License:Apache License
@Around("execution(* *(..)) && @annotation(Loggable)") public Object around(ProceedingJoinPoint point) { long start = System.currentTimeMillis(); Object result;/*from www . ja v a 2s.co m*/ try { result = point.proceed(); logger.log(Level.INFO, "source location: {0}", point.getSourceLocation().toString()); logger.log(Level.INFO, "#%s(%s): %s in %[msec]s{0}{1}{2}{3}", new Object[] { MethodSignature.class.cast(point.getSignature()).getMethod().getName(), point.getArgs(), result, System.currentTimeMillis() - start }); return result; } catch (Throwable ex) { Logger.getLogger(MethodLogger.class.getName()).log(Level.SEVERE, null, ex); } throw new RuntimeException("ma non scassare la minchia"); }
From source file:org.iternine.jeppetto.dao.mongodb.MongoDBSessionAspect.java
License:Apache License
public Object manageMongoDBSession(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { try {/*from w w w . j av a 2 s . co m*/ Logger logger = LoggerFactory.getLogger(proceedingJoinPoint.getSourceLocation().getWithinType()); MongoDBSession.create(logger, proceedingJoinPoint.getSignature().toShortString()); Object result = proceedingJoinPoint.proceed(); MongoDBSession.flush(); return result; } finally { MongoDBSession.remove(); } }
From source file:org.spf4j.perf.aspects.FileMonitorAspect.java
License:Open Source License
@Around("call(long java.nio.channels.FileChannel.read(..))") public Object nioReadLong(final ProceedingJoinPoint pjp) throws Throwable { Long result = (Long) pjp.proceed(); if (result >= 0) { RECORDER_READ.getRecorder(pjp.getSourceLocation().getWithinType()).record(result); }/*from w ww . j a v a2 s . c om*/ return result; }
From source file:org.spf4j.perf.aspects.FileMonitorAspect.java
License:Open Source License
@Around("call(int java.nio.channels.FileChannel.read(..))") public Object nioReadInt(final ProceedingJoinPoint pjp) throws Throwable { Integer result = (Integer) pjp.proceed(); if (result >= 0) { RECORDER_READ.getRecorder(pjp.getSourceLocation().getWithinType()).record(result); }// w w w.ja va2 s.c om return result; }
From source file:org.spf4j.perf.aspects.FileMonitorAspect.java
License:Open Source License
@Around("call(long java.nio.channels.FileChannel.write(..))") public Object nioWriteLong(final ProceedingJoinPoint pjp) throws Throwable { Long result = (Long) pjp.proceed(); if (result >= 0) { RECORDER_WRITE.getRecorder(pjp.getSourceLocation().getWithinType()).record(result); }/*from ww w . j av a 2 s . com*/ return result; }
From source file:org.spf4j.perf.aspects.FileMonitorAspect.java
License:Open Source License
@Around("call(int java.nio.channels.FileChannel.write(..))") public Object nioWriteInt(final ProceedingJoinPoint pjp) throws Throwable { Integer result = (Integer) pjp.proceed(); RECORDER_WRITE.getRecorder(pjp.getSourceLocation().getWithinType()).record(result); return result; }
From source file:org.spf4j.perf.aspects.FileMonitorAspect.java
License:Open Source License
@Around("call(java.io.FileInputStream.new(java.io.File))") public Object fileIS(final ProceedingJoinPoint pjp) throws Throwable { pjp.proceed();// w w w. ja va2s .co m return new MeasuredFileInputStream((File) pjp.getArgs()[0], pjp.getSourceLocation().getWithinType(), RECORDER_READ); }
From source file:org.spf4j.perf.aspects.FileMonitorAspect.java
License:Open Source License
@Around("call(java.io.FileOutputStream.new(java.io.File))") public Object fileOS(final ProceedingJoinPoint pjp) throws Throwable { pjp.proceed();/* w w w.j a va2 s. c o m*/ return new MeasuredFileOutputStream((File) pjp.getArgs()[0], pjp.getSourceLocation().getWithinType(), RECORDER_WRITE); }
From source file:org.spf4j.perf.aspects.NetworkMonitorAspect.java
License:Open Source License
@Around("call(long java.nio.channels.SocketChannel.read(..))") public Object nioReadLong(final ProceedingJoinPoint pjp) throws Throwable { Long result = (Long) pjp.proceed(); if (result >= 0) { RECORDER_READ.getRecorder(pjp.getSourceLocation().getWithinType()).record(result); }/*from www . j av a 2 s . c o m*/ return result; }