/** * Returns the Spring AOP proxy. Cannot be {@code null}. */ @Override public Object getThis() { return this.methodInvocation.getProxy(); }
/** * Subclasses may need to override this if they want to perform custom * behaviour in around advice. However, subclasses should invoke this * method, which handles introduced interfaces and forwarding to the target. */ @Override @Nullable public Object invoke(MethodInvocation mi) throws Throwable { if (isMethodOnIntroducedInterface(mi)) { // Using the following method rather than direct reflection, we // get correct handling of InvocationTargetException // if the introduced method throws an exception. Object retVal = AopUtils.invokeJoinpointUsingReflection(this.delegate, mi.getMethod(), mi.getArguments()); // Massage return value if possible: if the delegate returned itself, // we really want to return the proxy. if (retVal == this.delegate && mi instanceof ProxyMethodInvocation) { Object proxy = ((ProxyMethodInvocation) mi).getProxy(); if (mi.getMethod().getReturnType().isInstance(proxy)) { retVal = proxy; } } return retVal; } return doProceed(mi); }
/** * Subclasses may need to override this if they want to perform custom * behaviour in around advice. However, subclasses should invoke this * method, which handles introduced interfaces and forwarding to the target. */ @Override @Nullable public Object invoke(MethodInvocation mi) throws Throwable { if (isMethodOnIntroducedInterface(mi)) { Object delegate = getIntroductionDelegateFor(mi.getThis()); // Using the following method rather than direct reflection, // we get correct handling of InvocationTargetException // if the introduced method throws an exception. Object retVal = AopUtils.invokeJoinpointUsingReflection(delegate, mi.getMethod(), mi.getArguments()); // Massage return value if possible: if the delegate returned itself, // we really want to return the proxy. if (retVal == delegate && mi instanceof ProxyMethodInvocation) { retVal = ((ProxyMethodInvocation) mi).getProxy(); } return retVal; } return doProceed(mi); }
thisObject = pmi.getProxy();
/** * Returns the Spring AOP proxy. Cannot be {@code null}. */ @Override public Object getThis() { return this.methodInvocation.getProxy(); }
/** * Returns the Spring AOP proxy. Cannot be {@code null}. */ @Override public Object getThis() { return this.methodInvocation.getProxy(); }
/** * Do the look up by interface type. * * @return Returns the name of the service or <tt>null</tt> if not found */ private String getBeanNameImpl(MethodInvocation mi) throws BeansException { if (mi instanceof ProxyMethodInvocation) { Object proxy = ((ProxyMethodInvocation) mi).getProxy(); Map beans = beanFactory.getBeansOfType(proxy.getClass()); Iterator iter = beans.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); if (proxy == entry.getValue() && !name.equals("DescriptorService")) { return name; } } } return null; } }
/** * Do the look up by interface type. * * @return Returns the name of the service or <tt>null</tt> if not found */ private String getBeanNameImpl(MethodInvocation mi) throws BeansException { if (mi instanceof ProxyMethodInvocation) { Object proxy = ((ProxyMethodInvocation) mi).getProxy(); Map beans = beanFactory.getBeansOfType(proxy.getClass()); Iterator iter = beans.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); if (proxy == entry.getValue() && !name.equals("DescriptorService")) { return name; } } } return null; } }
@Nullable @Override public Object invoke(@SuppressWarnings("null") MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); if (!method.isDefault()) { return invocation.proceed(); } Object[] arguments = invocation.getArguments(); Object proxy = ((ProxyMethodInvocation) invocation).getProxy(); return getMethodHandle(method).bindTo(proxy).invokeWithArguments(arguments); }
/** * Subclasses may need to override this if they want to perform custom * behaviour in around advice. However, subclasses should invoke this * method, which handles introduced interfaces and forwarding to the target. */ public Object invoke(MethodInvocation mi) throws Throwable { if (isMethodOnIntroducedInterface(mi)) { if (logger.isDebugEnabled()) { logger.debug("Invoking self on invocation [" + mi + "]; breaking interceptor chain"); } // Using the following method rather than direct reflection, we // get correct handling of InvocationTargetException // if the introduced method throws an exception. Object retVal = AopUtils.invokeJoinpointUsingReflection(this.delegate, mi.getMethod(), mi.getArguments()); // Massage return value if possible: if the delegate returned itself, // we really want to return the proxy. if (retVal == delegate && (mi instanceof ProxyMethodInvocation)) { retVal = ((ProxyMethodInvocation) mi).getProxy(); } return retVal; } // If we get here, just pass the invocation on. return mi.proceed(); }
/** * Subclasses may need to override this if they want to perform custom * behaviour in around advice. However, subclasses should invoke this * method, which handles introduced interfaces and forwarding to the target. */ @Override @Nullable public Object invoke(MethodInvocation mi) throws Throwable { if (isMethodOnIntroducedInterface(mi)) { // Using the following method rather than direct reflection, we // get correct handling of InvocationTargetException // if the introduced method throws an exception. Object retVal = AopUtils.invokeJoinpointUsingReflection(this.delegate, mi.getMethod(), mi.getArguments()); // Massage return value if possible: if the delegate returned itself, // we really want to return the proxy. if (retVal == this.delegate && mi instanceof ProxyMethodInvocation) { Object proxy = ((ProxyMethodInvocation) mi).getProxy(); if (mi.getMethod().getReturnType().isInstance(proxy)) { retVal = proxy; } } return retVal; } return doProceed(mi); }
/** * Subclasses may need to override this if they want to perform custom * behaviour in around advice. However, subclasses should invoke this * method, which handles introduced interfaces and forwarding to the target. */ @Override public Object invoke(MethodInvocation mi) throws Throwable { if (isMethodOnIntroducedInterface(mi)) { // Using the following method rather than direct reflection, we // get correct handling of InvocationTargetException // if the introduced method throws an exception. Object retVal = AopUtils.invokeJoinpointUsingReflection(this.delegate, mi.getMethod(), mi.getArguments()); // Massage return value if possible: if the delegate returned itself, // we really want to return the proxy. if (retVal == this.delegate && mi instanceof ProxyMethodInvocation) { Object proxy = ((ProxyMethodInvocation) mi).getProxy(); if (mi.getMethod().getReturnType().isInstance(proxy)) { retVal = proxy; } } return retVal; } return doProceed(mi); }
public Object invoke(MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); EntityViewAwareCrudMethodMetadata metadata = (EntityViewAwareCrudMethodMetadata) TransactionSynchronizationManager.getResource(method); if (metadata != null) { return invocation.proceed(); } EntityViewMetadataCacheKey cacheKey = new EntityViewMetadataCacheKey(method, ((ProxyMethodInvocation) invocation).getProxy().getClass()); EntityViewAwareCrudMethodMetadata methodMetadata = metadataCache.get(cacheKey); if (methodMetadata == null) { methodMetadata = new EntityViewAwareDefaultCrudMethodMetadata(cacheKey.proxyClass, method, evm); EntityViewAwareCrudMethodMetadata tmp = metadataCache.putIfAbsent(cacheKey, methodMetadata); if (tmp != null) { methodMetadata = tmp; } } TransactionSynchronizationManager.bindResource(method, methodMetadata); try { return invocation.proceed(); } finally { TransactionSynchronizationManager.unbindResource(method); } } }
/** * Subclasses may need to override this if they want to perform custom * behaviour in around advice. However, subclasses should invoke this * method, which handles introduced interfaces and forwarding to the target. */ @Override @Nullable public Object invoke(MethodInvocation mi) throws Throwable { if (isMethodOnIntroducedInterface(mi)) { Object delegate = getIntroductionDelegateFor(mi.getThis()); // Using the following method rather than direct reflection, // we get correct handling of InvocationTargetException // if the introduced method throws an exception. Object retVal = AopUtils.invokeJoinpointUsingReflection(delegate, mi.getMethod(), mi.getArguments()); // Massage return value if possible: if the delegate returned itself, // we really want to return the proxy. if (retVal == delegate && mi instanceof ProxyMethodInvocation) { retVal = ((ProxyMethodInvocation) mi).getProxy(); } return retVal; } return doProceed(mi); }
public Object invoke(MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); EntityViewAwareCrudMethodMetadata metadata = (EntityViewAwareCrudMethodMetadata) TransactionSynchronizationManager.getResource(method); if (metadata != null) { return invocation.proceed(); } EntityViewMetadataCacheKey cacheKey = new EntityViewMetadataCacheKey(method, ((ProxyMethodInvocation) invocation).getProxy().getClass()); EntityViewAwareCrudMethodMetadata methodMetadata = metadataCache.get(cacheKey); if (methodMetadata == null) { methodMetadata = new EntityViewAwareDefaultCrudMethodMetadata(cacheKey.proxyClass, method, evm); EntityViewAwareCrudMethodMetadata tmp = metadataCache.putIfAbsent(cacheKey, methodMetadata); if (tmp != null) { methodMetadata = tmp; } } TransactionSynchronizationManager.bindResource(method, methodMetadata); try { return invocation.proceed(); } finally { TransactionSynchronizationManager.unbindResource(method); } } }
/** * Subclasses may need to override this if they want to perform custom * behaviour in around advice. However, subclasses should invoke this * method, which handles introduced interfaces and forwarding to the target. */ @Override public Object invoke(MethodInvocation mi) throws Throwable { if (isMethodOnIntroducedInterface(mi)) { Object delegate = getIntroductionDelegateFor(mi.getThis()); // Using the following method rather than direct reflection, // we get correct handling of InvocationTargetException // if the introduced method throws an exception. Object retVal = AopUtils.invokeJoinpointUsingReflection(delegate, mi.getMethod(), mi.getArguments()); // Massage return value if possible: if the delegate returned itself, // we really want to return the proxy. if (retVal == delegate && mi instanceof ProxyMethodInvocation) { retVal = ((ProxyMethodInvocation) mi).getProxy(); } return retVal; } return doProceed(mi); }
thisObject = pmi.getProxy();