Package javassist.util.proxy

Examples of javassist.util.proxy.ProxyFactory$Find2MethodsArgs


    {
        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)
        {
            throw new WebBeansException(e);
View Full Code Here


    {
        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

                    {
                        // TODO move this part into JavassistProxyFactory
                        Class<?> proxyClass = interceptorProxyClasses.get(bean);
                        if (proxyClass == null)
                        {
                            ProxyFactory delegateFactory = JavassistProxyFactory.createProxyFactory(bean);
                            proxyClass = JavassistProxyFactory.getProxyClass(delegateFactory);
                            interceptorProxyClasses.put(bean, proxyClass);
                        }
                        Object delegate = proxyClass.newInstance();
                        delegateHandler = new DelegateHandler();
View Full Code Here

    {
       Object result = null;

        try
        {
            ProxyFactory pf = new ProxyFactory();
            pf.setInterfaces(new Class<?>[] {
                    Closable.class,
                    Serializable.class,
                    intf});
           
            pf.setHandler(new JmsProxyHandler(jmsComponent,intf));

            result = JavassistProxyFactory.getProxyClass(pf).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];
    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, new TaskAttemptID(), null, null, null };
      factory.setSuperclass(superType);
    }
    factory.setFilter(new MethodFilter() {
      @Override
      public boolean isHandled(Method m) {
        String name = m.getName();
        return "getConfiguration".equals(name) || "getCounter".equals(name) || "progress".equals(name);
      }
    });
    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 { // getCounter
          if (args.length == 1) {
            return MemPipeline.getCounters().findCounter((Enum<?>) args[0]);
          } else {
            return MemPipeline.getCounters().findCounter((String) args[0], (String) args[1]);
          }
        }
      }
    };
    try {
      Object newInstance = factory.create(types, args, handler);
      return (TaskInputOutputContext<?, ?, ?, ?>) newInstance;
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
View Full Code Here

    scanFields(classMeta, metaDbo);
  }
 
  @SuppressWarnings("unchecked")
  private <T> Class<T> createTheProxy(Class<?> mainClass) {
    ProxyFactory f = new ProxyFactory();
    f.setSuperclass(mainClass);
    f.setInterfaces(new Class[] {NoSqlProxy.class});
    f.setFilter(new MethodFilter() {
      public boolean isHandled(Method m) {
        // ignore finalize()
        if(m.getName().equals("finalize"))
          return false;
        else if(m.getName().equals("equals"))
          return false;
        else if(m.getName().equals("hashCode"))
          return false;
        return true;
      }
    });
    Class<T> clazz = f.createClass();
    testInstanceCreation(clazz);
   
    return clazz;
  }
View Full Code Here

                            return delegatingLoader;
                        }
                    };
                   
                    try {
                        ProxyFactory proxyFactory = new ProxyFactory();
                        proxyFactory.setInterfaces(interfaces);
                        proxyFactory.setSuperclass(superclass);

                        Class<?> proxyClass = proxyFactory.createClass();

                        try {
                            T proxy = (T) proxyClass.newInstance();

                            ((ProxyObject) proxy).setHandler(callback);
View Full Code Here

            @Override
            public Object makeMe(final Constructor<?> c, final Object[] args, final boolean neutralCCL)
                    throws Throwable {
                final MethodInterceptorHandler methodInterceptor = new MethodInterceptorHandler(locator, methodInterceptors);
                   
                final ProxyFactory proxyFactory = new ProxyFactory();
                proxyFactory.setSuperclass(implClass);
                proxyFactory.setFilter(METHOD_FILTER);
               
                return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {

                    @Override
                    public Object run() throws Exception {
                        ClassLoader currentCCL = null;
                        if (neutralCCL) {
                            currentCCL = Thread.currentThread().getContextClassLoader();
                        }
                 
                        try {
                          return proxyFactory.create(c.getParameterTypes(), args, methodInterceptor);
                        }
                        catch (InvocationTargetException ite) {
                            Throwable targetException = ite.getTargetException();
                            Logger.getLogger().debug(c.getDeclaringClass().getName(), c.getName(), targetException);
                            if (targetException instanceof Exception) {
View Full Code Here

    @Override
    public Object makeMe(final Constructor<?> c, final Object[] args, final boolean neutralCCL)
            throws Throwable {
        final MethodInterceptorHandler methodInterceptor = new MethodInterceptorHandler(this.clazzCreator.locator, methodInterceptors);
           
        final ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.setSuperclass(this.clazzCreator.implClass);
        proxyFactory.setFilter(METHOD_FILTER);
       
        return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {

            @Override
            public Object run() throws Exception {
                ClassLoader currentCCL = null;
                if (neutralCCL) {
                    currentCCL = Thread.currentThread().getContextClassLoader();
                }
         
                try {
                  return proxyFactory.create(c.getParameterTypes(), args, methodInterceptor);
                }
                catch (InvocationTargetException ite) {
                    Throwable targetException = ite.getTargetException();
                    Logger.getLogger().debug(c.getDeclaringClass().getName(), c.getName(), targetException);
                    if (targetException instanceof Exception) {
View Full Code Here

                            return delegatingLoader;
                        }
                    };
                   
                    try {
                        ProxyFactory proxyFactory = new ProxyFactory();
                        proxyFactory.setInterfaces(interfaces);
                        proxyFactory.setSuperclass(superclass);

                        Class<?> proxyClass = proxyFactory.createClass();

                        try {
                            T proxy = (T) proxyClass.newInstance();

                            ((ProxyObject) proxy).setHandler(callback);
View Full Code Here

TOP

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

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.