Documentation Archive Developer
Search
PATH Documentation > WebObjects

Table of Contents

WOStatisticsStore


Inherits from:
Object
Package:
com.webobjects.appserver


Class Description


The WOStatisticsStore object records statistics about a WebObjects application while that application runs. All WebObjects applications have a WOStatisticsStore object, which you can access by sending statisticsStore to the WOApplication object.


Recording Information

The WOStatisticsStore object records the bulk of its statistics at the end of each cycle of the request-response loop. Specifically, at the end of WOSession's appendToResponse method, the WOSession sends the recordStatisticsForResponse message to the WOStatisticsStore. This message tells the WOStatisticsStore to begin recording statistics. Then, WOSession sends it a descriptionForResponse message. This method sends the response component a descriptionForResponse message. The default implementation of descriptionForResponse in WOComponent returns the component's name.

You can override descriptionForResponse in each of your components if you want to record more information. For example, you might want to record the values of all of the component's variables or perhaps just one or two key variables.

If you want to record extra information about the session, you can override WOStatisticsStore's recordStatisticsForResponse method.


Maintaining a Log File

You can maintain an application log file by sending the message setLogFile to the WOStatisticsStore object. When a log file has been specified, each session records information in the log file about the pages it accessed.

The log is maintained in Common Log File Format (CLFF) so that it can be analyzed by any standard CLFF-analysis tool. (For more information about the statistics recorded in the log file, see the formatDescription method description.) If a log file has been specified, the WOSession object keeps its own statistics about which pages it has accessed. When the session terminates, it writes this information to the log file.




Method Types


Constructor
WOStatisticsStore
Recording information
applicationDidHandleComponentActionRequestWithPageNamed
applicationDidHandleDirectActionRequestWithActionNamed
applicationWillHandleComponentActionRequest
applicationWillHandleDirectActionRequest
recordStatisticsForResponse
descriptionForResponse
setSessionMovingAverageSampleSize
transactionMovingAverageSampleSize
Retrieving information
statistics
memoryUsage
Maintaining a CLFF log file
setLogFile
logFileRotationFrequencyInDays
logFile
Recording information in the CLFF log file
formatDescription
logString
Securing access to the WOStats page
setPassword
validateLogin


Constructors



WOStatisticsStore

protected WOStatisticsStore()

Returns an initialized WOStatisticsStore.


Instance Methods



applicationDidHandleComponentActionRequestWithPageNamed

public void applicationDidHandleComponentActionRequestWithPageNamed( String pageName)

A component action request handler should call this method at the appropriate time to register the fact that it just handled a component action request.

applicationDidHandleDirectActionRequestWithActionNamed

public void applicationDidHandleDirectActionRequestWithActionNamed( String anActionName)

A direct action request handler should call this method at the appropriate time to register the fact that it just handled a direct action request.

applicationWillHandleComponentActionRequest

public void applicationWillHandleComponentActionRequest()

A component action request handler should call this method at the appropriate time to register the fact that it is about to handle a component action request.

applicationWillHandleDirectActionRequest

public void applicationWillHandleDirectActionRequest()

A direct action request handler should call this method at the appropriate time to register the fact that it is about to handle a direct action request.

descriptionForResponse

public String descriptionForResponse( WOResponse aResponse, WOContext aContext)

Records information about the current response by sending the descriptionForResponse message to the response page and returning the result. This method is invoked at the end of the request-response loop in WOSession's appendToResponse method, after the recordStatisticsForResponse method.

formatDescription

public String formatDescription( String responseDescription, WOResponse aResponse, WOContext aContext)

If log file recording is enabled, this method formats the string responseDescription in using Common Log File Format (CLFF). The resulting string contains:

You enable log file recording by setting a log file using the setLogFile method.

This method is used by WOSession to record information about the current transaction when log file recording is enabled.

See Also: logFile, logString



logFile

public String logFile()

Returns the full path to the CLFF log file. This log file does not exist unless you send setLogFile to the WOStatisticsStore.

See Also: formatDescription, logFileRotationFrequencyInDays, logString



logFileRotationFrequencyInDays

