From e651773acf5a39d3800821512c7cca4be3504ddd Mon Sep 17 00:00:00 2001 From: fhanik Date: Mon, 28 May 2007 15:16:13 +0000 Subject: [PATCH] implement method callbacks git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@542247 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/catalina/connector/CometEventImpl.java | 39 +++++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/java/org/apache/catalina/connector/CometEventImpl.java b/java/org/apache/catalina/connector/CometEventImpl.java index 672edf0a1..27a023655 100644 --- a/java/org/apache/catalina/connector/CometEventImpl.java +++ b/java/org/apache/catalina/connector/CometEventImpl.java @@ -74,6 +74,11 @@ public class CometEventImpl implements CometEvent { */ protected HashSet cometOperations = new HashSet(3); + /** + * Current set of configurations + */ + protected HashSet cometConfigurations = new HashSet(3); + protected WorkerThreadCheck threadCheck = new WorkerThreadCheck(); private static final Object threadCheckHolder = new Object(); @@ -139,31 +144,47 @@ public class CometEventImpl implements CometEvent { public void configure(CometEvent.CometConfiguration... options) throws IOException, IllegalStateException { checkWorkerThread(); - throw new UnsupportedOperationException(); + synchronized (cometConfigurations) { + cometConfigurations.clear(); + for (CometEvent.CometConfiguration cc : options) { + cometConfigurations.add(cc); + } + request.action(ActionCode.ACTION_COMET_CONFIGURE,options); + } } public void register(CometEvent.CometOperation... operations) throws IOException, IllegalStateException { - //add it to the registered set - for (CometEvent.CometOperation co : operations ) { - if ( !cometOperations.contains(co) ) { - cometOperations.add(co); - //TODO notify poller + synchronized (cometOperations) { + //add it to the registered set + for (CometEvent.CometOperation co : operations) { + if (!cometOperations.contains(co)) { + cometOperations.add(co); + request.action(ActionCode.ACTION_COMET_REGISTER, co); + } } } } public void unregister(CometOperation... operations) throws IOException, IllegalStateException { - throw new UnsupportedOperationException(); + synchronized (cometOperations) { + //remove from the registered set + for (CometEvent.CometOperation co : operations) { + if (cometOperations.contains(co)) { + cometOperations.remove(co); + request.action(ActionCode.ACTION_COMET_UNREGISTER, co); + } + } + } } public CometConfiguration[] getConfiguration() { - throw new UnsupportedOperationException(); + return (CometConfiguration[])cometConfigurations.toArray(new CometConfiguration[0]); } public CometOperation[] getRegisteredOps() { - throw new UnsupportedOperationException(); + return (CometOperation[])cometOperations.toArray(new CometOperation[0]); } public String toString() { -- 2.11.0