com.waveset.util
Class WavesetProperties

java.lang.Object
  extended bycom.waveset.util.WavesetProperties

public class WavesetProperties
extends java.lang.Object

A class that provides a cached interface to the waveset.properties file. This file originally contained general system operation options, but now contains mainly special options for debugging and testing.

If you have something that needs to be propgated to multiple web servers in a cluster, it should go into SystemConfiguration (which is backed by the repository) rather than this file.

If you have something that is specific to a particular server, it belongs in ServerConfiguration (which is part of SystemConfiguration).

The file is expected to contain various debug and test properties, which are intended for use only during development. Putting them in a file rather than in the repository makes them easier to view and modify. The file is also more convenient than putting a bunch of -D options in the launch scripts and JBuilder configuration.

See the Waveset.properties file for documentation on the available properties and what they do.

Calling the method getProperty() will load the properties file on the first request, and keep it in memory thereafter. There is no provision for checking for file updates; you will have to shut down the process to reload the file.


Nested Class Summary
static interface WavesetProperties.Listener
          Implement this interface and call
   WavesetProperties.registerListener(this)
to have your propertiesFileChanged() method called whenever the underlying properties file changes.
static interface WavesetProperties.PropertiesProvider
          Properties provider to be used for loading waveset properties Currently this is used by the netbeans plugin to override the default WavesetProperties loading mechanism.
 
Field Summary
static java.lang.String code_id
           
static int MAX_POST_FILE_SIZE_DEFAULT
          This default value (10MB) can be overridden by specifying max.post.file.size.
static java.lang.String MAX_POST_FILE_SIZE_PROPERTY
           
static int MAX_POST_MEMORY_SIZE_DEFAULT
          This default value (8K) can be overridden by specifying max.post.memory.size.
static java.lang.String MAX_POST_MEMORY_SIZE_PROPERTY
           
 
Constructor Summary
WavesetProperties()
           
 
Method Summary
static Message checkContentLength(int reqContentLength)
          Check the specified length against maximum file size limit.
static void commentProperty(java.lang.String name)
          Comment a property out of the Waveset.properties file and store it.
static void deRegisterListener(WavesetProperties.Listener listener)
           
static boolean getBoolean(java.lang.String name)
          Get the value of a property as a boolean.
static boolean getBoolean(java.lang.String name, boolean dflt)
          Get the value of a property as a boolean.
static int getInt(java.lang.String name)
          Get the value of a property as an integer.
static int getInt(java.lang.String name, int dflt)
          Get the value of a property as an integer.
static int getMaxPostFileSize()
           
static int getMaxPostMemorySize()
           
static java.util.Map getProperties()
          Return a copy of the properties.
static java.lang.Object getProperty(java.lang.String name)
          Get the value of a property.
static java.lang.String getString(java.lang.String name)
          Get the value of a property as a string.
static GenericObject getSystemConfiguration(LighthouseContext vm)
          Get the system configuration object.
static java.lang.Object getSystemConfiguration(LighthouseContext vm, java.lang.String name)
          Get a system configuration property value.
static java.lang.String getVersion()
          Get the value of the version property.
static void propertiesChanged()
          Notify all listeners that properties are changed
static void registerListener(WavesetProperties.Listener listener)
          Register a class to be notified when the properties file changes.
static void reload()
          Reload the properties from the file.
static void setPropertiesProvider(WavesetProperties.PropertiesProvider provider)
          Set the properties provider to be used for loading waveset properties.
static void setProperty(java.lang.String name, boolean value)
          Modify the value of a boolean property temporarily.
static void setProperty(java.lang.String name, java.lang.Object value)
          Modify the value of a property temporarily.
static void storeProperty(java.lang.String name, java.lang.Object value)
          Modify the "permanent" value of a property.
static void storeProperty(java.lang.String name, java.lang.Object value, boolean enableIfDisabled)
          Modify the "permanent" value of a property.
static void storeVersion(java.lang.String value)
          Modify the "permanent" value of the version property.
static boolean testProperty(java.lang.String name, java.lang.Object expected)
          Test a property value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

MAX_POST_MEMORY_SIZE_DEFAULT

public static final int MAX_POST_MEMORY_SIZE_DEFAULT
This default value (8K) can be overridden by specifying max.post.memory.size.

See Also:
Constant Field Values

MAX_POST_MEMORY_SIZE_PROPERTY

public static final java.lang.String MAX_POST_MEMORY_SIZE_PROPERTY
See Also:
Constant Field Values

MAX_POST_FILE_SIZE_DEFAULT

public static final int MAX_POST_FILE_SIZE_DEFAULT
This default value (10MB) can be overridden by specifying max.post.file.size.

See Also:
Constant Field Values

MAX_POST_FILE_SIZE_PROPERTY

public static final java.lang.String MAX_POST_FILE_SIZE_PROPERTY
See Also:
Constant Field Values
Constructor Detail

