Apple WebObjects 3.5 Manual de usuario Pagina 47

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 218
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 46
Initialization and Deallocation Methods
47
- awake {
/* initializations go here */
}
public void awake () {
/* initializations go here. */
}
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
For example, the Visitors application has this
init method in Application.wos:
// WebScript Visitors Application.wos
- init {
[super init];
lastVisitor = @"";
[self setTimeOut:7200];
return self;
}
// Java Visitors Application.java
public Application () {
super();
...
lastVisitor = "";
setTimeOut(7200);
...
}
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.
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”
(page 109).
The application’s
awake method is invoked at the start of every cycle of the
request-response loop. Therefore, in the
awake method, you perform
anything that should happen before each and every user request is
processed. For example, the DodgeDemo example application keeps track
of the number of requests the application has received. It increments and
logs that number at the top of the request-response loop:
Vista de pagina 46
1 2 ... 42 43 44 45 46 47 48 49 50 51 52 ... 217 218

Comentarios a estos manuales

Sin comentarios