org.springframework.aop.SpringProxy Java Examples

The following examples show how to use org.springframework.aop.SpringProxy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AopProxyUtils.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Extract the user-specified interfaces that the given proxy implements,
 * i.e. all non-Advised interfaces that the proxy implements.
 * @param proxy the proxy to analyze (usually a JDK dynamic proxy)
 * @return all user-specified interfaces that the proxy implements,
 * in the original order (never {@code null} or empty)
 * @see Advised
 */
public static Class<?>[] proxiedUserInterfaces(Object proxy) {
	Class<?>[] proxyInterfaces = proxy.getClass().getInterfaces();
	int nonUserIfcCount = 0;
	if (proxy instanceof SpringProxy) {
		nonUserIfcCount++;
	}
	if (proxy instanceof Advised) {
		nonUserIfcCount++;
	}
	if (proxy instanceof DecoratingProxy) {
		nonUserIfcCount++;
	}
	Class<?>[] userInterfaces = new Class<?>[proxyInterfaces.length - nonUserIfcCount];
	System.arraycopy(proxyInterfaces, 0, userInterfaces, 0, userInterfaces.length);
	Assert.notEmpty(userInterfaces, "JDK proxy must implement one or more interfaces");
	return userInterfaces;
}
 
Example #2
Source File: AopProxyUtils.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Extract the user-specified interfaces that the given proxy implements,
 * i.e. all non-Advised interfaces that the proxy implements.
 * @param proxy the proxy to analyze (usually a JDK dynamic proxy)
 * @return all user-specified interfaces that the proxy implements,
 * in the original order (never {@code null} or empty)
 * @see Advised
 */
public static Class<?>[] proxiedUserInterfaces(Object proxy) {
	Class<?>[] proxyInterfaces = proxy.getClass().getInterfaces();
	int nonUserIfcCount = 0;
	if (proxy instanceof SpringProxy) {
		nonUserIfcCount++;
	}
	if (proxy instanceof Advised) {
		nonUserIfcCount++;
	}
	if (proxy instanceof DecoratingProxy) {
		nonUserIfcCount++;
	}
	Class<?>[] userInterfaces = new Class<?>[proxyInterfaces.length - nonUserIfcCount];
	System.arraycopy(proxyInterfaces, 0, userInterfaces, 0, userInterfaces.length);
	Assert.notEmpty(userInterfaces, "JDK proxy must implement one or more interfaces");
	return userInterfaces;
}
 
Example #3
Source File: AopProxyUtils.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Extract the user-specified interfaces that the given proxy implements,
 * i.e. all non-Advised interfaces that the proxy implements.
 * @param proxy the proxy to analyze (usually a JDK dynamic proxy)
 * @return all user-specified interfaces that the proxy implements,
 * in the original order (never {@code null} or empty)
 * @see Advised
 */
public static Class<?>[] proxiedUserInterfaces(Object proxy) {
	Class<?>[] proxyInterfaces = proxy.getClass().getInterfaces();
	int nonUserIfcCount = 0;
	if (proxy instanceof SpringProxy) {
		nonUserIfcCount++;
	}
	if (proxy instanceof Advised) {
		nonUserIfcCount++;
	}
	if (proxy instanceof DecoratingProxy) {
		nonUserIfcCount++;
	}
	Class<?>[] userInterfaces = new Class<?>[proxyInterfaces.length - nonUserIfcCount];
	System.arraycopy(proxyInterfaces, 0, userInterfaces, 0, userInterfaces.length);
	Assert.notEmpty(userInterfaces, "JDK proxy must implement one or more interfaces");
	return userInterfaces;
}
 
Example #4
Source File: AopProxyUtilsTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testCompleteProxiedInterfacesWorksWithNull() {
	AdvisedSupport as = new AdvisedSupport();
	Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
	assertEquals(2, completedInterfaces.length);
	List<?> ifaces = Arrays.asList(completedInterfaces);
	assertTrue(ifaces.contains(Advised.class));
	assertTrue(ifaces.contains(SpringProxy.class));
}
 
