public class PubSubServiceImpl extends DefaultComponent implements PubSubService
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_XP |
protected PubSubProvider |
provider
The currently-configured provider.
|
protected PubSubProviderDescriptor |
providerDescriptor
The descriptor for the currently-configured provider, or
null if it's the default. |
protected List<PubSubProviderDescriptor> |
providerDescriptors
All the registered descriptors.
|
protected Map<String,List<BiConsumer<String,byte[]>>> |
subscribers
List of subscribers for each topic.
|
lastModified
Constructor and Description |
---|
PubSubServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
activate(ComponentContext context)
Activates the component.
|
void |
deactivate(ComponentContext context)
Deactivates the component.
|
int |
getApplicationStartedOrder()
The component notification order for
Component.applicationStarted(org.nuxeo.runtime.model.ComponentContext) . |
protected void |
providerDescriptorChanged() |
void |
publish(String topic,
byte[] message)
Publishes a message to the given topic.
|
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
protected void |
registerProvider(PubSubProviderDescriptor descriptor) |
void |
registerSubscriber(String topic,
BiConsumer<String,byte[]> subscriber)
Registers a subscriber for the given topic.
|
void |
start(ComponentContext context)
Start the component.
|
void |
stop(ComponentContext context)
Stop the component.
|
void |
unregisterContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
protected void |
unregisterProvider(PubSubProviderDescriptor descriptor) |
void |
unregisterSubscriber(String topic,
BiConsumer<String,byte[]> subscriber)
Unregisters a subscriber for the given topic.
|
getAdapter, getLastModified, registerExtension, setLastModified, setModifiedNow, unregisterExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicationStarted
public static final String CONFIG_XP
protected List<PubSubProviderDescriptor> providerDescriptors
protected PubSubProvider provider
protected PubSubProviderDescriptor providerDescriptor
null
if it's the default.protected Map<String,List<BiConsumer<String,byte[]>>> subscribers
public PubSubServiceImpl()
public void activate(ComponentContext context)
Component
This method is called by the runtime when a component is activated.
activate
in interface Component
activate
in class DefaultComponent
context
- the runtime contextpublic void deactivate(ComponentContext context)
Component
This method is called by the runtime when a component is deactivated.
deactivate
in interface Component
deactivate
in class DefaultComponent
context
- the runtime contextpublic void start(ComponentContext context)
Component
start
in interface Component
start
in class DefaultComponent
public void stop(ComponentContext context)
Component
stop
in interface Component
stop
in class DefaultComponent
public int getApplicationStartedOrder()
Component
Component.applicationStarted(org.nuxeo.runtime.model.ComponentContext)
.
Components are notified in increasing order. Order 1000 is the default order for components that don't care. Order 100 is the repository initialization.
getApplicationStartedOrder
in interface Component
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
registerContribution
in class DefaultComponent
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
unregisterContribution
in class DefaultComponent
protected void registerProvider(PubSubProviderDescriptor descriptor)
protected void unregisterProvider(PubSubProviderDescriptor descriptor)
protected void providerDescriptorChanged()
public void publish(String topic, byte[] message)
PubSubService
publish
in interface PubSubService
topic
- the topicmessage
- the messagepublic void registerSubscriber(String topic, BiConsumer<String,byte[]> subscriber)
PubSubService
The subscriber must deal with the message without delay and return immediately, usually by storing it in a thread-safe datastructure.
registerSubscriber
in interface PubSubService
topic
- the topicsubscriber
- the subscriber, who will receive the topic and a byte[]
messagepublic void unregisterSubscriber(String topic, BiConsumer<String,byte[]> subscriber)
PubSubService
unregisterSubscriber
in interface PubSubService
topic
- the topicsubscriber
- the subscriberCopyright © 2017 Nuxeo. All rights reserved.