Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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

See Also:
  `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

### getName

    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

  Returns:
    name of the server.

### findChannel

    public Channel findChannel(java.lang.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

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

  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

    public void deleteChannel(Client client,
                              java.lang.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

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

  Parameters:
    `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 message
  Throws:
    PubSubSecurityException - If any security error occurs.

### subscribeToChannel

    public 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());

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

### unsubscribeToChannel

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

  Parameters:
    `channel` - Channel url
    `listener` - ChannelMessageListener object

### getClientManager

    public ClientManager getClientManager()

  Get ClientManager for Client

  Returns:
    ClientManager instance.

### getMessageFactory

    public MessageFactory getMessageFactory()

  Get MessageFactory for creating messages.

  Returns:
    MessageFactory instance.

### isAllowPublishDirectly

    public boolean isAllowPublishDirectly()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 BEA Systems All Rights Reserved.