Example #5
Source File: SpringStopwatchSource.java    From javasimon with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected String getMeaningfulClassName(Class<?> targetClass) {
	if (java.lang.reflect.Proxy.isProxyClass(targetClass)) {
		for (Class<?> iface : targetClass.getInterfaces()) {
			if (iface != SpringProxy.class && iface != Advised.class) {
				return iface.getName();
			}
		}
	}
	return targetClass.getName();
}
 
Example #6
Source File: AopProxyUtilsTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompleteProxiedInterfacesWorksWithNull() {
	AdvisedSupport as = new AdvisedSupport();
	Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
	assertEquals(2, completedInterfaces.length);
	List<?> ifaces = Arrays.asList(completedInterfaces);
	assertTrue(ifaces.contains(Advised.class));
	assertTrue(ifaces.contains(SpringProxy.class));
}
 
Example #7
Source File: AopProxyUtils.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Extract the user-specified interfaces that the given proxy implements,
 * i.e. all non-Advised interfaces that the proxy implements.
 * @param proxy the proxy to analyze (usually a JDK dynamic proxy)
 * @return all user-specified interfaces that the proxy implements,
 * in the original order (never {@code null} or empty)
 * @see Advised
 */
public static Class<?>[] proxiedUserInterfaces(Object proxy) {
	Class<?>[] proxyInterfaces = proxy.getClass().getInterfaces();
	int nonUserIfcCount = 0;
	if (proxy instanceof SpringProxy) {
		nonUserIfcCount++;
	}
	if (proxy instanceof Advised) {
		nonUserIfcCount++;
	}
	Class<?>[] userInterfaces = new Class<?>[proxyInterfaces.length - nonUserIfcCount];
	System.arraycopy(proxyInterfaces, 0, userInterfaces, 0, userInterfaces.length);
	Assert.notEmpty(userInterfaces, "JDK proxy must implement one or more interfaces");
	return userInterfaces;
}
 
