com.atlassian.jira.config.properties
Class JiraPropertiesImpl

java.lang.Object
  extended by com.atlassian.jira.config.properties.JiraPropertiesImpl
All Implemented Interfaces:
JiraProperties

public class JiraPropertiesImpl
extends Object
implements JiraProperties

Handles getting and setting of system properties.

Non-null values are cached. If you need the latest value of the system property, call refresh() before you access that property. If you are changing a system property wish the changed value to be seen by this class immediately you need to call setProperty(String, Object) or setProperties(java.util.Properties) method of this class. Doing this often is a potential performance problem, as Boolean.getBoolean(String a) is a blocking operation, so you should NOT do this for every SQL statement or Web request etc.

For reading properties, this class catches SecurityExceptions and returns null or default values provided. However, this class will not catch such exceptions when setting system properties.

Since:
v6.1

Constructor Summary
JiraPropertiesImpl(PropertiesAccessor propertiesAccessor)
           
 
Method Summary
 Boolean getBoolean(String key)
          Returns a cached system property as a Boolean.
 String getCustomDirectoryPlugins()
           
 Integer getInteger(String key)
          Returns a cached system property as an Integer.
 Integer getInteger(String key, Integer defaultInteger)
          Returns a cached system property as an Integer, or a default value if property is not set.
 Long getLong(String key)
          Returns a cached system property as a Long.
 Long getLong(String key, Long defaultLong)
          Returns a cached system property as a Long, or a default value if property is not set.
 Properties getProperties()
          Returns a snapshot of all the set system properties.
 String getProperty(String key)
          Returns a cached system property as a String.
 String getProperty(String key, String defaultString)
          Returns a cached system property as a String, or a default value if property is not set.
 boolean isBundledPluginsDisabled()
           
 boolean isCustomPathPluginsEnabled()
           
 boolean isDangerMode()
           
 boolean isDarkFeaturesDisabled()
           
 boolean isDecodeMailParameters()
           
 boolean isDevMode()
           
 boolean isI18nReloadBundles()
           
 boolean isSuperBatchingDisabled()
           
 boolean isWebSudoDisabled()
           
 boolean isXsrfDetectionCheckRequired()
           
 boolean isXsrfDiagnostics()
           
 void refresh()
          Causes any previously cached values to be invalidated.
 void setProperties(Properties props)
          Sets the system properties and invalidates the accessor accordingly.
<T> void
setProperty(String key, T value)
          Sets a system property and invalidates the accessor accordingly, or unsets the property if value is null.
 boolean showPerformanceMonitor()
           
 void unsetProperty(String key)
          Unsets a system property and invalidates the accessor accordingly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JiraPropertiesImpl

public JiraPropertiesImpl(PropertiesAccessor propertiesAccessor)
Method Detail

getProperty

public String getProperty(String key)
Returns a cached system property as a String.

This call will not raise SecurityException, it will return null instead.

Specified by:
getProperty in interface JiraProperties
Parameters:
key - the name of the system property.
Returns:
the value of the system property, or null if property is not set or SecurityException occurs.

getProperty

public String getProperty(String key,
                          String defaultString)
Returns a cached system property as a String, or a default value if property is not set.

Note that if the property is not set, the accessor will remain unchanged.

This call will not raise SecurityException, it will return defaultString instead.

Specified by:
getProperty in interface JiraProperties
Parameters:
key - the name of the system property.
defaultString - default value
Returns:
the value of the system property, or defaultString if property is not set or SecurityException occurs.

setProperty

public <T> void setProperty(String key,
                            T value)
Sets a system property and invalidates the accessor accordingly, or unsets the property if value is null. The value set is the result of Object.toString() called on the value.

Specified by:
setProperty in interface JiraProperties
Parameters:
key - the name of the system property.
value - the value

unsetProperty

public void unsetProperty(String key)
Unsets a system property and invalidates the accessor accordingly.

Specified by:
unsetProperty in interface JiraProperties
Parameters:
key - the name of the system property.

getBoolean

public Boolean getBoolean(String key)
Returns a cached system property as a Boolean.

This call will not raise SecurityException, it will return false instead.

Because of the way system properties are read by the Boolean class, this method will never return null, nor it is possible to provide a variant with the default value. See Boolean.getBoolean(String). You can however use getProperty(String) and convert it to Boolean manually for that desired effect.

