Package javassist.util.proxy

Examples of javassist.util.proxy.ProxyFactory$ProxyDetails


    {
        X instance = null;
        try
        {
            //X TODO cache proxy class!
            ProxyFactory proxyFactory = JavassistProxyFactory.createProxyFactory(this);
           
            ResourceInjectionService resourceService = ServiceLoader.getService(ResourceInjectionService.class);
            this.actualResourceReference = resourceService.getResourceReference(this.resourceReference);
            proxyFactory.setHandler(new ResourceProxyHandler(this.actualResourceReference));
           
            instance = (X)(JavassistProxyFactory.getProxyClass(proxyFactory).newInstance());
        }
        catch (Exception e)
        {
View Full Code Here


    {
        WebBeansAnnotation result = null;

        try
        {
            ProxyFactory pf = new ProxyFactory();
            pf.setInterfaces(new Class<?>[] { annotationType, Annotation.class });
            pf.setSuperclass(WebBeansAnnotation.class);
            pf.setHandler(new WebBeansAnnotation(annotationType));

            result = (WebBeansAnnotation) pf.create(new Class[] { Class.class }, new Object[] { annotationType });

        }
        catch (Exception e)
        {
            WebBeansUtil.throwRuntimeExceptions(e);
View Full Code Here

            if (injectionTarget.getDecoratorStack().size() > 0)
            {
                Class<?> proxyClass = JavassistProxyFactory.getInterceptorProxyClasses().get(injectionTarget);
                if (proxyClass == null)
                {
                    ProxyFactory delegateFactory = JavassistProxyFactory.createProxyFactory(injectionTarget);
                    proxyClass = JavassistProxyFactory.getProxyClass(delegateFactory);
                    JavassistProxyFactory.getInterceptorProxyClasses().put(injectionTarget, proxyClass);
                }
                Object delegate = proxyClass.newInstance();
                delegateHandler = new DelegateHandler(threadLocal.get(),ejbContext);
View Full Code Here

            {
                return (T)clazz.newInstance();
            }
           
            //Proxy factory instance
            ProxyFactory factory = new ProxyFactory();           
           
            EjbBeanProxyHandler handler = new EjbBeanProxyHandler(bean,creationalContext);           
            factory.setHandler(handler);
            factory.setInterfaces(new Class[]{iface});
        
            return (T)(JavassistProxyFactory.defineEjbBeanProxyClass(bean, factory).newInstance());
           
        }
        catch(Exception e)
View Full Code Here

   * Note: The intention of this is to provide the bare essentials that are
   * required to make the {@linkplain MemPipeline} work. It lacks even the basic
   * things that can proved some support for unit testing pipeline.
   */
  private static TaskInputOutputContext<?, ?, ?, ?> getInMemoryContext(final Configuration conf) {
    ProxyFactory factory = new ProxyFactory();
    Class<TaskInputOutputContext> superType = TaskInputOutputContext.class;
    Class[] types = new Class[0];
    Object[] args = new Object[0];
    final TaskAttemptID taskAttemptId = new TaskAttemptID();
    if (superType.isInterface()) {
      factory.setInterfaces(new Class[] { superType });
    } else {
      types = new Class[] { Configuration.class, TaskAttemptID.class, RecordWriter.class, OutputCommitter.class,
          StatusReporter.class };
      args = new Object[] { conf, taskAttemptId, null, null, null };
      factory.setSuperclass(superType);
    }

    final Set<String> handledMethods = ImmutableSet.of("getConfiguration", "getCounter",
                                                  "progress", "getTaskAttemptID");
    factory.setFilter(new MethodFilter() {
      @Override
      public boolean isHandled(Method m) {
        return handledMethods.contains(m.getName());
      }
    });
    MethodHandler handler = new MethodHandler() {
      @Override
      public Object invoke(Object arg0, Method m, Method arg2, Object[] args) throws Throwable {
        String name = m.getName();
        if ("getConfiguration".equals(name)) {
          return conf;
        } else if ("progress".equals(name)) {
          // no-op
          return null;
        } else if ("getTaskAttemptID".equals(name)) {
          return taskAttemptId;
        } else if ("getCounter".equals(name)){ // getCounter
          if (args.length == 1) {
            return MemPipeline.getCounters().findCounter((Enum<?>) args[0]);
          } else {
            return MemPipeline.getCounters().findCounter((String) args[0], (String) args[1]);
          }
        } else {
          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

    public static <T> T defineEjbBeanProxy(EjbBean<T> bean, Class<?> iface, CreationalContext<?> creationalContext)
    {
        try
        {
            bean.setIface(iface);
            ProxyFactory factory = new ProxyFactory();
           
            EjbBeanProxyHandler handler = new EjbBeanProxyHandler(bean,creationalContext);
           
            factory.setHandler(handler);
           
            if(iface == null)
            {
                factory.setInterfaces(bean.getDeploymentInfo().getBusinessLocalInterfaces().toArray(new Class[0]));
            }
            else
            {
                factory.setInterfaces(new Class[]{iface});
            }
        
            return (T)(JavassistProxyFactory.getProxyClass(factory).newInstance());
           
        }catch(Exception e)
View Full Code Here

   * Note: The intention of this is to provide the bare essentials that are
   * required to make the {@linkplain MemPipeline} work. It lacks even the basic
   * things that can proved some support for unit testing pipeline.
   */
  private static TaskInputOutputContext<?, ?, ?, ?> getInMemoryContext(final Configuration conf) {
    ProxyFactory factory = new ProxyFactory();
    Class<TaskInputOutputContext> superType = TaskInputOutputContext.class;
    Class[] types = new Class[0];
    Object[] args = new Object[0];
    final TaskAttemptID taskAttemptId = new TaskAttemptID();
    if (superType.isInterface()) {
      factory.setInterfaces(new Class[] { superType });
    } else {
      types = new Class[] { Configuration.class, TaskAttemptID.class, RecordWriter.class, OutputCommitter.class,
          StatusReporter.class };
      args = new Object[] { conf, taskAttemptId, null, null, null };
      factory.setSuperclass(superType);
    }

    final Set<String> handledMethods = ImmutableSet.of("getConfiguration", "getCounter",
                                                  "progress", "getNumReduceTasks", "getTaskAttemptID");
    factory.setFilter(new MethodFilter() {
      @Override
      public boolean isHandled(Method m) {
        return handledMethods.contains(m.getName());
      }
    });
    MethodHandler handler = new MethodHandler() {
      @Override
      public Object invoke(Object arg0, Method m, Method arg2, Object[] args) throws Throwable {
        String name = m.getName();
        if ("getConfiguration".equals(name)) {
          return conf;
        } else if ("progress".equals(name)) {
          // no-op
          return null;
        } else if ("getTaskAttemptID".equals(name)) {
          return taskAttemptId;
        } else if ("getNumReduceTasks".equals(name)) {
          return 1;
        } else if ("getCounter".equals(name)){ // getCounter
          if (args.length == 1) {
            return MemPipeline.getCounters().findCounter((Enum<?>) args[0]);
          } else {
            return MemPipeline.getCounters().findCounter((String) args[0], (String) args[1]);
          }
        } else {
          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

        try
        {
            Class<?> proxyClass = normalScopedBeanProxyClasses.get(bean);
            if (proxyClass == null)
            {
                ProxyFactory fact = createProxyFactory(bean);

                proxyClass = getProxyClass(fact);
                normalScopedBeanProxyClasses.put(bean, proxyClass);
            }
           
View Full Code Here

        try
        {
            Class<?> proxyClass = dependentScopedBeanProxyClasses.get(bean);
            if (proxyClass == null)
            {
                ProxyFactory fact = createProxyFactory(bean);
                proxyClass = getProxyClass(fact);
                dependentScopedBeanProxyClasses.put(bean, proxyClass);
            }
           
            result = proxyClass.newInstance();
View Full Code Here

        }

        Class<?>[] interfaceArray = new Class<?>[interfaceList.size()];
        interfaceArray = interfaceList.toArray(interfaceArray);

        ProxyFactory fact = new ProxyFactory();       
        fact.setInterfaces(interfaceArray);
        fact.setSuperclass(superClass);       

        // turn off caching since this is utterly broken
        // this is a static field, but we do not know who else
        // might turn it on again ...
        ProxyFactory.useCache = false;
View Full Code Here

TOP

Related Classes of javassist.util.proxy.ProxyFactory$ProxyDetails

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.