public class HmtpServlet extends HttpServlet implements ActorHolder, Actor
Constructor and Description |
---|
HmtpServlet() |
Modifier and Type | Method and Description |
---|---|
void |
addClientLinkActor(com.caucho.hmtp.server.ClientLinkActor linkActor) |
protected com.caucho.hmtp.server.ClientLinkActor |
createClientLinkActor(java.lang.String uid,
MessageStream hmtpStream)
Creates and returns the actor for the client link
|
protected Mailbox |
createServletMailbox() |
protected WebSocketListener |
createWebSocketListener() |
void |
destroyClientLinkActor(ActorHolder linkActor) |
Actor |
getActor() |
java.lang.String |
getAddress()
Returns the address of the
ActorHolder at the end
of the stream. |
ManagedBroker |
getBroker()
Returns the owning broker
|
java.lang.String |
getBrokerAddress() |
protected MessageStream |
getFallbackStream() |
Mailbox |
getMailbox() |
void |
init()
Initialize the servlet.
|
boolean |
isClosed()
Tests if the stream is closed.
|
void |
message(java.lang.String to,
java.lang.String from,
java.io.Serializable payload)
Sends a unidirectional message to an
ActorHolder ,
addressed by the Actor's address. |
void |
messageError(java.lang.String to,
java.lang.String from,
java.io.Serializable payload,
BamError error)
Sends a message error to an
ActorHolder ,
addressed by the Actor's address. |
void |
query(long id,
java.lang.String to,
java.lang.String from,
java.io.Serializable payload)
Sends a query/RPCinformation call
The receiver of a
query acts as a service and the
caller acts as a client. |
void |
queryError(long id,
java.lang.String to,
java.lang.String from,
java.io.Serializable payload,
BamError error)
Sends a query error from a failed query.
|
void |
queryResult(long id,
java.lang.String to,
java.lang.String from,
java.io.Serializable payload)
Sends a query response for a query
|
void |
removeClientLinkActor(ActorHolder linkActor) |
void |
service(ServletRequest request,
ServletResponse response)
Service a request.
|
void |
setActorStream(Actor actorStream) |
void |
setAddress(java.lang.String address) |
void |
setBroker(Broker broker) |
void |
setMailbox(Mailbox mailbox) |
java.lang.String |
toString() |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
public java.lang.String getAddress()
MessageStream
ActorHolder
at the end
of the stream.getAddress
in interface ActorHolder
getAddress
in interface MessageStream
public void setAddress(java.lang.String address)
setAddress
in interface ActorHolder
public java.lang.String getBrokerAddress()
public void init()
GenericServlet
init
in class GenericServlet
public void service(ServletRequest request, ServletResponse response) throws java.io.IOException, ServletException
HttpServlet
service
in interface Servlet
service
in class HttpServlet
request
- request information. Normally servlets will cast this
to HttpServletRequest
response
- response information. Normally servlets will cast this
to HttpServletRequest
java.io.IOException
ServletException
protected WebSocketListener createWebSocketListener()
protected com.caucho.hmtp.server.ClientLinkActor createClientLinkActor(java.lang.String uid, MessageStream hmtpStream)
public void addClientLinkActor(com.caucho.hmtp.server.ClientLinkActor linkActor)
public void removeClientLinkActor(ActorHolder linkActor)
public void destroyClientLinkActor(ActorHolder linkActor)
protected Mailbox createServletMailbox()
public Actor getActor()
getActor
in interface ActorHolder
public void setActorStream(Actor actorStream)
public ManagedBroker getBroker()
MessageStream
getBroker
in interface ActorHolder
getBroker
in interface MessageStream
public void setBroker(Broker broker)
setBroker
in interface ActorHolder
public Mailbox getMailbox()
getMailbox
in interface ActorHolder
public void setMailbox(Mailbox mailbox)
setMailbox
in interface ActorHolder
protected MessageStream getFallbackStream()
public void message(java.lang.String to, java.lang.String from, java.io.Serializable payload)
MessageStream
ActorHolder
,
addressed by the Actor's address.message
in interface MessageStream
to
- the target actor's addressfrom
- the source actor's addresspayload
- the message payloadpublic void messageError(java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
MessageStream
ActorHolder
,
addressed by the Actor's address. Actor protocols may choose to send
error messages if a message fails for some reason.
In general, Actors should not rely on the delivery of error messages.
If an error return is required, use an RPC query instead.messageError
in interface MessageStream
to
- the target actor's addressfrom
- the source actor's addresspayload
- the message payloaderror
- the message errorpublic void query(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
MessageStream
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 stream MUST send a queryResult
or
queryError
to the client using the same id
,
because RPC clients rely on a response.query
in interface MessageStream
id
- the query identifier used to match requests with responsesto
- the service actor's addressfrom
- the client actor's addresspayload
- the query payloadpublic void queryResult(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
MessageStream
queryResult
in interface MessageStream
id
- the query identifier used to match requests with responsesto
- the client actor's addressfrom
- the service actor's addresspayload
- the result payloadpublic void queryError(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
MessageStream
queryError
in interface MessageStream
id
- the query identifier used to match requests with responsesto
- the client actor's addressfrom
- the service actor's addresspayload
- the query payloaderror
- additional error informationpublic boolean isClosed()
MessageStream
isClosed
in interface MessageStream
public java.lang.String toString()
toString
in class GenericServlet