Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jini.rio.event
Class EventHandler

    java.lang.Object
      org.jini.rio.event.EventHandler

Direct Known Subclasses:
  DispatchEventHandler, RoundRobinEventHandler

    public abstract class EventHandler

extends Object

The EventHandler is an abstract class which handles the basic event plumbing. The EventHandler sets up a LandLordLessor for the event type and creates leased event registrations for event registrants

Nested Class Summary
`protected static class` | `EventHandler.EventRegistrationResource` Container class for event registration objects which are created and behave as the resource that is being leased and controlled by the ServiceResource

Field Summary
`protected EventDescriptor` | `descriptor`
`protected long` | `ektime`
`protected LandlordLessor` | `landlord`
`protected LeasedListManager` | `resourceMgr`
`static String` | `RESPONSE_WATCH`
`protected StopWatch` | `responseWatch`
`protected long` | `sendTime`
`protected int` | `sent`
`protected long` | `sequenceNumber` The sequence number is an increasing value that will act as a hint to the number of occurances of an event type.
`protected long` | `sktime`
`protected int` | `step`
`protected long` | `t0`
`protected long` | `t1`
`protected float` | `tmp`
`protected WatchDataSourceRegistry` | `watchRegistry`

Constructor Summary
`EventHandler(EventDescriptor descriptor)` Use this constructor to create an EventHandler for a given EventDescriptor with a LandlordLessor created with default values used for LeasePeriodPolicy
`EventHandler(EventDescriptor descriptor, Configuration config)` Use this constructor to create an EventHandler for a given EventDescriptor with a LandlordLessor created with specific values used for LeaseDurationPolicy.

Method Summary
`void` | `createWatch(WatchDataSourceRegistry watchRegistry)` Create a response time watch for this EventHandler, which will track the response time for event consumers, measured by how long each fire() invocation takes
`void` | `destroyWatch()` Destroys the response time watch.
`abstract void` | `fire(RemoteServiceEvent event)` The fire method must be overridden by classes that extend this EventHandler, hence the reason the method is declared abstract.
`protected ServiceResource` | `getNextServiceResource()` Used to get the next `ServiceResource` from a `LandlordLessor`
`int` | `getRegistrantCount()` Gets the total number of ServiceResource instances contained by the LandlordLessor used by this EventHandler
`Watch` | `getWatch()` Get the response time watch for this EventHandler
`protected void` | `printStats()` Convenience method to print statisitics for every thousand events sent.
`EventRegistration` | `register(Object eventSource, RemoteEventListener listener, MarshalledObject handback, long duration)` Registers a RemoteEventListener for this event type.
`void` | `terminate()` Terminates this EventHandler.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### descriptor

    protected EventDescriptor descriptor

### landlord

    protected LandlordLessor landlord

### sent

    protected int sent

### sktime

    protected long sktime

### ektime

    protected long ektime

### tmp

    protected float tmp

### responseWatch

    protected StopWatch responseWatch

### watchRegistry

    protected WatchDataSourceRegistry watchRegistry

### resourceMgr

    protected LeasedListManager resourceMgr

### RESPONSE_WATCH

    public static final String RESPONSE_WATCH

See Also:
  Constant Field Values

### step

    protected int step

### t0

    protected long t0

### t1

    protected long t1

### sendTime

    protected long sendTime

### sequenceNumber

    protected long sequenceNumber

  The sequence number is an increasing value that will act as a hint to the number of occurances of an event type. The sequence number should differ if and only if the RemoteEvent objects are a response to different events. The sequence number should be increased only afetr an event has been sent

Constructor Detail

### EventHandler

    public EventHandler(EventDescriptor descriptor)
                 throws Exception

  Use this constructor to create an EventHandler for a given EventDescriptor with a LandlordLessor created with default values used for LeasePeriodPolicy

  Parameters:
    `descriptor` - EventDescriptor for the event to handle
  Throws:
    `Exception` - If a landlord lease manager cannot be created

### EventHandler

    public EventHandler(EventDescriptor descriptor,
                        Configuration config)
                 throws Exception

  Use this constructor to create an EventHandler for a given EventDescriptor with a LandlordLessor created with specific values used for LeaseDurationPolicy. If either of the values specified for the lease duration are null defaults will be used to create the LandlordLessor.

  Parameters:
    `descriptor` - EventDescriptor for the event to handle
    `config` - A Configuration object
  Throws:
    `Exception` - If a landlord lease manager cannot be created

Method Detail

### register

    public EventRegistration register(Object eventSource,
                                      RemoteEventListener listener,
                                      MarshalledObject handback,
                                      long duration)
                               throws LeaseDeniedException

  Registers a RemoteEventListener for this event type. This method will be delegated from the EventProducer#register method invocation

  Parameters:
    `eventSource` - The event source
    `listener` - RemoteEventListener
    `handback` - MarshalledObject
    `duration` - Requested EventRegistration lease
  Returns:
    EventRegistration
  Throws:
    `LeaseDeniedException` - If the lease manager denies the lease

### terminate

    public void terminate()

  Terminates this EventHandler. This causes all event registrant leases to be cancelled , and if any watches have been created those watches will be destroyed

### createWatch

    public void createWatch(WatchDataSourceRegistry watchRegistry)

  Create a response time watch for this EventHandler, which will track the response time for event consumers, measured by how long each fire() invocation takes

  Parameters:
    `watchRegistry` - The WatchRegistry to register the StopWatch

### destroyWatch

    public void destroyWatch()

  Destroys the response time watch. Once this method is called the watches will be rendered useless

### getWatch

    public Watch getWatch()

  Get the response time watch for this EventHandler

  Returns:
    The response time StopWatch. If the watch was not created this method returns null

### fire

    public abstract void fire(RemoteServiceEvent event)
                       throws NoEventConsumerException

  The fire method must be overridden by classes that extend this EventHandler, hence the reason the method is declared abstract.

  Parameters:
    `event` - The event to send
  Throws:
    `NoEventConsumerException` - This method may choose to throw a NoEventConsumerException if there are no event consumers registered

### getRegistrantCount

    public int getRegistrantCount()

  Gets the total number of ServiceResource instances contained by the LandlordLessor used by this EventHandler

  Returns:
    The registrant count

### getNextServiceResource

    protected ServiceResource getNextServiceResource()

  Used to get the next `ServiceResource` from a `LandlordLessor`

  Returns:
    The next `ServiceResource` contained by the `LandlordLessor`. If there are no `ServiceResource` instances available in the `LandlordLessor` then a value a null is returned

### printStats

    protected void printStats()

  Convenience method to print statisitics for every thousand events sent. This method will only print result if the `-Dorg.jini.rio.debug` flag is set

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © Project Rio.