/** Returns the class loader to host generated classes for {@code type}. */ public static ClassLoader getClassLoader(Class<?> type) { return getClassLoader(type, type.getClassLoader()); }
public Object createProxy(InjectorOptions injectorOptions, Class<?> expectedType) throws InternalProvisionException { if (injectorOptions.disableCircularProxies) { throw InternalProvisionException.circularDependenciesDisabled(expectedType); } if (!expectedType.isInterface()) { throw InternalProvisionException.cannotProxyClass(expectedType); } if (invocationHandlers == null) { invocationHandlers = new ArrayList<>(); } DelegatingInvocationHandler<T> invocationHandler = new DelegatingInvocationHandler<>(); invocationHandlers.add(invocationHandler); // TODO: if I create a proxy which implements all the interfaces of // the implementation type, I'll be able to get away with one proxy // instance (as opposed to one per caller). ClassLoader classLoader = BytecodeGen.getClassLoader(expectedType); return expectedType.cast( Proxy.newProxyInstance( classLoader, new Class[] {expectedType, CircularDependencyProxy.class}, invocationHandler)); }
public static net.sf.cglib.proxy.Enhancer newEnhancer(Class<?> type, Visibility visibility) { net.sf.cglib.proxy.Enhancer enhancer = new net.sf.cglib.proxy.Enhancer(); enhancer.setSuperclass(type); enhancer.setUseFactory(false); if (visibility == Visibility.PUBLIC) { enhancer.setClassLoader(getClassLoader(type)); } enhancer.setNamingPolicy(ENHANCER_NAMING_POLICY); logger.fine("Loading " + type + " Enhancer with " + enhancer.getClassLoader()); return enhancer; } /*end[AOP]*/
if (publiclyCallable) { generator.setClassLoader(getClassLoader(type));
/** * Returns the class loader to host generated classes for {@code type}. */ public static ClassLoader getClassLoader(Class<?> type) { return getClassLoader(type, type.getClassLoader()); }
/** * Returns the class loader to host generated classes for {@code type}. */ public static ClassLoader getClassLoader(Class<?> type) { return getClassLoader(type, type.getClassLoader()); }
/** * Returns the class loader to host generated classes for {@code type}. */ public static ClassLoader getClassLoader(Class<?> type) { return getClassLoader(type, type.getClassLoader()); }
/** Returns the class loader to host generated classes for {@code type}. */ public static ClassLoader getClassLoader(Class<?> type) { return getClassLoader(type, type.getClassLoader()); }
/** Returns the class loader to host generated classes for {@code type}. */ public static ClassLoader getClassLoader(Class<?> type) { return getClassLoader(type, type.getClassLoader()); }
return factoryRawType.cast(Proxy.newProxyInstance(BytecodeGen.getClassLoader(factoryRawType), new Class[] { factoryRawType }, invocationHandler));
return factoryRawType.cast(Proxy.newProxyInstance(BytecodeGen.getClassLoader(factoryRawType), new Class[] { factoryRawType }, invocationHandler));
public Object createProxy(Errors errors, Class<?> expectedType) throws ErrorsException { // TODO: if I create a proxy which implements all the interfaces of // the implementation type, I'll be able to get away with one proxy // instance (as opposed to one per caller). if (!expectedType.isInterface()) { throw errors.cannotSatisfyCircularDependency(expectedType).toException(); } if (invocationHandlers == null) { invocationHandlers = new ArrayList<DelegatingInvocationHandler<T>>(); } DelegatingInvocationHandler<T> invocationHandler = new DelegatingInvocationHandler<T>(); invocationHandlers.add(invocationHandler); ClassLoader classLoader = BytecodeGen.getClassLoader(expectedType); return expectedType.cast(Proxy.newProxyInstance(classLoader, new Class[] { expectedType, CircularDependencyProxy.class }, invocationHandler)); }
public Object createProxy(Errors errors, Class<?> expectedType) throws ErrorsException { // TODO: if I create a proxy which implements all the interfaces of // the implementation type, I'll be able to get away with one proxy // instance (as opposed to one per caller). if (!expectedType.isInterface()) { throw errors.cannotSatisfyCircularDependency(expectedType).toException(); } if (invocationHandlers == null) { invocationHandlers = new ArrayList<DelegatingInvocationHandler<T>>(); } DelegatingInvocationHandler<T> invocationHandler = new DelegatingInvocationHandler<T>(); invocationHandlers.add(invocationHandler); ClassLoader classLoader = BytecodeGen.getClassLoader(expectedType); return expectedType.cast(Proxy.newProxyInstance(classLoader, new Class[] { expectedType, CircularDependencyProxy.class }, invocationHandler)); }
public Object createProxy(Errors errors, Class<?> expectedType) throws ErrorsException { // TODO: if I create a proxy which implements all the interfaces of // the implementation type, I'll be able to get away with one proxy // instance (as opposed to one per caller). if (!expectedType.isInterface()) { throw errors.cannotSatisfyCircularDependency(expectedType).toException(); } if (invocationHandlers == null) { invocationHandlers = new ArrayList<DelegatingInvocationHandler<T>>(); } DelegatingInvocationHandler<T> invocationHandler = new DelegatingInvocationHandler<T>(); invocationHandlers.add(invocationHandler); ClassLoader classLoader = BytecodeGen.getClassLoader(expectedType); return expectedType.cast(Proxy.newProxyInstance(classLoader, new Class[] { expectedType, CircularDependencyProxy.class }, invocationHandler)); }
public Object createProxy(InjectorOptions injectorOptions, Class<?> expectedType) throws InternalProvisionException { if (injectorOptions.disableCircularProxies) { throw InternalProvisionException.circularDependenciesDisabled(expectedType); } if (!expectedType.isInterface()) { throw InternalProvisionException.cannotProxyClass(expectedType); } if (invocationHandlers == null) { invocationHandlers = new ArrayList<>(); } DelegatingInvocationHandler<T> invocationHandler = new DelegatingInvocationHandler<>(); invocationHandlers.add(invocationHandler); // TODO: if I create a proxy which implements all the interfaces of // the implementation type, I'll be able to get away with one proxy // instance (as opposed to one per caller). ClassLoader classLoader = BytecodeGen.getClassLoader(expectedType); return expectedType.cast( Proxy.newProxyInstance( classLoader, new Class[] {expectedType, CircularDependencyProxy.class}, invocationHandler)); }
public Object createProxy(InjectorOptions injectorOptions, Class<?> expectedType) throws InternalProvisionException { if (injectorOptions.disableCircularProxies) { throw InternalProvisionException.circularDependenciesDisabled(expectedType); } if (!expectedType.isInterface()) { throw InternalProvisionException.cannotProxyClass(expectedType); } if (invocationHandlers == null) { invocationHandlers = new ArrayList<>(); } DelegatingInvocationHandler<T> invocationHandler = new DelegatingInvocationHandler<>(); invocationHandlers.add(invocationHandler); // TODO: if I create a proxy which implements all the interfaces of // the implementation type, I'll be able to get away with one proxy // instance (as opposed to one per caller). ClassLoader classLoader = BytecodeGen.getClassLoader(expectedType); return expectedType.cast( Proxy.newProxyInstance( classLoader, new Class[] {expectedType, CircularDependencyProxy.class}, invocationHandler)); }
public static net.sf.cglib.proxy.Enhancer newEnhancer(Class<?> type, Visibility visibility) { net.sf.cglib.proxy.Enhancer enhancer = new net.sf.cglib.proxy.Enhancer(); enhancer.setSuperclass(type); enhancer.setUseFactory(false); if (visibility == Visibility.PUBLIC) { enhancer.setClassLoader(getClassLoader(type)); } enhancer.setNamingPolicy(ENHANCER_NAMING_POLICY); logger.fine("Loading " + type + " Enhancer with " + enhancer.getClassLoader()); return enhancer; } /*end[AOP]*/
public static net.sf.cglib.reflect.FastClass newFastClass(Class<?> type, Visibility visibility) { net.sf.cglib.reflect.FastClass.Generator generator = new net.sf.cglib.reflect.FastClass.Generator(); generator.setType(type); if (visibility == Visibility.PUBLIC) { generator.setClassLoader(getClassLoader(type)); } generator.setNamingPolicy(FASTCLASS_NAMING_POLICY); logger.fine("Loading " + type + " FastClass with " + generator.getClassLoader()); return generator.create(); }
public static net.sf.cglib.proxy.Enhancer newEnhancer(Class<?> type, Visibility visibility) { net.sf.cglib.proxy.Enhancer enhancer = new net.sf.cglib.proxy.Enhancer(); enhancer.setSuperclass(type); enhancer.setUseFactory(false); if (visibility == Visibility.PUBLIC) { enhancer.setClassLoader(getClassLoader(type)); } enhancer.setNamingPolicy(ENHANCER_NAMING_POLICY); logger.fine("Loading " + type + " Enhancer with " + enhancer.getClassLoader()); return enhancer; } /*end[AOP]*/
public static net.sf.cglib.proxy.Enhancer newEnhancer(Class<?> type, Visibility visibility) { net.sf.cglib.proxy.Enhancer enhancer = new net.sf.cglib.proxy.Enhancer(); enhancer.setSuperclass(type); enhancer.setUseFactory(false); if (visibility == Visibility.PUBLIC) { enhancer.setClassLoader(getClassLoader(type)); } enhancer.setNamingPolicy(ENHANCER_NAMING_POLICY); logger.fine("Loading " + type + " Enhancer with " + enhancer.getClassLoader()); return enhancer; } /*end[AOP]*/