Package com.caucho.hessian.client

Examples of com.caucho.hessian.client.HessianProxyFactory


   * If not specified, a default HessianProxyFactory will be created.
   * <p>Allows to use an externally configured factory instance,
   * in particular a custom HessianProxyFactory subclass.
   */
  public void setProxyFactory(HessianProxyFactory proxyFactory) {
    this.proxyFactory = (proxyFactory != null ? proxyFactory : new HessianProxyFactory());
  }
View Full Code Here


    protected HessianConnectionFactory hessianConnectionFactory = new HttpClientConnectionFactory();

    @SuppressWarnings("unchecked")
    public HessianRpcInvoker(Class<T> serviceType, URL url, ProxyFactory proxyFactory){
        super(serviceType, url);
        HessianProxyFactory hessianProxyFactory = new HessianProxyFactory();
        String client = url.getParameter(Constants.CLIENT_KEY, Constants.DEFAULT_HTTP_CLIENT);
        if ("httpclient".equals(client)) {
            hessianProxyFactory.setConnectionFactory(hessianConnectionFactory);
        } else if (client != null && client.length() > 0 && ! Constants.DEFAULT_HTTP_CLIENT.equals(client)) {
            throw new IllegalStateException("Unsupported http protocol client=\"" + client + "\"!");
        }
        int timeout = url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
        hessianProxyFactory.setConnectTimeout(timeout);
        hessianProxyFactory.setReadTimeout(timeout);
        invoker = proxyFactory.getInvoker((T)hessianProxyFactory.create(serviceType, url.setProtocol("http").toJavaURL(), Thread.currentThread().getContextClassLoader()), serviceType, url);
    }
View Full Code Here

        this.localDir = localDir;
    }

    @Override
    public void init() throws Exception {
        HessianProxyFactory factory = new HessianProxyFactory();
        filePublishedService = (FilePublishedApi) factory.create(FilePublishedApi.class, remoteUrl);
    }
View Full Code Here

    }

    @Test
    public void client() throws MalformedURLException {
        final ClassLoader loader = Thread.currentThread().getContextClassLoader();
        final HessianProxyFactory clientFactory = new HessianProxyFactory(loader);
        final SerializerFactory factory = new SerializerFactory(loader);
        factory.setAllowNonSerializable(true);
        clientFactory.setSerializerFactory(factory);
        final HessianWebService client = HessianWebService.class.cast(clientFactory.create(HessianWebService.class, "http://127.0.0.1:" + port + "/HessianServiceTest/hessian/" + MyHessianWebService.class.getSimpleName()));

        final Out out = client.call(new In("test"));
        assertThat(out, instanceOf(Out.class));
        assertEquals("test", out.value);
    }
View Full Code Here

    }

    @Test
    public void client() throws MalformedURLException {
        final ClassLoader loader = Thread.currentThread().getContextClassLoader();
        final HessianProxyFactory clientFactory = new HessianProxyFactory(loader);
        final SerializerFactory factory = new SerializerFactory(loader);
        factory.setAllowNonSerializable(true);
        clientFactory.setSerializerFactory(factory);
        final CdiService client = CdiService.class.cast(clientFactory.create(CdiService.class, "http://127.0.0.1:" + port + "/web/hessian/service"));

        final Out out = client.call(new In("test"));
        assertThat(out, instanceOf(Out.class));
        assertEquals("test", out.value);
    }
View Full Code Here

    }

    @Test
    public void client() throws MalformedURLException {
        final ClassLoader loader = Thread.currentThread().getContextClassLoader();
        final HessianProxyFactory clientFactory = new HessianProxyFactory(loader);
        final SerializerFactory factory = new SerializerFactory(loader);
        factory.setAllowNonSerializable(true);
        clientFactory.setSerializerFactory(factory);
        final CdiService client = CdiService.class.cast(clientFactory.create(CdiService.class, "http://127.0.0.1:" + port + "/web/hessian/foo"));

        final Out out = client.call(new In("test"));
        assertThat(out, instanceOf(Out.class));
        assertEquals("test", out.value);
    }
View Full Code Here

    }
  }
 
  public static void execute1(){
        String url = "http://localhost:8080/HessianServer/remoting/acrmapi";
        HessianProxyFactory proxyFactory = new HessianHttpProxyFactory();
        proxyFactory.setConnectTimeout(3000);
        proxyFactory.setReadTimeout(3000);
        proxyFactory.setHessian2Reply(false);
        proxyFactory.setDebug(true);
        try {
          AcrmApi api=proxyFactory.create(AcrmApi.class, url);
          System.out.println(api.login("guxuede", "123"));
          //System.out.println(api.getContacts());
          //System.out.println(api.uglilyCode("hessian"));
          //System.out.println(api.getContacts());
          //System.out.println(api.logout());
View Full Code Here

      //executeHello();
    }
   
    public static void executeWeibo(){
        String url = "http://localhost:8080/HessianServer/remoting/weibo1";
        HessianProxyFactory proxyFactory = new HessianProxyFactory();
        HessianConnectionFactory connFactory=new MyConnectionFactory();
        proxyFactory.setConnectionFactory(connFactory);
        connFactory.setHessianProxyFactory(proxyFactory);

      try {
        IWeibo weibo;
        weibo = (IWeibo) proxyFactory.create(IWeibo.class, url);
        System.out.println(weibo.getContacts());
      } catch (Exception e) {
        System.out.println("Exception:"+ ((InteractionException)e).getTypeId());
        e.printStackTrace();
      }
     
      try {
        IWeibo weibo;
        weibo = (IWeibo) proxyFactory.create(IWeibo.class, url);
        System.out.println(weibo.getContacts());
      } catch (Exception e) {
        System.out.println("Exception:"+ ((InteractionException)e).getTypeId());
        e.printStackTrace();
      }
View Full Code Here

    }
   
   
    public static void executeWithServlet(){
        String url = "http://localhost:8080/HessianServer/hessianService";
        HessianProxyFactory factory = new HessianProxyFactory();
        factory.setUser("guxuede");
        factory.setPassword("dg23hhjs");
        try {
            IEye hello = (IEye) factory.create(IEye.class, url);
            hello.look();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

        }
    }

    public static void executeHello(){
        String url = "http://localhost:8080/HessianServer/remoting/hello";
        HessianProxyFactory factory = new HessianProxyFactory();
        factory.setUser("guxuede");
        factory.setPassword("dg23hhjs");
        System.out.println(factory.getBasicAuth());
        try {
            HelloHessian hello = (HelloHessian) factory.create(HelloHessian.class, url);
            System.out.println(hello.sayHello());
            MyCar car = hello.getMyCar();
            System.out.println(car.toString());
            for (Map.Entry<String, String> entry : hello.myBabays().entrySet()) {
                System.out.println(entry.getKey() + "   " + entry.getValue());
View Full Code Here

TOP

Related Classes of com.caucho.hessian.client.HessianProxyFactory

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.