当前位置: 首页>>代码示例>>Java>>正文


Java Enhancer.setNamingPolicy方法代码示例

本文整理汇总了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;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:17,代码来源:ComponentInstantiationPostProcessor.java

示例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;
}
 
开发者ID:sterodium,项目名称:sterodium-rmi,代码行数:23,代码来源:RemoteObjectProxyFactory.java

示例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();
}
 
开发者ID:Metrink,项目名称:croquet,代码行数:29,代码来源:EntityManagerProxyFactory.java

示例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();

}
 
开发者ID:Metrink,项目名称:croquet,代码行数:30,代码来源:QueryRunnerProxyFactory.java

示例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;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:17,代码来源:ComponentInstantiationPostProcessor.java

示例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();
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:18,代码来源:FunctionalTestClassLoader.java

示例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();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:17,代码来源:DynamicFinders.java

示例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();
}
 
开发者ID:slowlizard,项目名称:cqrs4j,代码行数:10,代码来源:BaseAnnotationEventListenerBeanPostProcessor.java

示例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;
}
 
开发者ID:joshng,项目名称:papaya,代码行数:9,代码来源:ProxyUtil.java


注:本文中的net.sf.cglib.proxy.Enhancer.setNamingPolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。