List of usage examples for org.aspectj.lang ProceedingJoinPoint toLongString
String toLongString();
From source file:com.klistret.cmdb.utility.spring.OptimisticLocking.java
License:Open Source License
public Object commitTransaction(ProceedingJoinPoint pjp) throws Throwable { try {// w w w . ja v a 2 s. c o m return pjp.proceed(); } catch (HibernateOptimisticLockingFailureException e) { Signature signature = pjp.getSignature(); logger.error("Stale in declaration:{}, name: {}, long: {} message: {}", new Object[] { signature.getDeclaringTypeName(), signature.getName(), pjp.toLongString(), e.getMessage() }); throw new ApplicationException("Stale entity captured."); } }
From source file:com.zoltran.perf.aspect.PerformanceMonitorAspect.java
License:Open Source License
@Around(value = "execution(@com.zoltran.perf.aspect.PerformanceMonitor * *(..)) && @annotation(annot)", argNames = "pjp,annot") public Object performanceMonitoredMethod(ProceedingJoinPoint pjp, PerformanceMonitor annot) throws Throwable { final long start = System.currentTimeMillis(); Object result = pjp.proceed(); final long elapsed = System.currentTimeMillis() - start; MeasurementRecorderSource mrs = mrecSources.getUnchecked(annot.recorderSource()); mrs.getRecorder(pjp.toLongString()).record(elapsed); if (elapsed > annot.warnThresholdMillis()) { if (elapsed > annot.errorThresholdMillis()) { LOG.error("Execution time {} ms for {} exceeds error threshold of {} ms, arguments {}", new Object[] { elapsed, pjp.toShortString(), annot.errorThresholdMillis(), pjp.getArgs() }); } else {// w w w . j a v a 2s.c om LOG.warn("Execution time {} ms for {} exceeds warning threshold of {} ms, arguments {}", new Object[] { elapsed, pjp.toShortString(), annot.warnThresholdMillis(), pjp.getArgs() }); } } else { LOG.debug("Execution time {} ms for {}, arguments {}", new Object[] { elapsed, pjp.toShortString(), pjp.getArgs() }); } return result; }
From source file:hornet.framework.metrologie.aspect.MetrologieAspect.java
License:CeCILL license
/** * ArroundMethod pour pour la gestion des chronometres : - Arret du chronometre precedent. - Demarrage du * chronometre. - Execution de la methode. - Arret du chronometre. - Redemarrage du chronometre precedent. * * @param jointPoint// w w w. ja v a 2 s. c o m * the joint point * @return the object * @throws Throwable * the Throwable */ public Object loggerTraceMetrologie(final ProceedingJoinPoint jointPoint) throws Throwable { LOGGER.debug("{}->{} : {}", this.previousChronoName, this.chronoNametoStart, jointPoint.toLongString()); if (this.previousChronoName != null) { ChronometreSet.get().getChrono(this.previousChronoName).stop(); } ChronometreSet.get().getChrono(this.chronoNametoStart).start(); Object obj; try { obj = jointPoint.proceed(); } finally { ChronometreSet.get().getChrono(this.chronoNametoStart).stop(); if (this.previousChronoName != null) { ChronometreSet.get().getChrono(this.previousChronoName).start(); } } return obj; }
From source file:io.starter.security.securefield.SecureFieldAspect.java
@Around(FIELD_GET) public Object getSecureField(ProceedingJoinPoint pjp) throws Throwable { String cnm = Thread.currentThread().getStackTrace()[8].getClassName(); // System.err.println("Calling: " + cnm); // if iBatis is calling, do not decrypt if (cnm.toLowerCase().contains("ibatis") && SKIP_IBATIS_CALLER) { return pjp.proceed(pjp.getArgs()); }//from w w w . j av a 2 s . com Logger.debug("Get Secure Field for: " + pjp.toLongString()); Object targetObject = pjp.getTarget(); String secureFieldName = pjp.getSignature().getName(); Field secureField = targetObject.getClass().getDeclaredField(secureFieldName); secureField.setAccessible(true); Object encryptedObject = secureField.get(targetObject); secureField.setAccessible(false); return SecureEncrypter.decrypt(String.valueOf(encryptedObject)); }
From source file:io.starter.security.securefield.SecureFieldAspect.java
@Around(FIELD_SET) public Object setSecureField(ProceedingJoinPoint pjp) throws Throwable { String cnm = Thread.currentThread().getStackTrace()[8].getClassName(); // System.err.println("Calling: " + cnm); // if iBatis is calling, do not encrypt if (cnm.toLowerCase().contains("ibatis") && SKIP_IBATIS_CALLER) { return pjp.proceed(pjp.getArgs()); }/*w w w . j a v a 2 s.co m*/ Logger.debug("Set Secure Field for: " + pjp.toLongString()); String clearTextValue = String.valueOf(pjp.getArgs()[0]); String encryptedValue = SecureEncrypter.encrypt(clearTextValue); Object targetObject = pjp.getTarget(); String secureFieldName = pjp.getSignature().getName(); Field secureField = targetObject.getClass().getDeclaredField(secureFieldName); secureField.setAccessible(true); secureField.set(targetObject, encryptedValue); secureField.setAccessible(false); return null; }
From source file:net.kamhon.ieagle.aop.DwrDelegateAdvice.java
License:Apache License
public Object invoke(ProceedingJoinPoint pjp) throws Throwable { log.debug(pjp.toLongString()); Object retVal = null;// w w w . ja va2 s .co m try { retVal = pjp.proceed(); } catch (Exception ex) { if (!(ex instanceof ValidatorException)) { log.error(ex, ex.fillInStackTrace()); } throw ex; } return retVal; }
From source file:org.apache.usergrid.persistence.cassandra.util.TraceTagAspect.java
License:Apache License
public Object applyTrace(ProceedingJoinPoint pjp) throws Throwable { String tagName = pjp.toLongString(); logger.debug("Applyng trace on {}", tagName); TimedOpTag timedOpTag = traceTagManager.timerInstance(); boolean success = true; try {//from w ww. jav a 2 s. c om return pjp.proceed(); } catch (Exception e) { success = false; throw e; } finally { timedOpTag.stopAndApply(tagName, success); traceTagManager.addTimer(timedOpTag); logger.debug("TimedOpTag added in Aspect on {}", tagName); } }
From source file:org.easyrec.utils.spring.profile.aop.JamonProfilingAspectAdvice.java
License:Open Source License
public Object profileInvocation(ProceedingJoinPoint pjp) throws Throwable { if (logger.isDebugEnabled()) { logger.debug("profiling call for method" + pjp.toLongString()); }/* ww w. j a v a 2 s .com*/ Monitor mon = MonitorFactory.start(createMonitorName(pjp)); try { return pjp.proceed(); } finally { mon.stop(); long now = System.currentTimeMillis(); if (now - lastOutput > outputInterval) { lastOutput = now; try { outputStats(); } catch (IOException ioe) { logger.warn("error writing to '" + getReportOutputLocation() + "'", ioe); } } } }
From source file:org.easyrec.utils.spring.profile.aop.JamonProfilingAspectAdvice.java
License:Open Source License
/** * @param pjp/*from w w w . j a v a 2s . co m*/ * @return */ private String createMonitorName(ProceedingJoinPoint pjp) { if (GROUPING_CLASS.equals(grouping)) { return pjp.toLongString(); } else if (GROUPING_METHOD.equals(grouping)) { return pjp.getSignature().toLongString(); } else { throw new IllegalStateException( "parameter 'grouping' must be one of [" + GROUPING_CLASS + "," + GROUPING_METHOD + "]"); } }
From source file:org.spf4j.perf.aspects.PerformanceMonitorAspect.java
License:Open Source License
@Around(value = "execution(@org.spf4j.annotations.PerformanceMonitor * *(..)) && @annotation(annot)", argNames = "pjp,annot") public Object performanceMonitoredMethod(final ProceedingJoinPoint pjp, final PerformanceMonitor annot) throws Throwable { final long start = System.currentTimeMillis(); Object result = pjp.proceed(); final long elapsed = System.currentTimeMillis() - start; MeasurementRecorderSource mrs = REC_SOURCES.getUnchecked(annot.recorderSource()); mrs.getRecorder(pjp.toLongString()).record(elapsed); final long warnThresholdMillis = annot.warnThresholdMillis(); if (elapsed > warnThresholdMillis) { final long errorThresholdMillis = annot.errorThresholdMillis(); if (elapsed > errorThresholdMillis) { LOG.error("Execution time {} ms for {} exceeds error threshold of {} ms, arguments {}", elapsed, pjp.toShortString(), errorThresholdMillis, pjp.getArgs()); } else {//from w ww .j a va2s. co m LOG.warn("Execution time {} ms for {} exceeds warning threshold of {} ms, arguments {}", elapsed, pjp.toShortString(), warnThresholdMillis, pjp.getArgs()); } } else { if (annot.defaultInfoLog()) { LOG.info("Execution time {} ms for {}, arguments {}", elapsed, pjp.toShortString(), pjp.getArgs()); } else { LOG.debug("Execution time {} ms for {}, arguments {}", elapsed, pjp.toShortString(), pjp.getArgs()); } } return result; }