Example #8
Source File: AopProxyUtils.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Determine the complete set of interfaces to proxy for the given AOP configuration.
 * <p>This will always add the {@link Advised} interface unless the AdvisedSupport's
 * {@link AdvisedSupport#setOpaque "opaque"} flag is on. Always adds the
 * {@link org.springframework.aop.SpringProxy} marker interface.
 * @return the complete set of interfaces to proxy
 * @see Advised
 * @see org.springframework.aop.SpringProxy
 */
public static Class<?>[] completeProxiedInterfaces(AdvisedSupport advised) {
	Class<?>[] specifiedInterfaces = advised.getProxiedInterfaces();
	if (specifiedInterfaces.length == 0) {
		// No user-specified interfaces: check whether target class is an interface.
		Class<?> targetClass = advised.getTargetClass();
		if (targetClass != null) {
			if (targetClass.isInterface()) {
				advised.setInterfaces(targetClass);
			}
			else if (Proxy.isProxyClass(targetClass)) {
				advised.setInterfaces(targetClass.getInterfaces());
			}
			specifiedInterfaces = advised.getProxiedInterfaces();
		}
	}
	boolean addSpringProxy = !advised.isInterfaceProxied(SpringProxy.class);
	boolean addAdvised = !advised.isOpaque() && !advised.isInterfaceProxied(Advised.class);
	int nonUserIfcCount = 0;
	if (addSpringProxy) {
		nonUserIfcCount++;
	}
	if (addAdvised) {
		nonUserIfcCount++;
	}
	Class<?>[] proxiedInterfaces = new Class<?>[specifiedInterfaces.length + nonUserIfcCount];
	System.arraycopy(specifiedInterfaces, 0, proxiedInterfaces, 0, specifiedInterfaces.length);
	if (addSpringProxy) {
		proxiedInterfaces[specifiedInterfaces.length] = SpringProxy.class;
	}
	if (addAdvised) {
		proxiedInterfaces[proxiedInterfaces.length - 1] = Advised.class;
	}
	return proxiedInterfaces;
}
 
Example #9
Source File: CodelessDaoFactoryBean.java    From sca-best-practice with Apache License 2.0 5 votes vote down vote up
@Override
public CodelessDao getObject() {
    ProxyFactory result = new ProxyFactory();
    result.setTarget(codelessDaoProxy);
    result.setInterfaces(CodelessDao.class, SpringProxy.class);
    result.addAdvice(SurroundingTransactionDetectorMethodInterceptor.INSTANCE);
    result.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    result.addAdvice(new DefaultMethodInvokingMethodInterceptor());
    return (CodelessDao)result.getProxy(classLoader);
}
 
Example #10
Source File: AopUtils.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Select an invocable method on the target type: either the given method itself
 * if actually exposed on the target type, or otherwise a corresponding method
 * on one of the target type's interfaces or on the target type itself.
 * @param method the method to check
 * @param targetType the target type to search methods on (typically an AOP proxy)
 * @return a corresponding invocable method on the target type
 * @throws IllegalStateException if the given method is not invocable on the given
 * target type (typically due to a proxy mismatch)
 * @since 4.3
 * @see MethodIntrospector#selectInvocableMethod(Method, Class)
 */
public static Method selectInvocableMethod(Method method, @Nullable Class<?> targetType) {
	if (targetType == null) {
		return method;
	}
	Method methodToUse = MethodIntrospector.selectInvocableMethod(method, targetType);
	if (Modifier.isPrivate(methodToUse.getModifiers()) && !Modifier.isStatic(methodToUse.getModifiers()) &&
			SpringProxy.class.isAssignableFrom(targetType)) {
		throw new IllegalStateException(String.format(
				"Need to invoke method '%s' found on proxy for target class '%s' but cannot " +
				"be delegated to target bean. Switch its visibility to package or protected.",
				method.getName(), method.getDeclaringClass().getSimpleName()));
	}
	return methodToUse;
}
 
Example #11
Source File: AopProxyUtilsTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testCompleteProxiedInterfacesWorksWithNull() {
	AdvisedSupport as = new AdvisedSupport();
	Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
	assertEquals(2, completedInterfaces.length);
	List<?> ifaces = Arrays.asList(completedInterfaces);
	assertTrue(ifaces.contains(Advised.class));
	assertTrue(ifaces.contains(SpringProxy.class));
}
 
Example #12
Source File: AopUtils.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Select an invocable method on the target type: either the given method itself
 * if actually exposed on the target type, or otherwise a corresponding method
 * on one of the target type's interfaces or on the target type itself.
 * @param method the method to check
 * @param targetType the target type to search methods on (typically an AOP proxy)
 * @return a corresponding invocable method on the target type
 * @throws IllegalStateException if the given method is not invocable on the given
 * target type (typically due to a proxy mismatch)
 * @since 4.3
 * @see MethodIntrospector#selectInvocableMethod(Method, Class)
 */
public static Method selectInvocableMethod(Method method, @Nullable Class<?> targetType) {
	if (targetType == null) {
		return method;
	}
	Method methodToUse = MethodIntrospector.selectInvocableMethod(method, targetType);
	if (Modifier.isPrivate(methodToUse.getModifiers()) && !Modifier.isStatic(methodToUse.getModifiers()) &&
			SpringProxy.class.isAssignableFrom(targetType)) {
		throw new IllegalStateException(String.format(
				"Need to invoke method '%s' found on proxy for target class '%s' but cannot " +
				"be delegated to target bean. Switch its visibility to package or protected.",
				method.getName(), method.getDeclaringClass().getSimpleName()));
	}
	return methodToUse;
}
 
Example #13
Source File: AopProxyUtils.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Determine the complete set of interfaces to proxy for the given AOP configuration.
 * <p>This will always add the {@link Advised} interface unless the AdvisedSupport's
 * {@link AdvisedSupport#setOpaque "opaque"} flag is on. Always adds the
 * {@link org.springframework.aop.SpringProxy} marker interface.
 * @param advised the proxy config
 * @param decoratingProxy whether to expose the {@link DecoratingProxy} interface
 * @return the complete set of interfaces to proxy
 * @since 4.3
 * @see SpringProxy
 * @see Advised
 * @see DecoratingProxy
 */
static Class<?>[] completeProxiedInterfaces(AdvisedSupport advised, boolean decoratingProxy) {
	Class<?>[] specifiedInterfaces = advised.getProxiedInterfaces();
	if (specifiedInterfaces.length == 0) {
		// No user-specified interfaces: check whether target class is an interface.
		Class<?> targetClass = advised.getTargetClass();
		if (targetClass != null) {
			if (targetClass.isInterface()) {
				advised.setInterfaces(targetClass);
			}
			else if (Proxy.isProxyClass(targetClass)) {
				advised.setInterfaces(targetClass.getInterfaces());
			}
			specifiedInterfaces = advised.getProxiedInterfaces();
		}
	}
	boolean addSpringProxy = !advised.isInterfaceProxied(SpringProxy.class);
	boolean addAdvised = !advised.isOpaque() && !advised.isInterfaceProxied(Advised.class);
	boolean addDecoratingProxy = (decoratingProxy && !advised.isInterfaceProxied(DecoratingProxy.class));
	int nonUserIfcCount = 0;
	if (addSpringProxy) {
		nonUserIfcCount++;
	}
	if (addAdvised) {
		nonUserIfcCount++;
	}
	if (addDecoratingProxy) {
		nonUserIfcCount++;
	}
	Class<?>[] proxiedInterfaces = new Class<?>[specifiedInterfaces.length + nonUserIfcCount];
	System.arraycopy(specifiedInterfaces, 0, proxiedInterfaces, 0, specifiedInterfaces.length);
	int index = specifiedInterfaces.length;
	if (addSpringProxy) {
		proxiedInterfaces[index] = SpringProxy.class;
		index++;
	}
	if (addAdvised) {
		proxiedInterfaces[index] = Advised.class;
		index++;
	}
	if (addDecoratingProxy) {
		proxiedInterfaces[index] = DecoratingProxy.class;
	}
	return proxiedInterfaces;
}
 
Example #14
Source File: EagleTraceProxyFactory.java    From eagle with Apache License 2.0 4 votes vote down vote up
private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) {
    Class<?>[] interfaces = config.getProxiedInterfaces();
    return (interfaces.length == 0 || (interfaces.length == 1 && SpringProxy.class.equals(interfaces[0])));
}
 
Example #15
Source File: AopProxyUtils.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determine the complete set of interfaces to proxy for the given AOP configuration.
 * <p>This will always add the {@link Advised} interface unless the AdvisedSupport's
 * {@link AdvisedSupport#setOpaque "opaque"} flag is on. Always adds the
 * {@link org.springframework.aop.SpringProxy} marker interface.
 * @param advised the proxy config
 * @param decoratingProxy whether to expose the {@link DecoratingProxy} interface
 * @return the complete set of interfaces to proxy
 * @since 4.3
 * @see SpringProxy
 * @see Advised
 * @see DecoratingProxy
 */
static Class<?>[] completeProxiedInterfaces(AdvisedSupport advised, boolean decoratingProxy) {
	Class<?>[] specifiedInterfaces = advised.getProxiedInterfaces();
	if (specifiedInterfaces.length == 0) {
		// No user-specified interfaces: check whether target class is an interface.
		Class<?> targetClass = advised.getTargetClass();
		if (targetClass != null) {
			if (targetClass.isInterface()) {
				advised.setInterfaces(targetClass);
			}
			else if (Proxy.isProxyClass(targetClass)) {
				advised.setInterfaces(targetClass.getInterfaces());
			}
			specifiedInterfaces = advised.getProxiedInterfaces();
		}
	}
	boolean addSpringProxy = !advised.isInterfaceProxied(SpringProxy.class);
	boolean addAdvised = !advised.isOpaque() && !advised.isInterfaceProxied(Advised.class);
	boolean addDecoratingProxy = (decoratingProxy && !advised.isInterfaceProxied(DecoratingProxy.class));
	int nonUserIfcCount = 0;
	if (addSpringProxy) {
		nonUserIfcCount++;
	}
	if (addAdvised) {
		nonUserIfcCount++;
	}
	if (addDecoratingProxy) {
		nonUserIfcCount++;
	}
	Class<?>[] proxiedInterfaces = new Class<?>[specifiedInterfaces.length + nonUserIfcCount];
	System.arraycopy(specifiedInterfaces, 0, proxiedInterfaces, 0, specifiedInterfaces.length);
	int index = specifiedInterfaces.length;
	if (addSpringProxy) {
		proxiedInterfaces[index] = SpringProxy.class;
		index++;
	}
	if (addAdvised) {
		proxiedInterfaces[index] = Advised.class;
		index++;
	}
	if (addDecoratingProxy) {
		proxiedInterfaces[index] = DecoratingProxy.class;
	}
	return proxiedInterfaces;
}
 
Example #16
Source File: AopProxyUtils.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Determine the complete set of interfaces to proxy for the given AOP configuration.
 * <p>This will always add the {@link Advised} interface unless the AdvisedSupport's
 * {@link AdvisedSupport#setOpaque "opaque"} flag is on. Always adds the
 * {@link org.springframework.aop.SpringProxy} marker interface.
 * @param advised the proxy config
 * @param decoratingProxy whether to expose the {@link DecoratingProxy} interface
 * @return the complete set of interfaces to proxy
 * @since 4.3
 * @see SpringProxy
 * @see Advised
 * @see DecoratingProxy
 */
static Class<?>[] completeProxiedInterfaces(AdvisedSupport advised, boolean decoratingProxy) {
	Class<?>[] specifiedInterfaces = advised.getProxiedInterfaces();
	if (specifiedInterfaces.length == 0) {
		// No user-specified interfaces: check whether target class is an interface.
		Class<?> targetClass = advised.getTargetClass();
		if (targetClass != null) {
			if (targetClass.isInterface()) {
				advised.setInterfaces(targetClass);
			}
			else if (Proxy.isProxyClass(targetClass)) {
				advised.setInterfaces(targetClass.getInterfaces());
			}
			specifiedInterfaces = advised.getProxiedInterfaces();
		}
	}
	boolean addSpringProxy = !advised.isInterfaceProxied(SpringProxy.class);
	boolean addAdvised = !advised.isOpaque() && !advised.isInterfaceProxied(Advised.class);
	boolean addDecoratingProxy = (decoratingProxy && !advised.isInterfaceProxied(DecoratingProxy.class));
	int nonUserIfcCount = 0;
	if (addSpringProxy) {
		nonUserIfcCount++;
	}
	if (addAdvised) {
		nonUserIfcCount++;
	}
	if (addDecoratingProxy) {
		nonUserIfcCount++;
	}
	Class<?>[] proxiedInterfaces = new Class<?>[specifiedInterfaces.length + nonUserIfcCount];
	System.arraycopy(specifiedInterfaces, 0, proxiedInterfaces, 0, specifiedInterfaces.length);
	int index = specifiedInterfaces.length;
	if (addSpringProxy) {
		proxiedInterfaces[index] = SpringProxy.class;
		index++;
	}
	if (addAdvised) {
		proxiedInterfaces[index] = Advised.class;
		index++;
	}
	if (addDecoratingProxy) {
		proxiedInterfaces[index] = DecoratingProxy.class;
	}
	return proxiedInterfaces;
}
 
Example #17
Source File: AopUtils.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Select an invocable method on the target type: either the given method itself
 * if actually exposed on the target type, or otherwise a corresponding method
 * on one of the target type's interfaces or on the target type itself.
 * @param method the method to check
 * @param targetType the target type to search methods on (typically an AOP proxy)
 * @return a corresponding invocable method on the target type
 * @throws IllegalStateException if the given method is not invocable on the given
 * target type (typically due to a proxy mismatch)
 * @since 4.3
 * @see MethodIntrospector#selectInvocableMethod(Method, Class)
 */
public static Method selectInvocableMethod(Method method, Class<?> targetType) {
	Method methodToUse = MethodIntrospector.selectInvocableMethod(method, targetType);
	if (Modifier.isPrivate(methodToUse.getModifiers()) && !Modifier.isStatic(methodToUse.getModifiers()) &&
			SpringProxy.class.isAssignableFrom(targetType)) {
		throw new IllegalStateException(String.format(
				"Need to invoke method '%s' found on proxy for target class '%s' but cannot " +
				"be delegated to target bean. Switch its visibility to package or protected.",
				method.getName(), method.getDeclaringClass().getSimpleName()));
	}
	return methodToUse;
}
 
Example #18
Source File: AopUtils.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Check whether the given object is a JDK dynamic proxy or a CGLIB proxy.
 * <p>This method additionally checks if the given object is an instance
 * of {@link SpringProxy}.
 * @param object the object to check
 * @see #isJdkDynamicProxy
 * @see #isCglibProxy
 */
public static boolean isAopProxy(@Nullable Object object) {
	return (object instanceof SpringProxy && (Proxy.isProxyClass(object.getClass()) ||
			object.getClass().getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR)));
}
 
Example #19
Source File: AopUtils.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Check whether the given object is a JDK dynamic proxy.
 * <p>This method goes beyond the implementation of
 * {@link Proxy#isProxyClass(Class)} by additionally checking if the
 * given object is an instance of {@link SpringProxy}.
 * @param object the object to check
 * @see java.lang.reflect.Proxy#isProxyClass
 */
public static boolean isJdkDynamicProxy(@Nullable Object object) {
	return (object instanceof SpringProxy && Proxy.isProxyClass(object.getClass()));
}
 
Example #20
Source File: AopUtils.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Check whether the given object is a JDK dynamic proxy.
 * <p>This method goes beyond the implementation of
 * {@link Proxy#isProxyClass(Class)} by additionally checking if the
 * given object is an instance of {@link SpringProxy}.
 * @param object the object to check
 * @see java.lang.reflect.Proxy#isProxyClass
 */
public static boolean isJdkDynamicProxy(@Nullable Object object) {
	return (object instanceof SpringProxy && Proxy.isProxyClass(object.getClass()));
}
 
Example #21
Source File: DefaultAopProxyFactory.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Determine whether the supplied {@link AdvisedSupport} has only the
 * {@link org.springframework.aop.SpringProxy} interface specified
 * (or no proxy interfaces specified at all).
 */
private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) {
	Class<?>[] ifcs = config.getProxiedInterfaces();
	return (ifcs.length == 0 || (ifcs.length == 1 && SpringProxy.class.isAssignableFrom(ifcs[0])));
}
 
Example #22
Source File: AopUtils.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Check whether the given object is a CGLIB proxy.
 * <p>This method goes beyond the implementation of
 * {@link ClassUtils#isCglibProxy(Object)} by additionally checking if
 * the given object is an instance of {@link SpringProxy}.
 * @param object the object to check
 * @see ClassUtils#isCglibProxy(Object)
 */
public static boolean isCglibProxy(@Nullable Object object) {
	return (object instanceof SpringProxy &&
			object.getClass().getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR));
}
 
Example #23
Source File: AopUtils.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Check whether the given object is a CGLIB proxy.
 * <p>This method goes beyond the implementation of
 * {@link ClassUtils#isCglibProxy(Object)} by additionally checking if
 * the given object is an instance of {@link SpringProxy}.
 * @param object the object to check
 * @see ClassUtils#isCglibProxy(Object)
 */
public static boolean isCglibProxy(Object object) {
	return (object instanceof SpringProxy && ClassUtils.isCglibProxy(object));
}
 
Example #24
Source File: AopUtils.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Check whether the given object is a JDK dynamic proxy.
 * <p>This method goes beyond the implementation of
 * {@link Proxy#isProxyClass(Class)} by additionally checking if the
 * given object is an instance of {@link SpringProxy}.
 * @param object the object to check
 * @see java.lang.reflect.Proxy#isProxyClass
 */
public static boolean isJdkDynamicProxy(Object object) {
	return (object instanceof SpringProxy && Proxy.isProxyClass(object.getClass()));
}
 
Example #25
Source File: AopUtils.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Check whether the given object is a JDK dynamic proxy or a CGLIB proxy.
 * <p>This method additionally checks if the given object is an instance
 * of {@link SpringProxy}.
 * @param object the object to check
 * @see #isJdkDynamicProxy
 * @see #isCglibProxy
 */
public static boolean isAopProxy(Object object) {
	return (object instanceof SpringProxy &&
			(Proxy.isProxyClass(object.getClass()) || ClassUtils.isCglibProxyClass(object.getClass())));
}
 
Example #26
Source File: DefaultAopProxyFactory.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determine whether the supplied {@link AdvisedSupport} has only the
 * {@link org.springframework.aop.SpringProxy} interface specified
 * (or no proxy interfaces specified at all).
 */
private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) {
	Class<?>[] ifcs = config.getProxiedInterfaces();
	return (ifcs.length == 0 || (ifcs.length == 1 && SpringProxy.class.isAssignableFrom(ifcs[0])));
}
 
Example #27
Source File: AopUtils.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check whether the given object is a CGLIB proxy.
 * <p>This method goes beyond the implementation of
 * {@link ClassUtils#isCglibProxy(Object)} by additionally checking if
 * the given object is an instance of {@link SpringProxy}.
 * @param object the object to check
 * @see ClassUtils#isCglibProxy(Object)
 */
public static boolean isCglibProxy(Object object) {
	return (object instanceof SpringProxy && ClassUtils.isCglibProxy(object));
}
 
Example #28
Source File: AopUtils.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check whether the given object is a JDK dynamic proxy.
 * <p>This method goes beyond the implementation of
 * {@link Proxy#isProxyClass(Class)} by additionally checking if the
 * given object is an instance of {@link SpringProxy}.
 * @param object the object to check
 * @see java.lang.reflect.Proxy#isProxyClass
 */
public static boolean isJdkDynamicProxy(Object object) {
	return (object instanceof SpringProxy && Proxy.isProxyClass(object.getClass()));
}
 
Example #29
Source File: AopUtils.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check whether the given object is a JDK dynamic proxy or a CGLIB proxy.
 * <p>This method additionally checks if the given object is an instance
 * of {@link SpringProxy}.
 * @param object the object to check
 * @see #isJdkDynamicProxy
 * @see #isCglibProxy
 */
public static boolean isAopProxy(Object object) {
	return (object instanceof SpringProxy &&
			(Proxy.isProxyClass(object.getClass()) || ClassUtils.isCglibProxyClass(object.getClass())));
}
 
Example #30
Source File: DefaultAopProxyFactory.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Determine whether the supplied {@link AdvisedSupport} has only the
 * {@link org.springframework.aop.SpringProxy} interface specified
 * (or no proxy interfaces specified at all).
 */
private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) {
	Class<?>[] ifcs = config.getProxiedInterfaces();
	return (ifcs.length == 0 || (ifcs.length == 1 && SpringProxy.class.isAssignableFrom(ifcs[0])));
}