|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fulmine.event.subscription.Subscription
public class Subscription
The base implementation of a subscription.
Thread safe.
Field Summary |
---|
Fields inherited from interface fulmine.event.subscription.ISubscription |
---|
WILDCARD_DOMAIN, WILDCARD_ID_REGEX, WILDCARD_TYPE |
Constructor Summary | |
---|---|
protected |
Subscription(ISubscriptionParameters parameters)
Construct the subscription to match the subscription passed in. |
Method Summary | |
---|---|
boolean |
addListener(IEventListener listener)
Add the listener to the IEventListener instances associated with
this ISubscription . |
boolean |
addMatch(IEventSource source)
Add the event source as a matched reference. |
void |
destroy()
This is called when the object is being removed from application use. |
protected boolean |
doAddOperation(IEventSource source)
Template method for the operation to perform when a source match is added. |
protected boolean |
doRemoveOperation(IEventSource source)
Template method for the operation to perform when a source match is removed. |
boolean |
equals(Object obj)
|
String |
getAddress()
Get the unique address for this. |
IDomain |
getDomain()
Get the domain attribute of this object. |
String |
getIdentity()
Get the identification string for this entity. |
List<IEventListener> |
getListeners()
Get a copy of the internal List of all the
IEventListener instances used by the subscription to register
against the subscribed IEventSource instances. |
protected org.apache.commons.logging.Log |
getLog()
|
Collection<IEventSource> |
getMatches()
Get a copy of the internal Collection of all the
IEventSource instances referenced by this subscription. |
IType |
getType()
Get the type attribute of this object. |
int |
hashCode()
|
boolean |
includes(IAddressable parameters)
Determine if the IAddressable attributes of this parameters
instance would include those of another. |
boolean |
removeListener(IEventListener listener)
Remove the listener from the IEventListener instances associated
with this ISubscription . |
boolean |
removeMatch(ISubscriptionParameters parameters)
Remove the event source(s) identified by the parameters from this subscription's matched references. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected Subscription(ISubscriptionParameters parameters)
subscription
- the subscription subscription for thisMethod Detail |
---|
public final boolean addMatch(IEventSource source)
ISubscription
The source is only added if the subscription does not already contain the source as a match.
This is an idempotent operation.
addMatch
in interface ISubscription
source
- the event source
true
if the event source was added,
false
if the subscription already has the source as
a matched referencepublic final boolean removeMatch(ISubscriptionParameters parameters)
ISubscription
Note: if the parameters include wildcards, multiple event sources may be removed.
removeMatch
in interface ISubscription
parameters
- the subscription parameters identifying any matching event
sources to remove
true
if at least one event source was found and
removed, false
if no event source was found to
removepublic final Collection<IEventSource> getMatches()
ISubscription
Collection
of all the
IEventSource
instances referenced by this subscription. The order
of the collection elements is arbitrary.
getMatches
in interface ISubscription
IEventSource
instances referenced by this subscriptionpublic final List<IEventListener> getListeners()
ISubscription
List
of all the
IEventListener
instances used by the subscription to register
against the subscribed IEventSource
instances.
getListeners
in interface ISubscription
List
of all the listeners
that are registered against all subscribed IEventSource
instances. The order of the listeners is the order of calling
ISubscription.addListener(IEventListener)
.public final boolean addListener(IEventListener listener)
ISubscription
IEventListener
instances associated with
this ISubscription
. The subscription will register the listener
with any currently matched IEventSource
instances.
This is an idempotent operation.
addListener
in interface ISubscription
listener
- the listener to add to the subscription's list of listeners
true
if the listener was added, false
if it already existedpublic final boolean removeListener(IEventListener listener)
ISubscription
IEventListener
instances associated
with this ISubscription
. The subscription will remove the
listener from any currently matched IEventSource
instances.
This is an idempotent operation.
removeListener
in interface ISubscription
listener
- the listener to remove from the subscription's list of
listeners
true
if the listener was removed, false
if it was not foundpublic final IDomain getDomain()
IAddressable
getDomain
in interface IAddressable
IAddressable.getType()
public final String getIdentity()
IAddressable
getIdentity
in interface IAddressable
String
identity providing an identification for this
entity within its type and domain.IAddressable.getType()
,
IAddressable.getDomain()
public final IType getType()
IAddressable
getType
in interface IAddressable
IAddressable.getDomain()
public final String getAddress()
IAddressable
getAddress
in interface IAddressable
public final boolean includes(IAddressable parameters)
ISubscriptionParameters
IAddressable
attributes of this parameters
instance would include those of another. For this instance to include the
other, each attribute of this instance must be an exact match or a more
generalised match of corresponding attribute in the other.
For example, assuming the type and domain are equal, if this instance has the identity regular expression "foo.*" and the other instance has the identity "foo bar", then this instance effectively includes the other (it is more generalised). However, it would not include the other if the other instance has an identity regular expression ".*" as this is now more generalised than this instance.
includes
in interface ISubscriptionParameters
parameters
- the other IAddressable
instance to compare with this
true
if the attributes of this instance include
those of the otherpublic void destroy()
IDestroyable
This method must not throw a RuntimeException
.
destroy
in interface IDestroyable
protected boolean doAddOperation(IEventSource source)
source
- the source the operation applies to
true
if the operation did somethingprotected boolean doRemoveOperation(IEventSource source)
source
- the source the operation applies to
true
if the operation did somethingprotected org.apache.commons.logging.Log getLog()
public final String toString()
toString
in class Object
public final int hashCode()
hashCode
in class Object
public final boolean equals(Object obj)
equals
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |