• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ProxyMethodInvocation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.aop.ProxyMethodInvocation的典型用法代码示例。如果您正苦于以下问题:Java ProxyMethodInvocation类的具体用法?Java ProxyMethodInvocation怎么用?Java ProxyMethodInvocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProxyMethodInvocation类属于org.springframework.aop包,在下文中一共展示了ProxyMethodInvocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getBeanNameImpl

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:BeanIdentifierImpl.java


示例2: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:DelegatePerTargetObjectIntroductionInterceptor.java


示例3: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:DelegatingIntroductionInterceptor.java


示例4: invokeWithRetry

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
@SuppressWarnings("PMD.AvoidCatchingThrowable")
public Object invokeWithRetry(MethodInvocation methodInvocation, int count) throws Throwable {
    MethodInvocation methodInvocationCopy = ((ProxyMethodInvocation) methodInvocation).invocableClone();
    try {
        return methodInvocationCopy.proceed();
    } catch (Throwable thrownException) {
        LOGGER.warn("Ratel - Retry Policy was triggered for service {} because: {} ", methodInvocation.getMethod(),
                thrownException.getMessage());
        final Class<? extends Throwable> retryOnException = config.getRetryOnException();
        if (shouldRetry(count, thrownException, retryOnException)) {
            Thread.sleep(config.getWaitingTime());

            return invokeWithRetry(methodInvocation, count + 1);
        }

        throw thrownException;
    }
}
 
开发者ID:PayU-Tech,项目名称:Ratel,代码行数:19,代码来源:RetryPolicyInvocationHandler.java


示例5: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
/**
 * 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)) {
		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);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:DelegatePerTargetObjectIntroductionInterceptor.java


示例6: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
/**
 * 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)) {
		// 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);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:DelegatingIntroductionInterceptor.java


示例7: testRetryContextIsNotAvailable

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
@Test
public void testRetryContextIsNotAvailable() throws Throwable {

    ProxyMethodInvocation methodInvocation = mock(ProxyMethodInvocation.class);

    when(methodInvocation.invocableClone()).thenReturn(methodInvocation);
    when(methodInvocation.proceed()).then(invocation -> {
        Assert.assertNotNull(RetrySynchronizationManager.getContext());
        return "foo";
    });


    RdbmsRetryOperationsInterceptor interceptor = new RdbmsRetryOperationsInterceptor();
    interceptor.setLabel("mylabel"); //Avoids NPE in RetryOperationsInterceptor.invoke
    interceptor.invoke(methodInvocation);

    verify(methodInvocation, times(1)).invocableClone();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:19,代码来源:RdbmsRetryOperationsInterceptorTest.java


示例8: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi);
	JoinPointMatch jpm = getJoinPointMatch(pmi);
	return invokeAdviceMethod(pjp, jpm, null, null);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:AspectJAroundAdvice.java


示例9: bindParameters

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
private void bindParameters(ProxyMethodInvocation invocation, JoinPointMatch jpm) {
	// Note: Can't use JoinPointMatch.getClass().getName() as the key, since
	// Spring AOP does all the matching at a join point, and then all the invocations
	// under this scenario, if we just use JoinPointMatch as the key, then
	// 'last man wins' which is not what we want at all.
	// Using the expression is guaranteed to be safe, since 2 identical expressions
	// are guaranteed to bind in exactly the same way.
	invocation.setUserAttribute(getExpression(), jpm);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AspectJExpressionPointcut.java


示例10: currentJoinPoint

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
/**
 * Lazily instantiate joinpoint for the current invocation.
 * Requires MethodInvocation to be bound with ExposeInvocationInterceptor.
 * <p>Do not use if access is available to the current ReflectiveMethodInvocation
 * (in an around advice).
 * @return current AspectJ joinpoint, or through an exception if we're not in a
 * Spring AOP invocation.
 */
public static JoinPoint currentJoinPoint() {
	MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	JoinPoint jp = (JoinPoint) pmi.getUserAttribute(JOIN_POINT_KEY);
	if (jp == null) {
		jp = new MethodInvocationProceedingJoinPoint(pmi);
		pmi.setUserAttribute(JOIN_POINT_KEY, jp);
	}
	return jp;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AbstractAspectJAdvice.java


示例11: getJoinPointMatch

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
/**
 * Get the current join point match at the join point we are being dispatched on.
 */
protected JoinPointMatch getJoinPointMatch() {
	MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	return getJoinPointMatch((ProxyMethodInvocation) mi);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:AbstractAspectJAdvice.java


示例12: getBeanName

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
/**
 * Find the bean name for the given invocation. Assumes that an ExposeBeanNameAdvisor
 * has been included in the interceptor chain.
 * @param mi MethodInvocation that should contain the bean name as an attribute
 * @return the bean name (never {@code null})
 * @throws IllegalStateException if the bean name has not been exposed
 */
public static String getBeanName(MethodInvocation mi) throws IllegalStateException {
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalArgumentException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	String beanName = (String) pmi.getUserAttribute(BEAN_NAME_ATTRIBUTE);
	if (beanName == null) {
		throw new IllegalStateException("Cannot get bean name; not set on MethodInvocation: " + mi);
	}
	return beanName;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:ExposeBeanNameAdvisors.java


示例13: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	pmi.setUserAttribute(BEAN_NAME_ATTRIBUTE, this.beanName);
	return mi.proceed();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ExposeBeanNameAdvisors.java


示例14: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
public Object invoke(MethodInvocation mi) throws Throwable {
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi);
	JoinPointMatch jpm = getJoinPointMatch(pmi);
	return invokeAdviceMethod(pjp, jpm, null, null);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:AspectJAroundAdvice.java


示例15: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入依赖的package包/类
public Object invoke(MethodInvocation mi) throws Throwable {
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	pmi.setUserAttribute(BEAN_NAME_ATTRIBUTE, this.beanName);
	return mi.proceed();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:ExposeBeanNameAdvisors.java



注:本文中的org.springframework.aop.ProxyMethodInvocation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JsonBackReference类代码示例发布时间:2022-05-22
下一篇:
Java INode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap