Class XSingleInstanceService
java.lang.Object
net.sourceforge.jnlp.services.XSingleInstanceService
- All Implemented Interfaces:
SingleInstanceService, ExtendedSingleInstanceService
This class implements SingleInstanceService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classImplements a server that listens for arguments from new instances of this application -
Field Summary
FieldsModifier and TypeFieldDescription(package private) booleanprivate final List<SingleInstanceListener> private static final Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the specified SingleInstanceListenervoidcheckSingleInstanceRunning(JNLPFile jnlpFile) Check if another instance of this application is already runningvoidInitialize the new SingleInstanceServiceprivate voidnotifySingleInstanceListeners(String[] arguments) Notify any SingleInstanceListener with new argumentsvoidRemove the specified SingleInstanceListenerprivate voidsendProgramArgumentsToExistingApplication(int port, 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 Details
-
LOG
-
listeners
-
initialized
boolean initialized
-
-
Constructor Details
-
XSingleInstanceService
XSingleInstanceService()Create a new XSingleInstanceService
-
-
Method Details
-
initializeSingleInstance
public void initializeSingleInstance()Initialize the new SingleInstanceService- Specified by:
initializeSingleInstancein interfaceExtendedSingleInstanceService- Throws:
InstanceExistsException- if the instance already exists
-
checkSingleInstanceRunning
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
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, String[] arguments) throws IOException Send the arguments for this application to the main instance- Parameters:
port- the port at which the SingleInstanceServer is listening atarguments- the new arguments- Throws:
IOException- on any io exception
-
notifySingleInstanceListeners
Notify any SingleInstanceListener with new arguments- Parameters:
arguments- the new arguments to the application
-
addSingleInstanceListener
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
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
-