Application Initialization
The application init method is invoked only once, when the application is launched. You perform two main tasks in the application's init method:
- Initialize application variables
- Configure applicationwide settings
// WebScript Visitors Application.wos - init { [super init]; lastVisitor = @""; [self setTimeOut:7200]; return self; } // Java Visitors Application.java public Application () { super(); ...This method begins by calling the application's init method. Then, it initializes the application variable lastVisitor to be the empty string. (The application has just started, so there has been no last visitor.) Finally, it sets the application to terminate after it has been running 2 hours.
lastVisitor = ""; setTimeOut(7200); ...
}
This example sets the application time-out value. You might want to do other configurations in the application object's init method as well. For example, you can control how pages and components are cached and how state is stored. For more information, read the chapter "Managing State".
// WebScript DodgeDemo Application.wos - awake { ++requestCount; [self logWithFormat:@"Now serving request %@", requestCount]; } // Java DodgeDemo Application.java public void awake() { ++requestCount; this.logString("Now serving request " + requestCount); }
Table of Contents Next Section