Specified by:
getBoolean in interface JiraProperties
Parameters:
key - the name of the system property.
Returns:
the value of the system property, or false if property is not set or SecurityException occurs.

getInteger

public Integer getInteger(String key)
Returns a cached system property as an Integer.

This call will not raise SecurityException, it will return null instead.

Specified by:
getInteger in interface JiraProperties
Parameters:
key - the name of the system property.
Returns:
the value of the system property, or null if property is not set or SecurityException occurs.

getInteger

public Integer getInteger(String key,
                          Integer defaultInteger)
Returns a cached system property as an Integer, or a default value if property is not set.

Note that if the property is not set, the accessor will remain unchanged.

This call will not raise SecurityException, it will return defaultInteger instead.

Specified by:
getInteger in interface JiraProperties
Parameters:
key - the name of the system property.
defaultInteger - default value
Returns:
the value of the system property, or defaultInteger if property is not set or SecurityException occurs.

getLong

public Long getLong(String key)
Returns a cached system property as a Long.

This call will not raise SecurityException, it will return null instead.

Specified by:
getLong in interface JiraProperties
Parameters:
key - the name of the system property.
Returns:
the value of the system property, or null if property is not set or SecurityException occurs.

getLong

public Long getLong(String key,
                    Long defaultLong)
Returns a cached system property as a Long, or a default value if property is not set.

Note that if the property is not set, the accessor will remain unchanged.

This call will not raise SecurityException, it will return defaultLong instead.

Specified by:
getLong in interface JiraProperties
Parameters:
key - the name of the system property.
defaultLong - default value
Returns:
the value of the system property, or defaultLong if property is not set or SecurityException occurs.

getProperties

public Properties getProperties()
Returns a snapshot of all the set system properties. This is not a view.

This call will not raise SecurityException, it will return an empty set of properties instead.

Specified by:
getProperties in interface JiraProperties
Returns:
system properties.

setProperties

public void setProperties(Properties props)
Sets the system properties and invalidates the accessor accordingly.

Specified by:
setProperties in interface JiraProperties
Parameters:
props - the properties to set.
See Also:
System#setProperties(Properties)}

refresh

public void refresh()
Description copied from interface: JiraProperties
Causes any previously cached values to be invalidated. As long as this object is used to set or retrieve system properties it is not necessary to call this method. Call it only if you caused a system property change in another way than JiraProperties.setProperty(String, Object), JiraProperties.setProperties(java.util.Properties) or JiraProperties.unsetProperty(String).

Specified by:
refresh in interface JiraProperties

isDevMode

public boolean isDevMode()
Specified by:
isDevMode in interface JiraProperties
Returns:
true if jira is running in dev mode (meaning jira.home lock files will be ignored)

isXsrfDetectionCheckRequired

public boolean isXsrfDetectionCheckRequired()
Specified by:
isXsrfDetectionCheckRequired in interface JiraProperties

isSuperBatchingDisabled

public boolean isSuperBatchingDisabled()
Specified by:
isSuperBatchingDisabled in interface JiraProperties

isDecodeMailParameters

public boolean isDecodeMailParameters()
Specified by:
isDecodeMailParameters in interface JiraProperties

isCustomPathPluginsEnabled

public boolean isCustomPathPluginsEnabled()
Specified by:
isCustomPathPluginsEnabled in interface JiraProperties

getCustomDirectoryPlugins

public String getCustomDirectoryPlugins()
Specified by:
getCustomDirectoryPlugins in interface JiraProperties

isWebSudoDisabled

public boolean isWebSudoDisabled()
Specified by:
isWebSudoDisabled in interface JiraProperties

isI18nReloadBundles

public boolean isI18nReloadBundles()
Specified by:
isI18nReloadBundles in interface JiraProperties

showPerformanceMonitor

public boolean showPerformanceMonitor()
Specified by:
showPerformanceMonitor in interface JiraProperties

isBundledPluginsDisabled

public boolean isBundledPluginsDisabled()
Specified by:
isBundledPluginsDisabled in interface JiraProperties

isDarkFeaturesDisabled

public boolean isDarkFeaturesDisabled()
Specified by:
isDarkFeaturesDisabled in interface JiraProperties

isDangerMode

public boolean isDangerMode()
Specified by:
isDangerMode in interface JiraProperties

isXsrfDiagnostics

public boolean isXsrfDiagnostics()
Specified by:
isXsrfDiagnostics in interface JiraProperties


Copyright © 2002-2014 Atlassian. All Rights Reserved.