Package net.sourceforge.jnlp.services
Class SingleInstanceLock
java.lang.Object
net.sourceforge.jnlp.services.SingleInstanceLock
This class represents a Lock for single instance jnlp applications.
The lock is per-session, per user.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSingleInstanceLock(JNLPFile jnlpFile) Create an object to manage the instance lock for the specified JNLP file. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateWithPort(int localPort) Create/overwrite the instance lock for the jnlp file.(package private) booleanexists()Returns true if the lock file already exists.private StringReturns a string identifying this display.private FilegetLockFile(JNLPFile jnlpFile) Return a file object that represents the lock file.private StringgetLockFileName(JNLPFile jnlpFile) Returns the name of the lock file.intgetPort()Returns the port in this lock file.private booleanisPortFree(int port) Returns true if the port is free.booleanisValid()Returns true if the lock if valid.private voidParse the lock file.
-
Field Details
-
LOG
-
INVALID_PORT
public static final int INVALID_PORT- See Also:
-
lockFile
-
port
private int port
-
-
Constructor Details
-
SingleInstanceLock
Create an object to manage the instance lock for the specified JNLP file.- Parameters:
jnlpFile- the jnlp file to create the lock for
-
-
Method Details
-
createWithPort
Create/overwrite the instance lock for the jnlp file.- Parameters:
localPort- the network port for the lock- Throws:
IOException- on any io problems
-
isValid
public boolean isValid()Returns true if the lock if valid. That is, the lock exists, and port it points to is listening for incoming messages. -
getPort
public int getPort()Returns the port in this lock file. -
exists
boolean exists()Returns true if the lock file already exists. -
isPortFree
private boolean isPortFree(int port) Returns true if the port is free. -
getLockFile
Return a file object that represents the lock file. The lock file itself may or may not exist.- Parameters:
jnlpFile- the applicaton for which to create the lock
-
getLockFileName
Returns the name of the lock file.- Parameters:
jnlpFile- the applicaton for which to create the lock
-
parseFile
Parse the lock file.- Throws:
NumberFormatExceptionIOException
-
getCurrentDisplay
Returns a string identifying this display.Implementation note: On systems with X support, this is the DISPLAY variable
- Returns:
- a string that is guaranteed to be not null.
-