Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base
Class JiveGlobals

java.lang.Object
  extended by com.jivesoftware.base.JiveGlobals

public class JiveGlobals
extends java.lang.Object

This class controls access to a number of global propeties in the applcation.

Additionally, this class controls access to Jive properties. If the application is on, property manipulation must be done through this class and not the database or xml files directly.

Properties come in 3 types:

  1. Local properties - these are set in jiveHome/jive_startup.xml
  2. Database properties - these are stored in the jiveProperty database table
  3. Localized properties - these are stored in the jiveLocalizedProp database table.

As mentioned above, local (or startup) properties are stored in the jive_startup.xml file in the jiveHome directory. These properties bootstrap the application and start things like database access and cache settings. Jive needs to know the physical location of the jiveHome directory. This can be set in a number of ways:

All Jive property names must be in the form prop.name - parts of the name must be separated by ".". The value can be any valid String, including strings with line breaks.

Methods to control local properties (in jive_startup.xml):

Methods to control database properties (in the jiveProperty table): Methods to control localized properties (in the jiveLocalizedProp table):


Nested Class Summary
static interface JiveGlobals.JiveHomeProvider
          A pluggable way to specify a value for jiveHome.
 
Field Summary
static boolean failedLoading
          Indicates loading a reference to the jiveHome directory failed.
static java.lang.String jiveHome
          Location of the jiveHome directory.
static JiveProperties setupProperties
          Local Jive properties (from jive_startup.xml).
 
Method Summary
static void deleteJiveProperty(java.lang.String name)
          Deletes a Jive property.
static void deleteLocalizedJiveProperty(java.lang.String name, java.util.Locale locale)
          Deletes a localized Jive property.
static void deleteLocalProperty(java.lang.String name)
          Deletes a local property.
static java.lang.String formatDate(java.util.Date date)
          Formats a Date object and returns a formatted String.
static java.lang.String formatDateTime(java.util.Date date)
          Formats a Date object to return a date and time using the global locale.
static boolean getBuildBooleanProperty(java.lang.String name, boolean defaultValue)
          Returns the specified build property as a boolean or returns defaultValue if the property doesn't exist or isn't parseable.
static java.lang.String getBuildProperty(java.lang.String name)
          Returns a build-level property.
static java.lang.String getCharacterEncoding()
          Returns the character set that Jive uses for encoding.
static boolean getJiveBooleanProperty(java.lang.String name)
          Returns the specified Jive property as a boolean or returns false if the property doesn't exist or isn't parseable.
static boolean getJiveBooleanProperty(java.lang.String name, boolean defaultValue)
          Returns the specified Jive property as a boolean or returns defaultValue if the property doesn't exist or isn't parseable.
static java.lang.String getJiveHome()
          Returns the location of the jiveHome directory.
static int getJiveIntProperty(java.lang.String name, int defaultValue)
          Returns the specified Jive property as an integer or returns the defaultValue if the property does't exist or the value isn't a number.
static java.util.List getJiveProperties(java.lang.String parent)
          Return all immediate children property values of a parent Jive property as a list of strings, or an empty list if there are no children.
static java.lang.String getJiveProperty(java.lang.String name)
          Returns the value of the specified property or null if the value doesn't exist.
static java.lang.String getJiveProperty(java.lang.String name, java.lang.String defaultValue)
          Returns a Jive property.
static java.util.List getJivePropertyNames()
          Returns all Jive property names.
static java.util.List getJivePropertyNames(java.lang.String parent)
          Return all immediate children property names of a parent Jive property as a list of strings, or an empty list if there are no children.
static java.util.Locale getLocale()
          Returns the global Locale used by Jive.
static java.lang.String getLocalizedJiveProperty(java.lang.String name, java.util.Locale locale)
          Returns a localized Jive property given its name and locale.
static java.util.List getLocalizedJivePropertyNames()
          Returns a list of the localized Jive properties
static java.util.List getLocalizedPropertyLocales(java.lang.String name)
          Returns a list of locales where this property is set.
static java.util.List getLocalProperties(java.lang.String parent)
          Return all immediate children property values of a parent local property as a list of strings, or an empty list if there are no children.
static java.lang.String getLocalProperty(java.lang.String name)
          Returns a local property.
static int getLocalProperty(java.lang.String name, int defaultValue)
          Returns a local property as an integer.
