public class Core
extends java.lang.Object
Manages default folder structure and the following levels of properties (or options):
System.getProperties()
method.
Plug-in properties are properties defined within the attributes
section of a plug-in manifest file. Only attributes that are declared as child attributes
of the first "de.ims.icarus.properties" attribute are considered to be
property definitions and will be processed in order of their
definition and checked for being a plain property definition (using the
id
field as key and value
field as value for a new property
entry) or a link pointing to a resource that can be used to load properties from.
Such links have to use the "de.ims.icarus.propertiesPath" string as id
and their
value
field will be used to locate the properties resource(s).
Note that there can be multiple attributes legally sharing the same id
,
however only the last attribute's value
will be used for the
property in question! In the case of multiple attributes linking to property
resources all of them will be read following the same pattern of overwriting.
If a plug-in wishes to disable the publishing of its declared property attributes
it can simply define an attribute with the "de.ims.icarus.ignoreAttributes" id
and a value
that causes a call to Boolean#parseBoolean(String)
to
return true
(any mix of upper and lower cases of the string "true").
This flag will prevent the traversal of all property definitions within the
declaring plug-in!
Application properties can be specified on startup via the -config
argument that has to point to a file that contains property definitions in a format
suitable to either Properties.load(InputStream)
or Properties.loadFromXML(InputStream)
.
The method to be applied is determined by the file ending of the supplied path. If ending
on ".xml" the Properties.loadFromXML(InputStream)
method will be used.
In addition one can set properties directly by using the same argument format as
of the Java VM itself:
Any argument starting with -D
will be interpreted as a key=value
string and parsed accordingly.
Example: -Dsome.property.key=some.value
Access to properties is also handled by this class using a hierarchical
approach for searching. When asked for a property value the internal properties maps
will be checked in reverse order of the levels described above until a mapping for the given
key is found. So for a call to getProperty(String)
a property defined on
plug-in level will override default system settings but will be hidden by
an application property defined as command line argument or in a config file
linked via command line argument. Additionally there are methods defined to
query specific collections of properties and all properties related methods
exist in two forms, one allowing for a default value to be supplied that will
be used in case no property for the given key could be found.
Modifier and Type | Class and Description |
---|---|
class |
Core.CoreOptions
Command line argument wrapper
|
static interface |
Core.NamedRunnable |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CORE_PLUGIN_KEY |
static java.lang.String |
DEFAULT_CORE_PLUGIN_ID |
static java.lang.String |
IGNORE_ATTRIBUTES_KEY |
static java.lang.String |
IGNORE_STREAM_REDIRECT_PROPERTY |
static java.lang.String |
PROPERTIES_KEY |
static java.lang.String |
PROPERTIES_PATH_KEY |
Modifier and Type | Method and Description |
---|---|
void |
addShutdownHook(Core.NamedRunnable hook) |
void |
addShutdownHook(java.lang.String name,
java.lang.Runnable r) |
java.lang.Object |
clone() |
java.nio.file.Path |
createTempFile(java.lang.String baseName) |
static void |
debugInit(java.lang.String... args) |
void |
ensureResource(java.lang.String filename,
java.lang.String path,
java.lang.ClassLoader loader) |
void |
ensureResource(java.lang.String foldername,
java.lang.String filename,
java.lang.String path,
java.lang.ClassLoader loader) |
java.lang.String |
getAppBuildDate() |
java.util.Map<java.lang.String,java.lang.String> |
getApplicationProperties() |
java.lang.String |
getApplicationProperty(java.lang.String key) |
java.lang.String |
getApplicationProperty(java.lang.String key,
java.lang.String defaultValue) |
java.lang.String |
getAppName() |
java.lang.String |
getAppRevision() |
java.lang.String |
getAppVendor() |
java.lang.String |
getAppVersion() |
java.nio.file.Path |
getCacheFolder() |
static Core |
getCore()
Returns the singleton
Core instance. |
java.nio.file.Path |
getDataFolder() |
java.nio.file.Path |
getExternalFolder() |
static java.util.List<java.awt.Image> |
getIconImages() |
static javax.swing.ImageIcon |
getLargeIcon() |
static javax.swing.Icon |
getLicenseIcon() |
static java.lang.String |
getLicenseText() |
java.nio.file.Path |
getLogFolder() |
static javax.swing.ImageIcon |
getMediumIcon() |
Core.CoreOptions |
getOptions() |
java.nio.file.Path |
getPluginFolder() |
java.util.Map<java.lang.String,java.lang.String> |
getPluginProperties() |
java.lang.String |
getPluginProperty(java.lang.String key) |
java.lang.String |
getPluginProperty(java.lang.String key,
java.lang.String defaultValue) |
java.lang.String |
getProperty(java.lang.String key) |
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue) |
java.nio.file.Path |
getRootFolder() |
Core.NamedRunnable[] |
getShutdownHooks() |
static javax.swing.ImageIcon |
getSmallIcon() |
java.nio.file.Path |
getTempFolder() |
java.lang.String |
getVersionProperty(java.lang.String key) |
boolean |
handleThrowable(java.lang.Throwable t) |
static boolean |
ignoreRedirect() |
static boolean |
isDebugActive() |
boolean |
isShuttingDown() |
static void |
main(java.lang.String[] args) |
static void |
showNotice() |
void |
shutdown(java.lang.Thread.UncaughtExceptionHandler handler) |
public static final java.lang.String IGNORE_STREAM_REDIRECT_PROPERTY
public static final java.lang.String DEFAULT_CORE_PLUGIN_ID
public static final java.lang.String PROPERTIES_PATH_KEY
public static final java.lang.String PROPERTIES_KEY
public static final java.lang.String IGNORE_ATTRIBUTES_KEY
public static final java.lang.String CORE_PLUGIN_KEY
public static void debugInit(java.lang.String... args)
public static boolean isDebugActive()
public static void main(java.lang.String[] args)
args
- public static boolean ignoreRedirect()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public static Core getCore()
Core
instance.public void addShutdownHook(Core.NamedRunnable hook)
public void addShutdownHook(java.lang.String name, java.lang.Runnable r)
public Core.NamedRunnable[] getShutdownHooks()
public boolean isShuttingDown()
public void shutdown(java.lang.Thread.UncaughtExceptionHandler handler)
public Core.CoreOptions getOptions()
public java.nio.file.Path getRootFolder()
public java.nio.file.Path getLogFolder()
public java.nio.file.Path getPluginFolder()
public java.nio.file.Path getDataFolder()
public java.nio.file.Path getTempFolder()
public java.nio.file.Path getCacheFolder()
public java.nio.file.Path getExternalFolder()
public java.nio.file.Path createTempFile(java.lang.String baseName) throws java.io.IOException
java.io.IOException
public java.lang.String getProperty(java.lang.String key)
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
public java.lang.String getApplicationProperty(java.lang.String key)
public java.lang.String getApplicationProperty(java.lang.String key, java.lang.String defaultValue)
public java.lang.String getPluginProperty(java.lang.String key)
public java.lang.String getPluginProperty(java.lang.String key, java.lang.String defaultValue)
public java.util.Map<java.lang.String,java.lang.String> getApplicationProperties()
public java.util.Map<java.lang.String,java.lang.String> getPluginProperties()
public static void showNotice()
public static java.lang.String getLicenseText()
public static javax.swing.Icon getLicenseIcon()
public static javax.swing.ImageIcon getSmallIcon()
public static javax.swing.ImageIcon getLargeIcon()
public static javax.swing.ImageIcon getMediumIcon()
public static java.util.List<java.awt.Image> getIconImages()
public void ensureResource(java.lang.String filename, java.lang.String path, java.lang.ClassLoader loader)
public void ensureResource(java.lang.String foldername, java.lang.String filename, java.lang.String path, java.lang.ClassLoader loader)
public java.lang.String getVersionProperty(java.lang.String key)
public java.lang.String getAppVendor()
public java.lang.String getAppName()
public java.lang.String getAppRevision()
public java.lang.String getAppBuildDate()
public java.lang.String getAppVersion()
public boolean handleThrowable(java.lang.Throwable t)