當前位置: 首頁>>代碼示例>>Java>>正文


Java AopUtils.isCglibProxy方法代碼示例

本文整理匯總了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;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:31,代碼來源:AopProxyUtils.java

示例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;
}
 
開發者ID:swxiao,項目名稱:bubble2,代碼行數:17,代碼來源:BeanContextUtil.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:AopProxyUtils.java

示例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);
    }
}
 
開發者ID:leiyong0326,項目名稱:phone,代碼行數:22,代碼來源:AopProxyUtils.java

示例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;
        }
    }
}
 
開發者ID:leiyong0326,項目名稱:phone,代碼行數:26,代碼來源:AopProxyUtils.java

示例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;
}
 
開發者ID:leiyong0326,項目名稱:phone,代碼行數:26,代碼來源:AopProxyUtils.java

示例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


注:本文中的org.springframework.aop.support.AopUtils.isCglibProxy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。