use of net.sf.cglib.proxy.Enhancer in project rest.li by linkedin.
the class GeneratePatchProxyFactory method newInstance.
@SuppressWarnings("unchecked")
static <T> T newInstance(Class<T> clazz, PatchTree patchTree, PathSpec pathSpec) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(clazz);
enhancer.setCallback(newMethodInterceptor(clazz, patchTree, pathSpec));
return (T) enhancer.create();
}
use of net.sf.cglib.proxy.Enhancer in project JessMA by ldcsaa.
the class FacadeProxy method getProxy.
@SuppressWarnings("unchecked")
private static final <F extends AbstractFacade<M, S>, M extends SessionMgr<S>, S> F getProxy(Class<F> daoClass, M mgr, Callback intercepter) {
Enhancer en = new Enhancer();
en.setSuperclass(daoClass);
en.setCallbackFilter(InterceptFilter.INSTANCE);
Callback[] callbacks = { NoOp.INSTANCE, intercepter };
en.setCallbacks(callbacks);
en.setInterceptDuringConstruction(false);
Class<?>[] argTypes = mgr != null ? new Class<?>[] { mgr.getClass() } : new Class<?>[] {};
Object[] args = mgr != null ? new Object[] { mgr } : new Object[] {};
return (F) en.create(argTypes, args);
}
use of net.sf.cglib.proxy.Enhancer 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;
}
use of net.sf.cglib.proxy.Enhancer 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;
}
use of net.sf.cglib.proxy.Enhancer in project simplejpa by appoxy.
the class ObjectBuilder method newEnancedInstance.
private static ObjectWithInterceptor newEnancedInstance(EntityManagerSimpleJPA em, Class tClass) {
LazyInterceptor interceptor = new LazyInterceptor(em);
Enhancer e = new Enhancer();
e.setSuperclass(tClass);
e.setCallback(interceptor);
Object bean = e.create();
ObjectWithInterceptor cwi = new ObjectWithInterceptor(bean, interceptor);
return cwi;
}
Aggregations