static java.util.Date getStartupDate()
          Returns the date the Jive system was started.
static java.util.TimeZone getTimeZone()
          Returns the global TimeZone used by Jive.
static boolean isSetup()
          Returns true if the application has been set up, false otherwise.
static boolean isWhiteLabel()
          Returns true if the application is running in white label mode, false otherwise.
static void setCharacterEncoding(java.lang.String characterEncoding)
          Sets the character set that Jive uses for encoding.
static void setConfigName(java.lang.String configName)
          Allows the name of the local config file name to be changed.
static void setJiveHome(java.lang.String jHome)
          Sets the location of the jiveHome directory.
static void setJiveProperties(java.util.Map propertyMap)
          Sets multiple Jive properties at once.
static void setJiveProperty(java.lang.String name, java.lang.String value)
          Sets a Jive property.
static void setLocale(java.util.Locale newLocale)
          Sets the global locale used by Jive.
static void setLocalizedJiveProperty(java.lang.String name, java.lang.String value, java.util.Locale locale)
          Sets a localized Jive property.
static void setLocalProperties(java.util.Map propertyMap)
          Sets multiple local properties at once.
static void setLocalProperty(java.lang.String name, java.lang.String value)
          Sets a local property.
static void setTimeZone(java.util.TimeZone newTimeZone)
          Sets the global time zone used by Jive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jiveHome

public static java.lang.String jiveHome
Location of the jiveHome directory.


failedLoading

public static boolean failedLoading
Indicates loading a reference to the jiveHome directory failed.


setupProperties

public static JiveProperties setupProperties
Local Jive properties (from jive_startup.xml).

Method Detail

getStartupDate

public static java.util.Date getStartupDate()
Returns the date the Jive system was started. This value can be used to calculate uptime.

Returns:
the date the Jive system was started.

getLocale

public static java.util.Locale getLocale()
Returns the global Locale used by Jive. A locale specifies language and country codes, and is used for internationalization. The default locale is system dependant and is determined by calling Locale.getDefault().

Returns:
the global locale used by Jive.

setLocale

public static void setLocale(java.util.Locale newLocale)
Sets the global locale used by Jive. A locale specifies language and country codes, and is used for formatting dates and numbers. The default locale comes from the JDK's Locale.getDefault().

Parameters:
newLocale - the global locale for Jive.

getCharacterEncoding

public static java.lang.String getCharacterEncoding()
Returns the character set that Jive uses for encoding. This is used for displaying content in skins, sending email watch updates, etc. The default encoding is ISO-8895-1, which is suitable for most Latin languages. If you need to support double byte character sets such as Chinese or Japanese, it's recommend that you use utf-8 as the charset (Unicode). Unicode offers simultaneous support for a large number of languages and is easy to convert into native charsets as necessary. You may also specifiy any other charset that is supported by your JVM. A list of encodings supported by the Sun JVM can be found here.

In order for a particular encoding to work (such as Unicode), your application server and database may need to be specially configured. Please consult your server documentation for more information. For example, SQLServer has a special column type for Unicode text, and the Resin application server can be configured to use a custom charset by adding a <character-encoding> element to the web.xml/resin.conf file. Any Servlet 2.3 compliant application servers also supports the method HttpServletRequest.setCharacterEncoding(String). A Servlet 2.3 filter called SetCharacterEncodingFilter is installed in this application's web.xml file, which will set the incoming character encoding to the one reported by this method.

Returns:
the global Jive character encoding.

setCharacterEncoding

public static void setCharacterEncoding(java.lang.String characterEncoding)
                                 throws java.io.UnsupportedEncodingException
Sets the character set that Jive uses for encoding. For a more complete description of the character encoding in this applcation, see getCharacterEncoding().

Parameters:
characterEncoding - the global Jive character encoding.
Throws:
java.io.UnsupportedEncodingException - if the specified character encoding is invalid.

getTimeZone

public static java.util.TimeZone getTimeZone()
Returns the global TimeZone used by Jive. The default is the JDK's default time zone.

Returns:
the global time zone used by Jive.

setTimeZone

public static void setTimeZone(java.util.TimeZone newTimeZone)
Sets the global time zone used by Jive.

Parameters:
newTimeZone - the new global time zone used by this application.

formatDate

public static java.lang.String formatDate(java.util.Date date)
Formats a Date object and returns a formatted String. This uses the date formatter which in turn uses the default locale.

