List of usage examples for org.aspectj.lang ProceedingJoinPoint getSignature
Signature getSignature();
getStaticPart().getSignature()
returns the same object From source file:com.ottervpn.webservice.server.rest.CheckPostValues.java
License:Apache License
/** * Check post values on find methods. This is actually a no-op but it allows * us to log method entry.// w w w . ja v a2 s . c o m * * @param pjp * @return * @throws Throwable */ @Around("target(com.ottervpn.webservice.server.rest.AbstractResource) && execution(* *.find*(..))") public Object checkParametersFind(ProceedingJoinPoint pjp) throws Throwable { final Logger log = Logger.getLogger(pjp.getSignature().getDeclaringType()); if (log.isDebugEnabled()) { log.debug(String.format("%s(%s): entry", pjp.getSignature().getName(), Arrays.toString(pjp.getArgs()))); } final Object results = pjp.proceed(pjp.getArgs()); return results; }
From source file:com.ottervpn.webservice.server.rest.UnexpectedResourceExceptionHandler.java
License:Apache License
/** * Check for an unhandled exception from a REST resource. If we catch one * AND the method returns a Response we can return a Server Internal Error * (500) error code instead of blowing up. We need to check though since * some methods don't return a Response. * /* w w w . j ava 2s . c om*/ * @param pjp * @return * @throws Throwable */ @Around("target(com.ottervpn.webservice.server.rest.AbstractResource)") public Object checkForUnhandledException(ProceedingJoinPoint pjp) throws Throwable { Object results = null; Logger log = Logger.getLogger(pjp.getSignature().getClass()); try { results = pjp.proceed(pjp.getArgs()); //} catch (ObjectNotFoundException e) { // // this is safe to log since we know that we've passed filtering. // String args = Arrays.toString(pjp.getArgs()); // results = Response.status(Status.NOT_FOUND).entity("object not found: " + args).build(); // if (log.isDebugEnabled()) { // log.debug("object not found: " + args); // } } catch (Exception e) { // find the method we called. We can't cache this since the method // may be overloaded Method method = findMethod(pjp); if ((method != null) && Response.class.isAssignableFrom(method.getReturnType())) { // if the method returns a response we can return a 500 message. if (!(e instanceof UnitTestException)) { if (log.isInfoEnabled()) { log.info(String.format("%s(): unhandled exception: %s", pjp.getSignature().getName(), e.getMessage()), e); } } else if (log.isTraceEnabled()) { log.info("unit test exception: " + e.getMessage()); } results = Response.status(Status.INTERNAL_SERVER_ERROR).build(); } else { // DO NOT LOG THE EXCEPTION. That just clutters the log - let // the final handler log it. throw e; } } return results; }
From source file:com.prussia.play.spring.service.aop.ServiceMonitor.java
License:Apache License
@Around("pointCut()") public Object around(ProceedingJoinPoint joinPoint) throws Throwable { logger.warn("around start.., {} ", joinPoint); long start = System.currentTimeMillis(); Object o = null;/* ww w . ja v a 2s. co m*/ try { o = joinPoint.proceed(); } catch (Throwable ex) { throw ex; } finally { logger.warn("ServiceMonitor:" + joinPoint.getSignature().getName() + " takes " + (System.currentTimeMillis() - start) + "ms"); updateStats(joinPoint.getSignature().getName(), (System.currentTimeMillis() - start)); } return o; }
From source file:com.qbao.cat.plugin.cache.RedisPluginTemplate.java
License:Apache License
@Override public Transaction beginLog(ProceedingJoinPoint pjp) { Transaction transaction = null;//w w w . ja va 2 s . c om BinaryClient jedis = (BinaryClient) pjp.getTarget(); if (jedis != null) { transaction = Cat.newTransaction("Cache.Redis_" + jedis.getHost(), pjp.getSignature().toString()); } return transaction; }
From source file:com.qbao.cat.plugin.common.CommonPluginTemplate.java
License:Apache License
@Override protected Transaction beginLog(ProceedingJoinPoint pjp) { StringBuilder type = new StringBuilder(); String packageStr = pjp.getSignature().getDeclaringType().getPackage().getName(); StringTokenizer st = new StringTokenizer(packageStr, "."); for (int i = 0; i < 2; i++) { type.append(st.nextToken());//from ww w . j a v a2 s .com type.append("."); } type.append("Method"); Transaction transaction = Cat.newTransaction(type.toString(), pjp.getSignature().toString()); return transaction; }
From source file:com.qbao.cat.plugin.common.CommonPluginTemplate2.java
License:Apache License
@Override protected Transaction beginLog(ProceedingJoinPoint pjp) { Transaction transaction = Cat.newTransaction("Common.Method", pjp.getSignature().toString()); return transaction; }
From source file:com.qbao.cat.plugin.db.nosql.NewMongoPluginTemplate.java
License:Apache License
@Override protected Transaction beginLog(ProceedingJoinPoint pjp) { Transaction transaction = null;//w ww. j a v a 2 s .c o m transaction = newTransaction("MongoDB", String.valueOf(pjp.getSignature().toShortString())); MongoCollection collector = (MongoCollection) pjp.getTarget(); Cat.logEvent("DB.Collection", collector.getNamespace().getFullName()); Cat.logEvent("Method", pjp.getSignature().toString()); return transaction; }
From source file:com.qbao.cat.plugin.db.nosql.OldMongoPluginTemplate.java
License:Apache License
protected Transaction beginLog(ProceedingJoinPoint pjp) { Transaction transaction = null;// w w w . j ava2 s . c o m transaction = newTransaction("MongoDB", String.valueOf(pjp.getSignature().toShortString())); DBCollection collector = (DBCollection) pjp.getTarget(); Cat.logEvent("Host", collector.getDB().getMongo().getServerAddressList().toString()); Cat.logEvent("Connection", collector.toString()); Cat.logEvent("DB", collector.getDB().getName()); Cat.logEvent("Method", pjp.getSignature().toString()); return transaction; }
From source file:com.qcadoo.model.internal.aop.MonitorableAdvice.java
License:Open Source License
public Object doBasicProfiling(final ProceedingJoinPoint pjp, final Monitorable monitorable) throws Throwable { long start = System.currentTimeMillis(); try {//from www .j a va2s . com return pjp.proceed(); } finally { long end = System.currentTimeMillis(); long difference = end - start; if (difference > monitorable.threshold() && PERFORMANCE_LOG.isWarnEnabled()) { PERFORMANCE_LOG.warn("Call " + pjp.getSignature().toShortString() + " took " + difference + " ms "); } else if (PERFORMANCE_LOG.isDebugEnabled()) { PERFORMANCE_LOG .debug("Call " + pjp.getSignature().toShortString() + " took " + difference + " ms "); } } }
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;/*from www . j ava 2s .c o m*/ 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(); } } }