Java Code Examples for org.springframework.cglib.proxy.Enhancer#setClassLoader()
The following examples show how to use
org.springframework.cglib.proxy.Enhancer#setClassLoader() .
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: CglibStaticConfigurationInstanceCreator.java From conf4j with MIT License | 6 votes |
@Override @SuppressWarnings("unchecked") public <T> T createInstance(ConfigurationModel configurationModel, ClassLoader classLoader) { Class<?> configurationType = configurationModel.getConfigurationType(); Enhancer enhancer = new Enhancer(); enhancer.setClassLoader(classLoader); enhancer.setNamingPolicy(Conf4jNamingPolicy.INSTANCE); enhancer.setInterceptDuringConstruction(false); if (configurationType.isInterface()) { enhancer.setInterfaces(new Class<?>[]{configurationType, Serializable.class}); } else { enhancer.setSuperclass(configurationType); enhancer.setInterfaces(new Class<?>[]{Serializable.class}); } enhancer.setCallbackFilter(new ProxyCallbackFilter(configurationModel)); enhancer.setCallbacks(new Callback[]{ new CglibStaticConfigurationMethodInterceptor(configurationModel), new SerializableNoOp(), }); return (T) enhancer.create(); }
Example 2
Source File: CglibDynamicConfigurationInstanceCreator.java From conf4j with MIT License | 6 votes |
@Override public <T> T createInstance(ConfigurationModel configurationModel, ClassLoader classLoader) { Class<?> configurationType = configurationModel.getConfigurationType(); Enhancer enhancer = new Enhancer(); enhancer.setClassLoader(classLoader); enhancer.setNamingPolicy(Conf4jNamingPolicy.INSTANCE); enhancer.setInterceptDuringConstruction(false); if (configurationType.isInterface()) { enhancer.setInterfaces(new Class<?>[]{configurationType, DynamicConfiguration.class}); } else { enhancer.setSuperclass(configurationType); enhancer.setInterfaces(new Class<?>[]{DynamicConfiguration.class}); } enhancer.setCallbackFilter(new ProxyCallbackFilter(configurationModel)); enhancer.setCallbacks(new Callback[]{ new CglibDynamicConfigurationMethodInterceptor(configurationModel), new SerializableNoOp() }); @SuppressWarnings("unchecked") T instance = (T) enhancer.create(); return instance; }