public class LauncherConf
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static LauncherConf |
create(java.lang.Class clazz)
Create the singleton class if it did not previously exist.
|
static LauncherConf |
create(java.lang.Class clazz,
java.lang.String envHome)
Create the singleton class if it did not previously exist.
|
static LauncherConf |
create(java.io.File userDir)
Create the singleton class if it did not previously exist.
|
static LauncherConf |
create(java.io.File userDir,
java.io.File userHome)
Create the singleton class if it did not previously exist.
|
static LauncherConf |
create(java.io.File userDir,
java.lang.String envHome)
Create the singleton class if it did not previously exist.
|
static LauncherConf |
create(java.net.URL userDir)
Create the singleton instance if it did not previously exist.
|
static LauncherConf |
create(java.net.URL userDir,
java.lang.String envHome)
Create the singleton class if it did not previously exist.
|
static LauncherConf |
create(java.net.URL userDir,
java.net.URL userHome)
Create the singleton class if it did not previously exist.
|
static void |
filterLaunchProperties(java.util.Map<java.lang.String,java.lang.String> args,
java.lang.String... filteredArgs)
Filter the launch properties of the main application.
|
static LauncherConf |
getInstance()
Return the unique LauncherConf instance.
|
static java.util.Map<java.lang.String,java.lang.String> |
getLaunchProperties(java.lang.String[] args)
Store the launch arguments of a main static method into a Map of <key,value>.
|
static java.util.Map<java.lang.String,java.lang.String> |
getLaunchProperties(java.lang.String[] args,
boolean keepDash)
Store the launch arguments of a main static method into a Map of <key,value>.
|
java.io.File |
getUserDir()
Return the user.dir directory.
|
java.net.URL |
getUserDirURL()
Return the user.dir directory.
|
java.io.File |
getUserHome()
Return the user.home directory.
|
java.net.URL |
getUserHomeURL()
Return the user.home directory.
|
static boolean |
isLocked()
Retur true if the current LauncherConf instance is locked.
|
void |
lock()
Lock the current LauncherConf instance such as to prevent further
reset() to have any effect. |
static boolean |
reset()
Reset the existing user configuration.
|
static void |
restart(MDIApplication appli)
Exit then restart the application with the same options.
|
public void lock()
reset()
to have any effect. This means that the
current LauncherConf instance can not be replaced.reset()
public static boolean isLocked()
public static void restart(MDIApplication appli) throws java.lang.Exception
MDIApplication.disposeApplication()
to exit if appli
is not null,
else it will simply call System.exit(0)
.appli
- the MDIApplication (can be null)java.lang.Exception
- if an exception occur before restartingpublic static LauncherConf getInstance()
getUserDir()
and getUserHome()
.public static boolean reset()
getInstance()
and other create
methods will be able to recreate it.
Note that it won't succeed if the current LauncherConf instance is locked.
LauncherConf launcherConf = LauncherConf.getInstance(); File userDir = launcherConf.getUserDir(); if (userDir == null) { LauncherConf.reset(); launcherConf = LauncherConf.create(MyClass.class); userDir = launcherConf.getUserDir(); } launcherConf.lock();
isLocked()
is truepublic static LauncherConf create(java.net.URL userDir)
userDir
- the forced user directory as a URLpublic static LauncherConf create(java.io.File userDir)
userDir
- the forced user directorypublic static LauncherConf create(java.io.File userDir, java.io.File userHome)
userDir
- the forced user.dir directoryuserHome
- the forced user.home directorypublic static LauncherConf create(java.net.URL userDir, java.net.URL userHome)
userDir
- the forced user.dir directoryuserHome
- the forced user.home directorypublic static LauncherConf create(java.lang.Class clazz)
clazz
- the Class used for the user directorypublic static LauncherConf create(java.io.File userDir, java.lang.String envHome)
userDir
- the forced user directoryenvHome
- the optional environment variable giving the path for the user.home directorypublic static LauncherConf create(java.net.URL userDir, java.lang.String envHome)
userDir
- the forced user directoryenvHome
- the optional environment variable giving the path for the user.home directorypublic static LauncherConf create(java.lang.Class clazz, java.lang.String envHome)
clazz
- the Class used for the user directoryenvHome
- the optional environment variable giving the path for the user.home directorypublic static void filterLaunchProperties(java.util.Map<java.lang.String,java.lang.String> args, java.lang.String... filteredArgs)
args
- the argumentsfilteredArgs
- the filtered keyspublic static java.util.Map<java.lang.String,java.lang.String> getLaunchProperties(java.lang.String[] args)
getLaunchProperties(java.lang.String[], boolean)
with the keepDash
argument
set to false.
The arguments can have one of the following pattern:
key1 prop1 key2 prop2 ...or
key1=prop1 key2=prop2 ...it is even possible to mix the two patterns such as:
key1 prop1 key2=prop2 ...
args
- the launch argumentspublic static java.util.Map<java.lang.String,java.lang.String> getLaunchProperties(java.lang.String[] args, boolean keepDash)
key1 prop1 key2 prop2 ...or
key1=prop1 key2=prop2 ...it is even possible to mix the two patterns such as:
key1 prop1 key2=prop2 ...For example, if we have:
key1 value1 -key2=value2 -key3 key4=23Then the method will return:
-key1 -key2=value2 -key3 key4=23Then the method will return:
args
- the launch argumentskeepDash
- true if the dash character at the beginning of each argument must be keptpublic java.io.File getUserDir()
public java.io.File getUserHome()
public java.net.URL getUserDirURL()
public java.net.URL getUserHomeURL()