org.ocap.system.event

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package org.ocap.system.event

The org.ocap.system.event package defines various system events.

See:
Description

Interface Summary
SystemEventListener | System event handler implemented by a trusted application and registered with `SystemEventManager`.

Class Summary
DeferredDownloadEvent | This class represents an event returned by the system when a deferred download is instigated by the receipt of a code version table with download_command = 0x01 (see [CCIF 2.0]).
ErrorEvent | This class represents an event returned by the system when an uncaught exception or implementation error is encountered, or by an application that wishes to log an error or an informational event.
RebootEvent | This class represents an event returned by the system when a reboot is instigated.
ResourceDepletionEvent | Event that indicates resources are low, and the system is about to destroy application(s) to attempt to correct this.
SystemEvent | This class is the basis for system event messages.
SystemEventManager | Registration mechanism for trusted applications to set the error handler.

## Package org.ocap.system.event Description

The org.ocap.system.event package defines various system events.

Following is a Java example demonstrating how an application can register to be the error event handler:

public class EventListenerAppSample implements SystemEventListener

{

private final static int MAX_EVENT_STORE = 5;

private static int eventCount = 0;

private SystemEvent[] imeStore = new SystemEvent[MAX_EVENT_STORE];

/**

* The zero argument constructor demonstrates a possible application example where

* the application registers to receive error events.

*/

public EventListenerAppSample()

{

// Get the system event manager.

SystemEventManager sem = SystemEventManager.getInstance();

// Set this object as the new error event listener.

sem.setEventListener(SystemEventManager.ERROR_EVENT_LISTENER, this);

}

/**

* Receives a message event from the implementation. This method will be used to process

* all of the error and informational messages sent to this registered error listener.

*

* This sample simply places the messages into an array. Additional processing is

* specific to the application. For example, an application may look at the error code

* and application identifier of the event and take recovery action for specific errors,

* in which case it would return null. The application may return non-null indicating that

* it has changed the event.

*

* @param see Event generated by the system or sent by an application.

*/

public void notifyEvent(SystemEvent me)

{

System.out.print("ErrorListenerAppSample.notifyEvent(); event type: ");

System.out.print(me.getTypeCode());

System.out.print("; date: ");

System.out.println(me.getDate());

eventCount = (eventCount == MAX_EVENT_STORE - 1) ? 0 : eventCount + 1;

imeStore[eventCount] = me; // Store the event for later retrieval.

}

}

Following is a Java example demonstrating how an application can log an error:

import org.ocap.event.*;

public class EventSenderSample

{

/** Our application-specific error code. */

private static final int ID_FOR_APP_SAMPLE = SystemEvent.BEGIN_APP_REC_ERROR_TYPES + 42;

public static void sendTestErrorEvent() {

// Create an error event.

ErrorEvent ee = new ErrorEvent(ID_FOR_APP_SAMPLE, "TestEvent");

// Get the default system event logger.

SystemEventManager sem = SystemEventManager.getInstance();

// Log an error to the default system error handler.

sem.log(ee);

}

}

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES