Previous Next Contents Index


IAppEvent interface (deprecated)

IAppEvent is deprecated and is provided for backward compatibility only. New applications should use the NAS API's two replacement interfaces: IAppEventMgr and IAppEventObj.

The IAppEvent interface represents the defined events an application supports. An AppLogic can define events that are triggered at a specified time or times or when triggered explicitly.

Currently, an AppLogic can execute two actions when an event is triggered:

Events are stored persistently in the Netscape Application Server, and are removed only when your application explicitly deletes them. They are typically used to schedule routine administrative tasks, such as making back-ups or getting statistics.

The IAppEvent interface defines methods for registering, triggering, enabling, disabling and deleting events. To create an instance of the IAppEvent interface, use the getAppEvent( ) method in the AppLogic class.

Package
com.kivasoft

Methods
Method
Description
deleteEvent( )
Removes a registered event from Netscape Application Server.
disableEvent( )
Disables a registered event.
enableEvent( )
Enables a registered event.
enumEvents( )
Enumerates through the list of registered events.
queryEvent( )
Returns the properties of a registered event.
registerEvent( )
Registers a named event for use in applications.
setEvent( )
Triggers a registered event.

Example
The following example shows AppLogic code that registers two application events:

Related Topics
getAppEvent( ) method in the AppLogic class

IAppEventMgr interface

IAppEventObj interface

IValList interface

deleteEvent( )
Removes a registered event from the Netscape Application Server.

Syntax
public int deleteEvent(
   String pEventName)

pEventName. The name of the registered event to delete.

Usage
Use deleteEvent( ) to remove an event that is no longer required. To temporarily stop a event from being triggered, use disableEvent( ).

Return Value
GXE.SUCCESS if the method succeeds.

Related Topics
disableEvent( )

registerEvent( )

disableEvent( )
Disables a registered event.

Syntax
public int disableEvent(
   String pEventName)

pEventName. The name of the registered event to disable.

Usage
Use disableEvent( ) to temporarily stop an event from being triggered. The event is disabled until it is enabled with enableEvent( ). To remove an event from the Netscape Application Server permanently, use deleteEvent( ).

Return Value
GXE.SUCCESS if the method succeeds.

Related Topics
deleteEvent( )

enableEvent( )

registerEvent( )

enableEvent( )
Enables a registered event.

Syntax
public int enableEvent(
   String pEventName)

pEventName. The name of the registered event to enable.

Usage
Use enableEvent( ) to prepare a specified event for activation. Call enableEvent( ) after you register an event with registerEvent( ), or to enable a trigger that was disabled with disableEvent( ).

Return Value
GXE.SUCCESS if the method succeeds.

Related Topics
disableEvent( )

registerEvent( )

enumEvents( )
Returns the list of registered events.

Syntax
public IEnumObject enumEvent()
Usage
Use enumEvents( ) to get information on all the registered events. The IEnumObject object returned by enumEvents( ) contains a set of IValList objects, one per event. Each IValList contains the properties assigned to the event when it was registered with registerEvent( ).

Tip
Use the methods in the IEnumObject interface to iterate through the contents of the returned IEnumObject object.

Example
The following AppLogic code shows how to use enumEvents( ) to get information on all the registered events and save it to a report:

// Open /tmp/report-file for writing the report

FileOutputStream outFile = null;
try {
outFile = new FileOutputStream("/tmp/report-file");
} catch (IOException e) {
}
if (outFile == null)
return streamResult("Can not open /tmp/report-file<br>");

ObjectOutputStream p = null;
try {
p = new ObjectOutputStream(outFile);
} catch (IOException e) {
}
if (p == null)
return streamResult("Cannot create ObjectOutputStream<br>");

// get appevent manager
IAppEvent appEvent = getAppEvent();

// Get the Enumeration object for all registered appevents
IEnumObject enumObj = appEvent.enumEvents();

// Retrieve the count of registered appevents
int count = enumObj.enumCount();
try {
p.writeObject("Number of Registered Events: ");
p.writeInt(count);
} catch (IOException e) {
return streamResult("Failed to write to report file<br>");
}

enumObj.enumReset(0);