Parameters:
date - the Date to format.
Returns:
a String representing the date.

formatDateTime

public static java.lang.String formatDateTime(java.util.Date date)
Formats a Date object to return a date and time using the global locale.

Parameters:
date - the Date to format.
Returns:
a String representing the date and time.

getJiveHome

public static java.lang.String getJiveHome()
Returns the location of the jiveHome directory.

Returns:
the location of the jiveHome directory.

setJiveHome

public static void setJiveHome(java.lang.String jHome)
Sets the location of the jiveHome directory. This method is only intended to be used during setup and should not set called in normal operations.


setConfigName

public static void setConfigName(java.lang.String configName)
Allows the name of the local config file name to be changed. The default is jive_startup.xml. Note, this is used for setup, upgrade or testing purposes and is not needed in normal operation.

Parameters:
configName - the name of the config file.

isSetup

public static boolean isSetup()
Returns true if the application has been set up, false otherwise.

Returns:
true if the application has been set up, false otherwise.

getLocalProperty

public static java.lang.String getLocalProperty(java.lang.String name)
Returns a local property. Local properties are stored in the file jive_startup.xml which exists in the jiveHome directory. Properties are always specified as "foo.bar.prop", which would map to the following entry in the XML file:
 <foo>
     <bar>
         <prop>some value</prop>
     </bar>
 </foo>
 

Parameters:
name - the name of the property to return.
Returns:
the property value specified by name.

getLocalProperty

public static int getLocalProperty(java.lang.String name,
                                   int defaultValue)
Returns a local property as an integer. If the specified property can't be found, or if the value is not a number, the defaultValue will be returned.

Parameters:
name - the name of the property to return.
defaultValue - the value returned if the property could not be loaded or was not a number.
Returns:
the property value specified by name or defaultValue.

getLocalProperties

public static java.util.List getLocalProperties(java.lang.String parent)
Return all immediate children property values of a parent local property as a list of strings, or an empty list if there are no children. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are A, B, and C (the value of C.D would not be returned using this method).

Parameters:
parent - the name of the parent property to return the children for.
Returns:
all child property values for the given parent.

setLocalProperty

public static void setLocalProperty(java.lang.String name,
                                    java.lang.String value)
Sets a local property. If the property doesn't already exists, a new one will be created.

Parameters:
name - the name of the property being set.
value - the value of the property being set.

setLocalProperties

public static void setLocalProperties(java.util.Map propertyMap)
Sets multiple local properties at once. If a property doesn't already exists, a new one will be created.

Parameters:
propertyMap - a map of properties, keyed on property name.

deleteLocalProperty

public static void deleteLocalProperty(java.lang.String name)
Deletes a local property. If the property doesn't exist, the method does nothing.

Parameters:
name - the name of the property to delete.

getJiveProperty

public static java.lang.String getJiveProperty(java.lang.String name)
Returns the value of the specified property or null if the value doesn't exist.

Parameters:
name - the name of the property to return.
Returns:
the property value specified by name or null if it doesn't exist.

getJiveProperty

public static java.lang.String getJiveProperty(java.lang.String name,
                                               java.lang.String defaultValue)
Returns a Jive property. If the specified property doesn't exist, the defaultValue will be returned.

Parameters:
name - the name of the property.
defaultValue - value returned if the property doesn't exist.
Returns:
the property value specified by name or the defaultValue if the property doesn't exist.

getJivePropertyNames

public static java.util.List getJivePropertyNames()
Returns all Jive property names.

Returns:
a List of all property names (Strings).

getJivePropertyNames

public static java.util.List getJivePropertyNames(java.lang.String parent)
Return all immediate children property names of a parent Jive property as a list of strings, or an empty list if there are no children. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are A, B, and C (C.D would not be returned using this method).

Returns:
a List of all immediate children property names (Strings).

getJiveProperties

public static java.util.List getJiveProperties(java.lang.String parent)
Return all immediate children property values of a parent Jive property as a list of strings, or an empty list if there are no children. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are X.Y.A, X.Y.B, and X.Y.C (the value of X.Y.C.D would not be returned using this method).

Parameters:
parent - the name of the parent property to return the children for.
Returns:
all child property values for the given parent.

getJiveIntProperty

public static int getJiveIntProperty(java.lang.String name,
                                     int defaultValue)
