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


Java Enhancer.setUseCache方法代码示例

本文整理汇总了Java中net.sf.cglib.proxy.Enhancer.setUseCache方法的典型用法代码示例。如果您正苦于以下问题:Java Enhancer.setUseCache方法的具体用法?Java Enhancer.setUseCache怎么用?Java Enhancer.setUseCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.cglib.proxy.Enhancer的用法示例。


在下文中一共展示了Enhancer.setUseCache方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
public static void main(String[] args) {
	while(true) {
		Enhancer enhancer = new Enhancer();
		enhancer.setSuperclass(ClassPermGenOOM.class);
		enhancer.setUseCache(Boolean.FALSE);
		
		enhancer.setCallback(new MethodInterceptor() {
			
			@Override
			public Object intercept(Object arg0, Method arg1, Object[] arg2,
					MethodProxy arg3) throws Throwable {
				return arg3.invokeSuper(arg0, arg2);
			}
		});
		enhancer.create();
	}
}
 
开发者ID:hdcuican,项目名称:java_learn,代码行数:18,代码来源:ClassPermGenOOM.java

示例2: main

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
public static void main(String[] args) {
    Tmp tmp = new Tmp();
    while (!Thread.interrupted()) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(Tmp.class);
        enhancer.setUseCache(false);
        enhancer.setCallback(new MethodInterceptor() {
            @Override
            public Object intercept(Object arg0, Method arg1, Object[] arg2, MethodProxy arg3) throws Throwable {
                return arg3.invokeSuper(arg0, arg2);
            }
        });
        enhancer.create();
    }
    System.out.println(tmp.hashCode());
}
 
开发者ID:zjulzq,项目名称:hotspot-gc-scenarios,代码行数:17,代码来源:Scenario4.java

示例3: BasicProxyFactoryImpl

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) {
	if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) {
		throw new AssertionFailure( "attempting to build proxy without any superclass or interfaces" );
	}

	Enhancer en = new Enhancer();
	en.setUseCache( false );
	en.setInterceptDuringConstruction( false );
	en.setUseFactory( true );
	en.setCallbackTypes( CALLBACK_TYPES );
	en.setCallbackFilter( FINALIZE_FILTER );
	if ( superClass != null ) {
		en.setSuperclass( superClass );
	}
	if ( interfaces != null && interfaces.length > 0 ) {
		en.setInterfaces( interfaces );
	}
	proxyClass = en.createClass();
	try {
		factory = ( Factory ) proxyClass.newInstance();
	}
	catch ( Throwable t ) {
		throw new HibernateException( "Unable to build CGLIB Factory instance" );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:ProxyFactoryFactoryImpl.java

示例4: benchmarkCglib

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
/**
 * Performs a benchmark of an interface implementation using cglib.
 *
 * @return The created instance, in order to avoid JIT removal.
 */
@Benchmark
public ExampleInterface benchmarkCglib() {
    Enhancer enhancer = new Enhancer();
    enhancer.setUseCache(false);
    enhancer.setClassLoader(newClassLoader());
    enhancer.setSuperclass(baseClass);
    CallbackHelper callbackHelper = new CallbackHelper(Object.class, new Class[]{baseClass}) {
        @Override
        protected Object getCallback(Method method) {
            if (method.getDeclaringClass() == baseClass) {
                return new FixedValue() {
                    @Override
                    public Object loadObject() throws Exception {
                        return null;
                    }
                };
            } else {
                return NoOp.INSTANCE;
            }
        }
    };
    enhancer.setCallbackFilter(callbackHelper);
    enhancer.setCallbacks(callbackHelper.getCallbacks());
    return (ExampleInterface) enhancer.create();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:31,代码来源:ClassByImplementationBenchmark.java

示例5: main

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
public static void main(String[] args) {
    while (true){
        Enhancer  enhancer = new Enhancer() ;
        enhancer.setSuperclass(HeapOOM.class);
        enhancer.setUseCache(false) ;
        enhancer.setCallback(new MethodInterceptor() {
            @Override
            public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
                return methodProxy.invoke(o,objects) ;
            }
        });
        enhancer.create() ;

    }
}
 
开发者ID:crossoverJie,项目名称:Java-Interview,代码行数:16,代码来源:MetaSpaceOOM.java

示例6: createProxy

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T createProxy(Class<T> targetClass) {
	Enhancer enhancer = new Enhancer();
	enhancer.setSuperclass(targetClass);
	enhancer.setUseCache(false);
	enhancer.setCallback(new MethodInterceptor() {
		public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
			System.out.println("方法调用前 先执行我。。。。。");
			Object obj = methodProxy.invokeSuper(object, args);
			System.out.println("方法调用后 再执行我。。。。。");
			return obj;
		}
	});
	return (T)enhancer.create();
}
 
