public final class Publishers extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addEventListener(ServerEventListener listener)
Add a single threaded event listener to receive all event notifications.
|
static void |
addEventListener(ServerEventListener listener,
int notificationMask)
Add a single threaded event listener to receive selected event
notifications.
|
static void |
addEventListener(ServerEventListener listener,
ThreadPool threadPool,
int notificationMask)
Add an event listener.
|
static void |
bootstrap(com.pushtechnology.diffusion.api.internal.topic.PublisherTopicTree topicTree,
com.pushtechnology.diffusion.clients.manager.ClientSessions clientManager,
ServerConfig serverConfig,
com.pushtechnology.diffusion.publisher.PublisherManager publisherManager,
com.pushtechnology.diffusion.publisher.AuthorisationManager authorisationManager,
com.pushtechnology.diffusion.publisher.ServerEventManager serverEventManager) |
static TopicMessage |
createDeltaMessage(String topicName)
Creates an empty delta message.
|
static TopicMessage |
createDeltaMessage(String topicName,
int capacity)
Creates an empty delta message.
|
static AttachableTopicMessage |
createDeltaMessage(String topicName,
int capacity,
Object attachment)
Creates an empty delta message.
|
static AttachableTopicMessage |
createDeltaMessage(String topicName,
Object attachment)
Creates an empty delta message with an attachment.
|
static TopicMessage |
createLoadMessage(String topicName)
Creates an empty Topic Load message.
|
static TopicMessage |
createLoadMessage(String topicName,
int capacity)
Creates an empty Topic Load message.
|
static Publisher |
createPublisher(String name)
Convenience method to create a default Publisher and register it with
Diffusion
Equivalent of creating a PublisherConfig instance with
ServerConfig.addPublisher(String, String) and passing to
loadPublisher(PublisherConfig) . |
static Publisher |
createPublisher(String name,
Class<? extends Publisher> instanceClass)
Convenience method to create a Publisher from a given Class and register
it with Diffusion
Equivalent of creating a PublisherConfig instance with
ServerConfig.addPublisher(String, String) and passing to
loadPublisher(PublisherConfig) . |
static Publisher |
createPublisher(String name,
String classname)
Convenience method to create a Publisher from a given classname and
register it with Diffusion
Equivalent of creating a PublisherConfig instance with
ServerConfig.addPublisher(String, String) and passing to
loadPublisher(PublisherConfig) . |
static Client |
getClient(String clientID)
Returns Client given a Client ID.
|
static List<Client> |
getClients()
Returns a list of all currently known Clients.
|
static List<Client> |
getClients(ConnectionCategory category)
Returns a list of all currently known Clients that are of a specified
connection category.
|
static int |
getNumberOfClients()
Returns the number of currently connected Clients.
|
static int |
getNumberOfClients(ConnectionCategory category)
Returns the number of currently Connected Clients of a specified
category.
|
static <T extends Publisher> |
getPublisherByName(String name)
Returns a Publisher given its name.
|
static Publisher |
getPublisherForTopic(String topicName)
Returns the Publisher for a named Topic.
|
static Publisher |
getPublisherForTopic(Topic topic)
Returns the Publisher for a given topic.
|
static List<Publisher> |
getPublishers()
Returns a list of all of the currently active Publishers.
|
static String |
getServerName()
Returns the current Diffusion server name.
|
static TopicTree |
getTopicTree()
This returns the topic tree which is the root of the topic hierarchy.
|
static Publisher |
loadPublisher(PublisherConfig config)
Loads a Publisher from a given
PublisherConfig . |
static void |
removeEventListener(ServerEventListener listener)
Remove an event listener.
|
static void |
setAuthorisationHandler(AuthorisationHandler handler)
Set the Authorisation Handler for all Publishers.
|
static void |
unloadPublisher(String name)
Unloads a publisher.
|
public static void bootstrap(com.pushtechnology.diffusion.api.internal.topic.PublisherTopicTree topicTree, com.pushtechnology.diffusion.clients.manager.ClientSessions clientManager, ServerConfig serverConfig, com.pushtechnology.diffusion.publisher.PublisherManager publisherManager, com.pushtechnology.diffusion.publisher.AuthorisationManager authorisationManager, com.pushtechnology.diffusion.publisher.ServerEventManager serverEventManager)
public static TopicMessage createLoadMessage(String topicName) throws MessageException
This is a convenience method equivalent to calling
Topic.createLoadMessage()
on an existing Topic. This can also be
used to create a message for a Topic that does not exist as it is
permitted to send fetch replies for non existent Topics.
topicName
- the topic name.MessageException
- if unable to create a message.public static TopicMessage createLoadMessage(String topicName, int capacity) throws MessageException
This is a convenience method equivalent to calling
Topic.createLoadMessage(int)
on an existing Topic. This can also
be used to create a message for a Topic that does not exist as it is
permitted to send fetch replies for non existent Topics.
topicName
- the topic name.capacity
- the initial capacity of the message in bytes - the
required space for data and user headers.MessageException
- if unable to create a message.public static TopicMessage createDeltaMessage(String topicName) throws MessageException
This is a convenience method equivalent to calling
Topic.createDeltaMessage()
on the Topic.
topicName
- the topic name.MessageException
- if unable to create a new message.public static TopicMessage createDeltaMessage(String topicName, int capacity) throws MessageException
This is a convenience method equivalent to calling
Topic.createDeltaMessage(int)
on the Topic.
topicName
- the topic name.capacity
- the initial capacity of the message in bytes, to allow
for data and user headers.MessageException
- if unable to create a new message.public static AttachableTopicMessage createDeltaMessage(String topicName, Object attachment) throws MessageException
This is a convenience method equivalent to calling
Topic.createDeltaMessage(Object)
on the Topic.
topicName
- the topic name.attachment
- the attachmentMessageException
- if unable to create a new message.public static AttachableTopicMessage createDeltaMessage(String topicName, int capacity, Object attachment) throws MessageException
This is a convenience method equivalent to calling
Topic.createDeltaMessage(int,Object)
on the Topic.
topicName
- the topic name.capacity
- the initial capacity of the message in bytes, to allow
for data and user headers.attachment
- the attachmentMessageException
- if unable to create a new message.public static List<Publisher> getPublishers()
public static <T extends Publisher> T getPublisherByName(String name)
T
- The expected type of the Publisher to be returned.name
- the configured Publisher name.ClassCastException
- if the found publisher cannot be cast.public static Publisher getPublisherForTopic(Topic topic)
topic
- the topic.public static Publisher getPublisherForTopic(String topicName)
topicName
- the full hierarchic Topic name.public static Publisher createPublisher(String name) throws APIException
ServerConfig.addPublisher(String, String)
and passing to
loadPublisher(PublisherConfig)
.name
- the name given to the PublisherAPIException
- if unable to create publisherpublic static Publisher createPublisher(String name, Class<? extends Publisher> instanceClass) throws APIException
ServerConfig.addPublisher(String, String)
and passing to
loadPublisher(PublisherConfig)
.name
- the name given to the PublisherinstanceClass
- the class of the Publisher to be instantiatedAPIException
- if unable to create publisherpublic static Publisher createPublisher(String name, String classname) throws APIException
ServerConfig.addPublisher(String, String)
and passing to
loadPublisher(PublisherConfig)
.name
- the name given to the Publisherclassname
- the class of the Publisher to be instantiatedAPIException
- if unable to create a publisherpublic static Publisher loadPublisher(PublisherConfig config) throws APIException
PublisherConfig
.
The configuration for a publisher can be created using
ServerConfig.addPublisher(String, String)
and then changes
applied as required before loading the Publisher using this method.
config
- the given PublisherConfig.APIException
- if unable to load the publisher.public static void unloadPublisher(String name)
name
- the publisher namepublic static String getServerName()
public static TopicTree getTopicTree()
public static void addEventListener(ServerEventListener listener) throws APIException
listener
- the listener.APIException
- if the listener does not implement one or more of
the sub-interfaces of ServerEventListener
.addEventListener(ServerEventListener, ThreadPool, int)
public static void addEventListener(ServerEventListener listener, int notificationMask) throws APIException
listener
- the listener.notificationMask
- bit mask of required events.APIException
- if the listener does not implement one or more of
the sub-interfaces of ServerEventListener
.addEventListener(ServerEventListener, ThreadPool, int)
public static void addEventListener(ServerEventListener listener, ThreadPool threadPool, int notificationMask) throws APIException
The object added must implement at least one of the sub-interfaces of
ServerEventListener
and may implement more than one.
If no thread pool is specified then the listener will have a dedicated thread for handling events which will be passed to the listener in the sequence that they occur.
If a thread pool is specified then each event notification will be executed by a thread from the pool. In this case events may not be presented to the listener in the order that they occur so this option should not be used if order of processing is important.
A notification mask may be supplied which will filter the event
notifications that are received for any listener. A value with all bits
set (i.e -1) would cause all events (listener methods) to be notified. To
select only a subset of events then a mask of the bit settings required
should be supplied using an 'or' of the required mask values. For
example, to receive only clientConnected
or clientClosed
events on a ClientListener
listener the mask
supplied should be ClientListener.CONNECTED
|
ClientListener.CLOSED
.
If the specified object is already known as a listener then it will be replaced with the specified notification criteria.
listener
- the listener object which must implement one or more of
the sub-interfaces of ServerEventListener
.threadPool
- this should be specified as null for single threaded
event notifications. If a thread pool is supplied then event
notifications will be passed to the thread pool for execution and
thus will be multi-threaded and may no arrive in the same sequence
that the events occurred.notificationMask
- a mask of bit settings to filter the event
notifications required. To receive all notifications a value of -1
should be specified.APIException
- if the object does not implement one or more of the
sub-interfaces of ServerEventListener
.public static void removeEventListener(ServerEventListener listener)
After this call the listener will no longer receive notifications on any of its sub-interface.
listener
- an object that has been previously added as a listener
using one of the
addEventListener
methods.public static void setAuthorisationHandler(AuthorisationHandler handler)
handler
- the Authorisation Handler to use. Null may be specified to
remove the current handler.public static Client getClient(String clientID)
clientID
- the client identifier.public static List<Client> getClients()
public static List<Client> getClients(ConnectionCategory category)
category
- the Client category.public static int getNumberOfClients()
public static int getNumberOfClients(ConnectionCategory category)
category
- the Client category.Copyright © 2016 Push Technology Ltd. All Rights Reserved.