Search in sources :

Example 1 with UndeclaredThrowableStrategy

use of net.sf.cglib.transform.impl.UndeclaredThrowableStrategy in project spring-loaded by spring-projects.

the class ProxyBuilder method createProxyFor.

static <T> T createProxyFor(Class<T> clazz, MethodInterceptor mi) {
    Enhancer enhancer = new Enhancer();
    //		if (classLoader != null) {
    //			enhancer.setClassLoader(classLoader);
    //			if (classLoader instanceof SmartClassLoader &&
    //					((SmartClassLoader) classLoader).isClassReloadable(proxySuperClass)) {
    //				enhancer.setUseCache(false);
    //			}
    //		}
    enhancer.setSuperclass(clazz);
    enhancer.setStrategy(new UndeclaredThrowableStrategy(UndeclaredThrowableException.class));
    //AopProxyUtils.completeProxiedInterfaces(this.advised));
    enhancer.setInterfaces(null);
    enhancer.setInterceptDuringConstruction(false);
    //getCallbacks(rootClass);
    Callback[] callbacks = new Callback[] { mi };
    enhancer.setCallbacks(callbacks);
    //		enhancer.setCallbackFilter(new ProxyCallbackFilter(
    //				this.advised.getConfigurationOnlyCopy(), this.fixedInterceptorMap, this.fixedInterceptorOffset));
    Class<?>[] types = new Class[callbacks.length];
    for (int x = 0; x < types.length; x++) {
        types[x] = callbacks[x].getClass();
    }
    enhancer.setCallbackTypes(types);
    // Generate the proxy class and create a proxy instance.
    //		Object proxy;
    //		if (this.constructorArgs != null) {
    //			proxy = enhancer.create(this.constructorArgTypes, this.constructorArgs);
    //		}
    //		else {
    @SuppressWarnings("unchecked") T proxy = (T) enhancer.create();
    //		}
    return proxy;
}
Also used : Callback(net.sf.cglib.proxy.Callback) Enhancer(net.sf.cglib.proxy.Enhancer) UndeclaredThrowableStrategy(net.sf.cglib.transform.impl.UndeclaredThrowableStrategy) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Example 2 with UndeclaredThrowableStrategy

use of net.sf.cglib.transform.impl.UndeclaredThrowableStrategy in project spring-loaded by spring-projects.

the class ProxyBuilder method createProxyFor.

static <T> T createProxyFor(Class<T> clazz, MethodInterceptor mi) {
    Enhancer enhancer = new Enhancer();
    //		if (classLoader != null) {
    //			enhancer.setClassLoader(classLoader);
    //			if (classLoader instanceof SmartClassLoader &&
    //					((SmartClassLoader) classLoader).isClassReloadable(proxySuperClass)) {
    //				enhancer.setUseCache(false);
    //			}
    //		}
    enhancer.setSuperclass(clazz);
    enhancer.setStrategy(new UndeclaredThrowableStrategy(UndeclaredThrowableException.class));
    //AopProxyUtils.completeProxiedInterfaces(this.advised));
    enhancer.setInterfaces(null);
    enhancer.setInterceptDuringConstruction(false);
    //getCallbacks(rootClass);
    Callback[] callbacks = new Callback[] { mi };
    enhancer.setCallbacks(callbacks);
    //		enhancer.setCallbackFilter(new ProxyCallbackFilter(
    //				this.advised.getConfigurationOnlyCopy(), this.fixedInterceptorMap, this.fixedInterceptorOffset));
    Class<?>[] types = new Class[callbacks.length];
    for (int x = 0; x < types.length; x++) {
        types[x] = callbacks[x].getClass();
    }
    enhancer.setCallbackTypes(types);
    // Generate the proxy class and create a proxy instance.
    //		Object proxy;
    //		if (this.constructorArgs != null) {
    //			proxy = enhancer.create(this.constructorArgTypes, this.constructorArgs);
    //		}
    //		else {
    @SuppressWarnings("unchecked") T proxy = (T) enhancer.create();
    //		}
    return proxy;
}
Also used : Callback(net.sf.cglib.proxy.Callback) Enhancer(net.sf.cglib.proxy.Enhancer) UndeclaredThrowableStrategy(net.sf.cglib.transform.impl.UndeclaredThrowableStrategy) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Aggregations

UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2 Callback (net.sf.cglib.proxy.Callback)2 Enhancer (net.sf.cglib.proxy.Enhancer)2 UndeclaredThrowableStrategy (net.sf.cglib.transform.impl.UndeclaredThrowableStrategy)2