net.sf.cglib.proxy.CallbackHelper Java Examples
The following examples show how to use
net.sf.cglib.proxy.CallbackHelper.
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: ClassByImplementationBenchmark.java From byte-buddy with Apache License 2.0 | 6 votes |
/** * 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}) { protected Object getCallback(Method method) { if (method.getDeclaringClass() == baseClass) { return new FixedValue() { public Object loadObject() { return null; } }; } else { return NoOp.INSTANCE; } } }; enhancer.setCallbackFilter(callbackHelper); enhancer.setCallbacks(callbackHelper.getCallbacks()); return (ExampleInterface) enhancer.create(); }