|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.Settings
public final class Settings
Settings provides access to several properties and resources that are used throughout the classes of this Antelmann.com framework.
The default settings are loaded from a well known location
which denotes a file that is commonly distributed along with the
antelmann.jar file.
The default settings can be overwritten by simply altering the Properties
returned by getProperties(), where a subsequent call to that
method will reflect the changes (similar to System.getProperties().
If the Settings are used in special environments (such as within an application
server), you may need to manually use the setClassLoader(ClassLoader)
method to specify a ClassLoader appropriate for the given context, before
accessing any resources.
| Field Summary | |
|---|---|
static String |
CURRENT_DIRECTORY
denotes the property key used to keep track of the current directory that file dialogs should use |
static String |
DEFAULT_PROPERTY_FILE
denotes the relative location of the file for the default Properties, so that it can be found through the ClassLoader |
| Method Summary | |
|---|---|
static void |
checkLicense(Object licensee)
calls checkLicense(licensee, null) |
static void |
checkLicense(Object licensee,
Component c)
checks whether there is a valid license installed for accessing the given object - a convenience method normally used by an application to check whether access to an object is licensed. |
static Properties |
extractOptions(String[] args)
based on option key '-'; useful for command line options |
static String[] |
getAllValuesForProperty(String prefix)
|
static ClassLoader |
getClassLoader()
returns the ClassLoader currently used to locate resources |
static File |
getCurrentDirectory()
provides a current working directory that may be altered and may be null |
static LicenseHandler |
getLicenseHandler()
returns the LicenseHandler currently in place to react if a call to checkLicense(Object) fails initially. |
static Number |
getNumber(String key,
Filter<? super Number> filter,
Number defaultValue)
|
static Number |
getNumber(String key,
Number defaultValue)
|
static Properties |
getOnlineProperties()
returns a fresh set of default Properties directly from the Antelmann.com website |
static Properties |
getProperties()
This method returns the current application properties; changes to the Properties will be reflected in subsequent calls to this method. |
static String |
getProperty(String key)
provides a shortcut for getProperties().getPropterty(key) |
static String |
getProperty(String key,
String defaultValue)
This method will try to find the value for the given key and return it - or return the defaultValue if the property was not found or the default property file could not be opened |
static URL |
getResource(String resource)
This method encapsulates calls to the embedded ClassLoader to ease dealing with problems when not finding the resource. |
static void |
init(Properties newProperties)
initializes the properties to be used by Settings; all previously set properties are lost |
static void |
installLicense(License l)
installs the given license to the LicenseManager - a convenience method. |
static boolean |
isTrue(String key)
|
static boolean |
isValueTrue(Object value)
|
static void |
load(File fileProperties)
first, this method tries to initialize with the default properties, but even if that fails, the properties are loaded from the given location. |
static void |
load(Properties additionalProperties)
first, this method tries to initialize with the default properties, but even if that fails, the given properties are loaded into the current ones. |
static void |
load(URL urlProperties)
first, this method tries to initialize with the default properties, but even if that fails, the properties are loaded from the given location. |
static Properties |
loadCascadingBasedOnFileNameProperty(File file,
String fileProperty)
the returned Properties are not automatically loaded into the properties of Settings |
static Object |
removeProperty(String key)
|
static void |
setClassLoader(ClassLoader cl)
sets the ClassLoader to be used in getResource(String);
by default, the ClassLoader of this Settings class is used |
static void |
setContextClassLoader()
|
static void |
setCurrentDirectory(File dir)
allows to alter the current working directory used in getCurrentDirectory() |
static void |
setLicenseHandler(LicenseHandler handler)
allows to react on failed license-checks by establishing a proper handler |
static Object |
setProperty(String key,
String value)
sets a property within these settings |
static void |
setSystemClassLoader()
sets the class loader to be used to the system class loader |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_PROPERTY_FILE
ClassLoader
public static final String CURRENT_DIRECTORY
| Method Detail |
|---|
public static File getCurrentDirectory()
public static void setCurrentDirectory(File dir)
getCurrentDirectory()
public static void setLicenseHandler(LicenseHandler handler)
getLicenseHandler(),
checkLicense(Object)public static LicenseHandler getLicenseHandler()
checkLicense(Object),
setLicenseHandler(LicenseHandler)
public static void checkLicense(Object licensee)
throws SecurityException
checkLicense(licensee, null)
SecurityExceptioncheckLicense(Object, Component)
public static void checkLicense(Object licensee,
Component c)
throws SecurityException
By establishing a LicenseHandler, this method - in the event of the license check initially failing - will not immediately fail by throwing an exception, but will first try to e.g. obtain or renew a license through a call to the LicenseHander. After the LicenseHandler was called, the method will once again check with the LicenseManager, whether a valid license is present.
licensee - any object for wich a license is to be checkedc - the parent component from where this call occurs (may be null).
This component (if present) can be used by the LicenseHandler to show
dialogs on top of the given component.
SecurityException - if the license check failed;
the exception cause will be
a LicensingExceptionsetLicenseHandler(LicenseHandler),
LicenseHandler,
License,
LicenseManager,
LicensingException
public static void installLicense(License l)
throws SecurityException
SecurityException - if the licenses could not be verified.
The embedded cause will be a LicensingExceptionLicense,
LicenseManager,
LicensingExceptionpublic static void setClassLoader(ClassLoader cl)
getResource(String);
by default, the ClassLoader of this Settings class is used
getResource(String)public static void setSystemClassLoader()
public static void setContextClassLoader()
public static ClassLoader getClassLoader()
setClassLoader(ClassLoader)
public static URL getResource(String resource)
throws ResourceNotFoundException
ResourceNotFoundException - if the given resource could not be foundsetClassLoader(ClassLoader)public static void init(Properties newProperties)
public static boolean isTrue(String key)
public static boolean isValueTrue(Object value)
public static Number getNumber(String key,
Number defaultValue)
public static Number getNumber(String key,
Filter<? super Number> filter,
Number defaultValue)
public static String getProperty(String key,
String defaultValue)
public static String getProperty(String key)
throws ResourceNotFoundException
getProperties().getPropterty(key)
ResourceNotFoundException - if the property file could not be locatedgetProperties()
public static Object setProperty(String key,
String value)
public static Object removeProperty(String key)
public static String[] getAllValuesForProperty(String prefix)
public static Properties getProperties()
throws ResourceNotFoundException
ResourceNotFoundException - if the property file could not be located
public static Properties loadCascadingBasedOnFileNameProperty(File file,
String fileProperty)
throws IOException
IOException
public static void load(File fileProperties)
throws IOException
IOException
public static void load(URL urlProperties)
throws IOException
IOException
public static void load(Properties additionalProperties)
throws IOException
IOExceptionpublic static Properties extractOptions(String[] args)
public static Properties getOnlineProperties()
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||