Package net.sf.cglib.proxy

Examples of net.sf.cglib.proxy.InvocationHandler


    }
   
    private Object createProxy(Class<?> proxyClass, final Invokable mockObject) {
        Factory proxy = (Factory)objenesis.newInstance(proxyClass);
        proxy.setCallbacks(new Callback[] {
            new InvocationHandler() {
                public Object invoke(Object receiver, Method method, Object[] args) throws Throwable {
                    return mockObject.invoke(new Invocation(receiver, method, args));
                }
            },
            NoOp.INSTANCE
View Full Code Here


    }

    @SuppressWarnings("unchecked")
    private <T> T cglibProxy(final Class<T> toStub, MethodInterceptor interceptor) {
        final ProxyInvocationHandler pih = new ProxyInvocationHandler(toStub, interceptor);
        return (T) Enhancer.create(toStub, new InvocationHandler() {

            public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
                return pih.invoke(o, method, objects);
            }
        });
View Full Code Here

    /** Unscoped Provider is needed to extract Injector... */
    private <T> T createProxy(final Key<T> key, final Provider<T> unscoped) {
        try {
            @SuppressWarnings("unchecked")
            final T proxy = (T) Enhancer.create(key.getTypeLiteral().getRawType(), new InvocationHandler() {
                @Override
                public Object invoke(final Object o, final Method method, final Object[] objects) throws Throwable {
                    try {
                        return method.invoke(getObject(), objects);
                    } catch (final InvocationTargetException e) {
View Full Code Here

        final Map<String, Supplier<?>> methods = ConfigurationProxyUtils.getMethodSuppliers(configClass, propertyFactory, configuration);
       
        if (configClass.isInterface()) {
            final Enhancer enhancer = new Enhancer();
            enhancer.setSuperclass(configClass);
            enhancer.setCallback(new InvocationHandler() {
                @Override
                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                    Supplier<?> supplier = (Supplier<?>)methods.get(method.getName());
                    return supplier.get();
                }
View Full Code Here

    }
   
    private Object createProxy(Class<?> proxyClass, final Invokable mockObject) {
        Factory proxy = (Factory)objenesis.newInstance(proxyClass);
        proxy.setCallbacks(new Callback[] {
            new InvocationHandler() {
                public Object invoke(Object receiver, Method method, Object[] args) throws Throwable {
                    return mockObject.invoke(new Invocation(receiver, method, args));
                }
            },
            NoOp.INSTANCE
View Full Code Here

    }
  }

  private Object createProxy(Class proxyClass, final Invokable mockObject) {
    Factory proxy = (Factory) objenesis.newInstance(proxyClass);
    proxy.setCallbacks(new Callback[] { new InvocationHandler() {
      public Object invoke(Object receiver, Method method, Object[] args) throws Throwable {
        return mockObject.invoke(new Invocation(receiver, method, args));
      }
    }, NoOp.INSTANCE });
    return proxy;
View Full Code Here

    }
   
    private Object createProxy(Class<?> proxyClass, final Invokable mockObject) {
        Factory proxy = (Factory)objenesis.newInstance(proxyClass);
        proxy.setCallbacks(new Callback[] {
            new InvocationHandler() {
                public Object invoke(Object receiver, Method method, Object[] args) throws Throwable {
                    return mockObject.invoke(new Invocation(receiver, method, args));
                }
            },
            NoOp.INSTANCE
View Full Code Here

TOP

Related Classes of net.sf.cglib.proxy.InvocationHandler

Copyright © 2018 www.massapicom. 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.