while (count > 0) {
IObject vListObj = enumObj.enumNext();
if (vListObj instanceof IValList) {
IValList vList = (IValList)vListObj;

String name =
vList.getValString(GX_AE_RE_KEY_NAME.GX_AE_RE_KEY_NAME);
try {
p.writeObject("\nDefinitions for AppEvent: ");
p.writeObject(name);
p.writeObject("\n");
} catch (IOException e) {
return streamResult("Failed to write to report file<br>");
}

// Reset the next GXVAL to retrieve
// from ValList to be the first one
vList.resetPosition();

// Iterate through all the GXVALs in the vallist
// and print them
Return Value
IEnumObject that contains the list of events, or null for failure.

Related Topics
getAppEvent( ) method in the AppLogic class

IValList interface

queryEvent( )
Returns the properties of a registered event.

Syntax
public IValList queryEvent(
   String pEventName)

pEventName. The name of the registered event to enable.

Usage
When an AppLogic calls registerEvent( ), it can specify any of the following:

Use queryEvent( ) to get the properties that were specified for a specific event.

Return Value
IValList object that contains information about the event.

Related Topics
registerEvent( )

registerEvent( )
Registers a named event for use in applications.

Syntax
public int registerEvent(
   String pEventName,
   IValList pValList)

pEventName. The name of the event to register.

pValList. The IValList object that specifies the properties of the event. The following table lists the keys and values you can specify:

Key
Value
GX_AE_RE_KEY_NAME. GX_AE_RE_KEY_NAME
A string representing the name of the event. If specified, the name must be the same one specified as the pEventName parameter.
GX_AE_RE_KEY_STATE. GX_AE_RE_KEY_STATE
A variable that specifies the initial state of the event:
GX_AE_RE_ES_FLAG.GX_AE_RE_EVENT_
DISABLED

GX_AE_RE_ES_FLAG.GX_AE_RE_EVENT_
ENABLED


GX_AE_RE_KEY_TIME. GX_AE_RE_KEY_TIME
The time at which the event will be triggered. Use the following format:
hh:mm:ss W/DD/MM
hh: 0 -23
mm: 0 - 59
ss: 0 - 59
W (day of the week): 0 - 6 with 0 = Sunday.
DD (day of the month): 1 - 31
MM (month): 1 - 12
Each of these fields may be either an asterisk (meaning all legal values) or a list of elements separated by commas. An element is either a number or two numbers separated by a minus sign indicating an inclusive range. For example, 2, 5 - 7:0:0 5/*/* means the event is triggered at 2 AM, 5AM, 6 AM and 7 AM every Friday.
The specification of days can be made by two fields: day of the month (DD) and day of the week (W). If both are specified, both take effect. For example, 1:0:0 1/15/* means the event is triggered at 1 AM every Monday, as well as on the fifteenth of each month. To specify days by only one field, set the other field to *.
GX_AE_RE_KEY_NREQ. GX_AE_RE_KEY_NREQ
The AppLogic to execute when the event is triggered. Use the following format:
GUIDGX-{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX?Param1=ABC&Param2=123
GX_AE_RE_KEY_MFILE. GX_AE_RE_KEY_MFILE*
The name of the file that contains the body of an email message.
GX_AE_RE_KEY_MTO. GX_AE_RE_KEY_MTO*
A comma separated list of users to send the email to.
GX_AE_RE_KEY_MHOST. GX_AE_RE_KEY_MHOST*
The name of the SMTP mail server.
GX_AE_RE_KEY_SADDR. GX_AE_RE_KEY_SADDR*
The sender's email address.

* You must specify all of these items if sending email when the event is triggered.

Usage
Use registerEvent( ) to define each event your application will use. You can specify that a triggered event sends an email, or runs an AppLogic, or both.

Return Value
GXE.SUCCESS if the method succeeds.

Example
The following example shows how to define and register an application event:

static final java.lang.String eventName1 = "RepGenEvent";


// Get the appevent manager
IAppEvent appEvent = getAppEvent();

// Create IValList to pass information for
// registration of an event
IValList eventInput1 = GX.CreateValList();

// Add the RepGenAgent appevent name to the vallist
eventInput1.setValString(GX_AE_RE_KEY_NAME.GX_AE_RE_KEY_NAME, eventName1);

// Set the appevent state to be enabled
eventInput1.setValInt(GX_AE_RE_KEY_STATE.GX_AE_RE_KEY_STATE, GX_AE_RE_ES_FLAG.GX_AE_RE_EVENT_ENABLED);

// Set the appevent time to be 05:00:00 hrs everyday
eventInput1.setValString(GX_AE_RE_KEY_TIME.GX_AE_RE_KEY_TIME, "5:0:0 */*/*");

// Set the appevent action to run an AppLogic
eventInput1.setValString(GX_AE_RE_KEY_NREQ.GX_AE_RE_KEY_NREQ, "GUIDGX-{620CB09B-1A1D-1315-AD23-0800207B918B}");

// Register the event
if (appEvent.registerEvent(eventName1, eventInput1) != GXE.SUCCESS)
return streamResult("Cannot register RepGenEvent<br>");
Related Topics
enableEvent( )

setEvent( )

getAppEvent( ) method in the AppLogic class

IValList interface

setEvent( )
Triggers a registered event.

Syntax
public int setEvent(
   String pEventName,
   int dwOverrideFlag,
   IValList pValList)

pEventName. The name of the event to trigger.

dwOverrideFlag. Specify 0 (zero) to trigger the event with the previously specified actions. To override the defined actions, you can specify the following:

pValList. The IValList object that specifies the event properties you want to override. Specify null to use the properties already defined for the event. The following table lists the keys and values you can specify:

Key
Value
GX_AE_RE_KEY_NAME. GX_AE_RE_KEY_NAME
A string representing the name of the event. If specified, the name must be the same one specified as the pEventName parameter.
GX_AE_RE_KEY_STATE. GX_AE_RE_KEY_STATE
A variable that specifies the initial state of the event:
GX_AE_RE_ES_FLAG.GX_AE_RE_EVENT_DISABLED
GX_AE_RE_ES_FLAG.GX_AE_RE_EVENT_ENABLED
GX_AE_RE_KEY_TIME. GX_AE_RE_KEY_TIME
The time at which the event will be triggered. Use the following format:
hh:mm:ss W/DD/MM
hh: 0 -23
mm: 0 - 59
ss: 0 - 59
W (day of the week): 0 - 6 with 0 = Sunday.
DD (day of the month): 1 - 31
MM (month): 1 - 12
Each of these fields may be either an asterisk (meaning all legal values) or a list of elements separated by commas. An element is either a number or two numbers separated by a minus sign indicating an inclusive range. For example, 2, 5 - 7:0:0 5/*/* means the event is triggered at 2 AM, 5AM, 6 AM and 7 AM every Friday.
The specification of days can be made by two fields: day of the month (DD) and day of the week (W). If both are specified, both take effect. For example, 1:0:0 1/15/* means the event is triggered at 1 AM every Monday, as well as on the fifteenth of each month. To specify days by only one field, set the other field to *.
GX_AE_RE_KEY_NREQ. GX_AE_RE_KEY_NREQ
The AppLogic to execute when the event is triggered. Use the following format:
GUIDGX-{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX?Param1=ABC&Param2=123
GX_AE_RE_KEY_MFILE. GX_AE_RE_KEY_MFILE*
The name of the file that contains the body of an email message.
GX_AE_RE_KEY_MTO. GX_AE_RE_KEY_MTO*
A comma separated list of users to send the email to.
GX_AE_RE_KEY_MHOST. GX_AE_RE_KEY_MHOST*
The name of the SMTP mail server.
GX_AE_RE_KEY_SADDR. GX_AE_RE_KEY_SADDR*
The sender's email address.

* You must specify all of these items if sending email when the event is triggered.

Usage
Use setEvent( ) to trigger a registered event immediately. This is useful for testing purposes.

Return Value
GXE.SUCCESS if the method succeeds.

Related Topics
registerEvent( )

getAppEvent( ) method in the AppLogic class

IValList interface

 

© Copyright 1999 Netscape Communications Corp.