/** * Invokes the target joinpoint for this invocation skipping any subsequent * interceptors in the chain. */ public Object invokeTarget() throws Throwable { try { return getActualMethod().invoke(getTargetObject(), arguments); } catch (Throwable t) { throw handleErrors(getTargetObject(), getMethod(), arguments, t); } }
/** * Copies complete state of Invocation object. * * @return a copy of this instance */ public Invocation copy() { MethodInvocation wrapper = new MethodInvocation(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor); wrapper.metadata = this.metadata; wrapper.currentInterceptor = this.currentInterceptor; wrapper.instanceResolver = this.instanceResolver; wrapper.setTargetObject(this.getTargetObject()); wrapper.setArguments(this.getArguments()); return wrapper; }
public <T extends Annotation> T resolveTypedAnnotation(Class<T> annotation) { T val = super.resolveTypedAnnotation(annotation); if (val != null) return val; if (getAdvisor() != null) { val = getAdvisor().resolveTypedAnnotation(getMethodHash(), getMethod(), annotation); if (val != null) return val; } return null; }
public InvocationContextAdapter(MethodInvocation delegate) { super(delegate.getMethod(), delegate.getArguments()); this.delegate = delegate; }
long hash = methodInvocation.getMethodHash(); MethodInfo info = methodInfos.getMethodInfo(hash); aspects = advised._getInstanceAdvisor().getInterceptors(aspects); MethodInvocation nextInvocation = new MethodInvocation(info, aspects); nextInvocation.setMetaData(invocation.getMetaData()); nextInvocation.setTargetObject(target); nextInvocation.setArguments(methodInvocation.getArguments()); nextInvocation.setAdvisor(this); InvocationResponse response = new InvocationResponse(nextInvocation.invokeNext()); response.setContextInfo(nextInvocation.getResponseContextInfo()); return response;
public InvocationResponse dynamicInvoke(Invocation invocation) throws Throwable { ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); EJBContainerInvocation newSi = null; pushEnc(); try { Thread.currentThread().setContextClassLoader(classloader); MethodInvocation si = (MethodInvocation) invocation; MethodInfo info = getAdvisor().getMethodInfo(si.getMethodHash()); if (info == null) { throw new RuntimeException("Could not resolve beanClass method from proxy call"); } newSi = new MessageContainerInvocation(info); newSi.setArguments(si.getArguments()); newSi.setMetaData(si.getMetaData()); newSi.setAdvisor(getAdvisor()); InvocationResponse response = new InvocationResponse(newSi.invokeNext()); response.setContextInfo(newSi.getResponseContextInfo()); return response; } finally { Thread.currentThread().setContextClassLoader(oldLoader); popEnc(); } }
/** * */ public Object invoke(org.jboss.aop.joinpoint.Invocation invocation) throws Throwable { if (invocation instanceof MethodInvocation) { org.jboss.aop.joinpoint.MethodInvocation methodInvocation = (org.jboss.aop.joinpoint.MethodInvocation)invocation; long methodHash = methodInvocation.getMethodHash(); Method managerMethod = manager.isManagerMethod(methodHash); if (managerMethod != null) { Object[] args = methodInvocation.getArguments(); return managerMethod.invoke(manager, args); } Object target = methodInvocation.getTargetObject(); Method method = methodInvocation.getMethod(); if (method == null) { HashMap methodMap = manager.getMethodMap(); MethodPersistentReference ref = (MethodPersistentReference)methodMap.get(new Long(methodHash)); method = (Method)ref.get(); } return method.invoke(target, methodInvocation.getArguments()); } return invocation.invokeNext(); }
public Method getMethod() { return wrapped.getMethod(); }
public Object invoke(org.jboss.aop.joinpoint.Invocation invocation) throws Throwable { if (invocation instanceof MethodInvocation) { // For non-advised methods, we can only do public method invocations org.jboss.aop.joinpoint.MethodInvocation methodInvocation = (org.jboss.aop.joinpoint.MethodInvocation)invocation; long methodHash = methodInvocation.getMethodHash(); HashMap methodMap = ClassProxyFactory.getMethodMap(obj.getClass()); MethodPersistentReference ref = (MethodPersistentReference)methodMap.get(new Long(methodHash)); Method method = (Method)ref.get(); Object[] args = methodInvocation.getArguments(); try { return method.invoke(obj, args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } } else { throw new RuntimeException("field invocations not implemented"); } } }
private void logMethod(boolean beforeAfter, Invocation invocation, Object result, Throwable t) { MethodInvocation mi = (MethodInvocation) invocation; StringBuilder builder = new StringBuilder(); Object target = mi.getTargetObject(); builder.append(target.getClass().getSimpleName()); builder.append('@'); builder.append(System.identityHashCode(target)); if (beforeAfter == false) builder.append(" before "); else builder.append(" after "); builder.append(mi.getActualMethod().getName()); if (beforeAfter == false) { builder.append(" params="); builder.append(Arrays.asList(mi.getArguments())); } else if (t == null) { builder.append(" result="); builder.append(result); } if (t != null) builder.append(" ended in error:"); log.trace(builder.toString(), t); } }
return invokeWithoutAdvisement(methodInvocation.getTargetObject(), methodInvocation.getMethodHash(), methodInvocation.getArguments());
public Object invokeMethod(InstanceAdvisor instanceAdvisor, Object target, long methodHash, Object[] arguments, MethodInfo info) throws Throwable { Interceptor[] aspects = info.getInterceptors(); if (instanceAdvisor != null && (instanceAdvisor.hasInterceptors())) { aspects = instanceAdvisor.getInterceptors(aspects); } MethodInvocation invocation = new MethodInvocation(info, aspects); invocation.setArguments(arguments); invocation.setTargetObject(target); return invocation.invokeNext(); }
public <T extends Annotation> T resolveTypedAnnotation(Class<T>[] annotations) { T val = super.resolveTypedAnnotation(annotations); if (val != null) return val; if (getAdvisor() != null) { val = getAdvisor().resolveTypedAnnotation(getMethod(), annotations); if (val != null) return val; } return null; }
public Object invoke(Invocation invocation) throws Throwable { MethodInvocation mi = (MethodInvocation) invocation; Method m = mi.getActualMethod(); Object[] args = mi.getArguments(); Object value = null; try { m.invoke(target, args); } catch(InvocationTargetException ite) { throw ite.getCause(); } return value; }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); if (methodName.equals("getProducerManager")) { return producer; } else if(methodName.equals("toString")) return toString(); long hash = MethodHashing.calculateHash(method); MethodInvocation sri = new MethodInvocation(interceptors, hash, method, method, null); sri.setArguments(args); return sri.invokeNext(); } }
protected static int getTransactionTimeout(MethodInvocation invocation) { return getTransactionTimeout(invocation.getAdvisor(), invocation.getActualMethod()); }
public Object[] getArguments() { Object[] args = super.getArguments(); if (args != null) { return args; } return NO_ARGS; }
public Method getActualMethod() { return wrapped.getActualMethod(); }
public Object getMetaData(Object group, Object attr) { return wrapped.getMetaData(group, attr); }
public long getMethodHash() { return wrapped.getMethodHash(); }