Java Code Examples for org.springframework.util.ClassUtils#isCglibProxyClass()

The following examples show how to use org.springframework.util.ClassUtils#isCglibProxyClass() . 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: ApacheDubboServiceBeanPostProcessor.java    From soul with Apache License 2.0 6 votes vote down vote up
private void handler(final ServiceBean serviceBean) {
    Class<?> clazz = serviceBean.getRef().getClass();
    if (ClassUtils.isCglibProxyClass(clazz)) {
        String superClassName = clazz.getGenericSuperclass().getTypeName();
        try {
            clazz = Class.forName(superClassName);
        } catch (ClassNotFoundException e) {
            log.error(String.format("class not found: %s", superClassName));
            return;
        }
    }
    final Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(clazz);
    for (Method method : methods) {
        SoulDubboClient soulDubboClient = method.getAnnotation(SoulDubboClient.class);
        if (Objects.nonNull(soulDubboClient)) {
            post(buildJsonParams(serviceBean, soulDubboClient, method));
        }
    }
}
 
Example 2
Source File: AlibabaDubboServiceBeanPostProcessor.java    From soul with Apache License 2.0 6 votes vote down vote up
private void handler(final ServiceBean serviceBean) {
    Class<?> clazz = serviceBean.getRef().getClass();
    if (ClassUtils.isCglibProxyClass(clazz)) {
        String superClassName = clazz.getGenericSuperclass().getTypeName();
        try {
            clazz = Class.forName(superClassName);
        } catch (ClassNotFoundException e) {
            log.error(String.format("class not found: %s", superClassName));
            return;
        }
    }
    final Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(clazz);
    for (Method method : methods) {
        SoulDubboClient soulDubboClient = method.getAnnotation(SoulDubboClient.class);
        if (Objects.nonNull(soulDubboClient)) {
            post(buildJsonParams(serviceBean, soulDubboClient, method));
        }
    }
}
 
Example 3
Source File: ConfigurationBeanFactoryMetadata.java    From spring-cloud-gray with Apache License 2.0 6 votes vote down vote up
public Method findFactoryMethod(String beanName) {
    if (!this.beansFactoryMetadata.containsKey(beanName)) {
        return null;
    }
    AtomicReference<Method> found = new AtomicReference<>(null);
    FactoryMetadata metadata = this.beansFactoryMetadata.get(beanName);
    Class<?> factoryType = this.beanFactory.getType(metadata.getBean());
    String factoryMethod = metadata.getMethod();
    if (ClassUtils.isCglibProxyClass(factoryType)) {
        factoryType = factoryType.getSuperclass();
    }
    ReflectionUtils.doWithMethods(factoryType, (method) -> {
        if (method.getName().equals(factoryMethod)) {
            found.compareAndSet(null, method);
        }
    });
    return found.get();
}
 
Example 4
Source File: QConfigAnnotationProcessor.java    From qconfig with MIT License 5 votes vote down vote up
private Class<?> getRealClass(Object bean) {
    Class<?> clazz = bean.getClass();
    while (ClassUtils.isCglibProxyClass(clazz)) {
        clazz = clazz.getSuperclass();
    }
    return clazz;
}
 
Example 5
Source File: SpringUtils.java    From onetwo with Apache License 2.0 5 votes vote down vote up
public static Class<?> getTargetClass(Object candidate) {
	Class<?> targetClass = AopUtils.getTargetClass(candidate);
	if(ClassUtils.isCglibProxyClass(targetClass)){
		targetClass = candidate.getClass().getSuperclass();
	}
	return targetClass;
}
 
Example 6
Source File: SpringClassUnwrapper.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public Class<?> getRealClassFromClass(Class<?> cls) {
    if (ClassUtils.isCglibProxyClass(cls)) {
        final Class<?> superclass = cls.getSuperclass();
        // Lambda's generated class names also contain $$ which makes them trigger CGLIB
        // proxy path. Adding more checks to handle this particular case.
        if (superclass != null && (superclass != Object.class || wasCglibEnhanced(cls))) {
            return getRealClassFromClass(superclass);
        }
    }
    return cls;
}
 
Example 7
Source File: GrpcAop.java    From saluki with Apache License 2.0 4 votes vote down vote up
private static boolean isAopProxy(Object object) {
  return Proxy.isProxyClass(object.getClass()) || ClassUtils.isCglibProxyClass(object.getClass());
}
 
Example 8
Source File: MonitoredMeasuringPointcut.java    From javasimon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean matches(Method method, Class targetClass) {
	return !ClassUtils.isCglibProxyClass(targetClass) && isMonitoredAnnotationOnClassOrMethod(method, targetClass);
}
 
Example 9
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 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()) || ClassUtils.isCglibProxyClass(object.getClass())));
}
 
Example 10
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 11
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())));
}