public double logFileRotationFrequencyInDays()

The number of days a log file lasts. That is, a log file's contents are flushed after a certain time interval to ensure that it does not grow too large and a new log file is started. This method returns that time interval.

Before a new log file is started, the contents of the current log file are saved to a backup file. You can then inspect this log file and/or remove it when its data has grown stale.

See Also: setLogFile



logString

public void logString(String aString)

Writes the string aString to the CLFF log file specified by logFile. The method is used to record a session's statistics when that session ends. You can also use it to record any string to the log file that might be helpful to you.

See Also: formatDescription



memoryUsage

public NSMutableDictionary memoryUsage()

Returns an NSMutableDictionary that indicates the total amount of memory in the Java Virtual Machine (access this value using the dictionary key "Total Memory"), and an approximation of the amount of free memory in the system (access this value using the dictionary key "Free Memory"). Both values are measured in bytes. These values can be obtained directly from the java.lang.Runtime object by using the totalMemory() and freeMemory() methods, respectively.

recordStatisticsForResponse

public void recordStatisticsForResponse( WOResponse aResponse, WOContext aContext)

Records statistics for the current cycle of the request-response loop. This method is invoked at the end of WOSession's appendToResponse method, immediately before the descriptionForResponse method. By default, this method records the name of the response page for later use by descriptionForResponse. You can override it if you want to record more information about the session before the current request and response are deallocated. You must begin your implementation by invoking the superclass method.

sessionMovingAverageSampleSize

public int sessionMovingAverageSampleSize()

Returns the sample size used to compute moving average statistics for each session. The WOStatisticsStore object uses this sample size to compute the response time for the last n transactions and the idle time between the last n transactions, where n is the number returned by this method. The default sample size is 10.

See Also: setSessionMovingAverageSampleSize



setLogFile

public void setLogFile( String filePath, double logRotation)

Sets the full path of the log file to which CLFF statistics will be recorded to filePath. The logRotation argument specifies the number of days statistics will be recorded to this log file. Every logRotation days, the contents of the current log file are saved to a backup file and a new log file is started.

The default is not to record information to a log file.

See Also: logFile, logFileRotationFrequencyInDays



setPassword

public void setPassword(String aPassword)

Implements security for the WOStats page by setting its password to aPassword. By default, there is no password, so any user can access the WOStats page (provided they know the URL). If you implement this method, when you enter the WOStats URL, a login panel appears. You can leave the User name field blank; as long as you type the appropriate password in the password field, the WOStats page will appear.

See Also: validateLogin



setSessionMovingAverageSampleSize

public void setSessionMovingAverageSampleSize(int aSize)

Sets the moving average sample size for each session to aSize. The WOStatisticsStore object uses this sample size to compute the response time for the last aSize transactions and the idle time between the last aSize transactions.

The default moving average session sample size is 10 transactions.

See Also: sessionMovingAverageSampleSize



setTransactionMovingAverageSampleSize

public void setTransactionMovingAverageSampleSize(int aSize)

Sets the moving average sample size for each transaction to aSize. The WOStatisticsStore object uses this sample size to compute the response time for the last aSize transactions and the idle time between the last aSize transactions.

The default moving average transaction sample size is 100 transactions.

See Also: transactionMovingAverageSampleSize



statistics

public NSDictionary statistics()

Returns a dictionary containing the statistics that the WOStatisticsStore records.

The averages that are displayed by this method are not computed until this method is invoked. Therefore, invoking this method is costly and should not be done at every request.



transactionMovingAverageSampleSize

public int transactionMovingAverageSampleSize()

Returns the sample size used to compute moving average statistics for each transaction. The WOStatisticsStore object uses this sample size to compute the response time for the last n transactions and the idle time between the last n transactions, where n is the number returned by this method. The default sample size is 100.

See Also: setTransactionMovingAverageSampleSize



validateLogin

public boolean validateLogin( String string, WOSession aSession)

Returns true if string is the password set by setPassword, and false otherwise. The password controls if the user can see the WOStats page.

© 2001 Apple Computer, Inc. (Last Published April 15, 2001)


Table of Contents