X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fjava%2Fdolda%2Fdolcon%2Fprotocol%2FCommand.java;h=57db9640ee2397ae69e3226b844e1aa583fbf5e5;hb=e90ca845da9e7104c8c1cf88964bdc1880561e44;hp=98f888170192da2c0ad6d3c6093c494857e35438;hpb=1335284e7aff6313ddc37954532ab7b6e323aa73;p=doldaconnect.git diff --git a/lib/java/dolda/dolcon/protocol/Command.java b/lib/java/dolda/dolcon/protocol/Command.java index 98f8881..57db964 100644 --- a/lib/java/dolda/dolcon/protocol/Command.java +++ b/lib/java/dolda/dolcon/protocol/Command.java @@ -7,9 +7,13 @@ public class Command { Set listeners = new HashSet(); Response resp; - public interface Listener { - public void done(Response resp) throws Exception; - public void error(Exception cause); + public abstract class Listener { + public Listener() { + addlst(this); + } + + public abstract void done(Response resp) throws Exception; + public abstract void error(Exception cause); } public Command(List tokens) { @@ -20,17 +24,17 @@ public class Command { this(Arrays.asList(tokens)); } - public void addListener(Listener l) { + private synchronized void addlst(Listener l) { listeners.add(l); } - public void done(Response resp) throws Exception { + public synchronized void done(Response resp) throws Exception { this.resp = resp; for(Listener l : listeners) l.done(resp); } - public void error(Exception cause) { + public synchronized void error(Exception cause) { for(Listener l : listeners) l.error(cause); }