com.caucho.bam
Class SimpleBamService

java.lang.Object
  extended by com.caucho.bam.AbstractBamService
      extended by com.caucho.bam.SimpleBamService
All Implemented Interfaces:
BamService, BamStream
Direct Known Subclasses:
BamJmsService, BamLogService, BamMailService, BamPhpAgent, DeployService, GenericService, HmuxReceiver, ImUser, JMXService, MemoryNick

public class SimpleBamService
extends AbstractBamService
implements BamStream

Abstract class for a service that implements its own BamAgentStream. Simple services will implement both the HmtpService and BamAgentStream interfaces in a single class. This abstract class simplifies the implementation of this kind of service.


Constructor Summary
protected SimpleBamService()
           
 
Method Summary
 BamStream getAgentStream()
          Returns the resource's stream
protected  BamSkeleton getBamSkeleton()
           
 BamStream getBrokerStream()
          Returns the stream to the broker
 void message(java.lang.String to, java.lang.String from, java.io.Serializable value)
          Callback to handle messages
 void messageError(java.lang.String to, java.lang.String from, java.io.Serializable value, BamError error)
          Callback to handle messages
 void presence(java.lang.String to, java.lang.String from, java.io.Serializable value)
          General presence, for clients announcing availability
 void presenceError(java.lang.String to, java.lang.String from, java.io.Serializable value, BamError error)
          An error response to a client
 void presenceProbe(java.lang.String to, java.lang.String from, java.io.Serializable value)
          Presence probe from the server to a client
 void presenceSubscribe(java.lang.String to, java.lang.String from, java.io.Serializable value)
          A subscription request from a client
 void presenceSubscribed(java.lang.String to, java.lang.String from, java.io.Serializable value)
          A subscription response to a client
 void presenceUnavailable(java.lang.String to, java.lang.String from, java.io.Serializable value)
          General presence, for clients announcing unavailability
 void presenceUnsubscribe(java.lang.String to, java.lang.String from, java.io.Serializable value)
          An unsubscription request from a client
 void presenceUnsubscribed(java.lang.String to, java.lang.String from, java.io.Serializable value)
          A unsubscription response to a client
 void queryError(long id, java.lang.String to, java.lang.String from, java.io.Serializable value, BamError error)
          Handles the query error from a corresponding queryGet or querySet.
 boolean queryGet(long id, java.lang.String to, java.lang.String from, java.io.Serializable value)
          Sends a query information call (get), returning true if this handler understands the query class, and false if it does not.
 void queryResult(long id, java.lang.String to, java.lang.String from, java.io.Serializable value)
          Handles the query response from a corresponding queryGet or querySet.
 boolean querySet(long id, java.lang.String to, java.lang.String from, java.io.Serializable value)
          Sends a query update request (set), returning true if this handler understands the query class, and false if it does not.
 void setBrokerStream(BamStream brokerStream)
          Sets the stream to the broker
 
Methods inherited from class com.caucho.bam.AbstractBamService
getAgentFilter, getBrokerFilter, getJid, logData, logValue, onAgentStart, onAgentStop, setJid, startAgent, stopAgent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.caucho.bam.BamStream
getJid
 

Constructor Detail

SimpleBamService

protected SimpleBamService()
Method Detail

getBamSkeleton

protected BamSkeleton getBamSkeleton()

getBrokerStream

public BamStream getBrokerStream()
Returns the stream to the broker


setBrokerStream

public void setBrokerStream(BamStream brokerStream)
Sets the stream to the broker


getAgentStream

public BamStream getAgentStream()
Returns the resource's stream

Specified by:
getAgentStream in interface BamService
Specified by:
getAgentStream in class AbstractBamService

message

public void message(java.lang.String to,
                    java.lang.String from,
                    java.io.Serializable value)
Callback to handle messages

Specified by:
message in interface BamStream
Parameters:
to - the target JID
from - the source JID
value - the message payload

