Package net.sf.cglib.proxy

Examples of net.sf.cglib.proxy.Factory


        return _name;
    }

    @DB(txn=false)
    public static <T> UpdateBuilder getUpdateBuilder(final T entityObject) {
        final Factory factory = (Factory)entityObject;
        assert(factory != null);
        return (UpdateBuilder)factory.getCallback(1);
    }
View Full Code Here


    @SuppressWarnings("unchecked")
    @Override @DB(txn=false)
    public SearchBuilder<T> createSearchBuilder() {
        final T entity = (T)_searchEnhancer.create();
        final Factory factory = (Factory)entity;
        SearchBuilder<T> builder = new SearchBuilder<T>(entity, _allAttributes);
        factory.setCallback(0, builder);
        return builder;
    }
View Full Code Here

    }

    @Override @DB(txn=false)
    public <K> SearchCriteria2 createSearchCriteria2(Class<K> resultType) {
        final T entity = (T)_searchEnhancer.create();
        final Factory factory = (Factory)entity;
        SearchCriteria2 sc = new SearchCriteria2(entity, resultType, _allAttributes, this);
        factory.setCallback(0, sc);
        return sc;
    }
View Full Code Here

    }

    @Override @DB(txn=false)
    public SearchCriteria2 createSearchCriteria2() {
        final T entity = (T)_searchEnhancer.create();
        final Factory factory = (Factory)entity;
        SearchCriteria2 sc = new SearchCriteria2(entity, entity.getClass(), _allAttributes, this);
        factory.setCallback(0, sc);
        return sc;
    }
View Full Code Here

    public static ConstructorArgs getCurrentConstructorArgs() {
        return currentConstructorArgs.get();
    }

    public static MockMethodInterceptor getInterceptor(final Object mock) {
        final Factory factory = (Factory) mock;
        return (MockMethodInterceptor) factory.getCallback(0);
    }
View Full Code Here

            attsToPut.add(new ReplaceableAttribute(EntityManagerFactoryImpl.DTYPE, ai.getDiscriminatorValue(), true));
        }

        LazyInterceptor interceptor = null;
        if (o instanceof Factory) {
            Factory factory = (Factory) o;
            /*
             * for (Callback callback2 : factory.getCallbacks()) {
             * if(logger.isLoggable(Level.FINER)) logger.finer("callback=" +
             * callback2); if (callback2 instanceof LazyInterceptor) {
             * interceptor = (LazyInterceptor) callback2; } }
             */
            interceptor = (LazyInterceptor) factory.getCallback(0);
        }

        for (PersistentProperty field : ai.getPersistentProperties()) {
            Object ob = field.getProperty(o);

View Full Code Here

        return lastOpStats;
    }

    public static <T> void replaceEntityManager(T newInstance, EntityManagerSimpleJPA em) {
        if (newInstance instanceof Factory) {
            Factory factory = (Factory) newInstance;
            LazyInterceptor interceptor = (LazyInterceptor) factory.getCallback(0);
            interceptor.setEntityManager(em);
        }
    }
View Full Code Here

            throw new IllegalArgumentException("could not imposterise " + mockedType, e);
        }
    }
   
    private Object createProxy(Class<?> proxyClass, final Invokable mockObject) {
        Factory proxy = (Factory)objenesis.newInstance(proxyClass);
        proxy.setCallbacks(new Callback[] {
            new InvocationHandler() {
                public Object invoke(Object receiver, Method method, Object[] args) throws Throwable {
                    return mockObject.invoke(new Invocation(receiver, method, args));
                }
            },
View Full Code Here

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

        Enhancer.registerCallbacks(enhancedClass, new Callback[] { interceptor });

        Factory factory;
        try {
            factory = (Factory) ClassInstantiatorFactoryCE.getInstantiator().newInstance(enhancedClass);
        } catch (final InstantiationException e) {
            throw new RuntimeException("Fail to instantiate mock for " + toProxyClass + " on " + ClassInstantiatorFactoryCE.getJVM() + " JVM");
        }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
        if (isProxyClass(target.getClass())) {
            Factory factory = (Factory)target;
            Callback[] callbacks = factory.getCallbacks();
            if (callbacks.length != 1 || !(callbacks[0] instanceof CglibMethodInterceptor)) {
                throw new IllegalArgumentException("The object is not a known proxy.");
            }
            CglibMethodInterceptor interceptor = (CglibMethodInterceptor)callbacks[0];
            return (R)interceptor.invocationHandler.getCallableReference();
View Full Code Here

TOP

Related Classes of net.sf.cglib.proxy.Factory

Copyright © 2018 www.massapicom. 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.