Package net.sf.cglib.proxy

Examples of net.sf.cglib.proxy.Enhancer.create()


            return "Hello, World!";
          }
     
        }, NoOp.INSTANCE } );
   
    return (BeanInterface)enhancer.create();
  }
 
 
  private static class InterfaceMethodFilter implements CallbackFilter
  {
View Full Code Here


    public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(interfaze);
        enhancer.setCallback(new CglibMethodInterceptor<T>(interfaze, wire));
        Object proxy = enhancer.create();
        return interfaze.cast(proxy);
    }

    /**
     * create the proxy with cglib. use the same JDKInvocationHandler as
View Full Code Here

    public <T> T createProxy(CallableReference<T> callableReference) throws ProxyCreationException {
        Enhancer enhancer = new Enhancer();
        Class<T> interfaze = callableReference.getBusinessInterface();
        enhancer.setSuperclass(interfaze);
        enhancer.setCallback(new CglibMethodInterceptor<T>(callableReference));
        Object proxy = enhancer.create();
        return interfaze.cast(proxy);
    }

    /**
     * create the callback proxy with cglib. use the same
View Full Code Here

     */
    public <T> T createCallbackProxy(Class<T> interfaze, final List<RuntimeWire> wires) throws ProxyCreationException {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(interfaze);
        enhancer.setCallback(new CglibMethodInterceptor<T>(interfaze, wires));
        Object proxy = enhancer.create();
        return interfaze.cast(proxy);
    }

    @SuppressWarnings("unchecked")
    public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
View Full Code Here

                    throws Throwable {
                    return h.invoke(obj, method, args);
                }
               
            });
            return enhancer.create();
        } else {
            return super.getProxyInternal(loader, interfaces, h);
        }
    }
   
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public <T> T newInstance(final Class<T> cls) {
        final Enhancer enhancer = lookupOrCreateEnhancerFor(cls);
        return (T) enhancer.create();
    }

    private Enhancer lookupOrCreateEnhancerFor(final Class<?> cls) {
        Enhancer enhancer = enhancerByClass.get(cls);
        if (enhancer == null) {
View Full Code Here

    public <T> T createProxy(final Class<T> interfaze, Invocable invocable) throws ProxyCreationException {
        if (invocable instanceof RuntimeEndpoint) {
            Enhancer enhancer = new Enhancer();
            enhancer.setSuperclass(interfaze);
            enhancer.setCallback(new CglibMethodInterceptor<T>(interfaze, invocable));
            Object proxy = enhancer.create();
            return interfaze.cast(proxy);
        }       
        ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, invocable, null);
        return createProxy(serviceReference);
    }
View Full Code Here

    public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException {
        Enhancer enhancer = new Enhancer();
        Class<T> interfaze = callableReference.getBusinessInterface();
        enhancer.setSuperclass(interfaze);
        enhancer.setCallback(new CglibMethodInterceptor<T>(callableReference));
        Object proxy = enhancer.create();
    ((ServiceReferenceImpl)callableReference).setProxy(proxy);
        return interfaze.cast(proxy);
    }

    /**
 
View Full Code Here

    public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
        Enhancer enhancer = new Enhancer();
        Class<T> interfaze = callbackReference.getBusinessInterface();
        enhancer.setSuperclass(interfaze);
        enhancer.setCallback(new CglibMethodInterceptor<T>(callbackReference));
        Object object = enhancer.create();
        T proxy = interfaze.cast(object);
        ((ServiceReferenceExt<T>)callbackReference).setProxy(proxy);
        return proxy;
    }
View Full Code Here

    public <T> T createProxy(CallableReference<T> callableReference) throws ProxyCreationException {
        Enhancer enhancer = new Enhancer();
        Class<T> interfaze = callableReference.getBusinessInterface();
        enhancer.setSuperclass(interfaze);
        enhancer.setCallback(new CglibMethodInterceptor<T>(callableReference));
        Object proxy = enhancer.create();
    ((CallableReferenceImpl)callableReference).setProxy(proxy);
        return interfaze.cast(proxy);
    }

    /**
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.