|
WebObjects 5.2.3 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.appserver.WOStatisticsStore
This class holds various runtime statistics of an application.
There is only one instance of this class in an application, so access to all methods must be thread-safe. If at all possible, use "volatile" instead of synchronization to avoid scalability issues here.
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 also 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 the components if
the user wants 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 the user want to record extra information about the session, the user can
override WOStatisticsStore's recordStatisticsForResponse
method.
setLogFile
to the WOStatisticsStore object.
When a log file has been specified, each session keeps information
about the previous requests, and pages, it has served. When the session expires,
it writes this aggregated information to the log file all at once. This is faster
than recording the information on a per request basis in the log file, but it has
the disadvantage that if an application crashes, all non-expired sessions' information
will be lost.
The session information is saved as several lines
in the Common Log File Format (CLFF), one line per request served.
The log is maintained in the CLFF format 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.).
recordStatisticsForResponse(WOResponse, WOContext)
,
descriptionForResponse(WOResponse, WOContext)
,
setLogFile(String, long)
,
formatDescription(String, WOResponse, WOContext)
Nested Class Summary |
Nested classes inherited from class com.webobjects.foundation.NSKeyValueCoding |
NSKeyValueCoding.DefaultImplementation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.Utility, NSKeyValueCoding.ValueAccessor |
Nested classes inherited from class com.webobjects.foundation.NSKeyValueCodingAdditions |
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility |
Field Summary |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding |
NullValue |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
KeyPathSeparator |
Constructor Summary | |
protected |
WOStatisticsStore()
Returns an initialized WOStatisticsStore. |
Method Summary | |
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. |
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. |
void |
applicationDidHandleWebServiceRequestWithActionNamed(String anActionName)
A web service request handler should call this method at the appropriate time to register the fact that it just handled a web service request. |
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. |
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. |
void |
applicationWillHandleWebServiceRequest()
A web service request handler should call this method at the appropriate time to register the fact that it is about to handle a web service request. |
static boolean |
canAccessFieldsDirectly()
WOStatisticsStore's implementation of this static method returns true, indicating that key-value coding is allowed to access fields in this object if an appropriate method isn't present. |
String |
descriptionForResponse(WOResponse aResponse,
WOContext aContext)
Records information about the current response by invoking descriptionForResponse on the current response page and
returning the result. |
String |
formatDescription(String statistics,
WOResponse aResponse,
WOContext aContext)
If log file recording is enabled, this method formats the string statistics using the Common Log File Format (CLFF). |
Object |
handleQueryWithUnboundKey(String key)
Conformance to NSKeyValueCoding.ErrorHandling. |
void |
handleTakeValueForUnboundKey(Object value,
String key)
Conformance to NSKeyValueCoding.ErrorHandling. |
String |
logFile()
Gets the full path of the log file. |
long |
logFileRotationFrequency()
The number of milliseconds a log file lasts. |
double |
logFileRotationFrequencyInDays()
Deprecated. Use logFileRotationFrequency() instead. |
void |
logString(String statistics)
Writes the string statistics to the log file specified
by logFile . |
NSMutableDictionary |
memoryUsage()
Gets 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" ). |
void |
recordStatisticsForResponse(WOResponse aResponse,
WOContext aContext)
Records statistics for the current cycle of the request-response loop. |
int |
sessionMovingAverageSampleSize()
The WOStatisticsStore object uses the returned 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. |
void |
setLogFile(String path,
double days)
Deprecated. Use setLogFile(String path, long milliseconds) instead |
void |
setLogFile(String path,
long milliseconds)
Sets the full path of the log file to which statistics will be recorded; these statistics will be in Common Log File Format (CLFF). |
void |
setPassword(String password)
Implements security for the WOStats page by setting its password to password . |
void |
setSessionMovingAverageSampleSize(int aCount)
Sets the moving average sample size for each session to aCount . |
void |
setTransactionMovingAverageSampleSize(int aCount)
Sets the moving average sample size for each transaction to aCount . |
NSDictionary |
statistics()
Gets a dictionary containing the statistics that the WOStatisticsStore records. |
void |
takeValueForKey(Object value,
String key)
Conformance to NSKeyValueCoding. |
void |
takeValueForKeyPath(Object value,
String keyPath)
Conformance to NSKeyValueCodingAdditions. |
int |
transactionMovingAverageSampleSize()
The WOStatisticsStore object uses the returned 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. |
void |
unableToSetNullForKey(String key)
Conformance to NSKeyValueCoding.ErrorHandling. |
boolean |
validateLogin(String string,
WOSession aSession)
Validates if the password string is correct so as to allow
viewing of the application's statistics. |
Object |
valueForKey(String key)
Conformance to NSKeyValueCoding. |
Object |
valueForKeyPath(String keyPath)
Conformance to NSKeyValueCodingAdditions. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected WOStatisticsStore()
Method Detail |
public void applicationDidHandleComponentActionRequestWithPageNamed(String pageName)
pageName
- input page namepublic void applicationDidHandleDirectActionRequestWithActionNamed(String anActionName)
anActionName
- the direct action namepublic void applicationDidHandleWebServiceRequestWithActionNamed(String anActionName)
anActionName
- the web service namepublic void applicationWillHandleComponentActionRequest()
public void applicationWillHandleDirectActionRequest()
public void applicationWillHandleWebServiceRequest()
public static boolean canAccessFieldsDirectly()
public String descriptionForResponse(WOResponse aResponse, WOContext aContext)
descriptionForResponse
on the current 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.
aResponse
- the current WOResponse to be describedaContext
- the WebObjects context in which the current response page resides
recordStatisticsForResponse(WOResponse, WOContext)
,
WOSession.appendToResponse(WOResponse, WOContext)
,
WOComponent.descriptionForResponse(WOResponse, WOContext)
public String formatDescription(String statistics, WOResponse aResponse, WOContext aContext)
statistics
using the Common Log File Format (CLFF). The
resulting string contains:
descriptionForResponse
method (by default,
this method returns the response component's name)
Log file recording is enabled 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.
statistics
- the description string to be formattedaResponse
- the current WOResponse to be describedaContext
- the current WebObjects context
descriptionForResponse(WOResponse, WOContext)
,
setLogFile(String, long)
public Object handleQueryWithUnboundKey(String key)
handleQueryWithUnboundKey
in interface NSKeyValueCoding.ErrorHandling
key
- NSKeyValueCoding.valueForKey(java.lang.String)
,
NSKeyValueCoding.UnknownKeyException
,
NSKeyValueCoding.DefaultImplementation
public void handleTakeValueForUnboundKey(Object value, String key)
handleTakeValueForUnboundKey
in interface NSKeyValueCoding.ErrorHandling
value
- key
- NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCoding.UnknownKeyException
,
NSKeyValueCoding.DefaultImplementation
public String logFile()
setLogFile
has been called.
setLogFile(String, long)
public long logFileRotationFrequency()
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 removed when its data has grown stale.
setLogFile(String, long)
public double logFileRotationFrequencyInDays()
logFileRotationFrequency()
public void logString(String statistics)
statistics
to the 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 you might find helpful.
statistics
- the input string giving the details of the sessionformatDescription(String, WOResponse, WOContext)
,
setLogFile(String, long)
public NSMutableDictionary memoryUsage()
"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.
public void recordStatisticsForResponse(WOResponse aResponse, WOContext aContext)
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 garbage collected. You must begin your implementation
by invoking the superclass method.
aResponse
- the response to be appendedaContext
- the WebObjects context in which the response will be
appendeddescriptionForResponse(WOResponse, WOContext)
,
WOSession.appendToResponse(WOResponse, WOContext)
public int sessionMovingAverageSampleSize()
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.
setSessionMovingAverageSampleSize(int)
public void setLogFile(String path, long milliseconds)
The default is not to record information to a log file.
path
- full path of the log filemilliseconds
- the log rotation period in millisecondslogFileRotationFrequency()
,
logFile()
public void setLogFile(String path, double days)
path
- full path of the log filedays
- specifies the log rotation period in dayssetLogFile(String, long)
public void setPassword(String password)
password
. By default, there is no password, and
access to the WOStats page is disabled. You can call this method to set
the access password or you can set the password in the Java system
properties through the property key "WOStatisticsPassword"
.
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.
password
- password for WOStats page is set to this valuevalidateLogin(String, WOSession)
,
NSProperties
public void setSessionMovingAverageSampleSize(int aCount)
aCount
.
The WOStatisticsStore object uses this sample size to compute the
response time for the last aCount
transactions and the idle time
between the last aCount
transactions.
The default moving average session sample size is 10 transactions.
aCount
- the moving average size per session is set to this valuesessionMovingAverageSampleSize()
public void setTransactionMovingAverageSampleSize(int aCount)
aCount
.
The WOStatisticsStore object uses this sample size to compute the
response time for the last aCount
transactions and the idle time
between the last aCount
transactions.
The default moving average transaction sample size is 100 transactions.
aCount
- the moving average size per transaction is set to this valuetransactionMovingAverageSampleSize()
public NSDictionary statistics()
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.
public void takeValueForKey(Object value, String key)
takeValueForKey
in interface NSKeyValueCoding
key
- identifies the property to be setvalue
- the value to which the property specified by key
should be setNSKeyValueCoding.NullValue
,
NSKeyValueCoding.valueForKey(java.lang.String)
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.ErrorHandling.handleTakeValueForUnboundKey(java.lang.Object, java.lang.String)
public void takeValueForKeyPath(Object value, String keyPath)
takeValueForKeyPath
in interface NSKeyValueCodingAdditions
keyPath
- identifies a derived property of the receivervalue
- value to which the derived property identified by
keyPath
will be setNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
public int transactionMovingAverageSampleSize()
setTransactionMovingAverageSampleSize(int)
public void unableToSetNullForKey(String key)
unableToSetNullForKey
in interface NSKeyValueCoding.ErrorHandling
key
- NSKeyValueCoding.takeValueForKey(Object value, String key)
,
NSKeyValueCoding.DefaultImplementation
public boolean validateLogin(String string, WOSession aSession)
string
is correct so as to allow
viewing of the application's statistics.
string
- the password to be validatedaSession
- the current WOSession for viewing statistics
true
if validation is done correctly;
false
otherwisesetPassword(String password)
public Object valueForKey(String key)
valueForKey
in interface NSKeyValueCoding
key
- identifies the property of an object
key
NSKeyValueCoding.NullValue
,
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.ErrorHandling.handleQueryWithUnboundKey(java.lang.String)
public Object valueForKeyPath(String keyPath)
valueForKeyPath
in interface NSKeyValueCodingAdditions
keyPath
- identifies the derived property of an object
keyPath
NSKeyValueCoding.valueForKey(java.lang.String)
,
NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
|
Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |