當前位置: 首頁>>代碼示例>>Java>>正文


Java Enhancer.setInterceptDuringConstruction方法代碼示例

本文整理匯總了Java中net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction方法的典型用法代碼示例。如果您正苦於以下問題:Java Enhancer.setInterceptDuringConstruction方法的具體用法?Java Enhancer.setInterceptDuringConstruction怎麽用?Java Enhancer.setInterceptDuringConstruction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.cglib.proxy.Enhancer的用法示例。


在下文中一共展示了Enhancer.setInterceptDuringConstruction方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: BasicProxyFactoryImpl

import net.sf.cglib.proxy.Enhancer; //導入方法依賴的package包/類
public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) {
	if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) {
		throw new AssertionFailure( "attempting to build proxy without any superclass or interfaces" );
	}

	Enhancer en = new Enhancer();
	en.setUseCache( false );
	en.setInterceptDuringConstruction( false );
	en.setUseFactory( true );
	en.setCallbackTypes( CALLBACK_TYPES );
	en.setCallbackFilter( FINALIZE_FILTER );
	if ( superClass != null ) {
		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" );
	}
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:26,代碼來源:ProxyFactoryFactoryImpl.java

示例2: handle

import net.sf.cglib.proxy.Enhancer; //導入方法依賴的package包/類
@Override
public boolean handle(Field f, Object target, Supplier<Fixture<S>> current) {

  if (f.isAnnotationPresent(org.magenta.annotations.InjectDataSpecification.class)) {

    InjectDataSpecification annotation = f.getAnnotation(org.magenta.annotations.InjectDataSpecification.class);

    if (DataSpecification.class.isAssignableFrom(f.getType())) {

      Enhancer e = new Enhancer();
      e.setSuperclass(current.get().getSpecification().getClass());
      e.setCallback(interceptor(supplierOfDataSpecification(current)));
      e.setInterceptDuringConstruction(false);

      DataSpecification proxy = (DataSpecification)e.create();


      FieldInjectorUtils.injectInto(target, f, proxy);
      return true;
    }else{
      throw new IllegalStateException("Invalid field : Annotation ["+InjectDataSpecification.class.getName()+"] is present on field named ["+f.getName()+"] on the class ["+f.getDeclaringClass().getCanonicalName()+"],\n but this field type should implement ["+DataSpecification.class.getName()+"] instead of ["+f.getType()+"].");
    }
  } else {
    return false;
  }
}
 
開發者ID:letrait,項目名稱:magenta,代碼行數:27,代碼來源:DataSpecificationFieldHandler.java

示例3: createProxyClass

import net.sf.cglib.proxy.Enhancer; //導入方法依賴的package包/類
@Override
protected Class<?> createProxyClass() {
	Enhancer en = new Enhancer();
   	en.setInterceptDuringConstruction(false);
   	en.setUseFactory(true);
   	
   	en.setSuperclass(unproxiedClass);
   	en.setInterfaces(new Class[] { Persistent.class });
   	en.setCallbackType(NoOp.class);
   	en.setStrategy(new DefaultGeneratorStrategy() {
		protected ClassGenerator transform(ClassGenerator cg) throws Exception {
			return new TransformingClassGenerator(cg, new AddPropertyTransformer(
					new String[] { ORIGINAL_ONE, ORIGINAL_THE_OTHER },
					new Type[] { Type.getType(String.class), Type.getType(List.class) }
				));
		}
   	});
   	
   	return en.createClass();
}
 
開發者ID:xingyuli,項目名稱:some-ldap,代碼行數:21,代碼來源:IndirectionsProxyFactory.java

示例4: getProxyFactory

import net.sf.cglib.proxy.Enhancer; //導入方法依賴的package包/類
public static Class getProxyFactory(Class persistentClass, Class[] interfaces)
		throws HibernateException {
	Enhancer e = new Enhancer();
	e.setSuperclass( interfaces.length == 1 ? persistentClass : null );
	e.setInterfaces(interfaces);
	e.setCallbackTypes(new Class[]{
		InvocationHandler.class,
		NoOp.class,
  		});
 		e.setCallbackFilter(FINALIZE_FILTER);
 		e.setUseFactory(false);
	e.setInterceptDuringConstruction( false );
	return e.createClass();
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:15,代碼來源:CGLIBLazyInitializer.java

示例5: handle

import net.sf.cglib.proxy.Enhancer; //導入方法依賴的package包/類
@Override
public boolean handle(Field f, Object target, Supplier<Fixture<S>> current) {

  if (f.isAnnotationPresent(org.magenta.annotations.InjectFluentRandom.class)) {

    InjectFluentRandom annotation = f.getAnnotation(org.magenta.annotations.InjectFluentRandom.class);

    if (FluentRandom.class.equals(f.getType())) {

      Enhancer e = new Enhancer();
      e.setSuperclass(FluentRandom.class);
      e.setCallback(interceptor(supplierOfFluentRandom(current)));
      e.setInterceptDuringConstruction(false);

      FluentRandom proxy = (FluentRandom)e.create();

      FieldInjectorUtils.injectInto(target, f, proxy);
      return true;
    }else{
      throw new IllegalStateException("Annotation "+InjectFluentRandom.class.getName()+" is present on field named "+f.getName()+", but this field type is not a "+FluentRandom.class.getName());
    }
  } else {
    return false;
  }


}
 
開發者ID:letrait,項目名稱:magenta,代碼行數:28,代碼來源:FluentRandomFieldHandler.java

示例6: createProxyClass

import net.sf.cglib.proxy.Enhancer; //導入方法依賴的package包/類
@Override
protected Class<?> createProxyClass() {
	Enhancer en = new Enhancer();
    en.setInterceptDuringConstruction(false);
    en.setUseFactory(true);
    
    en.setSuperclass(unproxiedClass);
    if (isDistinguishable(unproxiedClass)) {
        isDistinguishable = true;
        en.setInterfaces(new Class[] { Persistent.class, Distinguishable.class });
        en.setCallbackTypes(new Class[] { MethodInterceptor.class, NoOp.class });
        en.setCallbackFilter(FINALIZE_AND_DISTINGUISHABLE_INTEFERCE_FILTER);
    } else {
        en.setInterfaces(new Class[] { Persistent.class });
        en.setCallbackType(SetterInterceptor.class);
    }
    
    // Add an additional track field.
    en.setStrategy(new DefaultGeneratorStrategy() {
        protected ClassGenerator transform(ClassGenerator cg) throws Exception {
            return new TransformingClassGenerator(cg, new AddPropertyTransformer(
                    new String[] { MODIFIED_PROP_NAMES },
                    new Type[] { Type.getType(Set.class) }
                ));
        }
    });
    
    return en.createClass();
}
 
開發者ID:xingyuli,項目名稱:some-ldap,代碼行數:30,代碼來源:EntityProxyFactory.java


注:本文中的net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。