Skip to content
Snippets Groups Projects
Commit 11646f6f authored by Cristina Cocho's avatar Cristina Cocho
Browse files

new listener for log images

parent 165172c1
No related branches found
No related tags found
No related merge requests found
/*
* 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.bridge.listeners;
public interface ServerLogImageDataReadyListener {
public void updateImageData(String imageName);
}
......@@ -33,6 +33,7 @@ import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.bridge.events.ServerLogEvent;
import fr.ill.ics.bridge.events.ServerLogEvent.LogLevel;
import fr.ill.ics.bridge.listeners.ServerLogEventListener;
import fr.ill.ics.bridge.listeners.ServerLogImageDataReadyListener;
import fr.ill.ics.bridge.listeners.ServerLogXMLListener;
import fr.ill.ics.nomadserver.common.LogSubscriberPOA;
import fr.ill.ics.nomadserver.common.LogSubscriberPackage.Level;
......@@ -50,6 +51,8 @@ public class LogSubcriberImpl extends LogSubscriberPOA {
private Set<ServerLogXMLListener> logXMLListeners = new LinkedHashSet<ServerLogXMLListener>();
private List<String> pendingXMLMessages = new ArrayList<String>();
private ServerLogImageDataReadyListener logImageDataReadyListener;
private List<String> pendingImageDataReadyNames = new ArrayList<String>();
private LogPublisher logpublisher = null;
private int id = 0;
......@@ -127,6 +130,15 @@ public class LogSubcriberImpl extends LogSubscriberPOA {
}
}
/**
* Set new listener for server image data ready messages
*
* @param listener
*/
public void setLogImageDataReadyListener(ServerLogImageDataReadyListener listener) {
logImageDataReadyListener = listener;
}
public void setID(int subscriberID) {
id = subscriberID;
}
......@@ -189,6 +201,15 @@ public class LogSubcriberImpl extends LogSubscriberPOA {
}
}
}
public void notifyServerLogImageDataReadyListeners(String imageName) {
if (logImageDataReadyListener != null) {
synchronized (logImageDataReadyListener) {
logImageDataReadyListener.updateImageData(imageName);
}
}
}
public void readAndDispatch() {
// copy pending property changes to unblock any server calls
......@@ -218,6 +239,22 @@ public class LogSubcriberImpl extends LogSubscriberPOA {
String message = m.next();
notifyServerLogXMLListeners(message);
}
// copy pending image names to unblock any server calls
ArrayList<String> imageNames;
synchronized (pendingImageDataReadyNames) {
imageNames = new ArrayList<String>(pendingImageDataReadyNames);
pendingImageDataReadyNames.clear();
}
// notify property listeners
Iterator<String> n = imageNames.iterator();
while (n.hasNext()) {
String imageName = n.next();
notifyServerLogImageDataReadyListeners(imageName);
}
}
public void _notify(Type logType, Level logLevel, String message, int commandID, int servantID) {
......@@ -247,4 +284,11 @@ public class LogSubcriberImpl extends LogSubscriberPOA {
pendingXMLMessages.add(message);
}
}
@Override
public void notifyImageDataReady(String imageName) {
synchronized (pendingImageDataReadyNames) {
pendingImageDataReadyNames.add(imageName);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment