javawebparts.context
Class ContextSize

java.lang.Object
  |
  +--javawebparts.context.ContextSize

public class ContextSize
extends java.lang.Object

This class provides a way to get the size of a servlet context object. This was suggested by Wendy Smoak.

Author:
Frank W. Zammetti.

Field Summary
private  javax.servlet.ServletContext context
          Reference to servlet context this object is associated with.
private  java.util.ArrayList failureReasons
          Collection of reasons why context size could not be determined.
private  boolean ignoreNonSerializable
          This flag determines if the context size will continue to be calculated even when a non-serializable objects are found.
 
Constructor Summary
ContextSize(javax.servlet.ServletContext inContext)
          constructor.
 
Method Summary
 int getContextSize()
          This method is used to get the total size of a current, valid ServletContext object it is passed.
 void setIgnoreNonSerializable(boolean inSetting)
          Mutator for the ignoreNonSerializable field.
 java.util.List whyFailed()
          When getContextSize() returns -1, this method can be called to retrieve the collection of reasons it failed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

private javax.servlet.ServletContext context
Reference to servlet context this object is associated with.


failureReasons

private java.util.ArrayList failureReasons
Collection of reasons why context size could not be determined.


ignoreNonSerializable

private boolean ignoreNonSerializable
This flag determines if the context size will continue to be calculated even when a non-serializable objects are found. This can be useful when you know your context won't pass this tests here but want a size, and understand it will always be an understated size, but don't care. This feature was suggested by Wendy Smoak.

Constructor Detail

ContextSize

public ContextSize(javax.servlet.ServletContext inContext)
constructor.

Parameters:
inContext - object this object will be associated with.
Method Detail

setIgnoreNonSerializable

public void setIgnoreNonSerializable(boolean inSetting)
Mutator for the ignoreNonSerializable field.

Parameters:
inSetting - True to calculate context size regardless of whether non-serializable objects are found in it, false otherwise (false is the default).

getContextSize

public int getContextSize()
This method is used to get the total size of a current, valid ServletContext object it is passed.

Returns:
The total size of context in bytes, or -1 if the size could not be determined.

whyFailed

public java.util.List whyFailed()
When getContextSize() returns -1, this method can be called to retrieve the collection of reasons it failed.

Returns:
Collection of failures why the context size could not be determiend.


Copyright 2005 Frank W. Zammetti