org.objectweb.jonas.common
Class JProp

java.lang.Object
  extended by org.objectweb.jonas.common.JProp

public class JProp
extends java.lang.Object

This class manages configuration properties for a JOnAS Server. It adopts the singleton design-pattern. Configuration parameters are read from .properties file (jonas.properties or resource.properties). In order to support dynamically created resources, JProp also allows for a .properties file generation using a java.lang.Properties object content

Author:
jonas-team, Adriana Danes, Florent Benoit 05/2003 Florent Benoit. Add support of xml files and checkstyle

Field Summary
static java.lang.String DOMAIN_NAME
          Domain name
static java.lang.String JONAS_BASE
          -Djonas.base property
static java.lang.String JONAS_DEF_NAME
          Default server name
static java.lang.String JONAS_NAME
          JOnAS server name
static java.lang.String JONAS_VERSIONS
           
static java.lang.String JONASPREFIX
          Prefix for jonas.properties file
 
Method Summary
static void deleteInstance(java.lang.String fileName)
          Remove the JProp instance corresponding to the given file name from the 'multiple' data structure and delete the file
 void env2Ctx(javax.naming.Context ctx)
          Bind all the properties found in file properties in a naming context the naming context must be allocated by the caller
static java.lang.String getConfDir()
          Static method which return the working directory in jonas.base
 java.util.Properties getConfigFileEnv()
          Returns JOnAS environment as configured with files properties only.
 java.lang.String getConfigFileXml()
          Returns xml content of the resource file
 java.util.Properties getEnv()
          Returns JOnAS environment as configured with configuration file properties content and system properties.
static java.lang.String getInstallRoot()
          Static method which return the JOnAS install root value.
static JProp getInstance()
          Get the unique instance corresponding to the JOnAS server.
static JProp getInstance(java.lang.String fileName)
          Get one of the multiple instances corresponding to a given resource.
static JProp getInstance(java.lang.String fileName, java.util.Properties props)
          Get one of the multiple instances corresponding to a given resource.
static java.lang.String getJonasBase()
          Static method which return the jonas.base property
 java.lang.String getPropFile()
          Returns properties filename
 java.lang.String getValue(java.lang.String key)
          Returns the value of the related property.
 java.lang.String getValue(java.lang.String key, java.lang.String defaultVal)
          Returns the value of the related property.
 java.lang.String[] getValueAsArray(java.lang.String key)
          Returns the value of the related property as String [].
 boolean getValueAsBoolean(java.lang.String key, boolean def)
          Returns the value of the related property as boolean.
 java.lang.String getVersionFile()
           
static java.lang.String getWorkDir()
          Static method which return the working directory in jonas.base
static void main(java.lang.String[] args)
          Displays the JOnAS properties values, as they are set by the different property files.
static void removeInstance(java.lang.String fileName)
          Remove the JProp instance corresponding to the given file name from the 'multiple' data structure
 java.lang.String toString()
          String representation of the object for trace purpose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JONAS_VERSIONS

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

JONASPREFIX

public static final java.lang.String JONASPREFIX
Prefix for jonas.properties file

See Also:
Constant Field Values

DOMAIN_NAME

public static final java.lang.String DOMAIN_NAME
Domain name

See Also:
Constant Field Values

JONAS_NAME

public static final java.lang.String JONAS_NAME
JOnAS server name

See Also:
Constant Field Values

JONAS_DEF_NAME

public static final java.lang.String JONAS_DEF_NAME
Default server name

See Also:
Constant Field Values

JONAS_BASE

public static final java.lang.String JONAS_BASE
-Djonas.base property

See Also:
Constant Field Values
Method Detail

getInstance

public static JProp getInstance()
Get the unique instance corresponding to the JOnAS server. Create it at first call.

Returns:
unique instance corresponding to the JOnAS server.
Throws:
java.lang.Exception - if no JProp can be built

getInstance

public static JProp getInstance(java.lang.String fileName)
Get one of the multiple instances corresponding to a given resource. Create it at first call with a given configuration file name

Parameters:
fileName - the name of the configuration file which is given by the resource name
Returns:
one of the multiple instances corresponding to a given resource.
Throws:
java.lang.Exception - if no JProp can be built

getInstance

public static JProp getInstance(java.lang.String fileName,
                                java.util.Properties props)
Get one of the multiple instances corresponding to a given resource. Create it at first call with a given configuration file name

Parameters:
fileName - the name of the configuration file
props - the content of the configuration file to be written in fileName
Returns:
one of the multiple instances corresponding to a given resource.
Throws:
java.lang.Exception - if no JProp can be built

removeInstance

public static void removeInstance(java.lang.String fileName)
Remove the JProp instance corresponding to the given file name from the 'multiple' data structure

Parameters:
fileName - file name corresponding to the name of the resource to be removed

deleteInstance

public static void deleteInstance(java.lang.String fileName)
Remove the JProp instance corresponding to the given file name from the 'multiple' data structure and delete the file

Parameters:
fileName - file name corresponding to the name of the resource to be removed and deleted from the file system

getInstallRoot

public static java.lang.String getInstallRoot()
Static method which return the JOnAS install root value.

Returns:
the JOnAS install root value.

getJonasBase

public static java.lang.String getJonasBase()
Static method which return the jonas.base property

Returns:
the jonas.base property

getWorkDir

public static java.lang.String getWorkDir()
Static method which return the working directory in jonas.base

Returns:
the jonas.base property

getConfDir

public static java.lang.String getConfDir()
Static method which return the working directory in jonas.base

Returns:
the jonas.base property

getPropFile

public java.lang.String getPropFile()
Returns properties filename

Returns:
JOnAS properties filename

getEnv

public java.util.Properties getEnv()
Returns JOnAS environment as configured with configuration file properties content and system properties.

Returns:
JOnAS properties

getConfigFileEnv

public java.util.Properties getConfigFileEnv()
Returns JOnAS environment as configured with files properties only.

Returns:
JOnAS properties

getConfigFileXml

public java.lang.String getConfigFileXml()
Returns xml content of the resource file

Returns:
xml content of the resource file

getVersionFile

public java.lang.String getVersionFile()

getValue

public java.lang.String getValue(java.lang.String key,
                                 java.lang.String defaultVal)
Returns the value of the related property. With default values.

Parameters:
key - the search key
defaultVal - if the key is not found return this default value
Returns:
property value

getValue

public java.lang.String getValue(java.lang.String key)
Returns the value of the related property. The method returns null if the property is not found.

Parameters:
key - the wanted key
Returns:
property value, null if not exist

getValueAsBoolean

public boolean getValueAsBoolean(java.lang.String key,
                                 boolean def)
Returns the value of the related property as boolean.

Parameters:
key - the wanted key
def - default run if not found
Returns:
property value, true or false.

getValueAsArray

public java.lang.String[] getValueAsArray(java.lang.String key)
Returns the value of the related property as String []. The method returns null if the property is not found.

Parameters:
key - the wanted key
Returns:
property value, null if not exist

toString

public java.lang.String toString()
String representation of the object for trace purpose

Overrides:
toString in class java.lang.Object
Returns:
String representation of this object

env2Ctx

public void env2Ctx(javax.naming.Context ctx)
             throws java.lang.Exception
Bind all the properties found in file properties in a naming context the naming context must be allocated by the caller

Parameters:
ctx - given context for bindings properties
Throws:
java.lang.Exception - if it fails

main

public static void main(java.lang.String[] args)
Displays the JOnAS properties values, as they are set by the different property files.

Parameters:
args - the arguments for launching this program