|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rioproject.event.BasicEventConsumer
public class BasicEventConsumer
The BasicEventConsumer is a helper class that manages the
discovery of EventProducer instances that provide support for
user defined events. The BasicEventConsumer is to be used as a
local (within a JVM) utility, managing the discovery, event registration and
leasing of EventRegistration objects on behalf of
client(s). In this manner, clients wishing to easily register (subscribe) for the
notification of an event in the distributed system need not be overly
concerned with the underlying semantics and management of event
registrations, leases and events.
| Field Summary | |
|---|---|
static int |
DEFAULT_LEASE_DURATION
Default Lease duration is 5 minutes |
protected EventDescriptor |
edTemplate
|
protected long |
ektime
|
protected Map<Long,EventRegistration> |
eventRegistrationTable
|
protected List<RemoteServiceEventListener> |
eventSubscribers
|
protected MarshalledObject |
handback
|
protected long |
leaseDuration
|
protected Hashtable<ServiceID,org.rioproject.event.BasicEventConsumer.EventLeaseManager> |
leaseTable
|
protected int |
received
|
static String |
RESPONSE_WATCH
|
protected StopWatch |
responseWatch
|
protected long |
sktime
|
protected WatchDataSourceRegistry |
watchRegistry
|
| Constructor Summary | |
|---|---|
BasicEventConsumer(EventDescriptor edTemplate)
Create a BasicEventConsumer with an EventDescriptor |
|
BasicEventConsumer(EventDescriptor edTemplate,
Configuration config)
Create a BasicEventConsumer with an EventDescriptor |
|
BasicEventConsumer(EventDescriptor edTemplate,
RemoteServiceEventListener listener)
Create a BasicEventConsumer with an EventDescriptor and a RemoteServiceEventListener |
|
BasicEventConsumer(EventDescriptor edTemplate,
RemoteServiceEventListener listener,
Configuration config)
Create a BasicEventConsumer with an EventDescriptor and a RemoteServiceEventListener |
|
BasicEventConsumer(EventDescriptor edTemplate,
RemoteServiceEventListener listener,
MarshalledObject handback,
Configuration config)
Create a BasicEventConsumer with an EventDescriptor, a RemoteServiceEventListener, and a MarshalledObject to be used as a handback |
|
BasicEventConsumer(RemoteServiceEventListener listener)
Create a BasicEventConsumer with a RemoteServiceEventListener |
|
| Method Summary | |
|---|---|
void |
createWatch(WatchDataSourceRegistry watchRegistry)
Create a response time watch for this EventConsumer, which will track the response time for event consumers, measured by how long the response time takes |
boolean |
deregister(RemoteServiceEventListener listener)
De-registers a registered RemoteServiceEventListener from this EventConsumer |
void |
deregister(ServiceID serviceID)
This method handles the cleanup for removing a registration from a EventProducer instance |
void |
deregister(ServiceID serviceID,
boolean disconnect)
This method handles the cleanup for removing a registration from a EventProducer instance |
void |
destroyWatch()
Destroys the response time watch. |
protected void |
finalize()
Override finalize to ensure we unexport ourselves. |
protected EventDescriptor |
getDescriptor(Entry[] attrs,
EventDescriptor template)
Method to return a matching EventDescriptor from a service's set of attributes |
Object |
getEventRegistrationSource(long eventID)
Returns the source object of an EventRegistration given an event ID |
protected RemoteServiceEventListener[] |
getListeners()
Get all registered RemoteServiceEventListeners |
TrustVerifier |
getProxyVerifier()
Returns a TrustVerifier which can be used to verify
that a given proxy to this event consumer can be trusted |
Watch |
getWatch()
Get the response time watch for this EventConsumer |
void |
notify(RemoteEvent rEvent)
Remote event notification. |
protected void |
printStats()
Convenience method to print statistics for every thousand events sent. |
EventRegistration |
register(EventProducer eventProducer,
EventDescriptor eventDesc,
ServiceID serviceID)
Register for notification of event from an EventProducer. |
boolean |
register(RemoteServiceEventListener listener)
Register a RemoteServiceEventListener to this EventConsumer. |
boolean |
register(RemoteServiceEventListener listener,
MarshalledObject handback)
Register a RemoteServiceEventListener to this EventConsumer with a MarshalledObject handback object. |
EventRegistration |
register(ServiceItem item)
Given a ServiceItem this method checks to see if the ServiceItem contains a proxy of type EventProducer, performs event registration and ensures the Lease contained in the event registration is managed by a LeaseRenewalManager |
void |
terminate()
The terminate method will de-register for event notifications across all discovered EventProducer instances. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final List<RemoteServiceEventListener> eventSubscribers
protected final Hashtable<ServiceID,org.rioproject.event.BasicEventConsumer.EventLeaseManager> leaseTable
protected final Map<Long,EventRegistration> eventRegistrationTable
protected EventDescriptor edTemplate
protected int received
protected long sktime
protected long ektime
protected MarshalledObject handback
public static final int DEFAULT_LEASE_DURATION
protected long leaseDuration
protected StopWatch responseWatch
protected WatchDataSourceRegistry watchRegistry
public static final String RESPONSE_WATCH
| Constructor Detail |
|---|
public BasicEventConsumer(EventDescriptor edTemplate)
throws Exception
edTemplate - The EventDescriptor template
Exception - If the BasicEventConsumer cannot be created
public BasicEventConsumer(RemoteServiceEventListener listener)
throws Exception
listener - The RemoteServiceEventListener
Exception - If the BasicEventConsumer cannot be created
public BasicEventConsumer(EventDescriptor edTemplate,
Configuration config)
throws Exception
edTemplate - The EventDescriptor templateconfig - Configuration object
Exception - If the BasicEventConsumer cannot be created
public BasicEventConsumer(EventDescriptor edTemplate,
RemoteServiceEventListener listener)
throws Exception
edTemplate - The EventDescriptor templatelistener - The RemoteServiceEventListener
Exception - If the BasicEventConsumer cannot be created
public BasicEventConsumer(EventDescriptor edTemplate,
RemoteServiceEventListener listener,
Configuration config)
throws Exception
edTemplate - The EventDescriptor templatelistener - The RemoteServiceEventListenerconfig - Configuration object
Exception - If the BasicEventConsumer cannot be created
public BasicEventConsumer(EventDescriptor edTemplate,
RemoteServiceEventListener listener,
MarshalledObject handback,
Configuration config)
throws Exception
edTemplate - The EventDescriptor templatelistener - The RemoteServiceEventListenerhandback - The MarshalledObject to be used as a handbackconfig - Configuration object
Exception - If the BasicEventConsumer cannot be created| Method Detail |
|---|
public void terminate()
terminate in interface EventConsumerpublic boolean register(RemoteServiceEventListener listener)
register in interface EventConsumerlistener - The RemoteServiceEventListener
public boolean register(RemoteServiceEventListener listener,
MarshalledObject handback)
register in interface EventConsumerlistener - The RemoteServiceEventListenerhandback - The MarshalledObject to be used as a handback
public boolean deregister(RemoteServiceEventListener listener)
deregister in interface EventConsumerlistener - The RemoteServiceEventListener
public void createWatch(WatchDataSourceRegistry watchRegistry)
watchRegistry - The WatchDataSourceRegistry to register the watchpublic void destroyWatch()
public Watch getWatch()
public EventRegistration register(ServiceItem item)
item - The ServiceItem
EventRegistration, or null if the
service is not an EventProducer or the EventDescriptor
template the BasicEventConsumer was started with cannot be matched
NullPointerException - if the item parameter is null
public EventRegistration register(EventProducer eventProducer,
EventDescriptor eventDesc,
ServiceID serviceID)
EventProducer.
eventProducer - The EventProducer, must not be nulleventDesc - The EventDescriptor, must not be nullserviceID - The serviceID of the EventProducer to register
EventRegistration, or null if the
service is not an EventProducer or the EventDescriptor
template the BasicEventConsumer was started with cannot be matched
NullPointerException - if any og the parameters are nullpublic Object getEventRegistrationSource(long eventID)
getEventRegistrationSource in interface EventConsumereventID - The eventID
public void deregister(ServiceID serviceID)
serviceID - The serviceID of the EventProducer to deregister
NullPointerException - if the serviceID parameter is null
public void deregister(ServiceID serviceID,
boolean disconnect)
serviceID - The serviceID of the EventProducer to deregisterdisconnect - Whether to explicitly cancel the lease with the
EventProducer, or just let the least time out
NullPointerException - if the serviceID parameter is null
public void notify(RemoteEvent rEvent)
throws UnknownEventException
notify in interface RemoteEventListenerUnknownEventException - If the RemoteEvent cannot be downcast to a
RemoteServiceEventpublic TrustVerifier getProxyVerifier()
TrustVerifier which can be used to verify
that a given proxy to this event consumer can be trusted
getProxyVerifier in interface ServerProxyTrust
protected EventDescriptor getDescriptor(Entry[] attrs,
EventDescriptor template)
attrs - Array of attributestemplate - The EventDescriptor template
protected void printStats()
protected void finalize()
throws Throwable
finalize in class ObjectThrowableprotected RemoteServiceEventListener[] getListeners()
|
Copyright © Rio Project. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||