3 Replies Latest reply on Jan 10, 2008 8:19 AM by pmuir

    Hessian Support

    ralscha

      Hello

      The last couple of days I wrote a HessianResource class so a hessian client can talk to a seam application. I would like to share this code with the community. It's very experimental right now. Maybe some Seam gurus can review the code and give me some advice what could be done better. Currently there is no support for conversationId. The hessian protocol allows to send header information with the request and response. This could be a solution to send an id to a client and back to the server. But it looks like that the class HessianProxy does not support header informationen.

      You can download the class from here http://dev.ess.ch/hessianRiaDemo/HessianResource.java


      Here are the steps to configure a seam application with this resource

      1. Put the HessianResource in your source directory

      2. In the web.xml you have to configure the Seam Resource Servlet




      < servlet >
      <servlet-name>Seam Resource Servlet</servlet-name>
      <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
      </ servlet >

      <servlet-mapping>
      <servlet-name>Seam Resource Servlet</servlet-name>
      <url-pattern>/seam/resource/*</url-pattern>
      </servlet-mapping>




      3. Create an interface



      public interface BasicAPI {
      String hello();
      }




      4. Create an implementation



      @Name("hello")
      public class HelloWorld implements BasicAPI {
      @Override
      public String hello() {
      return "Hello from a Seam Component";
      }
      }





      5. Now you can start the web application

      6. Create a client program and call the component. The url is http://server_ip:port/contextNameOfWebapplication/seam/resource/hessian/beanName
      beanName is the same string you use in @Name("beanName")





      public class Client {
      public static void main(String[] args) {
      try {
      String url = "http://localhost:8080/sandbox/seam/resource/hessian/hello";

      HessianProxyFactory factory = new HessianProxyFactory();
      BasicAPI basic = (BasicAPI) factory.create(BasicAPI.class, url);

      System.out.println("hello(): " + basic.hello());
      } catch (MalformedURLException e) {
      e.printStackTrace();
      }
      }
      }




      I created a "seamified" version of the Caucho Words Demo too.

      Here is the live demo: http://dev.ess.ch/hessianRiaDemo

      and here is the source code: http://dev.ess.ch/hessianRiaDemo/HessianRiaSeamDemo.zip


      Regards
      Ralph