|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.cometd.server.AbstractService
public abstract class AbstractService
Abstract Bayeux Service
This class provides convenience methods to assist with the
creation of a Bayeux Services typically used to provide the
behaviour associated with a service channel (see Channel.isService()).
Specifically it provides:
BayeuxServer#getSession(String)} as an alternative to AbstractService.| Constructor Summary | |
|---|---|
AbstractService(BayeuxServer bayeux,
String name)
Instantiate the service. |
|
AbstractService(BayeuxServer bayeux,
String name,
int maxThreads)
Instantiate the service. |
|
| Method Summary | |
|---|---|
protected void |
addService(String channelId,
String methodName)
Add a service. |
protected void |
doInvoke(Method method,
ServerSession fromClient,
ServerMessage msg)
|
protected void |
exception(String method,
ServerSession fromClient,
LocalSession toClient,
ServerMessage msg,
Throwable x)
Handle Exception. |
BayeuxServer |
getBayeux()
|
LocalSession |
getLocalSession()
|
ServerSession |
getServerSession()
|
org.eclipse.jetty.util.thread.ThreadPool |
getThreadPool()
|
boolean |
isSeeOwnPublishes()
|
protected void |
send(ServerSession toClient,
String onChannel,
Object data,
String id)
Send data to a individual client. |
void |
setSeeOwnPublishes(boolean own)
|
void |
setThreadPool(org.eclipse.jetty.util.thread.ThreadPool pool)
Set the threadpool. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractService(BayeuxServer bayeux,
String name)
bayeux - The bayeux instance.name - The name of the service (used as client ID prefix).
public AbstractService(BayeuxServer bayeux,
String name,
int maxThreads)
bayeux - The bayeux instance.name - The name of the service (used as client ID prefix).maxThreads - The size of a ThreadPool to create to handle messages.| Method Detail |
|---|
public BayeuxServer getBayeux()
public LocalSession getLocalSession()
public ServerSession getServerSession()
public org.eclipse.jetty.util.thread.ThreadPool getThreadPool()
public void setThreadPool(org.eclipse.jetty.util.thread.ThreadPool pool)
ThreadPool is a LifeCycle,
then it is started by this method.
pool - public boolean isSeeOwnPublishes()
public void setSeeOwnPublishes(boolean own)
protected void addService(String channelId,
String methodName)
Listen to a channel and map a method to handle received messages. The method must have a unique name and one of the following signatures:
myMethod(ServerSession from,Object data)myMethod(ServerSession from,Object data,String|Object id)myMethod(ServerSession from,String channel,Object data,String|Object id)
Message then the message object itself is
passed rather than just the data.
Typically a service will be used to a channel in the "/service/**" space which is not a broadcast channel. Messages published to these channels are only delivered to server side clients like this service.
Any object returned by a mapped subscription method is delivered to the
calling client and not broadcast. If the method returns void or null,
then no response is sent. A mapped subscription method may also call
send(ServerSession, String, Object, String) to deliver a response
message(s) to different clients and/or channels. It may also publish
methods via the normal Bayeux API.
channelId - The channel to subscribe tomethodName - The name of the method on this object to call when messages
are received.
protected void send(ServerSession toClient,
String onChannel,
Object data,
String id)
Typically this method is only required if a service method sends response(s) to channels other than the subscribed channel. If the response is to be sent to the subscribed channel, then the data can simply be returned from the subscription method.
toClient - The target clientonChannel - The channel the message is fordata - The data of the messageid - The id of the message (or null for a random id).
protected void exception(String method,
ServerSession fromClient,
LocalSession toClient,
ServerMessage msg,
Throwable x)
method - the name of the method invoked that threw an exceptionfromClient - the remote session that sent the messagetoClient - the local session associated to this servicemsg - the message sent by the remote sessionx - the exception thrown
protected void doInvoke(Method method,
ServerSession fromClient,
ServerMessage msg)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||