public class HessianProxyFactory
extends java.lang.Object
implements com.caucho.services.client.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> <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());
The proxy can use HTTP basic authentication if the user and the password are set.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
_basicAuth |
private java.lang.String |
_connectionFactoryName |
private boolean |
_isChunkedPost |
private boolean |
_isDebug |
private boolean |
_isHessian2Reply |
private boolean |
_isHessian2Request |
private boolean |
_isOverloadEnabled |
private java.lang.String |
_password |
private long |
_readTimeout |
private HessianRemoteResolver |
_resolver |
private SerializerFactory |
_serializerFactory |
private java.lang.String |
_user |
protected static java.util.logging.Logger |
log |
Constructor and Description |
---|
HessianProxyFactory()
Creates the new proxy factory.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
base64(java.lang.String value)
Creates the Base64 value.
|
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.Class api,
java.lang.String urlName,
java.lang.ClassLoader loader)
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) |
AbstractHessianInput |
getHessianInput(java.io.InputStream is) |
AbstractHessianOutput |
getHessianOutput(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.
|
long |
getReadTimeout()
The socket timeout on requests in milliseconds.
|
HessianRemoteResolver |
getRemoteResolver()
Returns the remote resolver.
|
SerializerFactory |
getSerializerFactory()
Gets the serializer factory.
|
boolean |
isChunkedPost()
Set true if should use chunked encoding on the request.
|
boolean |
isDebug()
Gets the debug
|
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 |
setChunkedPost(boolean isChunked)
Set true if should use chunked encoding on the request.
|
void |
setConnectionFactoryName(java.lang.String connectionFactoryName)
Sets the name of the connection factory to use when connecting
to JMS Hessian services.
|
void |
setDebug(boolean isDebug)
Sets the debug
|
void |
setHessian2Reply(boolean isHessian2)
True if the proxy can read Hessian 2 responses.
|
void |
setHessian2Request(boolean isHessian2)
True if the proxy should send Hessian 2 requests.
|
void |
setOverloadEnabled(boolean isOverloadEnabled)
set true if overloaded methods are allowed (using mangling)
|
void |
setPassword(java.lang.String password)
Sets the password.
|
void |
setReadTimeout(long timeout)
The socket timeout on requests in milliseconds.
|
void |
setSerializerFactory(SerializerFactory factory)
Sets the serializer factory.
|
void |
setUser(java.lang.String user)
Sets the user.
|
protected static java.util.logging.Logger log
private SerializerFactory _serializerFactory
private HessianRemoteResolver _resolver
private java.lang.String _user
private java.lang.String _password
private java.lang.String _basicAuth
private boolean _isOverloadEnabled
private boolean _isHessian2Reply
private boolean _isHessian2Request
private boolean _isChunkedPost
private boolean _isDebug
private long _readTimeout
private java.lang.String _connectionFactoryName
public void setUser(java.lang.String user)
public void setPassword(java.lang.String password)
public void setConnectionFactoryName(java.lang.String connectionFactoryName)
public void setDebug(boolean isDebug)
public boolean isDebug()
public boolean isOverloadEnabled()
public void setOverloadEnabled(boolean isOverloadEnabled)
public void setChunkedPost(boolean isChunked)
public boolean isChunkedPost()
public long getReadTimeout()
public void setReadTimeout(long timeout)
public void setHessian2Reply(boolean isHessian2)
public void setHessian2Request(boolean isHessian2)
public HessianRemoteResolver getRemoteResolver()
public void setSerializerFactory(SerializerFactory factory)
public SerializerFactory getSerializerFactory()
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 com.caucho.services.client.ServiceProxyFactory
api
- the interface the proxy class needs to implementurl
- the URL where the client object is located.java.net.MalformedURLException
public java.lang.Object create(java.lang.Class api, java.lang.String urlName, java.lang.ClassLoader loader) throws java.net.MalformedURLException
String url = "http://localhost:8080/ejb/hello"); HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
api
- the interface the proxy class needs to implementurl
- the URL where the client object is located.java.net.MalformedURLException
public AbstractHessianInput getHessianInput(java.io.InputStream is)
public AbstractHessianOutput getHessianOutput(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
private java.lang.String base64(java.lang.String value)
public static char encode(long d)