Package net.sf.cglib.proxy

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


        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(renderKit.getClass());
        enhancer.setCallback(new ExtValGenericRenderKit(renderKit));
        enhancer.setClassLoader(Thread.currentThread().getContextClassLoader());

        return (RenderKit) enhancer.create();
    }

    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable
    {
        if(method.getName().equals("getRenderer"))
View Full Code Here


        /*
         * In OSGi, the classloader for the interface cannot access the classes for the CGLIB 
         */
        enhancer.setClassLoader(new ClassLoaderDelegate(targetJavaInterface.getClassLoader(), getClass().getClassLoader()));
        enhancer.setInterfaces(new Class[] {targetJavaInterface});
        return (Remote)enhancer.create();
    }
   
    private Object invokeTarget(Operation op, Object[] args) throws InvocationTargetException {
        return endpoint.invoke(op, args);
    }
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

       
    private FieldTarget getEnhancedObject() {
        Enhancer e = new Enhancer();
        e.setSuperclass(FieldTarget.class);       
        e.setCallback(new CallInterceptor());
        return (FieldTarget)e.create();       
    }

}

View Full Code Here

        final Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(clazz);
        enhancer.setInterfaces(interfaces);
        enhancer.setCallback(new CGLIBInvocationHandlerAdapter(invoker));
        try {
            return enhancer.create();
        } catch (CodeGenerationException e) { // cglib 2.0
        } catch (IllegalArgumentException e) { // cglib 2.0.2
        } catch (NoSuchMethodError e) {
        }
        return createWithConstructor(clazz, enhancer);
View Full Code Here

        AnnotatedEntryPointResolver resolver = new AnnotatedEntryPointResolver();

        Enhancer e = new Enhancer();
        e.setSuperclass(AnnotatedComponent2.class);
        e.setCallback(new DummyMethodCallback());
        Object proxy = e.create();

        MuleEventContext context = getTestEventContext(TEST_PAYLOAD);
        context.getMessage().setProperty(MuleProperties.MULE_METHOD_PROPERTY, "doSomething", PropertyScope.INVOCATION);
        InvocationResult result = resolver.invoke(proxy, context);
        assertEquals(result.getState(), InvocationResult.State.NOT_SUPPORTED);
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

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

    @SuppressWarnings("unchecked")
View Full Code Here

            final byte[] byteCode = generateRemoteInterface(targetJavaInterface);
            targetJavaInterface = classloader.defineClass(targetJavaInterface.getName(), byteCode);
            enhancer.setClassLoader(classloader);
        }
        enhancer.setInterfaces(new Class[] {targetJavaInterface});
        return (Remote)enhancer.create();
    }

    protected Object invokeTarget(Operation op, Object[] args) throws InvocationTargetException {
        return wire.invoke(op, args);
    }
View Full Code Here

        Class<T> interfaze = callableReference.getBusinessInterface();
        ClassLoader cl = new CglibClassLoader(interfaze.getClassLoader(), getClass().getClassLoader());      
        enhancer.setClassLoader(cl);
        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.