[jboss-user] [JBoss Seam] - Hessian Support

ralscha do-not-reply at jboss.com
Fri Nov 30 05:41:30 EST 2007


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109219#4109219

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109219



More information about the jboss-user mailing list