List of usage examples for org.aspectj.lang ProceedingJoinPoint getArgs
Object[] getArgs();
From source file:net.sf.taverna.t2.reference.impl.CacheAspect.java
License:Open Source License
/** * Called around a write or update operation on the backing store, writes * through to the cache after modifying the state of the backing store and * before returning from the dao method// w ww. jav a2 s.c om * * @param pjp * join point representing the ongoing method invocation to cache * @throws DaoException * if anything goes wrong */ public void putObject(final ProceedingJoinPoint pjp) throws DaoException { // Get the Identified being stored by the method we're advising Identified storedObject = (Identified) pjp.getArgs()[0]; try { // Run the store or update method pjp.proceed(); } catch (DaoException e) { throw e; } catch (Throwable e) { throw new DaoException("Unexpected exception type during aspect " + "based invocation", e); } /* * Assuming the method isn't null and has an identifier (which it will * if we haven't thrown an exception before now) write it back to the * cache provider */ if (storedObject != null && storedObject.getId() != null) getCacheProvider().put(storedObject); }
From source file:net.sf.taverna.t2.reference.impl.WriteQueueAspect.java
License:Open Source License
/** * Handle a 'get by T2Reference' operation on a Dao * /* w w w.ja v a2 s . co m*/ * @param pjp * the join point representing the ongoing method call to the dao * @return the entity identified by the T2Reference supplied to the method * to which this advice applies * @throws DaoException * if anything goes wrong */ public final Identified getObject(final ProceedingJoinPoint pjp) throws DaoException { Identified result = null; // Get the T2Reference from the argument to the get method T2Reference id = (T2Reference) pjp.getArgs()[0]; if (id != null) { // try the cache SoftReference<Identified> ref = cache.get(id); if (ref != null) result = ref.get(); if (result == null) // not in the cache, check if it's still in the write queue result = store.get(id); } // If we miss the cache then call the method as usual if (result == null) try { result = (Identified) pjp.proceed(); if (result != null) cache.put(id, new SoftReference<>(result)); } catch (DaoException e) { throw e; } catch (Throwable e) { throw new DaoException("Unexpected exception type during aspect " + "based invocation", e); } return result; }
From source file:net.sf.taverna.t2.reference.impl.WriteQueueAspect.java
License:Open Source License
/** * Called around a write or update operation on the backing store, writes * through to the cache after modifying the state of the backing store and * before returning from the dao method//from w w w. j a v a2 s. co m * * @param pjp * join point representing the ongoing method invocation to cache * @throws DaoException * if anything goes wrong */ public void putObject(final ProceedingJoinPoint pjp) throws DaoException { // Get the Identified being stored by the method we're advising final Identified storedObject = (Identified) pjp.getArgs()[0]; Runnable task = new Runnable() { @Override public void run() { try { // Run the store or update method pjp.proceed(); store.remove(storedObject.getId()); } catch (DaoException e) { throw e; } catch (Throwable e) { throw new DaoException("Unexpected exception type during aspect " + "based invocation", e); } } }; cache.put(storedObject.getId(), new SoftReference<>(storedObject)); store.put(storedObject.getId(), storedObject); executer.execute(task); }
From source file:net.sourceforge.safr.core.interceptor.SecurityAspect.java
License:Apache License
@Around("set(* *.*) && encryptAnnotatedDomainObjectField()") public Object setFieldAccess(ProceedingJoinPoint pjp) throws Throwable { FieldSignature signature = (FieldSignature) pjp.getSignature(); EncryptAttribute ea = getFieldEncryptAttribute(signature); Object[] args = pjp.getArgs(); // exchange original value with encrypted value args[0] = encrypt(ea, pjp.getTarget(), args[0]); // perform field access with encrypted value return pjp.proceed(args); }
From source file:net.sourceforge.safr.core.invocation.AspectJProceedingInvocation.java
License:Apache License
public AspectJProceedingInvocation(ProceedingJoinPoint pjp) { super(getMethod(pjp), pjp.getTarget(), pjp.getArgs()); this.pjp = pjp; }
From source file:nl.nn.ibistesttool.IbisDebuggerAdvice.java
License:Apache License
public Object debugPipeLineInputOutputAbort(ProceedingJoinPoint proceedingJoinPoint, PipeLine pipeLine, String correlationId, String message, IPipeLineSession pipeLineSession) throws Throwable { message = (String) ibisDebugger.pipeLineInput(pipeLine, correlationId, message); TreeSet keys = new TreeSet(pipeLineSession.keySet()); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { String sessionKey = (String) iterator.next(); Object sessionValue = pipeLineSession.get(sessionKey); sessionValue = ibisDebugger.pipeLineSessionKey(correlationId, sessionKey, sessionValue); pipeLineSession.put(sessionKey, sessionValue); }/*from www. ja v a 2 s.c o m*/ PipeLineResult pipeLineResult = null; try { PipeLineSessionDebugger pipeLineSessionDebugger = new PipeLineSessionDebugger(pipeLineSession); pipeLineSessionDebugger.setIbisDebugger(ibisDebugger); Object[] args = proceedingJoinPoint.getArgs(); args[3] = pipeLineSessionDebugger; pipeLineResult = (PipeLineResult) proceedingJoinPoint.proceed(args); } catch (Throwable throwable) { throw ibisDebugger.pipeLineAbort(pipeLine, correlationId, throwable); } pipeLineResult.setResult(ibisDebugger.pipeLineOutput(pipeLine, correlationId, pipeLineResult.getResult())); return pipeLineResult; }
From source file:nl.nn.ibistesttool.IbisDebuggerAdvice.java
License:Apache License
public Object debugPipeInputOutputAbort(ProceedingJoinPoint proceedingJoinPoint, PipeLine pipeLine, IPipe pipe, String messageId, Object message, IPipeLineSession pipeLineSession) throws Throwable { Object preservedObject = message; message = ibisDebugger.pipeInput(pipeLine, pipe, messageId, message); PipeRunResult pipeRunResult = null;//from www. j a va 2 s .co m try { Object[] args = proceedingJoinPoint.getArgs(); args[3] = message; pipeRunResult = (PipeRunResult) proceedingJoinPoint.proceed(args); } catch (Throwable throwable) { throw ibisDebugger.pipeAbort(pipeLine, pipe, messageId, throwable); } if (pipe instanceof IExtendedPipe) { IExtendedPipe pe = (IExtendedPipe) pipe; if (pe.isPreserveInput()) { pipeRunResult.setResult(ibisDebugger.preserveInput(messageId, preservedObject)); } } pipeRunResult.setResult(ibisDebugger.pipeOutput(pipeLine, pipe, messageId, pipeRunResult.getResult())); return pipeRunResult; }
From source file:nl.nn.ibistesttool.IbisDebuggerAdvice.java
License:Apache License
public Object debugPipeGetInputFrom(ProceedingJoinPoint proceedingJoinPoint, PipeLine pipeLine, IPipe pipe, String messageId, Object message, IPipeLineSession pipeLineSession) throws Throwable { if (pipe instanceof IExtendedPipe) { IExtendedPipe pe = (IExtendedPipe) pipe; message = debugGetInputFrom(pipeLineSession, messageId, message, pe.getGetInputFromSessionKey(), pe.getGetInputFromFixedValue(), pe.getEmptyInputReplacement()); }// w w w . ja v a 2s . co m Object[] args = proceedingJoinPoint.getArgs(); args[3] = message; return proceedingJoinPoint.proceed(args); }
From source file:nl.nn.ibistesttool.IbisDebuggerAdvice.java
License:Apache License
public Object debugSenderGetInputFrom(ProceedingJoinPoint proceedingJoinPoint, SenderWrapperBase senderWrapperBase, String correlationId, String message, ParameterResolutionContext parameterResolutionContext) throws Throwable { message = (String) debugGetInputFrom(parameterResolutionContext.getSession(), correlationId, message, senderWrapperBase.getGetInputFromSessionKey(), senderWrapperBase.getGetInputFromFixedValue(), null); if (ibisDebugger.stubSender(senderWrapperBase, correlationId)) { return null; } else {/*from www . j ava 2 s. c om*/ Object[] args = proceedingJoinPoint.getArgs(); args[2] = message; return proceedingJoinPoint.proceed(args); } }
From source file:nl.nn.ibistesttool.IbisDebuggerAdvice.java
License:Apache License
public Object debugReplyListenerInputOutputAbort(ProceedingJoinPoint proceedingJoinPoint, ICorrelatedPullingListener listener, String correlationId, IPipeLineSession pipeLineSession) throws Throwable { correlationId = ibisDebugger.replyListenerInput(listener, pipeLineSession.getMessageId(), correlationId); String result = null;//from ww w . j av a 2s. co m if (ibisDebugger.stubReplyListener(listener, correlationId)) { return null; } else { try { Object[] args = proceedingJoinPoint.getArgs(); args[1] = correlationId; result = (String) proceedingJoinPoint.proceed(args); } catch (Throwable throwable) { throw ibisDebugger.replyListenerAbort(listener, pipeLineSession.getMessageId(), throwable); } return ibisDebugger.replyListenerOutput(listener, pipeLineSession.getMessageId(), result); } }