org.ow2.jonas.lib.bootstrap
Class JProp

java.lang.Object
  extended by org.ow2.jonas.lib.bootstrap.JProp
All Implemented Interfaces:
ServerProperties

public class JProp
extends Object
implements ServerProperties

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 String DOMAIN_NAME
          Domain name
static String JONAS_BASE
          -Djonas.base property
static String JONAS_DEVELOPMENT
          jonas.development property
static String JONAS_MASTER
          jonas.master property
 
Constructor Summary
JProp()
          Public constructor which reads the JONAS properties file (jonas.properties).
 
Method Summary
static void deleteInstance(String fileName)
          Remove the JProp instance corresponding to the given file name from the 'multiple' data structure and delete the file
 void env2Ctx(Context ctx)
          Bind all the properties found in file properties in a naming context the naming context must be allocated by the caller
static String getConfDir()
          Static method which returns the configuration directory in jonas.base
 Properties getConfigFileEnv()
          Returns JOnAS environment as configured with files properties only.
 String getConfigFileXml()
          Returns xml content of the resource file.
 String getDomainName()
          Retrieve the Domain Name.
 Properties getEnv()
          Returns JOnAS environment as configured with configuration file properties content and system properties.
static JProp getInstance()
          Get the unique instance corresponding to the JOnAS server.
static JProp getInstance(String fileName)
          Get one of the multiple instances corresponding to a given resource.
static JProp getInstance(String fileName, Properties props)
          Get one of the multiple instances corresponding to a given resource.
static String getJonasBase()
          Static method which return the jonas.base property
static String getJonasRoot()
          Static method which return the jonas.root property
 String getPropFile()
          Returns properties filename
 String getPropFileName()
          Retrieve the configuration file name.
static String getRepositoriesBaseDir()
          Static method which returns the repositories directory in jonas.base
static String getRepositoriesRootDir()
          Static method which returns the repositories directory in jonas.root
 String getServerName()
          Retrieve the Server Name.
 String getValue(String key)
          Returns the value of the related property.
 String getValue(String key, String defaultVal)
          Returns the value of the related property.
 String[] getValueAsArray(String key)
          Returns the value of the related property as String [].
 boolean getValueAsBoolean(String key, boolean def)
          Returns the value of the related property as boolean.
 String getVersionFile()
           
 String getVersionsFile()
           
static String getWorkDir()
          Static method which return the working directory in jonas.base
 boolean isDevelopment()
          Needed to determine if the current server is in development mode.
 boolean isMaster()
          Needed to determine if the current server is a master.
static void main(String[] args)
          Displays the JOnAS properties values, as they are set by the different property files.
static void removeInstance(String fileName)
          Remove the JProp instance corresponding to the given file name from the 'multiple' data structure
 void setDevelopment(boolean development)
           
 void setMaster(boolean master)
           
 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

DOMAIN_NAME

public static final String DOMAIN_NAME
Domain name

See Also:
Constant Field Values

JONAS_BASE

public static final String JONAS_BASE
-Djonas.base property

See Also:
Constant Field Values

JONAS_MASTER

public static final String JONAS_MASTER
jonas.master property

See Also:
Constant Field Values

JONAS_DEVELOPMENT

public static final String JONAS_DEVELOPMENT
jonas.development property

See Also:
Constant Field Values
Constructor Detail

JProp

public JProp()
Public constructor which reads the JONAS properties file (jonas.properties).

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.

getInstance

public static JProp getInstance(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.

getInstance

public static JProp getInstance(String fileName,
                                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.

removeInstance

public static void removeInstance(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(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

getJonasRoot

public static String getJonasRoot()
Static method which return the jonas.root property

Returns:
the jonas.root property

getJonasBase

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

Returns:
the jonas.base property

getWorkDir

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

Returns:
the jonas.base property

getConfDir

public static String getConfDir()
Static method which returns the configuration directory in jonas.base

Returns:
The configuration directory in jonas.base

getRepositoriesRootDir

public static String getRepositoriesRootDir()
Static method which returns the repositories directory in jonas.root

Returns:
The repositories directory in jonas.root

getRepositoriesBaseDir

public static String getRepositoriesBaseDir()
Static method which returns the repositories directory in jonas.base

Returns:
The repositories directory in jonas.base

getPropFile

public String getPropFile()
Returns properties filename

Returns:
JOnAS properties filename

getEnv

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

Returns:
JOnAS properties

getConfigFileEnv

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

Specified by:
getConfigFileEnv in interface ServerProperties
Returns:
JOnAS properties

getPropFileName

public String getPropFileName()
Description copied from interface: ServerProperties
Retrieve the configuration file name.

Specified by:
getPropFileName in interface ServerProperties
Returns:
configuration file name

getConfigFileXml

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

Returns:
xml content of the resource file

getVersionFile

public String getVersionFile()

getValue

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

Specified by:
getValue in interface ServerProperties
Parameters:
key - the search key
defaultVal - if the key is not found return this default value
Returns:
property value

getValue

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

Specified by:
getValue in interface ServerProperties
Parameters:
key - the wanted key
Returns:
property value, null if not exist

getValueAsBoolean

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

Specified by:
getValueAsBoolean in interface ServerProperties
Parameters:
key - the wanted key
def - default run if not found
Returns:
property value, true or false.

getValueAsArray

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

Specified by:
getValueAsArray in interface ServerProperties
Parameters:
key - the wanted key
Returns:
property value, null if not exist

toString

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

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

env2Ctx

public void env2Ctx(Context ctx)
             throws 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:
Exception - if it fails

main

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

Parameters:
args - the arguments for launching this program

getDomainName

public String getDomainName()
Description copied from interface: ServerProperties
Retrieve the Domain Name.

Specified by:
getDomainName in interface ServerProperties
Returns:
The Domain Name

getServerName

public String getServerName()
Description copied from interface: ServerProperties
Retrieve the Server Name.

Specified by:
getServerName in interface ServerProperties
Returns:
the Server Name

getVersionsFile

public String getVersionsFile()
Specified by:
getVersionsFile in interface ServerProperties
Returns:
the VERSIONS file content as a String.

isMaster

public boolean isMaster()
Description copied from interface: ServerProperties
Needed to determine if the current server is a master.

Specified by:
isMaster in interface ServerProperties
Returns:
true of this server is a master, false otherwise

setMaster

public void setMaster(boolean master)

isDevelopment

public boolean isDevelopment()
Description copied from interface: ServerProperties
Needed to determine if the current server is in development mode.

Specified by:
isDevelopment in interface ServerProperties
Returns:
true of this server is in development mode, false otherwise

setDevelopment

public void setDevelopment(boolean development)


Copyright © 2010 OW2 Consortium. All Rights Reserved.