Author: fhanik Date: Wed Jun 13 11:51:38 2007 New Revision: 546999 URL: http://svn.apache.org/viewvc?view=rev&rev=546999 Log: simplify API a bit based on feedback
Modified: tomcat/trunk/java/org/apache/catalina/CometEvent.java tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java tomcat/trunk/java/org/apache/coyote/ActionCode.java tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Modified: tomcat/trunk/java/org/apache/catalina/CometEvent.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/CometEvent.java?view=diff&rev=546999&r1=546998&r2=546999 ============================================================================== --- tomcat/trunk/java/org/apache/catalina/CometEvent.java (original) +++ tomcat/trunk/java/org/apache/catalina/CometEvent.java Wed Jun 13 11:51:38 2007 @@ -163,44 +163,28 @@ public void setTimeout(int timeout) throws ServletException, UnsupportedOperationException; - - - /** - * Enumeration for a comet connection state. - * A comet session can be blocking or non blocking. - * COMET_NON_BLOCKING<br/> - * Option bit set for allowing non blocking IO - * when reading from the request or writing to the response<br/> - * COMET_BLOCKING<br/> - * Configure the comet connection for blocking IO, this is the default setting - * - * @see #configure(int) - */ - public enum CometConfiguration {COMET_BLOCKING, COMET_NON_BLOCKING}; - + /** * Configures the connection for desired IO options. * By default a Comet connection is configured for <br/> * a) Blocking IO - standard servlet usage<br/> * b) Register for READ events when data arrives<br/> * Tomcat Comet allows you to configure for additional options:<br/> - * the <code>COMET_NON_BLOCKING</code> bit signals whether writing and reading from the request + * the <code>configureBlocking(false)</code> bit signals whether writing and reading from the request * or writing to the response will be non blocking.<br/> - * the <code>COMET_BLOCKING</code> bit signals the container you wish for read and write to be done in a blocking fashion - * @param cometOptions int - the option bit set + * the <code>configureBlocking(true)</code> bit signals the container you wish for read and write to be done in a blocking fashion + * @param blocking - true to make read and writes blocking * @throws IllegalStateException - if this method is invoked outside of the BEGIN event - * @see #CometConfiguration * @see #isReadable() * @see #isWriteable() */ - public void configure(CometConfiguration... options) throws IllegalStateException; + public void configureBlocking(boolean blocking) throws IllegalStateException; /** * Returns the configuration for this Comet connection - * @return CometConfiguration[] - * @see #configure(CometConfiguration...) + * @return true if the connection is configured to be blocking, false for non blocing */ - public CometConfiguration[] getConfiguration(); + public boolean isBlocking(); /** * OP_CALLBACK - receive a CALLBACK event from the container Modified: tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java?view=diff&rev=546999&r1=546998&r2=546999 ============================================================================== --- tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java (original) +++ tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java Wed Jun 13 11:51:38 2007 @@ -29,6 +29,7 @@ import org.apache.catalina.util.StringManager; import org.apache.coyote.ActionCode; import org.apache.tomcat.util.net.PollerInterest; +import org.apache.tomcat.util.MutableBoolean; public class CometEventImpl implements CometEvent { @@ -79,9 +80,9 @@ protected HashSet<CometOperation> cometOperations = new HashSet<CometOperation>(3); /** - * Current set of configurations + * Blocking or not blocking */ - protected HashSet<CometConfiguration> cometConfigurations = new HashSet<CometConfiguration>(3); + protected boolean blocking = true; protected WorkerThreadCheck threadCheck = new WorkerThreadCheck(); @@ -95,7 +96,7 @@ public void clear() { request = null; response = null; - cometConfigurations.clear(); + blocking = true; cometOperations.clear(); } @@ -151,13 +152,12 @@ return cometOperations.contains(op); } - public void configure(CometEvent.CometConfiguration... options) throws IllegalStateException { + public void configureBlocking(boolean blocking) throws IllegalStateException { checkWorkerThread(); - cometConfigurations.clear(); - for (CometEvent.CometConfiguration cc : options) { - cometConfigurations.add(cc); - } - request.action(ActionCode.ACTION_COMET_CONFIGURE,options); + if ( getEventType() != EventType.BEGIN ) throw new IllegalStateException("Can only be configured during the BEGIN event."); + MutableBoolean bool = new MutableBoolean(blocking); + request.action(ActionCode.ACTION_COMET_CONFIGURE_BLOCKING,bool); + this.blocking = bool.get(); } public void register(CometEvent.CometOperation... operations) throws IllegalStateException { @@ -172,8 +172,8 @@ request.action(ActionCode.ACTION_COMET_REGISTER, translate(cometOperations.toArray(new CometOperation[0]))); } - public CometConfiguration[] getConfiguration() { - return (CometConfiguration[])cometConfigurations.toArray(new CometConfiguration[0]); + public boolean isBlocking() { + return blocking; } public CometOperation[] getRegisteredOps() { Modified: tomcat/trunk/java/org/apache/coyote/ActionCode.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ActionCode.java?view=diff&rev=546999&r1=546998&r2=546999 ============================================================================== --- tomcat/trunk/java/org/apache/coyote/ActionCode.java (original) +++ tomcat/trunk/java/org/apache/coyote/ActionCode.java Wed Jun 13 11:51:38 2007 @@ -159,7 +159,7 @@ /** * Configure a Comet connection */ - public static final ActionCode ACTION_COMET_CONFIGURE = new ActionCode(25); + public static final ActionCode ACTION_COMET_CONFIGURE_BLOCKING = new ActionCode(25); /** * Register notifications for events for a certain comet connection Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?view=diff&rev=546999&r1=546998&r2=546999 ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Wed Jun 13 11:51:38 2007 @@ -1227,7 +1227,9 @@ RequestInfo rp = request.getRequestProcessor(); if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) socket.getPoller().cometInterest(socket); - } else if (actionCode == ActionCode.ACTION_COMET_CONFIGURE) { + } else if (actionCode == ActionCode.ACTION_COMET_CONFIGURE_BLOCKING) { + MutableBoolean bool = (MutableBoolean)param; + if ( bool.get() ) throw new IllegalStateException("Not yet implemented"); } else if (actionCode == ActionCode.ACTION_COMET_READABLE) { MutableBoolean bool = (MutableBoolean)param; try { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]