开发者ID:hdcuican,项目名称:java_learn,代码行数:16,代码来源:CglibProxyTest.java

示例7: forClass

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
public static <T> MethodProxy<T> forClass(Class<T> clazz) {
    MethodSignatureInterceptor methodSignatureInterceptor = new MethodSignatureInterceptor();
    final Enhancer enhancer = new Enhancer();
    enhancer.setUseCache(false);
    enhancer.setSuperclass(clazz);
    enhancer.setCallbackType(methodSignatureInterceptor.getClass());
    final Class<?> proxyClass = enhancer.createClass();
    Enhancer.registerCallbacks(proxyClass, new Callback[]{methodSignatureInterceptor});
    T proxied = (T) ObjenesisHelper.newInstance(proxyClass);
    return new MethodProxy<>(methodSignatureInterceptor, proxied);
}
 
开发者ID:Qubite,项目名称:tomoko,代码行数:12,代码来源:MethodProxy.java

示例8: getInstance

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
/**
 * <pre>
 * cglib生成的子类实例
 * </pre>
 * 
 * @param supperClass
 * @return
 */
public static Object getInstance(Class<?> supperClass) {
	Enhancer enhancer = new Enhancer();
	//enhancer.setClassLoader(Thread.currentThread().getContextClassLoader());
	enhancer.setSuperclass(supperClass);
	enhancer.setCallback(new Interceptor());
	enhancer.setUseCache(false);
	Object dest = enhancer.create();
	//logger.info(dest.toString());
	return dest;
}
 
开发者ID:niaoge,项目名称:spring-dynamic,代码行数:19,代码来源:Interceptor.java

示例9: createEnhancedClass

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Class<? extends T> createEnhancedClass(Class<T> clazz, Class[] ancillaryTypes) {
    if (clazz == Object.class) {
        clazz = (Class<T>) TrivialSubclassOfObjectToWorkAroundCGLIBBug.class;
    }
    Enhancer e = new Enhancer();
    e.setClassLoader(clazz.getClassLoader());
    e.setSuperclass(clazz);
    e.setInterfaces(ancillaryTypes);
    e.setUseFactory(true);
    e.setUseCache(true);
    e.setCallbackType(MethodInterceptor.class);
    return e.createClass();
}
 
开发者ID:pobrelkey,项目名称:moxiemocks,代码行数:16,代码来源:CGLIBProxyFactory.java

示例10: benchmarkCglib

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
/**
 * Performs a benchmark for a trivial class creation using cglib.
 *
 * @return The created instance, in order to avoid JIT removal.
 */
@Benchmark
public Class<?> benchmarkCglib() {
    Enhancer enhancer = new Enhancer();
    enhancer.setUseCache(false);
    enhancer.setClassLoader(newClassLoader());
    enhancer.setSuperclass(baseClass);
    enhancer.setCallbackType(NoOp.class);
    return enhancer.createClass();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:15,代码来源:TrivialClassCreationBenchmark.java

示例11: enhanceServiceEndpointInterface

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
private Class enhanceServiceEndpointInterface(Class serviceEndpointInterface, ClassLoader classLoader) {
    Enhancer enhancer = new Enhancer();
    enhancer.setClassLoader(classLoader);
    enhancer.setSuperclass(GenericServiceEndpointWrapper.class);
    enhancer.setInterfaces(new Class[]{serviceEndpointInterface});
    enhancer.setCallbackFilter(new NoOverrideCallbackFilter(GenericServiceEndpointWrapper.class));
    enhancer.setCallbackTypes(new Class[]{NoOp.class, MethodInterceptor.class});
    enhancer.setUseFactory(false);
    enhancer.setUseCache(false);

    return enhancer.createClass();
}
 
开发者ID:apache,项目名称:tomee,代码行数:13,代码来源:SeiFactoryImpl.java

示例12: setUp

import net.sf.cglib.proxy.Enhancer; //导入方法依赖的package包/类
@Setup
public void setUp() {
   for(int i = 0; i < COUNT; i++) {
      Enhancer enhancer = new Enhancer();
      enhancer.setUseCache(false); // deactivate the cache to get a new instance each time
      enhancer.setCallbackType(NoOp.class);
      Class<?> c = enhancer.createClass();
      toInstantiate[i] = c;
   }
}
 
开发者ID:easymock,项目名称:objenesis,代码行数:11,代码来源:ConcurrentGetInstantiator.java


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