Oracle Fusion Middleware
Oracle WebLogic Server API Reference
11g Release 1 (10.3.4)

Part Number E13941-04

com.bea.httppubsub
Interface PubSubServer


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

Since:
10.3.0.0
See Also:
FactoryFinder

Method Summary
 void deleteChannel(Client client, String url)
          Delete the given url Channel and all its children and descents.
 Channel findChannel(String url)
          Lookup a given url Channel from PubSubServer.
 Channel findOrCreateChannel(Client client, String url)
           Lookup a given url Channel from PubSubServer.
 ClientManager getClientManager()
          Get ClientManager for Client
 MessageFactory getMessageFactory()
          Get MessageFactory for creating messages.
 String getName()
          Get the name of the server.
 void publishToChannel(LocalClient client, String channel, String payLoad)
           The method is a facade method which is used for publishing messages from server side.
 void subscribeToChannel(LocalClient client, String channel)
           The method is a facade method which is used to subscribe a Channel on server side.
 void unsubscribeToChannel(LocalClient client, String channel)
           This method is a facade method which is used to unsubscribe a Channel on server side.
 

Method Detail

getName

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

Returns:
name of the server.

findChannel

Channel findChannel(String url)
Lookup a given url Channel from PubSubServer.

Parameters:
url - name for the channel
Returns:
the found Channel or null if not found.

findOrCreateChannel

Channel 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.

Parameters:
client - client which is to create the Channel.
url - name for the channel
Returns:
the found or created Channel with the given Channel url.
Throws:
PubSubSecurityException - if client has no permission to create the given url Channel.

deleteChannel

void deleteChannel(Client client,
                   String url)
                   throws PubSubSecurityException
Delete the given url Channel and all its children and descents.

When deleting the Channel, this method will verify client's permission to check whether the client has permission to delete the Channel

Parameters:
client - client which is to delete the Channel
url - name of the channel
Throws:
PubSubSecurityException - if client has no permission to delete the given url Channel

publishToChannel

void 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);
 

Parameters:
client - LocalClient object.
channel - Channel pattern.
payLoad - String will be used to fill in "data" field of bayuex event message
Throws:
PubSubSecurityException - If any security error occurs.

subscribeToChannel

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"));
 

Parameters:
client - LocalClient object.
channel - Channel url
Throws:
PubSubSecurityException - If any security error occurs.

unsubscribeToChannel

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"));
 

Parameters:
client - LocalClient object
channel - Channel url

getClientManager

ClientManager getClientManager()
Get ClientManager for Client

Returns:
ClientManager instance.

getMessageFactory

MessageFactory getMessageFactory()
Get MessageFactory for creating messages.

Returns:
MessageFactory instance.

Copyright 1996, 2010, 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
Oracle WebLogic Server API Reference
11g Release 1 (10.3.4)

Part Number E13941-04