messageError

public void messageError(java.lang.String to,
                         java.lang.String from,
                         java.io.Serializable value,
                         BamError error)
Callback to handle messages

Specified by:
messageError in interface BamStream
Parameters:
to - the target JID
from - the source JID
value - the message payload
error - the message error

queryGet

public boolean queryGet(long id,
                        java.lang.String to,
                        java.lang.String from,
                        java.io.Serializable value)
Description copied from interface: BamStream
Sends a query information call (get), returning true if this handler understands the query class, and false if it does not. If queryGet returns true, the handler MUST send a queryResult or queryError to the sender, using the same id.

Specified by:
queryGet in interface BamStream
Parameters:
id - the query identifier used to match requests with responses
to - the target JID
from - the source JID, used as the target for the response
value - the query payload
Returns:
true if this handler understand the query, false otherwise

querySet

public boolean querySet(long id,
                        java.lang.String to,
                        java.lang.String from,
                        java.io.Serializable value)
Description copied from interface: BamStream
Sends a query update request (set), returning true if this handler understands the query class, and false if it does not. If querySet returns true, the handler MUST send a queryResult or queryError to the sender, using the same id.

Specified by:
querySet in interface BamStream
Parameters:
id - the query identifier used to match requests with responses
to - the target JID
from - the source JID, used as the target for the response
value - the query payload
Returns:
true if this handler understand the query, false otherwise

queryResult

public void queryResult(long id,
                        java.lang.String to,
                        java.lang.String from,
                        java.io.Serializable value)
Description copied from interface: BamStream
Handles the query response from a corresponding queryGet or querySet.

Specified by:
queryResult in interface BamStream
Parameters:
id - the query identifier used to match requests with responses
to - the target JID
from - the source JID, used as the target for the response
value - the result payload

queryError

public void queryError(long id,
                       java.lang.String to,
                       java.lang.String from,
                       java.io.Serializable value,
                       BamError error)
Description copied from interface: BamStream
Handles the query error from a corresponding queryGet or querySet.

Specified by:
queryError in interface BamStream
Parameters:
id - the query identifier used to match requests with responses
to - the target JID
from - the source JID, used as the target for the response
value - the query payload
error - additional error information

presence

public void presence(java.lang.String to,
                     java.lang.String from,
                     java.io.Serializable value)
General presence, for clients announcing availability

Specified by:
presence in interface BamStream

presenceUnavailable

public void presenceUnavailable(java.lang.String to,
                                java.lang.String from,
                                java.io.Serializable value)
General presence, for clients announcing unavailability

Specified by:
presenceUnavailable in interface BamStream

presenceProbe

public void presenceProbe(java.lang.String to,
                          java.lang.String from,
                          java.io.Serializable value)
Presence probe from the server to a client

Specified by:
presenceProbe in interface BamStream

presenceSubscribe

public void presenceSubscribe(java.lang.String to,
                              java.lang.String from,
                              java.io.Serializable value)
A subscription request from a client

Specified by:
presenceSubscribe in interface BamStream

presenceSubscribed

public void presenceSubscribed(java.lang.String to,
                               java.lang.String from,
                               java.io.Serializable value)
A subscription response to a client

Specified by:
presenceSubscribed in interface BamStream

presenceUnsubscribe

public void presenceUnsubscribe(java.lang.String to,
                                java.lang.String from,
                                java.io.Serializable value)
An unsubscription request from a client

Specified by:
presenceUnsubscribe in interface BamStream

presenceUnsubscribed

public void presenceUnsubscribed(java.lang.String to,
                                 java.lang.String from,
                                 java.io.Serializable value)
A unsubscription response to a client

Specified by:
presenceUnsubscribed in interface BamStream

presenceError

public void presenceError(java.lang.String to,
                          java.lang.String from,
                          java.io.Serializable value,
                          BamError error)
An error response to a client

Specified by:
presenceError in interface BamStream