Package javassist.util.proxy

Examples of javassist.util.proxy.ProxyFactory.create()


            args = new Object[] { instance, getConfiguration(), getTaskAttemptID(),
                null, null, NO_OP_OUTPUT_COMMITTER, null, null
            };
          }
          this.handler = new CtxtMethodHandler(this.getContext());
          this.context = (Mapper.Context) proxyFactory.create(paramTypes, args, handler);
        } catch (Exception e) {
          throw new CrunchRuntimeException(e);
        }
      }
      if (setupMethod != null) {
View Full Code Here


                NO_OP_OUTPUT_COMMITTER, null, null,
                NullWritable.class, NullWritable.class
            };
          }
          this.handler = new CtxtMethodHandler(this.getContext());
          this.context = (Reducer.Context) proxyFactory.create(paramTypes, args, handler);
        } catch (Exception e) {
          throw new CrunchRuntimeException(e);
        }
      }
     
View Full Code Here

          throw new IllegalStateException("Unhandled method " + name);
        }
      }
    };
    try {
      Object newInstance = factory.create(types, args, handler);
      return (TaskInputOutputContext<?, ?, ?, ?>) newInstance;
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
View Full Code Here

      InvocationHandler handler = new EndpointInvocationHandler(endpoint, session, businessInterface);
     
      ProxyFactory factory = new ProxyFactory();
      factory.setHandler(new MethodHandlerAdapter(handler));
      factory.setInterfaces(new Class[] { businessInterface });
      SimpleInterface javassistProxy = (SimpleInterface) factory.create(null, null);
     
      ClassLoader loader = Thread.currentThread().getContextClassLoader();
      SimpleInterface proxy = EndpointProxy.newProxyInstance(loader, session, businessInterface, endpoint);
     
      assertTrue(javassistProxy.equals(proxy));
View Full Code Here

        f.setSuperclass(Target5.class);
        Interceptor1 interceptor = new Interceptor1();
        f.setHandler(interceptor);
        f.setFilter(finalizeRemover);
        Class c = f.createClass();
        Target5 obj = (Target5)f.create(new Class[] { int.class }, new Object[] { new Integer(3) });
        assertEquals(3, obj.get());
    }


    public void testBridgeMethod() throws Exception {
View Full Code Here

    public void testJIRA127() throws Exception {
        ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.writeDirectory = ".";
        proxyFactory.setInterfaces(new Class[]{ Target127.Sub.class });
        Target127.Sub proxy = (Target127.Sub)proxyFactory.create(new Class[0], new Object[0], new MethodHandler() {
            public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable {
                return null;
            }
        });
        ((Target127.Super)proxy).item();    // proxyFactory must generate a bridge method.
View Full Code Here

      public Object invoke(Object arg0, Method arg1, Method arg2, Object[] arg3) throws Throwable {
        return conf;
      }
    };
    try {
      Object newInstance = factory.create(types, args, handler);
      return (TaskInputOutputContext<?, ?, ?, ?>) newInstance;
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
View Full Code Here

    Object enhanced = null;
    Class<?>[] typesArray = constructorArgTypes.toArray(new Class[constructorArgTypes.size()]);
    Object[] valuesArray = constructorArgs.toArray(new Object[constructorArgs.size()]);
    try {
      enhanced = enhancer.create(typesArray, valuesArray);
    } catch (Exception e) {
      throw new ExecutorException("Error creating lazy proxy.  Cause: " + e, e);
    }
    ((Proxy) enhanced).setHandler(callback);
    return enhanced;
View Full Code Here

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setSuperclass( globalContextImplType );
    proxyFactory.setFilter( new EntityMethodFilter() );

    try {
      return (G) proxyFactory.create(
          new Class<?>[] { ConfigurationContext.class },
          new Object[] { this },
          new EntityOrPropertyMethodHandler( entityContextImplType, propertyContextImplType ) );
    }
    catch (Exception e) {
View Full Code Here

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setSuperclass( entityContextImplType );
    proxyFactory.setFilter( new EntityOrPropertyMethodFilter() );

    try {
      return (E) proxyFactory.create(
          new Class<?>[] { ConfigurationContext.class },
          new Object[] { this },
          new EntityOrPropertyMethodHandler( entityContextImplType, propertyContextImplType ) );
    }
    catch (Exception e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.