/** * Create a new RemoteInvocation for the given AOP method invocation. * @param methodInvocation the AOP invocation to convert */ public RemoteInvocation(MethodInvocation methodInvocation) { this.methodName = methodInvocation.getMethod().getName(); this.parameterTypes = methodInvocation.getMethod().getParameterTypes(); this.arguments = methodInvocation.getArguments(); }
@Override public Object invoke(MethodInvocation mi) throws Throwable { this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis()); return mi.proceed(); }
@Override public Object invoke(MethodInvocation mi) throws Throwable { Object retVal = mi.proceed(); this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis()); return retVal; }
private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable { Object[] handlerArgs; if (method.getParameterCount() == 1) { handlerArgs = new Object[] {ex}; } else { handlerArgs = new Object[] {mi.getMethod(), mi.getArguments(), mi.getThis(), ex}; } try { method.invoke(this.throwsAdvice, handlerArgs); } catch (InvocationTargetException targetEx) { throw targetEx.getTargetException(); } }
@Override public Object execute() throws Throwable { logger.debug("Entering API call {}, arguments: {}", invocation.getMethod(), invocation.getArguments()); final Object proceed = invocation.proceed(); logger.debug("Exiting API call {}, returning: {}", invocation.getMethod(), proceed); return proceed; } };
/** * Create a new RemoteInvocation for the given AOP method invocation. * @param methodInvocation the AOP invocation to convert */ public RemoteInvocation(MethodInvocation methodInvocation) { this.methodName = methodInvocation.getMethod().getName(); this.parameterTypes = methodInvocation.getMethod().getParameterTypes(); this.arguments = methodInvocation.getArguments(); }
@Override @Nullable public Object invoke(final MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); CacheOperationInvoker aopAllianceInvoker = () -> { try { return invocation.proceed(); } catch (Throwable ex) { throw new CacheOperationInvoker.ThrowableWrapper(ex); } }; try { return execute(aopAllianceInvoker, invocation.getThis(), method, invocation.getArguments()); } catch (CacheOperationInvoker.ThrowableWrapper th) { throw th.getOriginal(); } }
@Override @Nullable public Object invoke(org.aopalliance.intercept.MethodInvocation inv) throws Throwable { return intercept(inv.getThis(), inv.getMethod(), inv.getArguments(), null); }
@Override @Nullable public Object invoke(final MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); CacheOperationInvoker aopAllianceInvoker = () -> { try { return invocation.proceed(); } catch (Throwable ex) { throw new CacheOperationInvoker.ThrowableWrapper(ex); } }; try { return execute(aopAllianceInvoker, invocation.getThis(), method, invocation.getArguments()); } catch (CacheOperationInvoker.ThrowableWrapper th) { throw th.getOriginal(); } }
/** * Perform a JAX-WS service invocation on the given port stub. * @param invocation the AOP method invocation * @param portStub the RMI port stub to invoke * @return the invocation result, if any * @throws Throwable in case of invocation failure * @see #getPortStub() */ @Nullable protected Object doInvoke(MethodInvocation invocation, @Nullable Object portStub) throws Throwable { Method method = invocation.getMethod(); try { return method.invoke(portStub, invocation.getArguments()); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } catch (Throwable ex) { throw new RemoteProxyFailureException("Invocation of stub method failed: " + method, ex); } }
@Override public Object invoke(MethodInvocation invocation) throws Exception { Class<?> declaringClass = invocation.getMethod().getDeclaringClass(); try { if (declaringClass.isAssignableFrom(adapterInterface) && genericParametersMatch(invocation, adapter)) { return invocation.getMethod().invoke(adapter, invocation.getArguments()); } return invocation.proceed(); } catch (InvocationTargetException e) { throw e.getCause() instanceof Exception ? (Exception) e.getCause() : e; } catch (Throwable e) { if (e instanceof Error) { throw (Error) e; } throw new InvocationTargetException(e); } }
@Override public Object invoke(MethodInvocation mi) throws Throwable { try { return mi.proceed(); } catch (RuntimeException ex) { // Let it throw raw if the type of the exception is on the throws clause of the method. if (!this.alwaysTranslate && ReflectionUtils.declaresException(mi.getMethod(), ex.getClass())) { throw ex; } else { PersistenceExceptionTranslator translator = this.persistenceExceptionTranslator; if (translator == null) { Assert.state(this.beanFactory != null, "No PersistenceExceptionTranslator set"); translator = detectPersistenceExceptionTranslators(this.beanFactory); this.persistenceExceptionTranslator = translator; } throw DataAccessUtils.translateIfNecessary(ex, translator); } } }
public static MethodInterceptorHolder create(MethodInvocation invocation) { String id = DigestUtils.md5DigestAsHex(String.valueOf(invocation.getMethod().hashCode()).getBytes()); String[] argNames = nameDiscoverer.getParameterNames(invocation.getMethod()); Object[] args = invocation.getArguments(); Map<String, Object> argMap = new LinkedHashMap<>(); for (int i = 0, len = args.length; i < len; i++) { argMap.put((argNames == null || argNames[i] == null) ? "arg" + i : argNames[i], args[i]); } return new MethodInterceptorHolder(id, invocation.getMethod(), invocation.getThis(), argMap); }
@Override public Object invoke(MethodInvocation invocation) throws Exception { try { // if the method is declared on the proxy, invoke it there for (Method proxyMethod : proxyMethods) { if (proxyMethod.getName().equals(invocation.getMethod().getName()) && Arrays.equals(proxyMethod.getParameterTypes(), invocation.getMethod().getParameterTypes())) { return proxyMethod.invoke(proxy, invocation.getArguments()); } } // otherwise, invoke it on the original object return invocation.proceed(); } catch (InvocationTargetException e) { throw e.getCause() instanceof Exception ? (Exception) e.getCause() : e; } catch (Throwable e) { if (e instanceof Error) { throw (Error) e; } throw new InvocationTargetException(e); } } }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); if (logger.isDebugEnabled()) { logger.debug("Incoming " + this.exporterNameClause + "remote call: " + Object retVal = invocation.proceed(); if (logger.isDebugEnabled()) { logger.debug("Finished processing of " + this.exporterNameClause + "remote call: " +