private static synchronized boolean lockSystemFolders(String[] args) { if (ourLock == null) { ourLock = new SocketLock(); } SocketLock.ActivateStatus activateStatus = ourLock.lock(PathManager.getConfigPath(false), true, args); if (activateStatus == SocketLock.ActivateStatus.NO_INSTANCE) { activateStatus = ourLock.lock(PathManager.getSystemPath(), false); } if (activateStatus != SocketLock.ActivateStatus.NO_INSTANCE) { if (isHeadless() || activateStatus == SocketLock.ActivateStatus.CANNOT_ACTIVATE) { showError( "Error", "Only one instance of " + ApplicationNamesInfo.getInstance().getFullProductName() + " can be run at a time."); } return false; } return true; }
public static synchronized void addExternalInstanceListener(Consumer<List<String>> consumer) { ourLock.setActivateListener(consumer); }