|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.util.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 |
defaultPropertyFile
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 ClassLoader |
getClassLoader()
returns the ClassLoader currently used to locate resources |
static LicenseHandler |
getLicenseHandler()
returns the LicenseHandler currently in place to react if a call to checkLicense(Object) fails initially. |
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)
sets the properties to be used by Settings; this should not be used unless you need to override the default properties |
static void |
installLicense(License l)
installs the given license to the LicenseManager - a convenience method. |
static void |
installLicenses(InputStream stream)
installs one or more License Objects from the given stream - a convenience method. |
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(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 void |
reset()
This method forces to reload the default settings from file. |
static void |
setClassLoader(ClassLoader cl)
sets the ClassLoader to be used in getResource(String);
by default, the system class loader is used |
static void |
setContextClassLoader()
|
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 (used by default) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static String defaultPropertyFile
ClassLoader
| Method Detail |
|---|
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 installLicenses(InputStream stream)
throws SecurityException
SecurityException - if one of the licenses within the stream
could not be verified. The embedded cause
will be a LicensingExceptionLicense,
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 system class loader is used
getResource(String)public static void init(Properties newProperties)
public static void setSystemClassLoader()
public static void setContextClassLoader()
public static ClassLoader getClassLoader()
public static URL getResource(String resource)
throws ResourceNotFoundException
ResourceNotFoundException - if the given resource could not be foundsetClassLoader(ClassLoader)
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 Properties getProperties()
throws ResourceNotFoundException
ResourceNotFoundException - if the property file could not be locatedreset()
public static void load(File fileProperties)
throws IOException
IOException
public static void load(URL urlProperties)
throws IOException
IOExceptionpublic static void reset()
getProperties() hereafter.
getProperties(),
defaultPropertyFilepublic static Properties getOnlineProperties()
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||