com.caucho.hmtp.server
Class HmtpServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.caucho.hmtp.server.HmtpServlet
All Implemented Interfaces:
Actor, ActorHolder, MessageStream, java.io.Serializable, Servlet, ServletConfig

public class HmtpServlet
extends HttpServlet
implements ActorHolder, Actor

HmtpWriteStream writes HMTP packets to an OutputStream.

See Also:
Serialized Form

Constructor Summary
HmtpServlet()
           
 
Method Summary
 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()
           
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HmtpServlet

public HmtpServlet()
Method Detail

getAddress

public java.lang.String getAddress()
Description copied from interface: MessageStream
Returns the address of the ActorHolder at the end of the stream.

Specified by:
getAddress in interface ActorHolder
Specified by:
getAddress in interface MessageStream

setAddress

public void setAddress(java.lang.String address)
Specified by:
setAddress in interface ActorHolder

getBrokerAddress

public java.lang.String getBrokerAddress()

init

public void init()
Description copied from class: GenericServlet
Initialize the servlet. Servlets should override this method if they need any initialization like opening pooled database connections.

Overrides:
init in class GenericServlet

service

public void service(ServletRequest request,
                    ServletResponse response)
             throws java.io.IOException,
                    ServletException
Description copied from class: HttpServlet
Service a request. Normally not overridden. If you need to override this, use GenericServlet instead.

Specified by:
service in interface Servlet
Overrides:
service in class HttpServlet
Parameters:
request - request information. Normally servlets will cast this to HttpServletRequest
response - response information. Normally servlets will cast this to HttpServletRequest
Throws:
java.io.IOException
ServletException

createWebSocketListener

protected WebSocketListener createWebSocketListener()

createClientLinkActor

protected com.caucho.hmtp.server.ClientLinkActor createClientLinkActor(java.lang.String uid,
                                                                       MessageStream hmtpStream)
Creates and returns the actor for the client link


addClientLinkActor

public void addClientLinkActor(com.caucho.hmtp.server.ClientLinkActor linkActor)

removeClientLinkActor

public void removeClientLinkActor(ActorHolder linkActor)

destroyClientLinkActor

public void destroyClientLinkActor(ActorHolder linkActor)

createServletMailbox

protected Mailbox createServletMailbox()

getActor

public Actor getActor()
Specified by:
getActor in interface ActorHolder

setActorStream

public void setActorStream(Actor actorStream)

getBroker

public ManagedBroker getBroker()
Description copied from interface: MessageStream
Returns the owning broker

Specified by:
getBroker in interface ActorHolder
Specified by:
getBroker in interface MessageStream

setBroker

public void setBroker(Broker broker)
Specified by:
setBroker in interface ActorHolder

getMailbox

public Mailbox getMailbox()
Specified by:
getMailbox in interface ActorHolder

setMailbox

public void setMailbox(Mailbox mailbox)
Specified by:
setMailbox in interface ActorHolder

getFallbackStream

protected MessageStream getFallbackStream()

message

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

Specified by:
message in interface MessageStream
Parameters:
to - the target actor's address
from - the source actor's address
payload - the message payload

messageError

public void messageError(java.lang.String to,
                         java.lang.String from,
                         java.io.Serializable payload,
                         BamError error)
Description copied from interface: MessageStream
Sends a message error to an 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.

Specified by:
messageError in interface MessageStream
Parameters:
to - the target actor's address
from - the source actor's address
payload - the message payload
error - the message error

query

public void query(long id,
                  java.lang.String to,
                  java.lang.String from,
                  java.io.Serializable payload)
Description copied from interface: MessageStream
Sends a query/RPCinformation call The receiver 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 stream 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 MessageStream
Parameters:
id - the query identifier used to match requests with responses
to - the service actor's address
from - the client actor's address
payload - the query payload

queryResult

public void queryResult(long id,
                        java.lang.String to,
                        java.lang.String from,
                        java.io.Serializable payload)
Description copied from interface: MessageStream
Sends a query response for a query

Specified by:
queryResult in interface MessageStream
Parameters:
id - the query identifier used to match requests with responses
to - the client actor's address
from - the service actor's address
payload - the result payload

queryError

public void queryError(long id,
                       java.lang.String to,
                       java.lang.String from,
                       java.io.Serializable payload,
                       BamError error)
Description copied from interface: MessageStream
Sends a query error from a failed query.

Specified by:
queryError in interface MessageStream
Parameters:
id - the query identifier used to match requests with responses
to - the client actor's address
from - the service actor's address
payload - the query payload
error - additional error information

isClosed

public boolean isClosed()
Description copied from interface: MessageStream
Tests if the stream is closed.

Specified by:
isClosed in interface MessageStream

toString

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