|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The PubSubServer class is the most important class of pub/sub server. It's responsible for managing channel, dispatching bayeux messages, configuring server according to deployment descriptor
FactoryFinder
Method Summary | |
void |
deleteChannel(Client client,
java.lang.String url)
Delete the given url Channel and all its children and descents. |
Channel |
findChannel(java.lang.String url)
Lookup a given url Channel from PubSubServer. |
Channel |
findOrCreateChannel(Client client,
java.lang.String url)
Lookup a given url Channel from PubSubServer. |
ClientManager |
getClientManager()
Get ClientManager for Client |
MessageFactory |
getMessageFactory()
Get MessageFactory for creating messages. |
java.lang.String |
getName()
Get the name of the server. |
boolean |
isAllowPublishDirectly()
|
void |
publishToChannel(LocalClient client,
java.lang.String channel,
java.lang.Object payLoad)
The method is a facade method which is used for publishing messages from server side. |
void |
subscribeToChannel(LocalClient client,
java.lang.String channel,
ChannelMessageListener listener)
The method is a facade method which is used to subscribe a Channel on server side. |
void |
unsubscribeToChannel(java.lang.String channel,
ChannelMessageListener listener)
This method is a facade method which is used to unsubscribe a Channel on server side. |
Method Detail |
public java.lang.String getName()
Get the name of the server. The name of the server can be configured in pubsub server deployment descriptor file WEB-INF/weblogic-pubsub.xml.
<server-config> <name>myserver</name> </server-config>
If the name of the server is not configured in descriptor file, then the name of the pubsub server will be the servlet context path of current web application and the leading and ending '/' characters will be striped
public Channel findChannel(java.lang.String url)
url
- name for the channelpublic Channel findOrCreateChannel(Client client, java.lang.String url) throws PubSubSecurityException
Lookup a given url Channel from PubSubServer. If not found, this method will create and return the Channel. All non-exist Channels in the channel url will be created implicitly.
When creating the Channel, this method will verify client's permission to check whether the client has permission to create the Channel.
client
- client which is to create the Channel.url
- name for the channelpublic void deleteChannel(Client client, java.lang.String url) throws PubSubSecurityException
client
- client which is to delete the Channelurl
- name of the channelpublic void publishToChannel(LocalClient client, java.lang.String channel, java.lang.Object payLoad) throws PubSubSecurityException
The method is a facade method which is used for publishing messages from server side. For example, to publish "message body" to Channel "/foo/bar", this method can be called like this:
PubSubServer server = FactoryFinder.getFactory(FactoryFinder.PUBSUBSERVER_FACTORY); LocalClient client = server.getClientManager().createLocalClient(); server.publishToChannel(client, "/foo/bar", "message body");The above is equal to the following:
PubSubServer server = FactoryFinder.getFactory(FactoryFinder.PUBSUBSERVER_FACTORY); LocalClient client = server.getClientManager().createLocalClient(); Channel channel = server.findOrCreateChannel(client, "/foo/bar"); EventMessage message = server.getMessageFactory().createEventMessage(client, "message body"); channel.publish(message, ChannelPattern.ITSELF);
client
- LocalClient object.channel
- Channel pattern.payLoad
- payLoad object. The toString() method of payLoad object
will be used to fill in "data" field of bayuex event messagepublic void subscribeToChannel(LocalClient client, java.lang.String channel, ChannelMessageListener listener) throws PubSubSecurityException
The method is a facade method which is used to subscribe a Channel on server side. User have to implement the callback method onPublish() of ChannelMessageListener interface. For example, to subscribe Channel "/foo/bar", this method can be called like this:
PubSubServer server =FactoryFinder.getFactory(FactoryFinder.PUBSUBSERVER_FACTORY); LocalClient client = server.getClientManager().createLocalClient(); server.subscribeToChannel(client, "/foo/bar", new MyChannelMessageListener());The above is equal to the following:
PubSubServer server =FactoryFinder.getFactory(FactoryFinder.PUBSUBSERVER_FACTORY); LocalClient client = server.getClientManager().createLocalClient(); Channel channel = server.findOrCreateChannel(client, "/foo/bar"); channel.registerListener(new MyChannelMessageListener());
client
- LocalClient object.channel
- Channel urllistener
- ChannelMessageListener objectpublic void unsubscribeToChannel(java.lang.String channel, ChannelMessageListener listener)
This method is a facade method which is used to unsubscribe a Channel on server side. This method is equal to the following:
Channel channel = server.findChannel("/foo/bar"); channel.unregisterListener(myListener);
channel
- Channel urllistener
- ChannelMessageListener objectpublic ClientManager getClientManager()
public MessageFactory getMessageFactory()
public boolean isAllowPublishDirectly()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |