當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。