Package net.sf.cglib.proxy

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


  public <T> T newInstance(Class<T> classToInstantiate) {
    Enhancer enhancer = new Enhancer();
    enhancer.setSuperclass(classToInstantiate);
    enhancer.setCallback(NoOpInterceptor.INSTANCE);
    return (T) enhancer.create();
  }
 
  public <T> T newInstance(Class<T> classToInstantiate, Object[] args) {
    List<Class<?>> argTypes = new ArrayList<Class<?>>();
    for (Object arg : args) {
View Full Code Here


      argTypes.add(MappingUtils.getRealClass(arg.getClass()));
    }
    Enhancer enhancer = new Enhancer();
    enhancer.setSuperclass(classToInstantiate);
    enhancer.setCallback(NoOpInterceptor.INSTANCE);
    return (T) enhancer.create(argTypes.toArray(new Class[0]), args);
  }

  public Object newInstance(Class<?>[] interfacesToProxy, final Object target) {
    Enhancer enhancer = new Enhancer();
    enhancer.setInterfaces(interfacesToProxy);
View Full Code Here

    enhancer.setCallback(new Dispatcher() {
      public Object loadObject() throws Exception {
        return target;
      }
    });
    return enhancer.create();
  }

  private static class NoOpInterceptor implements MethodInterceptor, Serializable {
    private static final NoOpInterceptor INSTANCE = new NoOpInterceptor();
View Full Code Here

        {
          return super.getClassName("WICKET_" + prefix, source, key, names);
        }
      });

      return e.create();
    }
  }

  /**
   * This interface is used to make the proxy forward writeReplace() call to the handler instead
View Full Code Here

  public static <T> T createProxy(final T underlying, final GenericInvocationHandler<T> invocationHandler) {
    // TODO refactor - to get rid of endless try - catch
    final ClassLoader currentThreadClassLoader = Thread.currentThread().getContextClassLoader();
    try {
      final Enhancer enhancer = createProxy(underlying, invocationHandler, ProxyNamingPolicy.INSTANCE, currentThreadClassLoader);
      return (T) enhancer.create();
    } catch (CodeGenerationException e) {
      // fallback, as proxied class might implement non-public interfaces
      // that have trouble with our ProxyNamingPolicy (for example for SQLite)
      try {
        final Enhancer enhancer = createProxy(underlying, invocationHandler, null, currentThreadClassLoader);
View Full Code Here

    } catch (CodeGenerationException e) {
      // fallback, as proxied class might implement non-public interfaces
      // that have trouble with our ProxyNamingPolicy (for example for SQLite)
      try {
        final Enhancer enhancer = createProxy(underlying, invocationHandler, null, currentThreadClassLoader);
        return (T) enhancer.create();
      } catch (CodeGenerationException ex) {
        //
        // well, wildfly (8.1.CR1) just doesn't like currentThreadClassLoader => needs to use the default one
        //
        try {
View Full Code Here

        //
        // well, wildfly (8.1.CR1) just doesn't like currentThreadClassLoader => needs to use the default one
        //
        try {
          final Enhancer enhancer = createProxy(underlying, invocationHandler, ProxyNamingPolicy.INSTANCE, null);
          return (T) enhancer.create();
        } catch (CodeGenerationException exc) {
          // fallback, as proxied class might implement non-public interfaces
          // that have trouble with our ProxyNamingPolicy (for example for SQLite)
            final Enhancer enhancer = createProxy(underlying, invocationHandler, null, null);
            return (T) enhancer.create();
View Full Code Here

          return (T) enhancer.create();
        } catch (CodeGenerationException exc) {
          // fallback, as proxied class might implement non-public interfaces
          // that have trouble with our ProxyNamingPolicy (for example for SQLite)
            final Enhancer enhancer = createProxy(underlying, invocationHandler, null, null);
            return (T) enhancer.create();
        }
      }
    }
  }
View Full Code Here

        {
          return super.getClassName("WICKET_" + prefix, source, key, names);
        }
      });

      return e.create();
    }
  }

  /**
   * This interface is used to make the proxy forward writeReplace() call to the handler instead
View Full Code Here

            enhancer.setInterfaces(allImplementedInterfaces);
            enhancer.setCallbackType(net.sf.cglib.proxy.MethodInterceptor.class);
            enhancer.setUseFactory(false);//????
            interceptor = new ConnectorMethodInterceptor(kernel.getKernelName(), abstractName);
            enhancer.setCallbacks(new Callback[]{interceptor});
            proxy = enhancer.create(new Class[0], new Object[0]);
        } else {
            proxy = connectionFactory;
        }

        //connect 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.