本文整理汇总了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" );
}
}
示例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;
}
}
示例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();
}
示例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();
}
示例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;
}
}
示例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();
}