Returns the specified Jive property as an integer or returns the defaultValue if the property does't exist or the value isn't a number.

Parameters:
name - the name of the property.
defaultValue - value returned if the property doesn't exist or was not a number.
Returns:
the property value specified by name or defaultValue.

getJiveBooleanProperty

public static boolean getJiveBooleanProperty(java.lang.String name)
Returns the specified Jive property as a boolean or returns false if the property doesn't exist or isn't parseable.

Parameters:
name - the name of the property to return.
Returns:
true if the property value exists and is set to "true" (ignoring case). Otherwise false is returned.

getJiveBooleanProperty

public static boolean getJiveBooleanProperty(java.lang.String name,
                                             boolean defaultValue)
Returns the specified Jive property as a boolean or returns defaultValue if the property doesn't exist or isn't parseable.

Parameters:
name - the name of the property.
defaultValue - value returned if the property doesn't exist.
Returns:
true if the property value exists and is set to "true" or false if the property value is "false" (ignoring case). If the value isn't set or isn't parseable then defaultValue is returned.

setJiveProperty

public static void setJiveProperty(java.lang.String name,
                                   java.lang.String value)
Sets a Jive property. If the property doesn't already exists, a new one will be created.

Parameters:
name - the name of the property being set.
value - the value of the property being set.

setJiveProperties

public static void setJiveProperties(java.util.Map propertyMap)
Sets multiple Jive properties at once. If a property doesn't already exists, a new one will be created.

Parameters:
propertyMap - a map of properties, keyed on property name.

deleteJiveProperty

public static void deleteJiveProperty(java.lang.String name)
Deletes a Jive property. If the property doesn't exist, the method does nothing. All children of the property will be deleted as well.

Parameters:
name - the name of the property to delete.

getLocalizedJivePropertyNames

public static java.util.List getLocalizedJivePropertyNames()
Returns a list of the localized Jive properties


getLocalizedJiveProperty

public static java.lang.String getLocalizedJiveProperty(java.lang.String name,
                                                        java.util.Locale locale)
Returns a localized Jive property given its name and locale. If the property doesn't exist then null will be returned.

Parameters:
name - the name of the property
locale - the locale this property applies to
Returns:
the property value specified by name and locale or null if it doesn't exist.

getLocalizedPropertyLocales

public static java.util.List getLocalizedPropertyLocales(java.lang.String name)
Returns a list of locales where this property is set. If the property doesn't exist or is not set then an empty list is returned.

Parameters:
name - the name of the property to check.
Returns:
a list of Locale objects where this property is set or an empty list if the property doesn't exist.

setLocalizedJiveProperty

public static void setLocalizedJiveProperty(java.lang.String name,
                                            java.lang.String value,
                                            java.util.Locale locale)
Sets a localized Jive property. If the property doesn't already exists, a new one will be created.

Parameters:
name - the name of the property being set.
value - the value of the property being set.
locale - the locale of the property

deleteLocalizedJiveProperty

public static void deleteLocalizedJiveProperty(java.lang.String name,
                                               java.util.Locale locale)
Deletes a localized Jive property. If the property doesn't exist, the method does nothing. All children of the property will be deleted as well.

Parameters:
name - the name of the property to delete.
locale - the locale of the property

isWhiteLabel

public static boolean isWhiteLabel()
Returns true if the application is running in white label mode, false otherwise. false is the default.

Returns:
true if we're in white label mode, false otherwise. False is the default.

getBuildProperty

public static java.lang.String getBuildProperty(java.lang.String name)
Returns a build-level property. These are properties that are part of the build itself and can not be overridden or changed at runtime.

Note, this method will be generally less performant that other property accessors, so it's best to cache the answer from this method.

Parameters:
name - the name of the proeprty
Returns:
the value of the property if it is set or null if the property is blank or if the prop doesn't exist.

getBuildBooleanProperty

public static boolean getBuildBooleanProperty(java.lang.String name,
                                              boolean defaultValue)
Returns the specified build property as a boolean or returns defaultValue if the property doesn't exist or isn't parseable.

Parameters:
name - the name of the property.
defaultValue - value returned if the property doesn't exist.
Returns:
true if the property value exists and is set to "true" or false if the property value is "false" (ignoring case). If the value isn't set or isn't parseable then defaultValue is returned.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.