private static class ProcedureManager.GlobalEventSubscriptions
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Map<ProcedureManager.Subscription,SessionListener> |
listeners
Map of session listener for each subscription.
|
private java.util.Queue<ProcedureManager.PublishTask> |
queue
Tasks for PUBLISH are posted here.
|
private java.util.Map<Session,java.util.List<ProcedureManager.Subscription>> |
subscriptions
The global list of subscriptions.
|
private boolean |
terminated
Flag indicating the listening loop was terminated.
|
Constructor and Description |
---|
GlobalEventSubscriptions()
Create a dedicated thread, in the server's context, which will
listen() for
PUBLISH tasks. |
Modifier and Type | Method and Description |
---|---|
java.util.List<ProcedureManager.Subscription> |
getAllSubscriptions()
Get all the global subscriptions, for all contexts.
|
java.util.List<ProcedureManager.Subscription> |
getSubscriptions()
Get all the global subscriptions, for this context.
|
private void |
listen()
|
void |
post(ProcedureManager.PublishTask task)
Post the given task to the
queue . |
void |
removeAll(java.lang.Object resource)
Remove all the global subscriptions for the given resource.
|
void |
removeAll(ProcedureManager.Subscription subscription)
Remove the specified subscription from the current context's global subscriptions.
|
void |
subscribe(ProcedureManager.Subscription subscription)
Register the specified
ProcedureManager.Subscription as global, for this context. |
private final java.util.Map<Session,java.util.List<ProcedureManager.Subscription>> subscriptions
private final java.util.Map<ProcedureManager.Subscription,SessionListener> listeners
private java.util.Queue<ProcedureManager.PublishTask> queue
private boolean terminated
public GlobalEventSubscriptions()
listen()
for
PUBLISH tasks.private void listen()
tasks
, on the queue
.
Once a task is received, an AssociatedThread
will be created and will execute the
task in the subscription's session
, using
SessionManager.executeInContext(com.goldencode.p2j.net.Session, java.lang.Runnable)
.
public void post(ProcedureManager.PublishTask task)
queue
.task
- The task for a PUBLISH event.public java.util.List<ProcedureManager.Subscription> getAllSubscriptions()
public void removeAll(java.lang.Object resource)
resource
- The resource which will be matched against the ProcedureManager.Subscription.subscriber
.public void removeAll(ProcedureManager.Subscription subscription)
subscription
- The subscription which will removed.public java.util.List<ProcedureManager.Subscription> getSubscriptions()
public void subscribe(ProcedureManager.Subscription subscription)
ProcedureManager.Subscription
as global, for this context.subscription
- The subscription to register.