public class BurlapProxyFactory extends java.lang.Object implements ServiceProxyFactory, javax.naming.spi.ObjectFactory
String url = "http://localhost: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> <name>hessian/hello</name> <factory>com.caucho.hessian.client.HessianProxyFactory</factory> <init url="http://localhost:8080/ejb/hello"/> 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/burlap/hello"); System.out.println("Hello: " + hello.helloWorld());
The proxy can use HTTP basic authentication if the user and the password are set.
Constructor and Description |
---|
BurlapProxyFactory()
Creates the new proxy factory.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
create(java.lang.Class api,
java.lang.String urlName)
Creates a new proxy with the specified URL.
|
java.lang.Object |
create(java.lang.String url)
Creates a new proxy with the specified URL.
|
static char |
encode(long d) |
AbstractBurlapInput |
getBurlapInput(java.io.InputStream is) |
BurlapOutput |
getBurlapOutput(java.io.OutputStream os) |
java.lang.Object |
getObjectInstance(java.lang.Object obj,
javax.naming.Name name,
javax.naming.Context nameCtx,
java.util.Hashtable<?,?> environment)
JNDI object factory so the proxy can be used as a resource.
|
BurlapRemoteResolver |
getRemoteResolver()
Returns the remote resolver.
|
boolean |
isOverloadEnabled()
Returns true if overloaded methods are allowed (using mangling)
|
protected java.net.URLConnection |
openConnection(java.net.URL url)
Creates the URL connection.
|
void |
setOverloadEnabled(boolean isOverloadEnabled)
set true if overloaded methods are allowed (using mangling)
|
void |
setPassword(java.lang.String password)
Sets the password.
|
void |
setUser(java.lang.String user)
Sets the user.
|
public void setUser(java.lang.String user)
public void setPassword(java.lang.String password)
public boolean isOverloadEnabled()
public void setOverloadEnabled(boolean isOverloadEnabled)
public BurlapRemoteResolver getRemoteResolver()
protected java.net.URLConnection openConnection(java.net.URL url) throws java.io.IOException
java.io.IOException
public java.lang.Object create(java.lang.String url) throws java.net.MalformedURLException, java.lang.ClassNotFoundException
url
- the URL where the client object is located.java.net.MalformedURLException
java.lang.ClassNotFoundException
public java.lang.Object create(java.lang.Class api, java.lang.String urlName) throws java.net.MalformedURLException
String url = "http://localhost:8080/ejb/hello"); HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
create
in interface ServiceProxyFactory
api
- the interface the proxy class needs to implementurl
- the URL where the client object is located.java.net.MalformedURLException
public AbstractBurlapInput getBurlapInput(java.io.InputStream is)
public BurlapOutput getBurlapOutput(java.io.OutputStream os)
public java.lang.Object getObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable<?,?> environment) throws java.lang.Exception
getObjectInstance
in interface javax.naming.spi.ObjectFactory
java.lang.Exception
public static char encode(long d)