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
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 {
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();
public void clear() {
request = null;
response = null;
- cometConfigurations.clear();
+ blocking = true;
cometOperations.clear();
}
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 {
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() {
/**
* 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
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 {