Package net.sourceforge.jnlp.services
Class XSingleInstanceService
- java.lang.Object
-
- net.sourceforge.jnlp.services.XSingleInstanceService
-
- All Implemented Interfaces:
SingleInstanceService,ExtendedSingleInstanceService
public class XSingleInstanceService extends java.lang.Object implements ExtendedSingleInstanceService
This class implements SingleInstanceService
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classXSingleInstanceService.SingleInstanceServerImplements a server that listens for arguments from new instances of this application
-
Field Summary
Fields Modifier and Type Field Description (package private) booleaninitializedprivate java.util.List<SingleInstanceListener>listenersprivate static LoggerLOG
-
Constructor Summary
Constructors Constructor Description XSingleInstanceService()Create a new XSingleInstanceService
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSingleInstanceListener(SingleInstanceListener sil)Add the specified SingleInstanceListenervoidcheckSingleInstanceRunning(JNLPFile jnlpFile)Check if another instance of this application is already runningvoidinitializeSingleInstance()Initialize the new SingleInstanceServiceprivate voidnotifySingleInstanceListeners(java.lang.String[] arguments)Notify any SingleInstanceListener with new argumentsvoidremoveSingleInstanceListener(SingleInstanceListener sil)Remove the specified SingleInstanceListenerprivate voidsendProgramArgumentsToExistingApplication(int port, java.lang.String[] arguments)Send the arguments for this application to the main instanceprivate voidstartListeningServer(SingleInstanceLock lockFile)Start the listening server to accept arguments from new instances of applications
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
listeners
private final java.util.List<SingleInstanceListener> listeners
-
initialized
boolean initialized
-
-
Method Detail
-
initializeSingleInstance
public void initializeSingleInstance()
Initialize the new SingleInstanceService- Specified by:
initializeSingleInstancein interfaceExtendedSingleInstanceService- Throws:
InstanceExistsException- if the instance already exists
-
checkSingleInstanceRunning
public void checkSingleInstanceRunning(JNLPFile jnlpFile)
Check if another instance of this application is already running- Specified by:
checkSingleInstanceRunningin interfaceExtendedSingleInstanceService- Parameters:
jnlpFile- TheJNLPFilethat specifies the application- Throws:
InstanceExistsException- if an instance of this application already exists
-
startListeningServer
private void startListeningServer(SingleInstanceLock lockFile)
Start the listening server to accept arguments from new instances of applications- Parameters:
lockFile- theSingleInstanceLockthat the server should use
-
sendProgramArgumentsToExistingApplication
private void sendProgramArgumentsToExistingApplication(int port, java.lang.String[] arguments) throws java.io.IOExceptionSend the arguments for this application to the main instance- Parameters:
port- the port at which the SingleInstanceServer is listening atarguments- the new arguments- Throws:
java.io.IOException- on any io exception
-
notifySingleInstanceListeners
private void notifySingleInstanceListeners(java.lang.String[] arguments)
Notify any SingleInstanceListener with new arguments- Parameters:
arguments- the new arguments to the application
-
addSingleInstanceListener
public void addSingleInstanceListener(SingleInstanceListener sil)
Add the specified SingleInstanceListener- Specified by:
addSingleInstanceListenerin interfaceSingleInstanceService- Parameters:
sil- the single instance listener to be added. No action is performed if it is null.- Throws:
InstanceExistsException- which is likely to terminate the application but not guaranteed to
-
removeSingleInstanceListener
public void removeSingleInstanceListener(SingleInstanceListener sil)
Remove the specified SingleInstanceListener- Specified by:
removeSingleInstanceListenerin interfaceSingleInstanceService- Parameters:
sil- the single instance listener to be removed. No action is performed if it is null or not in the notification list.- Throws:
InstanceExistsException- if an instance of this single instance application already exists
-
-