本文整理汇总了Java中org.springframework.aop.support.AopUtils.isCglibProxy方法的典型用法代码示例。如果您正苦于以下问题:Java AopUtils.isCglibProxy方法的具体用法?Java AopUtils.isCglibProxy怎么用?Java AopUtils.isCglibProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.aop.support.AopUtils
的用法示例。
在下文中一共展示了AopUtils.isCglibProxy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ultimateTargetClass
import org.springframework.aop.support.AopUtils; //导入方法依赖的package包/类
/**
* Determine the ultimate target class of the given bean instance, traversing
* not only a top-level proxy but any number of nested proxies as well —
* as long as possible without side effects, that is, just for singleton targets.
* @param candidate the instance to check (might be an AOP proxy)
* @return the ultimate target class (or the plain class of the given
* object as fallback; never {@code null})
* @see org.springframework.aop.TargetClassAware#getTargetClass()
* @see Advised#getTargetSource()
*/
public static Class<?> ultimateTargetClass(Object candidate) {
Assert.notNull(candidate, "Candidate object must not be null");
Object current = candidate;
Class<?> result = null;
while (current instanceof TargetClassAware) {
result = ((TargetClassAware) current).getTargetClass();
Object nested = null;
if (current instanceof Advised) {
TargetSource targetSource = ((Advised) current).getTargetSource();
if (targetSource instanceof SingletonTargetSource) {
nested = ((SingletonTargetSource) targetSource).getTarget();
}
}
current = nested;
}
if (result == null) {
result = (AopUtils.isCglibProxy(candidate) ? candidate.getClass().getSuperclass() : candidate.getClass());
}
return result;
}
示例2: getTargetObject
import org.springframework.aop.support.AopUtils; //导入方法依赖的package包/类
private static Object getTargetObject(Object proxy) {
try {
if (!AopUtils.isAopProxy(proxy)) {// 不是代理对象
return proxy;
}
if (AopUtils.isCglibProxy(proxy)) {// cglib代理对象
return getCglibProxyTargetObject(proxy);
}
if (AopUtils.isJdkDynamicProxy(proxy)) {// jdk动态代理
return getJdkDynamicProxyTargetObject(proxy);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return null;
}
示例3: ultimateTargetClass
import org.springframework.aop.support.AopUtils; //导入方法依赖的package包/类
/**
* Determine the ultimate target class of the given bean instance, traversing
* not only a top-level proxy but any number of nested proxies as well -
* as long as possible without side effects, that is, just for singleton targets.
* @param candidate the instance to check (might be an AOP proxy)
* @return the target class (or the plain class of the given object as fallback;
* never {@code null})
* @see org.springframework.aop.TargetClassAware#getTargetClass()
* @see Advised#getTargetSource()
*/
public static Class<?> ultimateTargetClass(Object candidate) {
Assert.notNull(candidate, "Candidate object must not be null");
Object current = candidate;
Class<?> result = null;
while (current instanceof TargetClassAware) {
result = ((TargetClassAware) current).getTargetClass();
Object nested = null;
if (current instanceof Advised) {
TargetSource targetSource = ((Advised) current).getTargetSource();
if (targetSource instanceof SingletonTargetSource) {
nested = ((SingletonTargetSource) targetSource).getTarget();
}
}
current = nested;
}
if (result == null) {
result = (AopUtils.isCglibProxy(candidate) ? candidate.getClass().getSuperclass() : candidate.getClass());
}
return result;
}
示例4: isMultipleProxy
import org.springframework.aop.support.AopUtils; //导入方法依赖的package包/类
/**
* 是否代理了多次
* see http://jinnianshilongnian.iteye.com/blog/1894465
* @param proxy
* @return
*/
public static boolean isMultipleProxy(Object proxy) {
try {
ProxyFactory proxyFactory = null;
if(AopUtils.isJdkDynamicProxy(proxy)) {
proxyFactory = findJdkDynamicProxyFactory(proxy);
}
if(AopUtils.isCglibProxy(proxy)) {
proxyFactory = findCglibProxyFactory(proxy);
}
TargetSource targetSource = (TargetSource) ReflectionUtils.getField(ProxyFactory_targetSource_FIELD, proxyFactory);
return AopUtils.isAopProxy(targetSource.getTarget());
} catch (Exception e) {
throw new IllegalArgumentException("proxy args maybe not proxy with cglib or jdk dynamic proxy. this method not support", e);
}
}
示例5: removeAdvisor
import org.springframework.aop.support.AopUtils; //导入方法依赖的package包/类
private static void removeAdvisor(Object proxy, Class<? extends Advice> adviceClass) {
if(!AopUtils.isAopProxy(proxy)) {
return;
}
ProxyFactory proxyFactory = null;
if(AopUtils.isJdkDynamicProxy(proxy)) {
proxyFactory = findJdkDynamicProxyFactory(proxy);
}
if(AopUtils.isCglibProxy(proxy)) {
proxyFactory = findCglibProxyFactory(proxy);
}
Advisor[] advisors = proxyFactory.getAdvisors();
if(advisors == null || advisors.length == 0) {
return;
}
for(Advisor advisor : advisors) {
if(adviceClass.isAssignableFrom(advisor.getAdvice().getClass())) {
proxyFactory.removeAdvisor(advisor);
break;
}
}
}
示例6: hasAdvice
import org.springframework.aop.support.AopUtils; //导入方法依赖的package包/类
private static boolean hasAdvice(Object proxy, Class<? extends Advice> adviceClass) {
if(!AopUtils.isAopProxy(proxy)) {
return false;
}
ProxyFactory proxyFactory = null;
if(AopUtils.isJdkDynamicProxy(proxy)) {
proxyFactory = findJdkDynamicProxyFactory(proxy);
}
if(AopUtils.isCglibProxy(proxy)) {
proxyFactory = findCglibProxyFactory(proxy);
}
Advisor[] advisors = proxyFactory.getAdvisors();
if(advisors == null || advisors.length == 0) {
return false;
}
for(Advisor advisor : advisors) {
if(adviceClass.isAssignableFrom(advisor.getAdvice().getClass())) {
return true;
}
}
return false;
}
示例7: getHandlerMap
import org.springframework.aop.support.AopUtils; //导入方法依赖的package包/类
private Map<String, Object> getHandlerMap(AbstractUrlHandlerMapping mapping) {
if (AopUtils.isCglibProxy(mapping)) {
// If the AbstractUrlHandlerMapping is a cglib proxy we can't call
// the final getHandlerMap() method.
return Collections.emptyMap();
}
return mapping.getHandlerMap();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:RequestMappingEndpoint.java