|
Oracle Fusion Middleware Java API Reference for Oracle WebLogic Server 12c (12.2.1) Part Number E55141-01 P4 Change 1723563 on 2015/10/09 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PubSubServer
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 | |
---|---|
abstract void |
deleteChannel(Client client, String url) Delete the given url Channel and all its children and descents. |
abstract Channel |
findChannel(String url) Lookup a given url Channel from PubSubServer. |
abstract Channel |
findOrCreateChannel(Client client, String url) Lookup a given url Channel from PubSubServer. |
abstract ClientManager |
getClientManager() Get ClientManager for Client |
abstract MessageFactory |
getMessageFactory() Get MessageFactory for creating messages. |
abstract String |
getName() Get the name of the server. |
abstract void |
publishToChannel(LocalClient client, String channel, String payLoad) The method is a facade method which is used for publishing messages from server side. |
abstract void |
subscribeToChannel(LocalClient client, String channel) The method is a facade method which is used to subscribe a Channel on server side. |
abstract void |
unsubscribeToChannel(LocalClient client, String channel) This method is a facade method which is used to unsubscribe a Channel on server side. |
Method Detail |
---|
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
Channel findChannel(String url)
url
- name for the channelChannel findOrCreateChannel(Client client, 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 channelPubSubSecurityException
- if client has no permission to create the given url Channel.void deleteChannel(Client client, String url) throws PubSubSecurityException
When deleting the Channel, this method will verify client's permission to check whether the client has permission to delete the Channel
client
- client which is to delete the Channelurl
- name of the channelPubSubSecurityException
- if client has no permission to delete the given url Channelvoid publishToChannel(LocalClient client, String channel, String 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, "/foo/bar", "message body"); channel.publish(message, ChannelPattern.ITSELF);
client
- LocalClient object.channel
- Channel pattern.payLoad
- String will be used to fill in "data" field of bayuex event messagePubSubSecurityException
- If any security error occurs.void subscribeToChannel(LocalClient client, String channel) throws PubSubSecurityException
The method is a facade method which is used to subscribe a Channel on server side. Message sent to the channel will be wrapped into a DeliveredMessageEvent object and passed to the listeners registered to the LocalClient. 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(); client.registerMessageListener(new MyDeliveredMessageListener()); server.subscribeToChannel(client, "/foo/bar");
The above is equal to the following:
PubSubServer server = FactoryFinder.getFactory(FactoryFinder.PUBSUBSERVER_FACTORY); LocalClient client = server.getClientManager().createLocalClient(); client.registerMessageListener(new MyDeliveredMessageListener()); Channel channel = server.findOrCreateChannel(client, "/foo/bar"); channel.subscribe(client, Channel.ChannelPattern.getPattern("/foo/bar"));
client
- LocalClient object.channel
- Channel urlPubSubSecurityException
- If any security error occurs.void unsubscribeToChannel(LocalClient client, String channel)
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.unsubscribe(myLocalClient, Channel.ChannelPattern.getPattern("/foo/bar"));
client
- LocalClient objectchannel
- Channel urlClientManager getClientManager()
MessageFactory getMessageFactory()
|
Copyright 1996, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Oracle Fusion Middleware Java API Reference for Oracle WebLogic Server 12c (12.2.1) Part Number E55141-01 P4 Change 1723563 on 2015/10/09 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |