Commit 57b661fc authored by ics's avatar ics

Synchronise clients for XBU and PAL files

parent e95140f0
......@@ -34,7 +34,9 @@ public class ResourceManager {
public final static int SCRIPT_FILE = 0;
public final static int SETTINGS_FILE = 1;
public final static int PAL_FILE = 2;
public final static int XBU_FILE = 3;
private String serverId;
private static ResourceManager instance = null;
......
......@@ -32,6 +32,8 @@ public class CommandZoneFileSync {
private List<INewScanListener> newScanListeners;
private List<INewSettingsFileListener> newSettingsFileListeners;
private List<INewXBUListener> newXBUListeners;
private List<INewPALListener> newPALListeners;
public static CommandZoneFileSync getInstance() {
......@@ -136,4 +138,104 @@ public class CommandZoneFileSync {
}
}
}
/**
* <p>Adds a new INewXBUListener to the list of listeners.
* If the listener already exists then ignor.
* @param INewXBUListener a new listener
*/
public void addNewXBUListener(INewXBUListener newXBUFileListener) {
if (newXBUListeners == null) {
this.newXBUListeners = new ArrayList<INewXBUListener>(2);
}
synchronized (newXBUListeners) {
if (!newXBUListeners.contains(newXBUFileListener)) {
newXBUListeners.add(newXBUFileListener);
}
}
}
/**
* <p>Removes a INewXBUListener.
* <br>If the listener does not exist in the list of listeners then ignor it.
*/
public void removeNewXBUListener(INewXBUListener newXBUFileListener) {
if (newXBUListeners != null) {
synchronized (newXBUListeners) {
if (newXBUListeners.contains(newXBUFileListener)) {
newXBUListeners.remove(newXBUFileListener);
}
if (newXBUListeners.isEmpty()) {
newXBUListeners = null;
}
}
}
}
/**
* Notifies listeners that a new XBU file has been created.
*/
public void notifyNewXBUListeners(String xbuName) {
if (newXBUListeners != null) {
synchronized (newXBUListeners) {
Iterator<INewXBUListener> listenerIterator = newXBUListeners.iterator();
while (listenerIterator.hasNext()) {
listenerIterator.next().newXBU(xbuName);
}
}
}
}
/**
* <p>Adds a new INewPALListener to the list of listeners.
* If the listener already exists then ignor.
* @param INewPALListener a new listener
*/
public void addNewPALListener(INewPALListener newPALFileListener) {
if (newPALListeners == null) {
this.newPALListeners = new ArrayList<INewPALListener>(2);
}
synchronized (newPALListeners) {
if (!newPALListeners.contains(newPALFileListener)) {
newPALListeners.add(newPALFileListener);
}
}
}
/**
* <p>Removes a INewPALListener.
* <br>If the listener does not exist in the list of listeners then ignor it.
*/
public void removeNewPALListener(INewPALListener newPALFileListener) {
if (newPALListeners != null) {
synchronized (newPALListeners) {
if (newPALListeners.contains(newPALFileListener)) {
newPALListeners.remove(newPALFileListener);
}
if (newPALListeners.isEmpty()) {
newPALListeners = null;
}
}
}
}
/**
* Notifies listeners that a new PAL file has been created.
*/
public void notifyNewPALListeners(String palName) {
if (newPALListeners != null) {
synchronized (newPALListeners) {
Iterator<INewPALListener> listenerIterator = newPALListeners.iterator();
while (listenerIterator.hasNext()) {
listenerIterator.next().newPAL(palName);
}
}
}
}
}
......@@ -552,6 +552,12 @@ public class CommandZoneSyncEventClient {
case ResourceManager.SETTINGS_FILE:
CommandZoneFileSync.getInstance().notifyNewSettingsFileListeners(newFileEvent.getFileName());
break;
case ResourceManager.PAL_FILE:
CommandZoneFileSync.getInstance().notifyNewPALListeners(newFileEvent.getFileName());
break;
case ResourceManager.XBU_FILE:
CommandZoneFileSync.getInstance().notifyNewXBUListeners(newFileEvent.getFileName());
break;
}
}
}
......
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.nscclient.notification.commandzone.sync;
/**
*
* @author ortizh
*
*/
public interface INewPALListener {
public void newPAL(String palName);
}
\ No newline at end of file
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.nscclient.notification.commandzone.sync;
/**
*
* @author ortizh
*
*/
public interface INewXBUListener {
public void newXBU(String xbuName);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment