Package net.sf.cglib.proxy

Examples of net.sf.cglib.proxy.Factory


                    + "Mockito can only mock visible & non-final classes");
        }
    }
   
    private Object createProxy(Class<?> proxyClass, final MethodInterceptor interceptor) {
        Factory proxy = (Factory) objenesis.newInstance(proxyClass);
        proxy.setCallbacks(new Callback[] {interceptor, NoOp.INSTANCE});
        return proxy;
    }
View Full Code Here


        return mock != null && isMockitoMock(mock);
    }
   
    @SuppressWarnings("unchecked")
    private static <T> MethodInterceptorFilter<MockHandler<T>> getInterceptor(T mock) {
        Factory factory = (Factory) mock;
        Callback callback = factory.getCallback(0);
        if(callback instanceof MethodInterceptorFilter) {
            return (MethodInterceptorFilter) callback;
        }
        return null;
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public <B, R extends ServiceReference<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

     * Marks the SearchBuilder as completed in building the search conditions.
     */
    @Override
    protected synchronized void finalize() {
        if (_entity != null) {
            Factory factory = (Factory)_entity;
            factory.setCallback(0, null);
            _entity = null;
        }

        if (_joins != null) {
            for (JoinBuilder<SearchBase<?, ?, ?>> join : _joins.values()) {
View Full Code Here

   

    @SuppressWarnings("unchecked")
    public T createSearchEntity(MethodInterceptor interceptor) {
        T entity = (T)_searchEnhancer.create();
        final Factory factory = (Factory)entity;
        factory.setCallback(0, interceptor);
        return entity;
    }
View Full Code Here

        return true;
    }

    @DB()
    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")
    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

@ApplicationScoped
public class ObjenesisProxifier extends AbstractCglibProxifier {

  public <T> T proxify(Class<T> type, MethodInvocation<? super T> handler) {
    Class<?> proxyClass = enhanceTypeWithCGLib(type, handler).createClass();
    Factory proxyInstance = (Factory) new ObjenesisStd().newInstance(proxyClass);
    proxyInstance.setCallbacks(new Callback[] {cglibMethodInterceptor(handler), NoOp.INSTANCE});
    return type.cast(proxyInstance);
  }
View Full Code Here

        @Override
        protected void filterConstructors(Class sc, List constructors) { }
    }

    private Object createProxy(Class<?> proxyClass, Callback callback) {
        Factory proxy = (Factory) objenesis.newInstance(proxyClass);
        proxy.setCallbacks(new Callback[] {callback, NoOp.INSTANCE});
        return proxy;
    }
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));
      }
    }, NoOp.INSTANCE });
    return proxy;
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.