Package net.sf.cglib.proxy

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


    public T createMock(Class<T> toMock, final MethodInterceptorFilter filter, Object optionalInstance) {
        validateClass(toMock);
        Enhancer enhancer = createEnhancer(toMock);
        enhancer.setCallbackType(filter.getClass());

        Class mockClass = enhancer.createClass();
       
        Enhancer.registerCallbacks(mockClass, new Callback[] { filter });

        Factory mock = createMock(mockClass);
View Full Code Here


    public T createMock(Class<T> toMock, final MethodInterceptorFilter filter) {
        validateClass(toMock);
        Enhancer enhancer = createEnhancer(toMock);
        enhancer.setCallbackType(filter.getClass());

        Class mockClass = enhancer.createClass();
        Enhancer.registerCallbacks(mockClass, new Callback[] { filter });

        Factory mock = createMock(mockClass);

        filter.setMock(mock);
View Full Code Here

        en.setSuperclass( superClass );
      }
      if ( interfaces != null && interfaces.length > 0 ) {
        en.setInterfaces( interfaces );
      }
      proxyClass = en.createClass();
      try {
        factory = ( Factory ) proxyClass.newInstance();
      }
      catch ( Throwable t ) {
        throw new HibernateException( "Unable to build CGLIB Factory instance" );
View Full Code Here

      NoOp.class,
        });
      e.setCallbackFilter(FINALIZE_FILTER);
      e.setUseFactory(false);
    e.setInterceptDuringConstruction( false );
    return e.createClass();
  }

  private CGLIBLazyInitializer(final String entityName, final Class persistentClass,
      final Class[] interfaces, final Serializable id, final Method getIdentifierMethod,
      final Method setIdentifierMethod, final AbstractComponentType componentIdType,
View Full Code Here

        en.setSuperclass( superClass );
      }
      if ( interfaces != null && interfaces.length > 0 ) {
        en.setInterfaces( interfaces );
      }
      proxyClass = en.createClass();
      try {
        factory = ( Factory ) proxyClass.newInstance();
      }
      catch ( Throwable t ) {
        throw new HibernateException( "Unable to build CGLIB Factory instance" );
View Full Code Here

        en.setSuperclass( superClass );
      }
      if ( interfaces != null && interfaces.length > 0 ) {
        en.setInterfaces( interfaces );
      }
      proxyClass = en.createClass();
      try {
        factory = ( Factory ) proxyClass.newInstance();
      }
      catch ( Throwable t ) {
        throw new HibernateException( "Unable to build CGLIB Factory instance" );
View Full Code Here

      NoOp.class,
        });
      e.setCallbackFilter(FINALIZE_FILTER);
      e.setUseFactory(false);
    e.setInterceptDuringConstruction( false );
    return e.createClass();
  }

  private CGLIBLazyInitializer(final String entityName, final Class persistentClass,
      final Class[] interfaces, final Serializable id, final Method getIdentifierMethod,
      final Method setIdentifierMethod, final AbstractComponentType componentIdType,
View Full Code Here

    });
    enhancer.setCallbackTypes(callbackTypes);
    enhancer.setUseFactory(false);
    enhancer.setNamingPolicy(new GuiceNamingPolicy());

    Class<?> proxied = enhancer.createClass();

    // Store callbacks.
    Enhancer.registerStaticCallbacks(proxied, callbacks);

    return createConstructionProxy(proxied, constructor.getParameterTypes());
View Full Code Here

        final Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(toProxyClass);
        enhancer.setInterfaces(auxiliaryTypes);
        enhancer.setCallbackType(newMethodInterceptor(handler).getClass());

        final Class<?> enhancedClass = enhancer.createClass();

        Enhancer.registerCallbacks(enhancedClass, new Callback[] { newMethodInterceptor(handler) });
        return (Class<T>) enhancedClass;
    }
View Full Code Here

        try {
            Enhancer enhancer = new Enhancer();
            enhancer.setInterfaces(new Class[] {forClass});
            enhancer.setCallbackFilter(FILTER);
            enhancer.setCallbackTypes(new Class[] {NoOp.class, MethodInterceptor.class});
            Class<?> newClass = enhancer.createClass();
            Enhancer.registerStaticCallbacks(newClass, new Callback[] {NoOp.INSTANCE,
                                                                       new InterfaceMethodInterceptor(reference, forClass)});
            result = newClass.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
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.