Apple WebObjects 3.5 Manual de usuario Pagina 48

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 218
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 47
Chapter 3 Common Methods
48
// 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);
}
Session Initialization
A session object is created each time the application receives a request from a
new user. An application may have multiple sessions running concurrently. The
session ends when a session time-out value is reached.
In the session object’s
init method, you set the session’s time-out value and
initialize variables that should have unique values for each session. For example,
in the CyberWind application, each session keeps track of which number it is.
These values are changed in the session object’s
init method:
//From CyberWind Session.wos
- init {
[super init];
[self setTimeOut:120]; // session idle time is 2 minutes.
[[self application] setSessionCount:[[self application]
sessionCount + 1];
sessionNumber = [[self application] sessionCount];
return self;
}
//From CyberWindJava Session.java
public Session() {
super();
Application application = (Application)application();
this.setTimeOut(120);
application.setSessionCount(application.sessionCount() + 1);
sessionNumber = application.sessionCount();
}
The session object’s awake method is invoked each time the user associated with
the session makes a new request. After the application object has performed its
own
awake method, it restores the appropriate session object and sends it the
awake message too.
The CyberWind application keeps track of the number of requests per session.
It increments the number in the session’s
awake method.
- awake {
requestCount++;
}
Vista de pagina 47
1 2 ... 43 44 45 46 47 48 49 50 51 52 53 ... 217 218

Comentarios a estos manuales

Sin comentarios