List of usage examples for org.aspectj.lang ProceedingJoinPoint getTarget
Object getTarget();
From source file:org.lexevs.cache.MethodCachingProxy.java
License:Open Source License
@Override protected Object getTarget(ProceedingJoinPoint joinPoint) { return joinPoint.getTarget(); }
From source file:org.nebulaframework.util.profiling.ProfilingAspect.java
License:Apache License
/** * Advice of Profiling Aspect. Measures and logs the exection * time of advised method.//from ww w . j a v a2 s. c o m * * @param pjp {ProceedingJoinPoint} * @return Object result * @throws Throwable if exception occurs */ @Around("profilingPointcut()") public Object profile(ProceedingJoinPoint pjp) throws Throwable { StopWatch sw = new StopWatch(); Log localLog = null; try { // Get Log localLog = LogFactory.getLog(pjp.getTarget().getClass()); // Start StopWatch sw.start(); // Proceed Invocation return pjp.proceed(); } finally { // Stop StopWatch sw.stop(); if (localLog == null) { // If local Log not found, use ProfilingAspect's Log localLog = log; } //Log Stats localLog.debug("[Profiling] " + pjp.getTarget().getClass().getName() + "->" + pjp.getSignature().getName() + "() | " + sw.getLastTaskTimeMillis() + " ms"); } }
From source file:org.nekorp.workflow.desktop.servicio.imp.EditorMonitorImp.java
License:Apache License
public void updateProperty(ProceedingJoinPoint pjp) throws Throwable { Object target = pjp.getTarget(); if (!(target instanceof Metadata)) { String methodName = pjp.getSignature().getName(); String propertyName = StringUtils.substringAfter(methodName, "set"); String primeraLetra = propertyName.charAt(0) + ""; propertyName = primeraLetra.toLowerCase() + StringUtils.substringAfter(propertyName, primeraLetra); Object oldValue = PropertyUtils.getProperty(target, propertyName); if (!oldValue.equals(pjp.getArgs()[0])) { EditorLog log = new EditorLog(); log.setTarget(target);/* w ww . j a va 2s . c o m*/ log.setProperty(propertyName); log.setOldValue(oldValue); redoLog = new LinkedList<>(); this.addUndo(log); } } pjp.proceed(); }
From source file:org.nekorp.workflow.desktop.view.binding.imp.BindingManagerImp.java
License:Apache License
@Around("modelChange()") public void updateProperty(ProceedingJoinPoint pjp) throws Throwable { //BindingManagerImp.LOGGER.debug("evento:"+pjp.getTarget()); pjp.proceed();// w w w. j av a 2s.co m String methodName = pjp.getSignature().getName(); String propertyName = StringUtils.substringAfter(methodName, "set"); String primeraLetra = propertyName.charAt(0) + ""; propertyName = primeraLetra.toLowerCase() + StringUtils.substringAfter(propertyName, primeraLetra); //TODO to weak code :< processModelUpdate(pjp.getTarget(), propertyName, pjp.getArgs()[0]); }
From source file:org.onebusaway.container.cache.CacheableMethodKeyFactoryManager.java
License:Apache License
public List<Method> getMatchingMethodsForJoinPoint(ProceedingJoinPoint pjp) { Signature sig = pjp.getSignature(); Object target = pjp.getTarget(); Class<?> type = target.getClass(); List<Method> matches = new ArrayList<Method>(); for (Method m : type.getDeclaredMethods()) { if (!m.getName().equals(sig.getName())) continue; // if (m.getModifiers() != sig.getModifiers()) // continue; Object[] args = pjp.getArgs(); Class<?>[] types = m.getParameterTypes(); if (args.length != types.length) continue; boolean miss = false; for (int i = 0; i < args.length; i++) { Object arg = args[i]; Class<?> argType = types[i]; if (argType.isPrimitive()) { if (argType.equals(Double.TYPE) && !arg.getClass().equals(Double.class)) miss = true;/* www. java 2 s .c om*/ } else { if (arg != null && !argType.isInstance(arg)) miss = true; } } if (miss) continue; matches.add(m); } return matches; }
From source file:org.openkoala.exception.support.springaop.AppExceptionInterceptor.java
License:Open Source License
public Object intercept(ProceedingJoinPoint point) throws Throwable { Method method = null;//from www . j a va2 s . c o m Class<? extends Object> target = point.getTarget().getClass(); Method[] methods = target.getDeclaredMethods(); for (Method tmp : methods) { if (point.getSignature().getName().equals(tmp.getName())) { method = tmp; break; } } Object o = null; try { o = point.proceed(); } catch (Exception e) { logger.error("Method[" + target.getName() + "." + method.getName() + "]", e); throw new BaseException(e); } return o; }
From source file:org.opensaas.jaudit.service.spring.AuditExecutor.java
License:LGPL
/** * Create an audit record detailing that a particular operation has taken * place.// ww w . ja v a 2s. c o m * * @param jp * The join point currently being fired. * @param annotation * The required annotation that triggers this join point. * @return The result of executing the method wrapped by this join point. * @throws Throwable * When there is an error. */ public Object recordAction(final ProceedingJoinPoint jp, final LifeCycleAudit annotation) throws Throwable { LOGGER.log(Level.FINE, "joinpoint={0}, target={2}, args={1}", new Object[] { jp.getSignature().toLongString(), Arrays.toString(jp.getArgs()), jp.getTarget() }); // make the call final Object retval = jp.proceed(); final AuditSubject auditSubject = getAuditSubject(jp, annotation, retval); String description = annotation.description(); if (description == null || description.length() < 1) { description = annotation.type().name(); } auditService.createLifeCycleAuditEvent(annotation.type(), auditSubject, description); return retval; }
From source file:org.opensaas.jaudit.service.spring.TransactionEventBridge.java
License:LGPL
/** * Create an audit record detailing that a particular operation has taken * place.//from ww w . j av a 2 s . c o m * * @param jp * The join point currently being fired. * @param annotation * The required annotation that triggers this join point. * @return The result of executing the method wrapped by this join point. * @throws Throwable * When there is an error. */ public Object recordAction(final ProceedingJoinPoint jp) throws Throwable { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "joinpoint={0}, target={2}, args={1}", new Object[] { jp.getSignature().toLongString(), Arrays.toString(jp.getArgs()), jp.getTarget() }); } // make the call final Object retval = jp.proceed(); if (PlatformTransactionManager.class.isAssignableFrom(jp.getTarget().getClass())) { final SessionRecord sr = AuditSession.getAuditSession() != null ? AuditSession.getAuditSession().getSessionRecord() : null; final String methodName = jp.getSignature().getName(); if ("getTransaction".equals(methodName)) { final TransactionStatus ts = (TransactionStatus) retval; if (ts.isNewTransaction()) { _applicationContext.publishEvent( new NewTransactionEvent((PlatformTransactionManager) jp.getTarget(), ts, sr)); } } } return retval; }
From source file:org.qifu.base.aspect.ServiceAuthorityCheckAspect.java
License:Apache License
@Around(AspectConstants.LOGIC_SERVICE_PACKAGE) public Object logicServiceProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable { MethodSignature signature = (MethodSignature) pjp.getSignature(); Annotation[] annotations = pjp.getTarget().getClass().getAnnotations(); String serviceId = AspectConstants.getServiceId(annotations); Subject subject = SecurityUtils.getSubject(); Method method = signature.getMethod(); if (subject.hasRole(Constants.SUPER_ROLE_ALL) || subject.hasRole(Constants.SUPER_ROLE_ADMIN)) { SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); }/*from ww w . ja va 2 s . c o m*/ if (StringUtils.isBlank(serviceId)) { // service id SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); } if (!this.isServiceAuthorityCheck(annotations)) { // ServiceAuthority check=false ? SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); } Annotation[] methodAnnotations = method.getAnnotations(); if (this.isServiceMethodAuthority(serviceId, methodAnnotations, subject)) { SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true); return pjp.proceed(); } logger.warn("[decline] user[" + subject.getPrincipal() + "] " + pjp.getTarget().getClass().getName() + " - " + signature.getMethod().getName()); SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), false); throw new AuthorityException(SysMessageUtil.get(SysMsgConstants.NO_PERMISSION)); }
From source file:org.raspinloop.agent.internal.aspect.SimulatedTimeAspect.java
License:Apache License
@Around("call(long java.util.concurrent.locks.Condition.awaitNanos(..)) && within(org.raspinloop.agent.internal.timeemulation.*) && !within(org.raspinloop.fmi.internal.timeemulation.SimulatedTime)") public long awaitnano(ProceedingJoinPoint joinPoint) throws Throwable { return SimulatedTime.awaitNanos((long) joinPoint.getArgs()[0], (Condition) joinPoint.getTarget()); }