public final class SingleAppInstance
extends java.lang.Object
onInit()
at your application's
startup and onExit()
at your application's shutdown and that's
all there is to it. SingleAppInstance
creates and locks a file
within the startup directory so if anyone is to execute your application
again the second onInit()
call fails with a message.
The onExit()
method unlocks and deletes the file.
If m_reportPopup
is true, a popup window is displayed for the
user to take action, else the user is informed via stderr
.
If you wish to change the look and feel of the popup window invoke
SingleAppInstance
after setting the look and feel inside your
application. If you wish to translate the messages for this component create
a new property file for your locale and place it inside
/gr/zeus/
where the default
"singleappinstance.properties" resides.
Modifier and Type | Method and Description |
---|---|
static SingleAppInstance |
getInstance()
This method returns the single instance of this class.
|
static SingleAppInstance |
getInstance(java.lang.String filename)
This method returns the single instance of this class.
|
boolean |
getReportPopup()
Gets whether to report via a popup or via
stderr . |
void |
onExit()
Release the file lock and delete the file.
|
void |
onInit()
Creates a file and obtains a lock.
|
void |
setReportPopup(boolean f)
Sets whether to report via a popup or via
stderr . |
public static SingleAppInstance getInstance()
public static SingleAppInstance getInstance(java.lang.String filename)
filename
- The filename to create and lock, should be unique and
within current folder.
public void onInit()
System.exit()
. Should be invoked ONCE
inside main()
in your application.public void onExit()
System.exit()
on your application.public boolean getReportPopup()
stderr
.
true
, a popup window is displayed,
else the user is informed via stderr
.public void setReportPopup(boolean f)
stderr
.
f
- If true
, via a popup window,
else via stderr
.