one.toys
Class RemoteCounter

java.lang.Object
  |
  +--one.world.core.Component
        |
        +--one.gui.Application
              |
              +--one.toys.RemoteCounter
All Implemented Interfaces:
Serializable

public final class RemoteCounter
extends Application

Implementation of a resettable, synchronizable counter.

Usage:

    RemoteCounter
 

Imported and Exported Event Handlers

Exported event handlers:

main
Handles environment events, linked to an environment's main imported event handler.

Imported event handlers:

request
Handles environment events and REP requests, linked to an environment's request exported event handler.

Version:
$Revision: 1.12 $
See Also:
Serialized Form

Inner classes inherited from class one.gui.Application
Application.Window
 
Inner classes inherited from class one.world.core.Component
Component.HandlerReference, Component.Importer
 
Field Summary
protected  int count
          The counter value.
protected  Timer.Notification countUpdate
          The count update timer notification.
protected  String host
          The host name of the remote counter to synchronize with.
protected  LeaseMaintainer leaseMaintainer
          A lease maintainer for the exported synchronization request handler.
protected  String name
          The name of the remote counter to synchronize with.
protected  int port
          The port number of the remote counter to synchronize with.
protected  RemoteReference syncReference
          The remote reference for the exported synchronization request handler.
protected  EventHandler syncRequestHandler
          The synchronization request handler.
protected  EventHandler updateHandler
          The count update handler.
 
Fields inherited from class one.gui.Application
ACTIVATING, ACTIVE, appName, height, INACTIVE, locationX, locationY, lock, main, mainWindow, operation, request, status, timer, width
 
Constructor Summary
RemoteCounter(Environment env)
          Create a new instance of RemoteCounter.
 
Method Summary
 void acquire()
          Acquire the resources needed by the remote counter application.
 void cancelUpdateTimer()
          Cancel the count update notifications.
 Application.Window createMainWindow()
          Create the remote counter's main window.
static void init(Environment env, Object closure)
          Initialize the remote counter..
 void release()
          Release the resources used by the remote counter application.
 void setCount(int newCount)
          Sets the count to the specified value.
 void setRemoteCounter(String host, int port, String name)
          Sets the host, port, and name fields.
 void setUpdateTimer()
          Set up the timed count update notification.
 void synchronize()
          Synchronizes this counter with the remote counter given by the host, port, and name fields.
 
Methods inherited from class one.gui.Application
createMainHandler, getDescriptor, signalError, start, stop
 
Methods inherited from class one.world.core.Component
declareExported, declareImported, equals, eventHandlers, getDescriptor, getEnvironment, getLinkedHandlers, getLinkedNumber, getTimer, hasEventHandler, hashCode, isFullyLinked, isLinked, isSealed, link, link, run, seal, unbox, undeclare, unlink, wrap
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

updateHandler

protected final EventHandler updateHandler
The count update handler.

syncRequestHandler

protected final EventHandler syncRequestHandler
The synchronization request handler.

count

protected int count
The counter value.

host

protected String host
The host name of the remote counter to synchronize with.

port

protected int port
The port number of the remote counter to synchronize with.

name

protected String name
The name of the remote counter to synchronize with.

countUpdate

protected Timer.Notification countUpdate
The count update timer notification.

syncReference

protected transient RemoteReference syncReference
The remote reference for the exported synchronization request handler. This is transient because it is the result of a local binding.

leaseMaintainer

protected transient LeaseMaintainer leaseMaintainer
A lease maintainer for the exported synchronization request handler. This is transient because it contains state related to a local binding.
Constructor Detail

RemoteCounter

public RemoteCounter(Environment env)
Create a new instance of RemoteCounter.
Parameters:
env - The environment for the new instance.
Method Detail

acquire

public void acquire()
Acquire the resources needed by the remote counter application.
Overrides:
acquire in class Application

release

public void release()
Release the resources used by the remote counter application.
Overrides:
release in class Application

setUpdateTimer

public void setUpdateTimer()
Set up the timed count update notification.

cancelUpdateTimer

public void cancelUpdateTimer()
Cancel the count update notifications.

createMainWindow

public Application.Window createMainWindow()
Create the remote counter's main window.
Overrides:
createMainWindow in class Application
Following copied from class: one.gui.Application
Returns:
The application's main window, or null if the application does not have a main window.

setCount

public void setCount(int newCount)
Sets the count to the specified value.
Parameters:
count - The new count value.

setRemoteCounter

public void setRemoteCounter(String host,
                             int port,
                             String name)
Sets the host, port, and name fields.
Parameters:
host - The new remote host name.
port - The new remote port number.
name - The new remote counter name.

synchronize

public void synchronize()
Synchronizes this counter with the remote counter given by the host, port, and name fields.

init

public static void init(Environment env,
                        Object closure)
Initialize the remote counter..
Parameters:
env - The environment.
closure - The closure.
Throws:
IllegalArgumentException - Signals that the closure is not a string array or a string array with illegal arguments.


(C) Copyright 2001 UW CSE