本文整理汇总了Java中net.sf.cglib.proxy.Enhancer.setNamingPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java Enhancer.setNamingPolicy方法的具体用法?Java Enhancer.setNamingPolicy怎么用?Java Enhancer.setNamingPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.cglib.proxy.Enhancer
的用法示例。
在下文中一共展示了Enhancer.setNamingPolicy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postProcessBeforeInstantiation
import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
@Override
public Object postProcessBeforeInstantiation(final Class<?> beanClass, final String beanName) throws BeansException {
if (_interceptors != null && _interceptors.size() > 0) {
if (ComponentMethodInterceptable.class.isAssignableFrom(beanClass)) {
final Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(beanClass);
enhancer.setCallbacks(getCallbacks());
enhancer.setCallbackFilter(getCallbackFilter());
enhancer.setNamingPolicy(ComponentNamingPolicy.INSTANCE);
final Object bean = enhancer.create();
return bean;
}
}
return null;
}
示例2: create
import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T create(Class<T> clazz, String widgetId) {
// creating proxy class
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(clazz);
enhancer.setUseFactory(true);
enhancer.setCallbackType(RemoteObjectMethodInterceptor.class);
if (clazz.getSigners() != null) {
enhancer.setNamingPolicy(NAMING_POLICY_FOR_CLASSES_IN_SIGNED_PACKAGES);
}
Class<?> proxyClass = enhancer.createClass();
// instantiating class without constructor call
ObjenesisStd objenesis = new ObjenesisStd();
Factory proxy = (Factory) objenesis.newInstance(proxyClass);
proxy.setCallbacks(new Callback[]{new RemoteObjectMethodInterceptor(this, invoker, widgetId)});
T widget = (T) proxy;
widgetIds.put(widget, widgetId);
return widget;
}
示例3: createProxy
import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
/**
* Creates a proxy object that will write-replace with a wrapper around the {@link EntityManager}.
* @param factory a factory to generate EntityManagers.
* @return the proxied instance.
*/
static EntityManager createProxy(final HibernateEntityManagerFactory factory) {
final EntityManagerInterceptor handler = new EntityManagerInterceptor(factory);
final Enhancer e = new Enhancer();
// make sure we're Serializable and have a write replace method
e.setInterfaces(new Class[] { EntityManager.class, Serializable.class, IWriteReplace.class });
e.setSuperclass(Object.class);
e.setCallback(handler);
e.setNamingPolicy(new DefaultNamingPolicy() {
@Override
public String getClassName(final String prefix,
final String source,
final Object key,
final Predicate names) {
return super.getClassName("CROQUET_ENTITY_MANAGER_PROXY_" + prefix, source, key, names);
}
});
LOG.trace("Created proxy for an EntityManager");
return (EntityManager)e.create();
}
示例4: createProxy
import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
/**
* Creates a proxy object that will write-replace with a wrapper around a {@link QueryRunner}.
* @param dataSourceFactory a provider to generate DataSources.
* @return the proxied instance.
*/
public static QueryRunner createProxy(final DataSourceFactory dataSourceFactory) {
final QueryRunnerInterceptor handler = new QueryRunnerInterceptor(dataSourceFactory);
final Enhancer e = new Enhancer();
// make sure we're Serializable and have a write replace method
e.setInterfaces(new Class[] { Serializable.class, IWriteReplace.class });
e.setSuperclass(QueryRunner.class);
e.setCallback(handler);
e.setNamingPolicy(new DefaultNamingPolicy() {
@Override
public String getClassName(final String prefix,
final String source,
final Object key,
final Predicate names) {
return super.getClassName("PROXY_" + prefix, source, key, names);
}
});
LOG.trace("Created proxy for an EntityManager");
return (QueryRunner)e.create();
}
示例5: postProcessBeforeInstantiation
import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
@Override
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
if (_interceptors != null && _interceptors.size() > 0) {
if (ComponentMethodInterceptable.class.isAssignableFrom(beanClass)) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(beanClass);
enhancer.setCallbacks(getCallbacks());
enhancer.setCallbackFilter(getCallbackFilter());
enhancer.setNamingPolicy(ComponentNamingPolicy.INSTANCE);
Object bean = enhancer.create();
return bean;
}
}
return null;
}
示例6: getProxyClass
import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
public static Class<?> getProxyClass(Class<?> clazz) {
Enhancer e = new Enhancer();
if (clazz.isInterface()) {
e.setSuperclass(clazz);
} else {
e.setSuperclass(clazz);
e.setInterfaces(clazz.getInterfaces());
}
e.setCallbackTypes(new Class[]{
InvocationHandler.class,
NoOp.class,
});
e.setCallbackFilter(BAD_OBJECT_METHOD_FILTER);
e.setUseFactory(true);
e.setNamingPolicy(new LithiumTestProxyNamingPolicy());
return e.createClass();
}
示例7: newDynamicFinder
import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
/**
* Creates a new dynamic finder instance.
*
* @param accessor specification for the accessor instance to create
* @param finderInterceptor the finder interceptor to use
* @return a Warp Persist-generated instance of the given dynamic finder
*/
public static Object newDynamicFinder(Class<?> accessor,
MethodInterceptor finderInterceptor) {
Enhancer enhancer = new Enhancer();
enhancer.setNamingPolicy(new WarpPersistNamingPolicy());
enhancer.setCallback(new AopAllianceCglibAdapter(finderInterceptor));
enhancer.setSuperclass(accessor);
return enhancer.create();
}
示例8: createAdapterProxy
import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
private Object createAdapterProxy(Class targetClass, Object eventHandler, AnnotationEventListenerAdapter adapter) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(targetClass);
enhancer.setClassLoader(targetClass.getClassLoader());
enhancer.setInterfaces(new Class[]{EventListener.class});
enhancer.setCallback(new AdapterInvocationHandler(adapter, eventHandler));
enhancer.setNamingPolicy(new Cqrs4jNamingPolicy());
return enhancer.create();
}
示例9: createEnhancer
import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
private static Enhancer createEnhancer(MethodInterceptor interceptor, Class<?> clazz, Class<?>... interfaces) {
Enhancer enhancer = new Enhancer();
enhancer.setNamingPolicy(ClassImposterizer.DEFAULT_POLICY);
enhancer.setCallback(interceptor);
enhancer.setSuperclass(clazz);
if (interfaces != null && interfaces.length > 0) enhancer.setInterfaces(interfaces);
return enhancer;
}