public class OptionsImpl extends Object implements IOptions, IShutdownListener
CACHE_DIRECTORY, CACHEBUST, DEBUG_MODE, DEFAULT_DELETE_DELAY, DELETE_DELAY, DEVELOPMENT_MODE, DISABLE_HASFILTERING, DISABLE_HASPLUGINBRANCHING, DISABLE_MODULENAMEIDENCODING, DISABLE_REQUIRELISTEXPANSION, propsFilename, SOURCE_MAPS, VERIFY_DEPS
Constructor and Description |
---|
OptionsImpl(boolean loadFromPropertiesFile,
IAggregator aggregator) |
Modifier and Type | Method and Description |
---|---|
String |
getCacheBust()
Convenience method for reading the
IOptions.CACHEBUST options
property. |
String |
getCacheDirectory()
Convenience method for reading the
IOptions.CACHE_DIRECTORY
options property. |
protected Properties |
getDefaultOptions() |
Map<String,String> |
getDefaultOptionsMap()
Returns an immutable map of the default options and their values.
|
int |
getDeleteDelay()
Convenience method for reading the
IOptions.DELETE_DELAY
options property. |
String |
getName()
Returns the name that can be used to track this options object using the IOptionsListener
interface.
|
String |
getOption(String name)
Returns the value of the specified option
|
Map<String,String> |
getOptionsMap()
Returns an immutable map of the current options and their values.
|
protected Properties |
getProps()
Returns the properties object for the current options.
|
File |
getPropsFile()
Returns a
File object to the properties file. |
String |
getPropsFilename()
Returns the filename of the properties file that the options
are loaded from/saved to.
|
protected Properties |
initDefaultOptions()
Returns the default options for this the aggregator service.
|
boolean |
isDebugMode()
Convenience method for reading the
IOptions.DEBUG_MODE
options property. |
boolean |
isDevelopmentMode()
Convenience method for reading the
IOptions.DEVELOPMENT_MODE
options property. |
boolean |
isDisableHasFiltering()
Convenience method for reading the
IOptions.DISABLE_HASFILTERING
options property. |
boolean |
isDisableHasPluginBranching()
Convenience method for reading the
IOptions.DISABLE_HASPLUGINBRANCHING
options property. |
boolean |
isDisableModuleNameIdEncoding()
Convenience method for reading the
IOptions.DISABLE_MODULENAMEIDENCODING
options property. |
boolean |
isDisableRequireListExpansion()
Convenience method for reading the
IOptions.DISABLE_REQUIRELISTEXPANSION
options property. |
boolean |
isSourceMapsEnabled()
Convenience method for reading the
IOptions.SOURCE_MAPS
options property. |
boolean |
isVerifyDeps()
Convenience method for reading the
IOptions.VERIFY_DEPS
options property. |
protected void |
loadFromUrl(Properties props,
URL url)
Load the properties in the specified url into
props . |
protected Properties |
loadProps(Properties props)
Loads the Options properties from the aggregator properties file
into the specified properties object.
|
protected void |
propertiesFileUpdated(Properties updated,
long sequence)
Listener method for being informed of changes to the properties file by another
instance of this class.
|
protected void |
propsFileUpdateNotify(Properties updatedProps,
long sequence)
Notify implementations of this class that are listening for properties file updates
on the same properties file that the properties file has been updated.
|
protected void |
saveProps(Properties props)
Saves the specified Options properties to the properties file for the
aggregator.
|
void |
setOption(String name,
boolean value)
Convenience method for setting options with boolean values.
|
void |
setOption(String name,
String value)
Sets the named option to the specified value.
|
protected void |
setProps(Properties props)
Sets the properties object for the current options and updates
the shadow map that is returned to callers of
getOptionsMap() . |
void |
shutdown(IAggregator aggregator)
This method is called from within the aggregator's
GenericServlet.destroy() method to notify listeners that the servlet
is shutting down. |
protected void |
updateNotify(long sequence)
Notify options change listeners that Options have been updated
|
public OptionsImpl(boolean loadFromPropertiesFile, IAggregator aggregator)
public boolean isVerifyDeps()
IOptions
IOptions.VERIFY_DEPS
options property.isVerifyDeps
in interface IOptions
IOptions.VERIFY_DEPS
property
as a booleanpublic boolean isDisableRequireListExpansion()
IOptions
IOptions.DISABLE_REQUIRELISTEXPANSION
options property.isDisableRequireListExpansion
in interface IOptions
IOptions.DISABLE_REQUIRELISTEXPANSION
property
as a booleanpublic boolean isDevelopmentMode()
IOptions
IOptions.DEVELOPMENT_MODE
options property.isDevelopmentMode
in interface IOptions
IOptions.DEVELOPMENT_MODE
property
as a booleanpublic boolean isDebugMode()
IOptions
IOptions.DEBUG_MODE
options property.isDebugMode
in interface IOptions
IOptions.DEBUG_MODE
property
as a booleanpublic boolean isSourceMapsEnabled()
IOptions
IOptions.SOURCE_MAPS
options property.isSourceMapsEnabled
in interface IOptions
IOptions.SOURCE_MAPS
property
as a booleanpublic boolean isDisableHasFiltering()
IOptions
IOptions.DISABLE_HASFILTERING
options property.isDisableHasFiltering
in interface IOptions
IOptions.DISABLE_HASFILTERING
property
as a booleanpublic boolean isDisableHasPluginBranching()
IOptions
IOptions.DISABLE_HASPLUGINBRANCHING
options property.isDisableHasPluginBranching
in interface IOptions
IOptions.DISABLE_HASPLUGINBRANCHING
property
as a booleanpublic boolean isDisableModuleNameIdEncoding()
IOptions
IOptions.DISABLE_MODULENAMEIDENCODING
options property.isDisableModuleNameIdEncoding
in interface IOptions
IOptions.DISABLE_MODULENAMEIDENCODING
property
as a booleanpublic String getCacheBust()
IOptions
IOptions.CACHEBUST
options
property.getCacheBust
in interface IOptions
IOptions.CACHEBUST
options property.public String getCacheDirectory()
IOptions
IOptions.CACHE_DIRECTORY
options property.getCacheDirectory
in interface IOptions
IOptions.CACHE_DIRECTORY
propertypublic int getDeleteDelay()
IOptions
IOptions.DELETE_DELAY
options property.getDeleteDelay
in interface IOptions
IOptions.DELETE_DELAY
property
as an int. If the property is not set, then
IOptions.DEFAULT_DELETE_DELAY
is returned.public void setOption(String name, boolean value) throws IOException
IOptions
setOption(name, Boolean.toString(value));
.setOption
in interface IOptions
name
- The name of the option to setvalue
- The boolean value.IOException
- If an error occurs persisting the updated options to the
aggregator properties file.public void setOption(String name, String value) throws IOException
IOptions
Use this method sparingly. Calling this method results in options listeners being called to inform them that the options have changed. Some listeners react to this by performing actions that can have significant adverse effects on performance. The cache manager, for example, purges the cache of all cached responses.
This method should not generally be called as part of normal operation of the aggregator. I may be called, for example, by a console command handler that allows admins or developers to set properties while the server is running. Changes to options made using this method are persisted to the properties file.
setOption
in interface IOptions
name
- The name of the option to setvalue
- The new option value. If null, then name
is
reset to its default value.IOException
- If an error occurs persisting the updated options to the
aggregator properties file.public String getOption(String name)
IOptions
public Map<String,String> getOptionsMap()
IOptions
getOptionsMap
in interface IOptions
public String getName()
IOptions
public Map<String,String> getDefaultOptionsMap()
IOptions
IOptions.setOption(String, boolean)
or IOptions.setOption(String, String)
.getDefaultOptionsMap
in interface IOptions
public String getPropsFilename()
public File getPropsFile()
File
object to the properties file.protected Properties loadProps(Properties props)
props
- The properties object to load. May be initialized with default
values.props
.protected void saveProps(Properties props) throws IOException
props
- The properties to saveIOException
protected void updateNotify(long sequence)
sequence
- The change sequence number.protected void propertiesFileUpdated(Properties updated, long sequence)
updated
- the updated propertiessequence
- the update sequence numberprotected void propsFileUpdateNotify(Properties updatedProps, long sequence)
updatedProps
- the updated propertiessequence
- the update sequence numberpublic void shutdown(IAggregator aggregator)
IShutdownListener
GenericServlet.destroy()
method to notify listeners that the servlet
is shutting down.shutdown
in interface IShutdownListener
aggregator
- The aggregator that is shutting downprotected void loadFromUrl(Properties props, URL url)
props
.props
- the properties object to updateurl
- the properties file to loadprotected Properties initDefaultOptions()
protected Properties getDefaultOptions()
protected Properties getProps()
protected void setProps(Properties props)
getOptionsMap()
.props
- The new properties.Copyright © 2011-2015 IBM. All Rights Reserved.