WavesetProperties

public WavesetProperties()
Method Detail

setPropertiesProvider

public static void setPropertiesProvider(WavesetProperties.PropertiesProvider provider)
Set the properties provider to be used for loading waveset properties. Currently this is used by the netbeans plugin to override the default WavesetProperties loading mechanism.


getProperty

public static java.lang.Object getProperty(java.lang.String name)
Get the value of a property.


getProperties

public static java.util.Map getProperties()
                                   throws WavesetException
Return a copy of the properties. Used by the debug pages.

Throws:
WavesetException

testProperty

public static boolean testProperty(java.lang.String name,
                                   java.lang.Object expected)
Test a property value.


getString

public static java.lang.String getString(java.lang.String name)
Get the value of a property as a string.


getInt

public static int getInt(java.lang.String name,
                         int dflt)
Get the value of a property as an integer. If the property does not exist, the supplied default value is used.


getInt

public static int getInt(java.lang.String name)
Get the value of a property as an integer. If the property does not exist, zero is returned.


getBoolean

public static boolean getBoolean(java.lang.String name)
Get the value of a property as a boolean. Boolean truth is defined by having a string property value whose first character is one of the following: t, T, y, Y, 1 All other values, including null, are considered false.


getBoolean

public static boolean getBoolean(java.lang.String name,
                                 boolean dflt)
Get the value of a property as a boolean. Boolean truth is defined by having a string property value whose first character is one of the following: t, T, y, Y, 1 All other values, are consisderd false. If the property does not exist, the supplied default value is used.


getVersion

public static java.lang.String getVersion()
Get the value of the version property.


setProperty

public static void setProperty(java.lang.String name,
                               java.lang.Object value)
Modify the value of a property temporarily.

These modifications will take priority over the values found in the Waveset.properties file until this class is reloaded.

Runtime modifications may or may not have any effect, it depends on who looks at the property and when. Most code tests the property once during initialization and then never again. So, it is best if you set property values very early during application initialization.


setProperty

public static void setProperty(java.lang.String name,
                               boolean value)
Modify the value of a boolean property temporarily.

These modifications will take priority over the values found in the Waveset.properties file until this class is reloaded.

Runtime modifications may or may not have any effect, it depends on who looks at the property and when. Most code tests the property once during initialization and then never again. So, it is best if you set property values very early during application initialization.


storeProperty

public static void storeProperty(java.lang.String name,
                                 java.lang.Object value)
                          throws WavesetException
Modify the "permanent" value of a property.

Parameters:
name - the property to update.
value - the value to replace any current value.

Changes the value stored in the Waveset.properties file as well as the transient value in the cached HashMap object.

Throws:
WavesetException

storeProperty

public static void storeProperty(java.lang.String name,
                                 java.lang.Object value,
                                 boolean enableIfDisabled)
                          throws WavesetException
Modify the "permanent" value of a property.

Parameters:
name - the property to update.
value - the value to replace any current value.
enableIfDisabled - if true and the property has been disabled (e.g., by a comment preceding the property name), the property will be re-enabled.

Changes the value stored in the Waveset.properties file as well as the transient value in the cached HashMap object.

Throws:
WavesetException

commentProperty

public static void commentProperty(java.lang.String name)
                            throws WavesetException
Comment a property out of the Waveset.properties file and store it. If the property is not found, this does nothing.

Parameters:
name - The name of the property to comment out.
Throws:
WavesetException - If the file cannot be read or written.

storeVersion

public static void storeVersion(java.lang.String value)
                         throws WavesetException
Modify the "permanent" value of the version property.

Parameters:
value - the version value
Throws:
WavesetException

registerListener

public static void registerListener(WavesetProperties.Listener listener)
Register a class to be notified when the properties file changes.


deRegisterListener

public static void deRegisterListener(WavesetProperties.Listener listener)

propertiesChanged

public static void propertiesChanged()
Notify all listeners that properties are changed


reload

public static void reload()
Reload the properties from the file.


getMaxPostMemorySize

public static int getMaxPostMemorySize()
Returns:
the currently configured limit for how much to keep in memory

getMaxPostFileSize

public static int getMaxPostFileSize()
Returns:
the currently configured limit for HTTP request bytes.

checkContentLength

public static Message checkContentLength(int reqContentLength)
Check the specified length against maximum file size limit.

Returns:
a message if it exceeds the configured limit.

getSystemConfiguration

public static GenericObject getSystemConfiguration(LighthouseContext vm)
                                            throws WavesetException
Get the system configuration object. This is applicable to more than just views, move somewhere else, consider something like the static methods on WavesetProperties.

Throws:
WavesetException

getSystemConfiguration

public static java.lang.Object getSystemConfiguration(LighthouseContext vm,
                                                      java.lang.String name)
                                               throws WavesetException
Get a system configuration property value.

Throws:
WavesetException