enhancer.setStrategy(new UndeclaredThrowableStrategy(UndeclaredThrowableException.class)); enhancer.setInterceptDuringConstruction(false);
enhancer.setStrategy(new UndeclaredThrowableStrategy(UndeclaredThrowableException.class)); enhancer.setInterceptDuringConstruction(false);
/** * Gets the proxy factory. * * @param persistentClass * the persistent class * @param interfaces * the interfaces * @return the proxy factory * @throws PersistenceException * the persistence exception */ public static Class getProxyFactory(Class persistentClass, Class[] interfaces) throws PersistenceException { 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(); }
@SuppressWarnings("unchecked") private static final <F extends AbstractFacade<M, S>, M extends SessionMgr<S>, S> F getProxy(Class<F> daoClass, M mgr, Callback intercepter) { Enhancer en = new Enhancer(); en.setSuperclass(daoClass); en.setCallbackFilter(InterceptFilter.INSTANCE); Callback[] callbacks = {NoOp.INSTANCE, intercepter}; en.setCallbacks(callbacks); en.setInterceptDuringConstruction(false); Class<?>[] argTypes = mgr != null ? new Class<?>[] {mgr.getClass()} : new Class<?>[] {}; Object[] args = mgr != null ? new Object[] {mgr} : new Object[] {}; return (F)en.create(argTypes, args); }
@Override public DataSource getObject() throws Exception { Enhancer enhancer = new Enhancer(); enhancer.setClassLoader(classLoader); enhancer.setUseCache(true); enhancer.setInterfaces(new Class<?>[] { DataSource.class }); enhancer.setInterceptDuringConstruction(true); enhancer.setCallback(this); return (DataSource) enhancer.create(); }
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(); }
public Object createProxy(final ClassLoader classLoader, final Class[] classes, final Callable<Object> dispatcher) { Enhancer e = new Enhancer(); e.setClassLoader(classLoader); e.setSuperclass(getTargetClass(classes)); e.setInterfaces(getInterfaces(classes)); e.setInterceptDuringConstruction(false); e.setCallback(new Dispatcher() { public Object loadObject() throws Exception { return dispatcher.call(); } }); e.setUseFactory(false); return e.create(); }
protected Enhancer createEnhancer(Class realMpClass, MessageProcessorId id, Map<String, String> attributes, String fileName, String lineNumber) { Enhancer e = new Enhancer(); e.setSuperclass(realMpClass); e.setUseCache(false); e.setAttemptLoad(true); e.setInterceptDuringConstruction(true); e.setNamingPolicy(new MunitNamingPolicy()); if (FactoryBean.class.isAssignableFrom(realMpClass)) { createFactoryBeanCallback(id, attributes, fileName, lineNumber, e); } else { createMessageProcessorCallback(id, attributes, fileName, lineNumber, e); } return e; }
public static Class getProxyFactory(Class persistentClass, Class[] interfaces) throws JormException { 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(); }
/** * Creates a proxy to a given concrete class. * * @param klass Concrete class to proxy. * @param handler Handler processing the method calls. * @return a new proxy for the specified class. * @throws InstantiationException on error. */ @SuppressWarnings("unchecked") public static <T> T create(Class<?> klass, MethodInterceptor handler) throws InstantiationException { // Don't ask me how this work... final Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(klass); enhancer.setInterceptDuringConstruction(true); enhancer.setCallbackType(handler.getClass()); final Class<?> proxyClass = enhancer.createClass(); final Factory proxy = (Factory) ClassInstantiatorFactory.getInstantiator().newInstance(proxyClass); proxy.setCallbacks(new Callback[] { handler }); return (T) proxy; } }
enhancer.setCallback( callback ); enhancer.setClassLoader( digester.getClassLoader() ); enhancer.setInterceptDuringConstruction( false ); if ( hasDefaultConstructor )
enhancer.setSuperclass(proxySuperClass); enhancer.setStrategy(new UndeclaredThrowableStrategy(UndeclaredThrowableException.class)); enhancer.setInterceptDuringConstruction(false); enhancer.setCallback(interceptor);
public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) { if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) { throw new FailureLog( "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 JormException( "Unable to build CGLIB Factory instance" ); } }
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" ); } }
e.setInterceptDuringConstruction(true); e.setUseCache(false); e.setAttemptLoad(true);
enhancer.setInterceptDuringConstruction(false);