Package javassist.util.proxy

Examples of javassist.util.proxy.MethodHandler


            public boolean isHandled(Method m) {
                return !m.getName().equals("finalize");
            }
        };

        handler = new MethodHandler() {
            public Object invoke(Object self, Method m, Method proceed,
                                 Object[] args) throws Throwable {
                System.out.println("calling: " + m.getName());
                return proceed.invoke(self, args)// execute the original method.
            }
View Full Code Here


                  // ignore finalize()
                  return !m.getName().equals("finalize");
              }
            });
            Class c = f.createClass();
            MethodHandler mi = new MethodHandler() {
              public Object invoke(Object self, Method m, Method proceed,
                                   Object[] args) throws Throwable {
                System.out.println("Name: " + m.getName());
                return proceed.invoke(self, args)// execute the original method.
              }
View Full Code Here

   }


   public <T> T createProxyFromInstance(final Object target, Class<T> proxifiedClass, Class<?>[] constructorTypes, Object[] constructorArguments)
   {
      MethodHandler interceptorMethodHandler = getMethodHandler(target, proxifiedClass);
      return createProxyInstance(createProxyClassWithHandler(proxifiedClass, interceptorMethodHandler), interceptorMethodHandler);
   }
View Full Code Here

  @Test(expected = ObjectQueryException.class)
  public void testWrongProxy() throws Exception {
    GenericSelectQuery<Person, Object> query = new GenericSelectQuery<Person, Object>(Person.class);
    ProxyFactory pf = new ProxyFactory();
    Object o = pf.create(null, null, new MethodHandler() {

      public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable {
        return null;
      }
    });
View Full Code Here

  @Test(expected = ObjectQueryException.class)
  public void testWrongProxyPrjection() throws Exception {
    GenericSelectQuery<Person, Object> query = new GenericSelectQuery<Person, Object>(Person.class);
    ProxyFactory pf = new ProxyFactory();
    Object o = pf.create(null, null, new MethodHandler() {

      public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable {
        return null;
      }
    });
View Full Code Here

TOP

Related Classes of javassist.util.proxy.MethodHandler

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.