com.caucho.hmtp
Class HmtpClient

java.lang.Object
  extended by com.caucho.hmtp.HmtpClient
All Implemented Interfaces:
ActorSender, RemoteActorSender, QuerySender

public class HmtpClient
extends java.lang.Object
implements RemoteActorSender

HMTP client protocol


Constructor Summary
HmtpClient(java.lang.String url)
           
HmtpClient(java.lang.String url, ActorHolder actor)
           
 
Method Summary
 void close()
          Closes the sender.
 void connect()
           
 void connect(java.lang.String user, java.io.Serializable credentials)
           
 void connect(java.lang.String user, java.lang.String password)
           
protected  void connectImpl()
           
protected  void finalize()
           
 void flush()
           
 java.lang.String getAddress()
          Returns the address
 Broker getBroker()
          The underlying broker.
 java.lang.String getBrokerAddress()
          Returns the broker address
 QueryManager getQueryManager()
           
 java.lang.String getUrl()
           
 boolean isClosed()
          Returns true if the sender is closed
protected  void loginImpl(java.lang.String uid, java.io.Serializable credentials)
          Login to the server
 void message(java.lang.String to, java.io.Serializable payload)
          Sends a unidirectional message to an ActorHolder, addressed by the Actor's address.
 long nextQueryId()
          Returns the next query identifier.
 java.io.Serializable query(java.lang.String to, java.io.Serializable payload)
          Sends a query information call (get) to an actor, blocking until the actor responds with a result or an error.
 java.io.Serializable query(java.lang.String to, java.io.Serializable payload, long timeout)
          Sends a query information call to an actor, blocking until the actor responds with a result or an error.
 void query(java.lang.String to, java.io.Serializable payload, QueryCallback callback)
          Sends a query information call (get) to an actor, providing a callback to receive the result or error.
 void setEncryptPassword(boolean isEncrypt)
           
 void setVirtualHost(java.lang.String host)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HmtpClient

public HmtpClient(java.lang.String url,
                  ActorHolder actor)
           throws java.io.IOException
Throws:
java.io.IOException

HmtpClient

public HmtpClient(java.lang.String url)
Method Detail

setVirtualHost

public void setVirtualHost(java.lang.String host)

setEncryptPassword

public void setEncryptPassword(boolean isEncrypt)

getBroker

public Broker getBroker()
Description copied from interface: ActorSender
The underlying broker.

Specified by:
getBroker in interface ActorSender
Specified by:
getBroker in interface QuerySender

connect

public void connect()

connect

public void connect(java.lang.String user,
                    java.lang.String password)

connect

public void connect(java.lang.String user,
                    java.io.Serializable credentials)

getUrl

public java.lang.String getUrl()
Specified by:
getUrl in interface RemoteActorSender

connectImpl

protected void connectImpl()

loginImpl

protected void loginImpl(java.lang.String uid,
                         java.io.Serializable credentials)
Login to the server


getAddress

public java.lang.String getAddress()
Returns the address

Specified by:
getAddress in interface QuerySender

getBrokerAddress

public java.lang.String getBrokerAddress()
Returns the broker address


flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
Description copied from interface: ActorSender
Closes the sender.

Specified by:
close in interface ActorSender

isClosed

public boolean isClosed()
Description copied from interface: ActorSender
Returns true if the sender is closed

Specified by:
isClosed in interface ActorSender

nextQueryId

public long nextQueryId()
Description copied from interface: ActorSender
Returns the next query identifier.

Specified by:
nextQueryId in interface ActorSender

message

public void message(java.lang.String to,
                    java.io.Serializable payload)
Description copied from interface: ActorSender
Sends a unidirectional message to an ActorHolder, addressed by the Actor's address.

Specified by:
message in interface ActorSender
Specified by:
message in interface QuerySender
Parameters:
to - the target actor's address
payload - the message payload

query

public java.io.Serializable query(java.lang.String to,
                                  java.io.Serializable payload)
Description copied from interface: ActorSender
Sends a query information call (get) to an actor, blocking until the actor responds with a result or an error. The target actor of a queryGet acts as a service and the caller acts as a client. Because BAM Actors are symmetrical, all Actors can act as services and clients for different RPC calls. The target actor MUST send a queryResult or queryError to the client using the same id, because RPC clients rely on a response.

Specified by:
query in interface ActorSender
Specified by:
query in interface QuerySender
Parameters:
to - the target actor's address
payload - the query payload

query

public java.io.Serializable query(java.lang.String to,
                                  java.io.Serializable payload,
                                  long timeout)
Description copied from interface: ActorSender
Sends a query information call to an actor, blocking until the actor responds with a result or an error. The target actor of a query acts as a service and the caller acts as a client. Because BAM Actors are symmetrical, all Actors can act as services and clients for different RPC calls. The target actor MUST send a queryResult or queryError to the client using the same id, because RPC clients rely on a response.

Specified by:
query in interface ActorSender
Specified by:
query in interface QuerySender
Parameters:
to - the target actor's address
payload - the query payload
timeout - time spent waiting for the query to return

query

public void query(java.lang.String to,
                  java.io.Serializable payload,
                  QueryCallback callback)
Description copied from interface: ActorSender
Sends a query information call (get) to an actor, providing a callback to receive the result or error. The target actor of a queryGet acts as a service and the caller acts as a client. Because BAM Actors are symmetrical, all Actors can act as services and clients for different RPC calls. The target actor MUST send a queryResult or queryError to the client using the same id, because RPC clients rely on a response.

Specified by:
query in interface ActorSender
Specified by:
query in interface QuerySender
Parameters:
to - the target actor's address
payload - the query payload
callback - the application's callback for the result

getQueryManager

public QueryManager getQueryManager()
Specified by:
getQueryManager in interface QuerySender

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object