host:8080/ejb/hello"; HelloHome hello = (HelloHome) factory.create(HelloHome.class, url); After creation, the stub can be like a regular Java class. Because it makes remote calls, it can throw more exceptions than a Java class. In particular, it may throw protocol exceptions. The factory can also be configured as a JNDI resource. The factory expects to parameters: "type" and "url", corresponding to the two arguments to
create
In Resin 3.0, the above example would be configured as:
<reference> <jndi-name>hessian/hello</jndi-name> <factory>com.caucho.hessian.client.HessianProxyFactory</factory> <init-param url="http://localhost:8080/ejb/hello"/> <init-param type="test.HelloHome"/> </reference>
To get the above resource, use JNDI as follows:
Context ic = new InitialContext(); HelloHome hello = (HelloHome) ic.lookup("java:comp/env/hessian/hello"); System.out.println("Hello: " + hello.helloWorld());
Authentication
The proxy can use HTTP basic authentication if the user and the password are set.