Package net.sf.cglib.proxy

Examples of net.sf.cglib.proxy.MethodInterceptor


    public void destroyProxy(Object proxy) {
        if (proxy == null) {
            return;
        }

        MethodInterceptor methodInterceptor = (MethodInterceptor) interceptors.remove(proxy);
        if (methodInterceptor != null) {
            doDestroy(methodInterceptor);
        }
    }
View Full Code Here


    public boolean isProxy(Object proxy) {
        return interceptors.containsKey(proxy);
    }

    public AbstractName getProxyTarget(Object proxy) {
        MethodInterceptor methodInterceptor = (MethodInterceptor) interceptors.get(proxy);
        if (methodInterceptor == null) {
            return null;
        }
        return getAbstractName(methodInterceptor);
    }
View Full Code Here

    }

    private Remote createRmiService(final Interface serviceInterface) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(UnicastRemoteObject.class);
        enhancer.setCallback(new MethodInterceptor() {
            public Object intercept(Object arg0, Method method, Object[] args, MethodProxy arg3) throws Throwable {
                try {
                    return invokeTarget(JavaInterfaceUtil.findOperation(method, serviceInterface.getOperations()), args);
                } catch (InvocationTargetException e) {
                    final Throwable cause = e.getCause();
View Full Code Here

    }

    void useCglib(final TypeDef<?> typeDef, Class<? extends TypeDef<?>> typeDefClass) {
      Enhancer enhancer = new Enhancer();
      enhancer.setSuperclass(typeDefClass);
      enhancer.setCallback(new MethodInterceptor() {
        @Override public Object intercept(
            Object obj, Method method, Object[] args, MethodProxy proxy)
            throws Throwable {
          return method.invoke(typeDef, args);
        }
View Full Code Here

public class CgLibTest {
  @Test
  public void createBean() {
    Enhancer e = new Enhancer();
    e.setSuperclass(MyClass.class);
    e.setCallback(new MethodInterceptor() {
      @Override
      public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        return method.getName();
      }
    });
View Full Code Here

    return of(instance, (Class<T>) instance.getClass());
  }

  private static <T> T of(final T instance, Class<?> instanceClass) {
    @SuppressWarnings("unchecked")
    T proxy = (T) Enhancer.create(instanceClass, new Class[] { NullProxyInterface.class }, new MethodInterceptor() {

      public Object intercept(Object obj, Method method, Object[] args,
          MethodProxy proxy) throws Throwable {

        if (method.getDeclaringClass() == NullProxyInterface.class) {
View Full Code Here

    public void testSimpleProxied() throws Exception
    {
        Enhancer enh = new Enhancer();
        enh.setInterfaces(new Class[] { BeanInterface.class });
        enh.setCallback(new MethodInterceptor() {
            @Override
            public Object intercept(Object obj, Method method,
                                        Object[] args, MethodProxy proxy)
                    throws Throwable
                {
View Full Code Here

    public void destroyProxy(Object proxy) {
        if (proxy == null) {
            return;
        }

        MethodInterceptor methodInterceptor = (MethodInterceptor) interceptors.remove(proxy);
        if (methodInterceptor != null) {
            doDestroy(methodInterceptor);
        }
    }
View Full Code Here

    public boolean isProxy(Object proxy) {
        return interceptors.containsKey(proxy);
    }

    public AbstractName getProxyTarget(Object proxy) {
        MethodInterceptor methodInterceptor = (MethodInterceptor) interceptors.get(proxy);
        if (methodInterceptor == null) {
            return null;
        }
        return getAbstractName(methodInterceptor);
    }
View Full Code Here

    public void destroyProxy(Object proxy) {
        if (proxy == null) {
            return;
        }

        MethodInterceptor methodInterceptor = (MethodInterceptor) interceptors.remove(proxy);
        if (methodInterceptor != null) {
            doDestroy(methodInterceptor);
        }
    }
View Full Code Here

TOP

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

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.