ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.able.examples.ablebean
Class SimpleAbleApp

java.lang.Object
  |
  +--com.ibm.able.examples.ablebean.SimpleAbleApp
All Implemented Interfaces:
AbleEventListener, java.util.EventListener, java.beans.PropertyChangeListener

public class SimpleAbleApp
extends java.lang.Object
implements AbleEventListener, java.beans.PropertyChangeListener

This class provides an application for the SimpleAbleBean. On a timed interval, a value is received and passed to the SimpleAbleBean for processing. It uses the the SimpleAbleAgent to generate these timed events and the data to be processed.

The SimpleAbleAgent generates events on a timer interval. When its timer expires, it updates an instance variable and puts the new value in its outputBuffer. It then sends a datachanged event. This SimpleAbleApp class listens for events sent by the SimpleAbleAgent so that it can trace activity.

When SimpleAbleApp receives any dataChanged event, it prints out the classname of the source of the event and the value of the event argument object. If the event was sent by its instance of the SimpleAbleAgent, it calls process on its SimpleAbleBean object.

SimpleAbleApp also listens for PropertyChangeEvents sent by its SimpleAbleBean object. The property and value of these events are simply written to the console as proof that the SimpleAbleBean's instance variable now matches the value provided from the SimpleAbleAgent.

All processing and events are handled on the thread owned by the SimpleAbleAgent's event queue processor. The thread running main in this class only creates the objects and starts that thread running. It ends the event queue processor thread after a finite interval.

Here is a summary of data flow processing:

  • SimpleAbleAgent is configured to create an AbleEvent every n seconds and call its process method at the end of the interval. The process method populates the buffer and sends a dataChanged event.
  • SimpleAbleApp listens for dataChanged events from the SimpleAbleAgent and calls the process method on the SimpleAbleBean on receipt.
  • SimpleAbleBean's process method takes the value from its inputBuffer and uses it to change a property. This sends a propertyChange event to registered listeners.
  • SimpleAbleApp listens for propertyChange events from the SimpleAbleBean and displays the old and new values for the property.


    Method Summary
    static java.lang.String Copyright()
              Determine the copyright of this class.
    protected static java.lang.String displayBuffer(java.lang.Object obj)
              Convert an objects to a string.
    protected static java.lang.String displayBuffer(java.lang.Object[] buf)
              Convert an array of objects to a string delimited by a blank and a newline.
     void handleAbleEvent(AbleEvent e)
              Process an Able event.
    static void main(java.lang.String[] args)
               
     void processAbleEvent(AbleEvent e)
              Display changes when agent modifies its output buffer.
     void propertyChange(java.beans.PropertyChangeEvent e)
              Handle a property change event.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Method Detail

    main

    public static void main(java.lang.String[] args)

    displayBuffer

    protected static java.lang.String displayBuffer(java.lang.Object[] buf)
    Convert an array of objects to a string delimited by a blank and a newline.

    displayBuffer

    protected static java.lang.String displayBuffer(java.lang.Object obj)
    Convert an objects to a string. If an array, convert to string of objects delimited by a blank and a newline.

    processAbleEvent

    public void processAbleEvent(AbleEvent e)
                          throws AbleException
    Display changes when agent modifies its output buffer.

    handleAbleEvent

    public void handleAbleEvent(AbleEvent e)
                         throws AbleException
    Process an Able event. Required by AbleEventListener interface.
    Specified by:
    handleAbleEvent in interface AbleEventListener
    Following copied from interface: com.ibm.able.AbleEventListener
    Parameters:
    theAbleEvent - The event to handle.
    Throws:
    AbleException - If an error occurs.

    propertyChange

    public void propertyChange(java.beans.PropertyChangeEvent e)
    Handle a property change event. Required by AbleEventListener interface. This implementation just displays the property name and its old and new values.
    Specified by:
    propertyChange in interface java.beans.PropertyChangeListener

    Copyright

    public static java.lang.String Copyright()
    Determine the copyright of this class.
    Returns:
    A String containing this class's copyright statement.


    ABLE 2.0.0 07/02/2003 10:25:01

    (C) Copyright IBM Corporation 1999, 2003