Commit f028f1f6 authored by legoc's avatar legoc
Browse files

Renamed status listener into event listener

parent 84b4e489
......@@ -6,7 +6,7 @@
<version>0.0.1</version>
</parent>
<artifactId>cameo-api</artifactId>
<version>0.1.7</version>
<version>0.1.8-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
......
......@@ -45,7 +45,7 @@ public class Application {
impl = new ApplicationImpl(args);
server = new Server(impl.getEndpoint());
server.registerStatusListener(impl.getEventListener());
server.registerEventListener(impl.getEventListener());
if (impl.getStarterEndpoint() != null) {
starterServer = new Server(impl.getStarterEndpoint());
......
......@@ -27,7 +27,7 @@ import java.util.concurrent.LinkedBlockingQueue;
*/
public class EventListener {
protected String name = null;
private String name = null;
private LinkedBlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>();
/**
......@@ -47,7 +47,7 @@ public class EventListener {
eventQueue.put(event);
} catch (InterruptedException e) {
System.out.println("interrupted StatusListener while putting");
System.out.println("interrupted EventListener while putting");
}
}
......@@ -59,7 +59,7 @@ public class EventListener {
return eventQueue.poll();
} catch (InterruptedException e) {
System.out.println("interrupted StatusListener while popping");
System.out.println("interrupted EventListener while popping");
return null;
}
}
......@@ -73,7 +73,7 @@ public class EventListener {
eventQueue.put(new CancelEvent(id, name));
} catch (InterruptedException e) {
System.out.println("interrupted StatusListener while putting");
System.out.println("interrupted EventListener while putting");
}
}
......
......@@ -106,12 +106,12 @@ public class Server {
impl.terminate();
}
public void registerStatusListener(EventListener listener) {
impl.registerStatusListener(listener);
public void registerEventListener(EventListener listener) {
impl.registerEventListener(listener);
}
public void unregisterStatusListener(EventListener listener) {
impl.unregisterStatusListener(listener);
public void unregisterEventListener(EventListener listener) {
impl.unregisterEventListener(listener);
}
/**
......
......@@ -52,8 +52,8 @@ class EventThread extends Thread {
// Send event to listeners.
// The EventListener contains the name attribute but not the application id because
// the id is not available at the registration.
ConcurrentLinkedDeque<EventListener> statusListeners = server.getEventListeners();
for (EventListener listener : statusListeners) {
ConcurrentLinkedDeque<EventListener> eventListeners = server.getEventListeners();
for (EventListener listener : eventListeners) {
// If the application name is null, all the status are pushed
// otherwise, filter on the name
......@@ -76,8 +76,8 @@ class EventThread extends Thread {
// Send event to listeners.
// The EventListener contains the name attribute but not the application id because
// the id is not available at the registration.
ConcurrentLinkedDeque<EventListener> resultListeners = server.getEventListeners();
for (EventListener listener : resultListeners) {
ConcurrentLinkedDeque<EventListener> eventListeners = server.getEventListeners();
for (EventListener listener : eventListeners) {
// Filter on the name
if (listener.getName() != null && listener.getName().equals(result.getName())) {
......@@ -91,8 +91,8 @@ class EventThread extends Thread {
// Send event to listeners.
// The EventListener contains the name attribute but not the application id because
// the id is not available at the registration.
ConcurrentLinkedDeque<EventListener> statusListeners = server.getEventListeners();
for (EventListener listener : statusListeners) {
ConcurrentLinkedDeque<EventListener> eventListeners = server.getEventListeners();
for (EventListener listener : eventListeners) {
// If the application name is null, all the status are pushed
// otherwise, filter on the name
......@@ -108,8 +108,8 @@ class EventThread extends Thread {
// Send event to listeners.
// The EventListener contains the name attribute but not the application id because
// the id is not available at the registration.
ConcurrentLinkedDeque<EventListener> statusListeners = server.getEventListeners();
for (EventListener listener : statusListeners) {
ConcurrentLinkedDeque<EventListener> eventListeners = server.getEventListeners();
for (EventListener listener : eventListeners) {
// If the application name is null, all the status are pushed
// otherwise, filter on the name
......
......@@ -83,10 +83,6 @@ public class InstanceImpl extends EventListener {
lastState = state;
}
public String getName() {
return name;
}
public int getId() {
return id;
}
......@@ -104,7 +100,7 @@ public class InstanceImpl extends EventListener {
}
public String getNameId() {
return name + "." + id;
return getName() + "." + id;
}
public boolean hasResult() {
......@@ -289,7 +285,7 @@ public class InstanceImpl extends EventListener {
}
public int getActualState() {
List<Info> infos = server.getApplicationInfos(name);
List<Info> infos = server.getApplicationInfos(getName());
for (Info info : infos) {
if (info.getId() == id) {
......@@ -302,7 +298,7 @@ public class InstanceImpl extends EventListener {
public void terminate() {
// Unregister the status.
server.unregisterStatusListener(this);
server.unregisterEventListener(this);
// Unregister the waiting.
waiting.remove();
......@@ -381,7 +377,7 @@ public class InstanceImpl extends EventListener {
@Override
public String toString() {
return name + "." + id + "@" + server.getEndpoint();
return getName() + "." + id + "@" + server.getEndpoint();
}
}
\ No newline at end of file
......@@ -138,11 +138,11 @@ public class ServerImpl extends ServicesImpl {
super.terminate();
}
public void registerStatusListener(EventListener listener) {
public void registerEventListener(EventListener listener) {
eventListeners.add(listener);
}
public void unregisterStatusListener(EventListener listener) {
public void unregisterEventListener(EventListener listener) {
eventListeners.remove(listener);
}
......@@ -208,7 +208,7 @@ public class ServerImpl extends ServicesImpl {
// we set the name of the application and register before starting because the id is not available
instance.setName(name);
registerStatusListener(instance);
registerEventListener(instance);
try {
// we connect to the stream port before starting the application
......@@ -251,7 +251,7 @@ public class ServerImpl extends ServicesImpl {
// we set the name of the application and register before starting because the id is not available
instance.setName(name);
registerStatusListener(instance);
registerEventListener(instance);
try {
// we connect to the stream port before starting the application
......@@ -349,7 +349,7 @@ public class ServerImpl extends ServicesImpl {
// we set the name of the application and register before starting because the id is not available
instance.setName(name);
registerStatusListener(instance);
registerEventListener(instance);
int applicationId = applicationInfo.getId();
......@@ -369,7 +369,7 @@ public class ServerImpl extends ServicesImpl {
} else {
// it is important not to forget to unregister the result, otherwise a memory leak will occur
unregisterStatusListener(instance);
unregisterEventListener(instance);
}
}
......
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