Java Mailing List Archive

http://www.junlu.com/

Home » dev-digest.tomcat »

dev Digest 7 Feb 2012 12:26:24 -0000 Issue 6234

dev-digest-help

2012-02-07


Author LoginPost Reply

dev Digest 7 Feb 2012 12:26:24 -0000 Issue 6234

Topics (messages 124566 through 124567):

svn commit: r1241411 - in /tomcat/trunk/java/org/apache/coyote/http11/upgrade: UpgradeAprProcessor.java UpgradeBioProcessor.java UpgradeNioProcessor.java UpgradeProcessor.java
 124566 by: markt.apache.org

svn commit: r1241441 - in /tomcat/trunk/java/org/apache/coyote: ./ ajp/ http11/ http11/upgrade/
 124567 by: markt.apache.org

Administrivia:

---------------------------------------------------------------------
To post to the list, e-mail: dev@(protected)
To unsubscribe, e-mail: dev-digest-unsubscribe@(protected)
For additional commands, e-mail: dev-digest-help@(protected)

----------------------------------------------------------------------


Attachment: dev_124566.ezm (zipped)
Author: markt
Date: Tue Feb 7 10:19:51 2012
New Revision: 1241411

URL: http://svn.apache.org/viewvc?rev=1241411&view=rev
Log:
eol

Modified:
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java  (contents, props changed)
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java  (contents, props changed)
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java  (contents, props changed)
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java  (contents, props changed)

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java?rev=1241411&r1=1241410&r2=1241411&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java Tue Feb 7 10:19:51 2012
@@(protected) @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.coyote.http11.upgrade;
-
-import java.io.IOException;
-
-import org.apache.coyote.http11.Http11AprProcessor;
-import org.apache.tomcat.jni.Socket;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
-import org.apache.tomcat.util.net.SocketStatus;
-import org.apache.tomcat.util.net.SocketWrapper;
-
-/**
- * Implementation note: The need to extend Http11Processor could probably be
- * removed if the Processor interface was expanded to cover all of the methods
- * required by the AbstractProtocol. That would simplify the code and further
- * reduce the size of instances of this class.
- */
-public class UpgradeAprProcessor extends Http11AprProcessor
-     implements UpgradeProcessor {
-
-   long socket;
-
-   public UpgradeAprProcessor(SocketWrapper<Long> wrapper,
-        UpgradeInbound inbound) {
-     this.socket = wrapper.getSocket().longValue();
-
-     this.upgradeInbound = inbound;
-     upgradeInbound.setUpgradeProcessor(this);
-     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
-     // Remove the default - no need for it here
-     this.compressableMimeTypes = null;
-   }
-
-
-   @Override
-   public SocketState upgradeDispatch() throws IOException {
-     return upgradeInbound.onData();
-   }
-
-
-   /*
-   * Output methods
-   */
-   @Override
-   public void flush() throws IOException {
-     // NOOP
-   }
-
-
-   @Override
-   public void write(int b) throws IOException {
-     Socket.send(socket, new byte[] {(byte) b}, 0, 1);
-   }
-
-
-   /*
-   * Input methods
-   */
-   @Override
-   public int read() throws IOException {
-     byte[] bytes = new byte[1];
-     Socket.recv(socket, bytes, 0, 1);
-     return bytes[0];
-   }
-
-
-   @Override
-   public int read(byte[] bytes) throws IOException {
-     return Socket.recv(socket, bytes, 0, bytes.length);
-   }
-
-
-   /*
-   * None of the following NO-OP methods are strictly necessary - assuming the
-   * there are no bugs in the connector code that cause upgraded connections
-   * to be treated as Http11, Comet or Async. These NO-OP methods are here for
-   * safety and to aid debugging during development.
-   */
-
-   @Override
-   public SocketState event(SocketStatus status) throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState process(SocketWrapper<Long> socketWrapper)
-        throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncDispatch(SocketStatus status) {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncPostProcess() {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http11.upgrade;
+
+import java.io.IOException;
+
+import org.apache.coyote.http11.Http11AprProcessor;
+import org.apache.tomcat.jni.Socket;
+import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
+import org.apache.tomcat.util.net.SocketStatus;
+import org.apache.tomcat.util.net.SocketWrapper;
+
+/**
+ * Implementation note: The need to extend Http11Processor could probably be
+ * removed if the Processor interface was expanded to cover all of the methods
+ * required by the AbstractProtocol. That would simplify the code and further
+ * reduce the size of instances of this class.
+ */
+public class UpgradeAprProcessor extends Http11AprProcessor
+     implements UpgradeProcessor {
+
+   long socket;
+
+   public UpgradeAprProcessor(SocketWrapper<Long> wrapper,
+        UpgradeInbound inbound) {
+     this.socket = wrapper.getSocket().longValue();
+
+     this.upgradeInbound = inbound;
+     upgradeInbound.setUpgradeProcessor(this);
+     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
+     // Remove the default - no need for it here
+     this.compressableMimeTypes = null;
+   }
+
+
+   @Override
+   public SocketState upgradeDispatch() throws IOException {
+     return upgradeInbound.onData();
+   }
+
+
+   /*
+   * Output methods
+   */
+   @Override
+   public void flush() throws IOException {
+     // NOOP
+   }
+
+
+   @Override
+   public void write(int b) throws IOException {
+     Socket.send(socket, new byte[] {(byte) b}, 0, 1);
+   }
+
+
+   /*
+   * Input methods
+   */
+   @Override
+   public int read() throws IOException {
+     byte[] bytes = new byte[1];
+     Socket.recv(socket, bytes, 0, 1);
+     return bytes[0];
+   }
+
+
+   @Override
+   public int read(byte[] bytes) throws IOException {
+     return Socket.recv(socket, bytes, 0, bytes.length);
+   }
+
+
+   /*
+   * None of the following NO-OP methods are strictly necessary - assuming the
+   * there are no bugs in the connector code that cause upgraded connections
+   * to be treated as Http11, Comet or Async. These NO-OP methods are here for
+   * safety and to aid debugging during development.
+   */
+
+   @Override
+   public SocketState event(SocketStatus status) throws IOException {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+
+   @Override
+   public SocketState process(SocketWrapper<Long> socketWrapper)
+        throws IOException {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+
+   @Override
+   public SocketState asyncDispatch(SocketStatus status) {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+
+   @Override
+   public SocketState asyncPostProcess() {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+}

Propchange: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java
------------------------------------------------------------------------------
  svn:eol-style = native

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java?rev=1241411&r1=1241410&r2=1241411&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java Tue Feb 7 10:19:51 2012
@@(protected) @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.coyote.http11.upgrade;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-
-import org.apache.coyote.http11.Http11Processor;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
-import org.apache.tomcat.util.net.SocketStatus;
-import org.apache.tomcat.util.net.SocketWrapper;
-
-/**
- * Implementation note: The need to extend Http11Processor could probably be
- * removed if the Processor interface was expanded to cover all of the methods
- * required by the AbstractProtocol. That would simplify the code and further
- * reduce the size of instances of this class.
- */
-public class UpgradeBioProcessor extends Http11Processor
-     implements UpgradeProcessor{
-
-   private InputStream inputStream;
-   private OutputStream outputStream;
-
-   public UpgradeBioProcessor(SocketWrapper<Socket> wrapper,
-        UpgradeInbound inbound) throws IOException {
-     this.inputStream = wrapper.getSocket().getInputStream();
-     this.outputStream = wrapper.getSocket().getOutputStream();
-     this.upgradeInbound = inbound;
-     upgradeInbound.setUpgradeProcessor(this);
-     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
-     // Remove the default - no need for it here
-     this.compressableMimeTypes = null;
-   }
-
-
-   @Override
-   public SocketState upgradeDispatch() throws IOException {
-     return upgradeInbound.onData();
-   }
-
-
-   /*
-   * Output methods
-   */
-   @Override
-   public void flush() throws IOException {
-     outputStream.flush();
-   }
-
-
-   @Override
-   public void write(int b) throws IOException {
-     outputStream.write(b);
-   }
-
-
-   /*
-   * Input methods
-   */
-   @Override
-   public int read() throws IOException {
-     return inputStream.read();
-   }
-
-
-   @Override
-   public int read(byte[] bytes) throws IOException {
-     return inputStream.read(bytes);
-   }
-
-
-   /*
-   * None of the following NO-OP methods are strictly necessary - assuming the
-   * there are no bugs in the connector code that cause upgraded connections
-   * to be treated as Http11, Comet or Async. These NO-OP methods are here for
-   * safety and to aid debugging during development.
-   */
-
-   @Override
-   public SocketState event(SocketStatus status) throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState process(SocketWrapper<Socket> socketWrapper)
-        throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncDispatch(SocketStatus status) {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncPostProcess() {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http11.upgrade;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+
+import org.apache.coyote.http11.Http11Processor;
+import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
+import org.apache.tomcat.util.net.SocketStatus;
+import org.apache.tomcat.util.net.SocketWrapper;
+
+/**
+ * Implementation note: The need to extend Http11Processor could probably be
+ * removed if the Processor interface was expanded to cover all of the methods
+ * required by the AbstractProtocol. That would simplify the code and further
+ * reduce the size of instances of this class.
+ */
+public class UpgradeBioProcessor extends Http11Processor
+     implements UpgradeProcessor{
+
+   private InputStream inputStream;
+   private OutputStream outputStream;
+
+   public UpgradeBioProcessor(SocketWrapper<Socket> wrapper,
+        UpgradeInbound inbound) throws IOException {
+     this.inputStream = wrapper.getSocket().getInputStream();
+     this.outputStream = wrapper.getSocket().getOutputStream();
+     this.upgradeInbound = inbound;
+     upgradeInbound.setUpgradeProcessor(this);
+     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
+     // Remove the default - no need for it here
+     this.compressableMimeTypes = null;
+   }
+
+
+   @Override
+   public SocketState upgradeDispatch() throws IOException {
+     return upgradeInbound.onData();
+   }
+
+
+   /*
+   * Output methods
+   */
+   @Override
+   public void flush() throws IOException {
+     outputStream.flush();
+   }
+
+
+   @Override
+   public void write(int b) throws IOException {
+     outputStream.write(b);
+   }
+
+
+   /*
+   * Input methods
+   */
+   @Override
+   public int read() throws IOException {
+     return inputStream.read();
+   }
+
+
+   @Override
+   public int read(byte[] bytes) throws IOException {
+     return inputStream.read(bytes);
+   }
+
+
+   /*
+   * None of the following NO-OP methods are strictly necessary - assuming the
+   * there are no bugs in the connector code that cause upgraded connections
+   * to be treated as Http11, Comet or Async. These NO-OP methods are here for
+   * safety and to aid debugging during development.
+   */
+
+   @Override
+   public SocketState event(SocketStatus status) throws IOException {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+
+   @Override
+   public SocketState process(SocketWrapper<Socket> socketWrapper)
+        throws IOException {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+
+   @Override
+   public SocketState asyncDispatch(SocketStatus status) {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+
+   @Override
+   public SocketState asyncPostProcess() {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+}

Propchange: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java
------------------------------------------------------------------------------
  svn:eol-style = native

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java?rev=1241411&r1=1241410&r2=1241411&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java Tue Feb 7 10:19:51 2012
@@(protected) @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.coyote.http11.upgrade;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.nio.channels.Selector;
-
-import org.apache.coyote.http11.Http11NioProcessor;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
-import org.apache.tomcat.util.net.NioChannel;
-import org.apache.tomcat.util.net.NioEndpoint;
-import org.apache.tomcat.util.net.NioSelectorPool;
-import org.apache.tomcat.util.net.SocketStatus;
-import org.apache.tomcat.util.net.SocketWrapper;
-
-/**
- * Implementation note: The need to extend Http11Processor could probably be
- * removed if the Processor interface was expanded to cover all of the methods
- * required by the AbstractProtocol. That would simplify the code and further
- * reduce the size of instances of this class.
- */
-public class UpgradeNioProcessor extends Http11NioProcessor
-     implements UpgradeProcessor {
-
-   private NioChannel nioChannel;
-   private NioSelectorPool pool;
-
-   public UpgradeNioProcessor(SocketWrapper<NioChannel> wrapper,
-        UpgradeInbound inbound, NioSelectorPool pool) {
-     this.nioChannel = wrapper.getSocket();
-     this.pool = pool;
-
-     this.upgradeInbound = inbound;
-     upgradeInbound.setUpgradeProcessor(this);
-     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
-     // Remove the default - no need for it here
-     this.compressableMimeTypes = null;
-   }
-
-
-   @Override
-   public SocketState upgradeDispatch() throws IOException {
-     return upgradeInbound.onData();
-   }
-
-
-   /*
-   * Output methods
-   */
-   @Override
-   public void flush() throws IOException {
-     NioEndpoint.KeyAttachment att =
-           (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
-     if (att == null) {
-        throw new IOException("Key must be cancelled");
-     }
-     long writeTimeout = att.getTimeout();
-     Selector selector = null;
-     try {
-        selector = pool.get();
-     } catch ( IOException x ) {
-        //ignore
-     }
-     try {
-        do {
-           if (nioChannel.flush(true, selector, writeTimeout)) {
-             break;
-           }
-        } while (true);
-     } finally {
-        if (selector != null) {
-           pool.put(selector);
-        }
-     }
-   }
-
-   @Override
-   public void write(int b) throws IOException {
-     writeToSocket(new byte[] {(byte) b});
-   }
-
-   /*
-   * Input methods
-   */
-   @Override
-   public int read() throws IOException {
-     byte[] bytes = new byte[1];
-     readSocket(true, bytes, 0, 1);
-     return bytes[0];
-   }
-
-   @Override
-   public int read(byte[] bytes) throws IOException {
-     return readSocket(true, bytes, 0, bytes.length);
-   }
-
-
-   /*
-   * Adapted from the NioInputBuffer.
-   */
-   private int readSocket(boolean block, byte[] bytes, int offset, int len)
-        throws IOException {
-
-     int nRead = 0;
-     nioChannel.getBufHandler().getReadBuffer().clear();
-     nioChannel.getBufHandler().getReadBuffer().limit(len);
-     if (block) {
-        Selector selector = null;
-        try {
-           selector = pool.get();
-        } catch ( IOException x ) {
-           // Ignore
-        }
-        try {
-           NioEndpoint.KeyAttachment att =
-                (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
-           if (att == null) {
-             throw new IOException("Key must be cancelled.");
-           }
-           nRead = pool.read(nioChannel.getBufHandler().getReadBuffer(),
-                nioChannel, selector, att.getTimeout());
-        } catch (EOFException eof) {
-           nRead = -1;
-        } finally {
-           if (selector != null) {
-             pool.put(selector);
-           }
-        }
-     } else {
-        nRead = nioChannel.read(nioChannel.getBufHandler().getReadBuffer());
-     }
-     if (nRead > 0) {
-        nioChannel.getBufHandler().getReadBuffer().flip();
-        nioChannel.getBufHandler().getReadBuffer().limit(nRead);
-        nioChannel.getBufHandler().getReadBuffer().get(bytes, offset, nRead);
-        return nRead;
-     } else if (nRead == -1) {
-        //return false;
-        throw new EOFException(sm.getString("iib.eof.error"));
-     } else {
-        return 0;
-     }
-   }
-
-
-   /*
-   * Adapted from the NioOutputBuffer
-   */
-   private synchronized int writeToSocket(byte[] bytes) throws IOException {
-
-     nioChannel.getBufHandler().getWriteBuffer().clear();
-     nioChannel.getBufHandler().getWriteBuffer().put(bytes);
-     nioChannel.getBufHandler().getWriteBuffer().flip();
-
-     int written = 0;
-     NioEndpoint.KeyAttachment att =
-           (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
-     if (att == null) {
-        throw new IOException("Key must be cancelled");
-     }
-     long writeTimeout = att.getTimeout();
-     Selector selector = null;
-     try {
-        selector = pool.get();
-     } catch ( IOException x ) {
-        //ignore
-     }
-     try {
-        written = pool.write(nioChannel.getBufHandler().getWriteBuffer(),
-             nioChannel, selector, writeTimeout, true);
-     } finally {
-        if (selector != null) {
-           pool.put(selector);
-        }
-     }
-     return written;
-   }
-
-   /*
-   * None of the following NO-OP methods are strictly necessary - assuming the
-   * there are no bugs in the connector code that cause upgraded connections
-   * to be treated as Http11, Comet or Async. These NO-OP methods are here for
-   * safety and to aid debugging during development.
-   */
-
-   @Override
-   public SocketState event(SocketStatus status) throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState process(SocketWrapper<NioChannel> socketWrapper)
-        throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncDispatch(SocketStatus status) {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncPostProcess() {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http11.upgrade;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.nio.channels.Selector;
+
+import org.apache.coyote.http11.Http11NioProcessor;
+import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
+import org.apache.tomcat.util.net.NioChannel;
+import org.apache.tomcat.util.net.NioEndpoint;
+import org.apache.tomcat.util.net.NioSelectorPool;
+import org.apache.tomcat.util.net.SocketStatus;
+import org.apache.tomcat.util.net.SocketWrapper;
+
+/**
+ * Implementation note: The need to extend Http11Processor could probably be
+ * removed if the Processor interface was expanded to cover all of the methods
+ * required by the AbstractProtocol. That would simplify the code and further
+ * reduce the size of instances of this class.
+ */
+public class UpgradeNioProcessor extends Http11NioProcessor
+     implements UpgradeProcessor {
+
+   private NioChannel nioChannel;
+   private NioSelectorPool pool;
+
+   public UpgradeNioProcessor(SocketWrapper<NioChannel> wrapper,
+        UpgradeInbound inbound, NioSelectorPool pool) {
+     this.nioChannel = wrapper.getSocket();
+     this.pool = pool;
+
+     this.upgradeInbound = inbound;
+     upgradeInbound.setUpgradeProcessor(this);
+     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
+     // Remove the default - no need for it here
+     this.compressableMimeTypes = null;
+   }
+
+
+   @Override
+   public SocketState upgradeDispatch() throws IOException {
+     return upgradeInbound.onData();
+   }
+
+
+   /*
+   * Output methods
+   */
+   @Override
+   public void flush() throws IOException {
+     NioEndpoint.KeyAttachment att =
+           (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
+     if (att == null) {
+        throw new IOException("Key must be cancelled");
+     }
+     long writeTimeout = att.getTimeout();
+     Selector selector = null;
+     try {
+        selector = pool.get();
+     } catch ( IOException x ) {
+        //ignore
+     }
+     try {
+        do {
+           if (nioChannel.flush(true, selector, writeTimeout)) {
+             break;
+           }
+        } while (true);
+     } finally {
+        if (selector != null) {
+           pool.put(selector);
+        }
+     }
+   }
+
+   @Override
+   public void write(int b) throws IOException {
+     writeToSocket(new byte[] {(byte) b});
+   }
+
+   /*
+   * Input methods
+   */
+   @Override
+   public int read() throws IOException {
+     byte[] bytes = new byte[1];
+     readSocket(true, bytes, 0, 1);
+     return bytes[0];
+   }
+
+   @Override
+   public int read(byte[] bytes) throws IOException {
+     return readSocket(true, bytes, 0, bytes.length);
+   }
+
+
+   /*
+   * Adapted from the NioInputBuffer.
+   */
+   private int readSocket(boolean block, byte[] bytes, int offset, int len)
+        throws IOException {
+
+     int nRead = 0;
+     nioChannel.getBufHandler().getReadBuffer().clear();
+     nioChannel.getBufHandler().getReadBuffer().limit(len);
+     if (block) {
+        Selector selector = null;
+        try {
+           selector = pool.get();
+        } catch ( IOException x ) {
+           // Ignore
+        }
+        try {
+           NioEndpoint.KeyAttachment att =
+                (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
+           if (att == null) {
+             throw new IOException("Key must be cancelled.");
+           }
+           nRead = pool.read(nioChannel.getBufHandler().getReadBuffer(),
+                nioChannel, selector, att.getTimeout());
+        } catch (EOFException eof) {
+           nRead = -1;
+        } finally {
+           if (selector != null) {
+             pool.put(selector);
+           }
+        }
+     } else {
+        nRead = nioChannel.read(nioChannel.getBufHandler().getReadBuffer());
+     }
+     if (nRead > 0) {
+        nioChannel.getBufHandler().getReadBuffer().flip();
+        nioChannel.getBufHandler().getReadBuffer().limit(nRead);
+        nioChannel.getBufHandler().getReadBuffer().get(bytes, offset, nRead);
+        return nRead;
+     } else if (nRead == -1) {
+        //return false;
+        throw new EOFException(sm.getString("iib.eof.error"));
+     } else {
+        return 0;
+     }
+   }
+
+
+   /*
+   * Adapted from the NioOutputBuffer
+   */
+   private synchronized int writeToSocket(byte[] bytes) throws IOException {
+
+     nioChannel.getBufHandler().getWriteBuffer().clear();
+     nioChannel.getBufHandler().getWriteBuffer().put(bytes);
+     nioChannel.getBufHandler().getWriteBuffer().flip();
+
+     int written = 0;
+     NioEndpoint.KeyAttachment att =
+           (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
+     if (att == null) {
+        throw new IOException("Key must be cancelled");
+     }
+     long writeTimeout = att.getTimeout();
+     Selector selector = null;
+     try {
+        selector = pool.get();
+     } catch ( IOException x ) {
+        //ignore
+     }
+     try {
+        written = pool.write(nioChannel.getBufHandler().getWriteBuffer(),
+             nioChannel, selector, writeTimeout, true);
+     } finally {
+        if (selector != null) {
+           pool.put(selector);
+        }
+     }
+     return written;
+   }
+
+   /*
+   * None of the following NO-OP methods are strictly necessary - assuming the
+   * there are no bugs in the connector code that cause upgraded connections
+   * to be treated as Http11, Comet or Async. These NO-OP methods are here for
+   * safety and to aid debugging during development.
+   */
+
+   @Override
+   public SocketState event(SocketStatus status) throws IOException {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+
+   @Override
+   public SocketState process(SocketWrapper<NioChannel> socketWrapper)
+        throws IOException {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+
+   @Override
+   public SocketState asyncDispatch(SocketStatus status) {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+
+
+   @Override
+   public SocketState asyncPostProcess() {
+     // TODO Log an error
+     return SocketState.CLOSED;
+   }
+}

Propchange: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java
------------------------------------------------------------------------------
  svn:eol-style = native

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java?rev=1241411&r1=1241410&r2=1241411&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java Tue Feb 7 10:19:51 2012
@@(protected) @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.coyote.http11.upgrade;
-
-import java.io.IOException;
-
-public interface UpgradeProcessor {
-
-   // Output methods
-   public void flush() throws IOException;
-   public void write(int b) throws IOException;
-
-   // Input methods
-   public int read() throws IOException;
-   public int read(byte[] bytes) throws IOException;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http11.upgrade;
+
+import java.io.IOException;
+
+public interface UpgradeProcessor {
+
+   // Output methods
+   public void flush() throws IOException;
+   public void write(int b) throws IOException;
+
+   // Input methods
+   public int read() throws IOException;
+   public int read(byte[] bytes) throws IOException;
+}

Propchange: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java
------------------------------------------------------------------------------
  svn:eol-style = native




Attachment: dev_124567.ezm (zipped)
Author: markt
Date: Tue Feb 7 12:25:57 2012
New Revision: 1241441

URL: http://svn.apache.org/viewvc?rev=1241441&view=rev
Log:
Refactor the connectors to allow lighter weight UpgradeProcessor
implementations that do not depend on Http11Processors.
The main change is the expansion of the Processor interface and the
use of that interface rather than the AbstractProcessor.

Added:
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/Constants.java
   - copied, changed from r1241411, tomcat/trunk/java/org/apache/coyote/Processor.java
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties
Modified:
  tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java
  tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
  tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java
  tomcat/trunk/java/org/apache/coyote/Processor.java
  tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
  tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
  tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
  tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java
  tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
  tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties
  tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
  tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
  tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
  tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
  tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
  tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
  tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java
  tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java Tue Feb 7 12:25:57 2012
@@(protected)
* Provides functionality and attributes common to all supported protocols
* (currently HTTP and AJP).
*/
-public abstract class AbstractProcessor<S> implements ActionHook, Processor {
+public abstract class AbstractProcessor<S> implements ActionHook, Processor<S> {

  protected Adapter adapter;
-   protected AsyncStateMachine asyncStateMachine;
+   protected AsyncStateMachine<S> asyncStateMachine;
  protected AbstractEndpoint endpoint;
  protected Request request;
  protected Response response;
@@(protected)<

  public AbstractProcessor(AbstractEndpoint endpoint) {
     this.endpoint = endpoint;
-     asyncStateMachine = new AsyncStateMachine(this);
+     asyncStateMachine = new AsyncStateMachine<S>(this);

     request = new Request();

@@(protected)<
  /**
   * The request associated with this processor.
   */
+   @Override
  public Request getRequest() {
     return request;
  }
@@(protected)<
  }


+   @Override
  public boolean isAsync() {
     return (asyncStateMachine != null && asyncStateMachine.isAsync());
  }


+   @Override
  public SocketState asyncPostProcess() {
     return asyncStateMachine.asyncPostProcess();
  }

-   protected abstract boolean isComet();
+   @Override
+   public abstract boolean isComet();

-   protected abstract boolean isUpgrade();
+   @Override
+   public abstract boolean isUpgrade();

  /**
   * Process HTTP requests. All requests are treated as HTTP requests to start
   * with although they may change type during processing.
   */
+   @Override
  public abstract SocketState process(SocketWrapper<S> socket)
     throws IOException;

  /**
   * Process in-progress Comet requests. These will start as HTTP requests.
   */
+   @Override
  public abstract SocketState event(SocketStatus status) throws IOException;

  /**
   * Process in-progress Servlet 3.0 Async requests. These will start as HTTP
   * requests.
   */
+   @Override
  public abstract SocketState asyncDispatch(SocketStatus status);

  /**
   * Processes data received on a connection that has been through an HTTP
   * upgrade.
   */
+   @Override
  public abstract SocketState upgradeDispatch() throws IOException;

+   @Override
  public abstract UpgradeInbound getUpgradeInbound();
}

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java Tue Feb 7 12:25:57 2012
@@(protected)

  // ------------------------------------------- Connection handler base class

-   protected abstract static class AbstractConnectionHandler<S,P extends AbstractProcessor<S>>
+   protected abstract static class AbstractConnectionHandler<S,P extends Processor<S>>
        implements AbstractEndpoint.Handler {

     protected abstract Log getLog();
@@(protected)
     protected RequestGroupInfo global = new RequestGroupInfo();
     protected AtomicLong registerCount = new AtomicLong(0);

-     protected ConcurrentHashMap<S,P> connections =
-        new ConcurrentHashMap<S,P>();
+     protected ConcurrentHashMap<S,Processor<S>> connections =
+        new ConcurrentHashMap<S,Processor<S>>();

     protected RecycledProcessors<P,S> recycledProcessors =
        new RecycledProcessors<P,S>(this);
@@(protected)

     public SocketState process(SocketWrapper<S> socket,
          SocketStatus status) {
-        P processor = connections.remove(socket.getSocket());
+        Processor<S> processor = connections.remove(socket.getSocket());

        socket.setAsync(false);

@@(protected)
     }

     protected abstract P createProcessor();
-     protected abstract void initSsl(SocketWrapper<S> socket, P processor);
-     protected abstract void longPoll(SocketWrapper<S> socket, P processor);
+     protected abstract void initSsl(SocketWrapper<S> socket,
+           Processor<S> processor);
+     protected abstract void longPoll(SocketWrapper<S> socket,
+           Processor<S> processor);
     protected abstract void upgradePoll(SocketWrapper<S> socket,
-           P processor);
-     protected abstract void release(SocketWrapper<S> socket, P processor,
-           boolean socketClosing, boolean addToPoller);
-     protected abstract P createUpgradeProcessor(SocketWrapper<S> socket,
+           Processor<S> processor);
+     protected abstract void release(SocketWrapper<S> socket,
+           Processor<S> processor, boolean socketClosing,
+           boolean addToPoller);
+     protected abstract Processor<S> createUpgradeProcessor(
+           SocketWrapper<S> socket,
          UpgradeInbound inbound) throws IOException;

     protected void register(AbstractProcessor<S> processor) {
@@(protected)
        }
     }

-     protected void unregister(AbstractProcessor<S> processor) {
+     protected void unregister(Processor<S> processor) {
        if (getProtocol().getDomain() != null) {
          synchronized (this) {
             try {
@@(protected)
     }
  }

-   protected static class RecycledProcessors<P extends AbstractProcessor<S>, S>
-        extends ConcurrentLinkedQueue<P> {
+   protected static class RecycledProcessors<P extends Processor<S>, S>
+        extends ConcurrentLinkedQueue<Processor<S>> {

     private static final long serialVersionUID = 1L;
     private transient AbstractConnectionHandler<S,P> handler;
@@(protected)
     }

     @Override
-     public boolean offer(P processor) {
+     public boolean offer(Processor<S> processor) {
        int cacheSize = handler.getProtocol().getProcessorCache();
        boolean offer = cacheSize == -1 ? true : size.get() < cacheSize;
        //avoid over growing our cache or add after we have stopped
@@(protected)
     }

     @Override
-     public P poll() {
-        P result = super.poll();
+     public Processor<S> poll() {
+        Processor<S> result = super.poll();
        if (result != null) {
          size.decrementAndGet();
        }
@@(protected)

     @Override
     public void clear() {
-        P next = poll();
+        Processor<S> next = poll();
        while (next != null) {
          handler.unregister(next);
          next = poll();

Modified: tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java Tue Feb 7 12:25:57 2012
@@(protected)
*                      error()
* </pre>
*/
-public class AsyncStateMachine {
+public class AsyncStateMachine<S> {

  /**
   * The string manager for this package.
@@(protected) {
  private volatile AsyncState state = AsyncState.DISPATCHED;
  // Need this to fire listener on complete
  private AsyncContextCallback asyncCtxt = null;
-   private Processor processor;
+   private Processor<S> processor;


-   public AsyncStateMachine(Processor processor) {
+   public AsyncStateMachine(Processor<S> processor) {
     this.processor = processor;
  }


Modified: tomcat/trunk/java/org/apache/coyote/Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/Processor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/Processor.java Tue Feb 7 12:25:57 2012
@@(protected) @@

package org.apache.coyote;

+import java.io.IOException;
import java.util.concurrent.Executor;

+import org.apache.coyote.http11.upgrade.UpgradeInbound;
+import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
+import org.apache.tomcat.util.net.SSLSupport;
+import org.apache.tomcat.util.net.SocketStatus;
+import org.apache.tomcat.util.net.SocketWrapper;
+

/**
* Common interface for processors of all protocols.
*/
-public interface Processor {
+public interface Processor<S> {
  Executor getExecutor();
+
+   SocketState process(SocketWrapper<S> socketWrapper) throws IOException;
+
+   SocketState event(SocketStatus status) throws IOException;
+
+   SocketState asyncDispatch(SocketStatus status);
+   SocketState asyncPostProcess();
+
+   UpgradeInbound getUpgradeInbound();
+   SocketState upgradeDispatch() throws IOException;
+
+   boolean isComet();
+   boolean isAsync();
+   boolean isUpgrade();
+
+   Request getRequest();
+
+   void recycle(boolean socketClosing);
+
+   void setSslSupport(SSLSupport sslSupport);
}

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java Tue Feb 7 12:25:57 2012
@@(protected)


  @Override
+   public void setSslSupport(SSLSupport sslSupport) {
+     // Should never reach this code but in case we do...
+     throw new IllegalStateException(
+           sm.getString("ajpprocessor.ssl.notsupported"));
+   }
+
+
+   @Override
  public SocketState event(SocketStatus status) throws IOException {
     // Should never reach this code but in case we do...
     throw new IOException(
@@(protected)
   *               allowing the processor to perform any additional
   *               clean-up that may be required
   */
+   @Override
  public void recycle(boolean socketClosing) {
     asyncStateMachine.recycle();

@@(protected)


  @Override
-   protected final boolean isComet() {
+   public final boolean isComet() {
     // AJP does not support Comet
     return false;
  }


  @Override
-   protected final boolean isUpgrade() {
+   public final boolean isUpgrade() {
     // AJP does not support HTTP upgrade
     return false;
  }

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java Tue Feb 7 12:25:57 2012
@@(protected) @@
package org.apache.coyote.ajp;

import org.apache.coyote.AbstractProtocol;
+import org.apache.coyote.Processor;
import org.apache.coyote.http11.upgrade.UpgradeInbound;
import org.apache.tomcat.util.net.SocketWrapper;
import org.apache.tomcat.util.res.StringManager;
@@(protected)
        extends AbstractConnectionHandler<S, P> {

     @Override
-     protected void initSsl(SocketWrapper<S> socket, P processor) {
+     protected void initSsl(SocketWrapper<S> socket, Processor<S> processor) {
        // NOOP for AJP
     }

     @Override
-     protected void longPoll(SocketWrapper<S> socket, P processor) {
+     protected void longPoll(SocketWrapper<S> socket,
+           Processor<S> processor) {
        // Same requirements for all AJP connectors
        connections.put(socket.getSocket(), processor);
        socket.setAsync(true);
     }

     @Override
-     protected void upgradePoll(SocketWrapper<S> socket, P processor) {
+     protected void upgradePoll(SocketWrapper<S> socket,
+           Processor<S> processor) {
        // TODO Should never happen. ISE?
     }


Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java Tue Feb 7 12:25:57 2012
@@(protected) @@
package org.apache.coyote.ajp;

import org.apache.coyote.AbstractProtocol;
+import org.apache.coyote.Processor;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.net.AbstractEndpoint;
@@(protected)
      */
     @Override
     public void release(SocketWrapper<Long> socket,
-           AjpAprProcessor processor, boolean isSocketClosing,
+           Processor<Long> processor, boolean isSocketClosing,
          boolean addToPoller) {
        processor.recycle(isSocketClosing);
        recycledProcessors.offer(processor);

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java Tue Feb 7 12:25:57 2012
@@(protected);
import java.util.Iterator;

import org.apache.coyote.AbstractProtocol;
+import org.apache.coyote.Processor;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.net.AbstractEndpoint;
@@(protected)
        if (log.isDebugEnabled())
          log.debug("Iterating through our connections to release a socket channel:"+socket);
        boolean released = false;
-        Iterator<java.util.Map.Entry<NioChannel, AjpNioProcessor>> it = connections.entrySet().iterator();
+        Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
        while (it.hasNext()) {
-           java.util.Map.Entry<NioChannel, AjpNioProcessor> entry = it.next();
+           java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
          if (entry.getKey().getIOChannel()==socket) {
             it.remove();
-             AjpNioProcessor result = entry.getValue();
+             Processor<NioChannel> result = entry.getValue();
             result.recycle(true);
             unregister(result);
             released = true;
@@(protected)
      */
     @Override
     public void release(SocketWrapper<NioChannel> socket) {
-        AjpNioProcessor processor = connections.remove(socket);
+        Processor<NioChannel> processor = connections.remove(socket);
        if (processor != null) {
          processor.recycle(true);
          recycledProcessors.offer(processor);
@@(protected)
      */
     @Override
     public void release(SocketWrapper<NioChannel> socket,
-           AjpNioProcessor processor, boolean isSocketClosing,
+           Processor<NioChannel> processor, boolean isSocketClosing,
          boolean addToPoller) {
        processor.recycle(isSocketClosing);
        recycledProcessors.offer(processor);

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java Tue Feb 7 12:25:57 2012
@@(protected);
import java.net.Socket;

import org.apache.coyote.AbstractProtocol;
+import org.apache.coyote.Processor;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.net.AbstractEndpoint;
@@(protected)
      */
     @Override
     public void release(SocketWrapper<Socket> socket,
-           AjpProcessor processor, boolean isSocketClosing,
+           Processor<Socket> processor, boolean isSocketClosing,
          boolean addToPoller) {
        processor.recycle(isSocketClosing);
        recycledProcessors.offer(processor);

Modified: tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties Tue Feb 7 12:25:57 2012
@@(protected)
ajpprocessor.request.process=Error processing request
ajpprocessor.certs.fail=Certificate conversion failed
ajpprocessor.comet.notsupported=The Comet protocol is not supported by this connector
+ajpprocessor.ssl.notsupported=The SSL protocol is not supported by this connector
ajpprocessor.httpupgrade.notsupported=HTTP upgrades are not supported by this connector

ajpmessage.null=Cannot append null value

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Tue Feb 7 12:25:57 2012
@@(protected)
  }


+   @Override
  public UpgradeInbound getUpgradeInbound() {
     return upgradeInbound;
  }
@@(protected)
        SocketWrapper<S> socketWrapper);


-   public final void recycle() {
+
+   @Override
+   public final void recycle(boolean isSocketClosing) {
     if (getInputBuffer() != null) {
        getInputBuffer().recycle();
     }

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Tue Feb 7 12:25:57 2012
@@(protected)
  }


+   @Override
+   public void setSslSupport(SSLSupport sslSupport) {
+     // NOOP for APR
+   }
+
  // ----------------------------------------------------- ActionHook Methods



Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Tue Feb 7 12:25:57 2012
@@(protected);
import java.io.IOException;

import org.apache.coyote.AbstractProtocol;
+import org.apache.coyote.Processor;
import org.apache.coyote.http11.upgrade.UpgradeAprProcessor;
import org.apache.coyote.http11.upgrade.UpgradeInbound;
import org.apache.juli.logging.Log;
@@(protected)
      */
     @Override
     public void release(SocketWrapper<Long> socket,
-           Http11AprProcessor processor, boolean isSocketClosing,
+           Processor<Long> processor, boolean isSocketClosing,
          boolean addToPoller) {
-        processor.recycle();
+        processor.recycle(isSocketClosing);
        recycledProcessors.offer(processor);
        if (addToPoller && proto.endpoint.isRunning()) {
          ((AprEndpoint)proto.endpoint).getPoller().add(
@@(protected)

     @Override
     protected void initSsl(SocketWrapper<Long> socket,
-           Http11AprProcessor processor) {
+           Processor<Long> processor) {
        // NOOP for APR
     }

     @Override
     protected void longPoll(SocketWrapper<Long> socket,
-           Http11AprProcessor processor) {
+           Processor<Long> processor) {
        connections.put(socket.getSocket(), processor);

        if (processor.isAsync()) {
          socket.setAsync(true);
-        } else if (processor.comet && proto.endpoint.isRunning()) {
+        } else if (processor.isComet() && proto.endpoint.isRunning()) {
          ((AprEndpoint) proto.endpoint).getCometPoller().add(
                socket.getSocket().longValue(), false);
        }
@@(protected)

     @Override
     protected void upgradePoll(SocketWrapper<Long> socket,
-           Http11AprProcessor processor) {
+           Processor<Long> processor) {
        connections.put(socket.getSocket(), processor);
        ((AprEndpoint) proto.endpoint).getPoller().add(
             socket.getSocket().longValue(), false);
@@(protected)
     }

     @Override
-     protected Http11AprProcessor createUpgradeProcessor(
+     protected Processor<Long> createUpgradeProcessor(
          SocketWrapper<Long> socket, UpgradeInbound inbound)
          throws IOException {
        return new UpgradeAprProcessor(socket, inbound);

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?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Tue Feb 7 12:25:57 2012
@@(protected)
  /**
   * Set the SSL information for this HTTP connection.
   */
+   @Override
  public void setSslSupport(SSLSupport sslSupport) {
     this.sslSupport = sslSupport;
  }

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Tue Feb 7 12:25:57 2012
@@(protected);
import java.util.Iterator;

import org.apache.coyote.AbstractProtocol;
+import org.apache.coyote.Processor;
import org.apache.coyote.http11.upgrade.UpgradeInbound;
import org.apache.coyote.http11.upgrade.UpgradeNioProcessor;
import org.apache.juli.logging.Log;
@@(protected)
        if (log.isDebugEnabled())
          log.debug("Iterating through our connections to release a socket channel:"+socket);
        boolean released = false;
-        Iterator<java.util.Map.Entry<NioChannel, Http11NioProcessor>> it = connections.entrySet().iterator();
+        Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
        while (it.hasNext()) {
-           java.util.Map.Entry<NioChannel, Http11NioProcessor> entry = it.next();
+           java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
          if (entry.getKey().getIOChannel()==socket) {
             it.remove();
-             Http11NioProcessor result = entry.getValue();
-             result.recycle();
+             Processor<NioChannel> result = entry.getValue();
+             result.recycle(true);
             unregister(result);
             released = true;
             break;
@@(protected)
      */
     @Override
     public void release(SocketWrapper<NioChannel> socket) {
-        Http11NioProcessor processor =
+        Processor<NioChannel> processor =
          connections.remove(socket.getSocket());
        if (processor != null) {
-           processor.recycle();
+           processor.recycle(true);
          recycledProcessors.offer(processor);
        }
     }
@@(protected)
      */
     @Override
     public void release(SocketWrapper<NioChannel> socket,
-           Http11NioProcessor processor, boolean isSocketClosing,
+           Processor<NioChannel> processor, boolean isSocketClosing,
          boolean addToPoller) {
-        processor.recycle();
+        processor.recycle(isSocketClosing);
        recycledProcessors.offer(processor);
        if (addToPoller) {
          socket.getSocket().getPoller().add(socket.getSocket());
@@(protected)

     @Override
     protected void initSsl(SocketWrapper<NioChannel> socket,
-           Http11NioProcessor processor) {
+           Processor<NioChannel> processor) {
        if (proto.isSSLEnabled() &&
             (proto.sslImplementation != null)
             && (socket.getSocket() instanceof SecureNioChannel)) {
@@(protected)

     @Override
     protected void longPoll(SocketWrapper<NioChannel> socket,
-           Http11NioProcessor processor) {
+           Processor<NioChannel> processor) {
        connections.put(socket.getSocket(), processor);

        if (processor.isAsync()) {
@@(protected)
     }

     @Override
-     protected Http11NioProcessor createUpgradeProcessor(
+     protected Processor<NioChannel> createUpgradeProcessor(
          SocketWrapper<NioChannel> socket, UpgradeInbound inbound)
          throws IOException {
        return new UpgradeNioProcessor(socket, inbound,
@@(protected)

     @Override
     protected void upgradePoll(SocketWrapper<NioChannel> socket,
-           Http11NioProcessor processor) {
+           Processor<NioChannel> processor) {
        connections.put(socket.getSocket(), processor);

        SelectionKey key = socket.getSocket().getIOChannel().keyFor(

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Tue Feb 7 12:25:57 2012
@@(protected)
  /**
   * Set the SSL information for this HTTP connection.
   */
-   public void setSSLSupport(SSLSupport sslSupport) {
+   @Override
+   public void setSslSupport(SSLSupport sslSupport) {
     this.sslSupport = sslSupport;
  }


Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Tue Feb 7 12:25:57 2012
@@(protected);
import java.net.Socket;

import org.apache.coyote.AbstractProtocol;
+import org.apache.coyote.Processor;
import org.apache.coyote.http11.upgrade.UpgradeBioProcessor;
import org.apache.coyote.http11.upgrade.UpgradeInbound;
import org.apache.juli.logging.Log;
@@(protected)
      */
     @Override
     public void release(SocketWrapper<Socket> socket,
-           Http11Processor processor, boolean isSocketClosing,
+           Processor<Socket> processor, boolean isSocketClosing,
          boolean addToPoller) {
-        processor.recycle();
+        processor.recycle(isSocketClosing);
        recycledProcessors.offer(processor);
     }

     @Override
     protected void initSsl(SocketWrapper<Socket> socket,
-           Http11Processor processor) {
+           Processor<Socket> processor) {
        if (proto.isSSLEnabled() && (proto.sslImplementation != null)) {
-           processor.setSSLSupport(
+           processor.setSslSupport(
                proto.sslImplementation.getSSLSupport(
                     socket.getSocket()));
        } else {
-           processor.setSSLSupport(null);
+           processor.setSslSupport(null);
        }

     }

     @Override
     protected void longPoll(SocketWrapper<Socket> socket,
-           Http11Processor processor) {
+           Processor<Socket> processor) {
        connections.put(socket.getSocket(), processor);
     }

@@(protected)
     }

     @Override
-     protected Http11Processor createUpgradeProcessor(
+     protected Processor<Socket> createUpgradeProcessor(
          SocketWrapper<Socket> socket, UpgradeInbound inbound)
          throws IOException {
        return new UpgradeBioProcessor(socket, inbound);
@@(protected)

     @Override
     protected void upgradePoll(SocketWrapper<Socket> socket,
-           Http11Processor processor) {
+           Processor<Socket> processor) {
        connections.put(socket.getSocket(), processor);
     }
  }

Copied: tomcat/trunk/java/org/apache/coyote/http11/upgrade/Constants.java (from r1241411, tomcat/trunk/java/org/apache/coyote/Processor.java)
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/Constants.java?p2=tomcat/trunk/java/org/apache/coyote/http11/upgrade/Constants.java&p1=tomcat/trunk/java/org/apache/coyote/Processor.java&r1=1241411&r2=1241441&rev=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/Constants.java Tue Feb 7 12:25:57 2012
@@(protected) @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.coyote;
-
-import java.util.concurrent.Executor;
-
-
-/**
- * Common interface for processors of all protocols.
- */
-public interface Processor {
-   Executor getExecutor();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http11.upgrade;
+
+public class Constants {
+
+   public static final String Package = "org.apache.coyote.http11.upgrade";
+}

Added: tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties?rev=1241441&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties (added)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties Tue Feb 7 12:25:57 2012
@@(protected) @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+nio.eof.error=Unexpected EOF read on the socket

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeAprProcessor.java Tue Feb 7 12:25:57 2012
@@(protected) @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.coyote.http11.upgrade;
-
-import java.io.IOException;
-
-import org.apache.coyote.http11.Http11AprProcessor;
-import org.apache.tomcat.jni.Socket;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
-import org.apache.tomcat.util.net.SocketStatus;
-import org.apache.tomcat.util.net.SocketWrapper;
-
-/**
- * Implementation note: The need to extend Http11Processor could probably be
- * removed if the Processor interface was expanded to cover all of the methods
- * required by the AbstractProtocol. That would simplify the code and further
- * reduce the size of instances of this class.
- */
-public class UpgradeAprProcessor extends Http11AprProcessor
-     implements UpgradeProcessor {
-
-   long socket;
-
-   public UpgradeAprProcessor(SocketWrapper<Long> wrapper,
-        UpgradeInbound inbound) {
-     this.socket = wrapper.getSocket().longValue();
-
-     this.upgradeInbound = inbound;
-     upgradeInbound.setUpgradeProcessor(this);
-     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
-     // Remove the default - no need for it here
-     this.compressableMimeTypes = null;
-   }
-
-
-   @Override
-   public SocketState upgradeDispatch() throws IOException {
-     return upgradeInbound.onData();
-   }
-
-
-   /*
-   * Output methods
-   */
-   @Override
-   public void flush() throws IOException {
-     // NOOP
-   }
-
-
-   @Override
-   public void write(int b) throws IOException {
-     Socket.send(socket, new byte[] {(byte) b}, 0, 1);
-   }
-
-
-   /*
-   * Input methods
-   */
-   @Override
-   public int read() throws IOException {
-     byte[] bytes = new byte[1];
-     Socket.recv(socket, bytes, 0, 1);
-     return bytes[0];
-   }
-
-
-   @Override
-   public int read(byte[] bytes) throws IOException {
-     return Socket.recv(socket, bytes, 0, bytes.length);
-   }
-
-
-   /*
-   * None of the following NO-OP methods are strictly necessary - assuming the
-   * there are no bugs in the connector code that cause upgraded connections
-   * to be treated as Http11, Comet or Async. These NO-OP methods are here for
-   * safety and to aid debugging during development.
-   */
-
-   @Override
-   public SocketState event(SocketStatus status) throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState process(SocketWrapper<Long> socketWrapper)
-        throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncDispatch(SocketStatus status) {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncPostProcess() {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http11.upgrade;
+
+import java.io.IOException;
+
+import org.apache.tomcat.jni.Socket;
+import org.apache.tomcat.util.net.SocketWrapper;
+
+/**
+ * Implementation note: The need to extend Http11Processor could probably be
+ * removed if the Processor interface was expanded to cover all of the methods
+ * required by the AbstractProtocol. That would simplify the code and further
+ * reduce the size of instances of this class.
+ */
+public class UpgradeAprProcessor extends UpgradeProcessor<Long> {
+
+   long socket;
+
+
+   public UpgradeAprProcessor(SocketWrapper<Long> wrapper,
+        UpgradeInbound upgradeInbound) {
+     super(upgradeInbound);
+
+     this.socket = wrapper.getSocket().longValue();
+   }
+
+
+   /*
+   * Output methods
+   */
+   @Override
+   public void flush() throws IOException {
+     // NOOP
+   }
+
+
+   @Override
+   public void write(int b) throws IOException {
+     Socket.send(socket, new byte[] {(byte) b}, 0, 1);
+   }
+
+
+   /*
+   * Input methods
+   */
+   @Override
+   public int read() throws IOException {
+     byte[] bytes = new byte[1];
+     Socket.recv(socket, bytes, 0, 1);
+     return bytes[0];
+   }
+
+
+   @Override
+   public int read(byte[] bytes) throws IOException {
+     return Socket.recv(socket, bytes, 0, bytes.length);
+   }
+}

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeBioProcessor.java Tue Feb 7 12:25:57 2012
@@(protected) @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.coyote.http11.upgrade;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-
-import org.apache.coyote.http11.Http11Processor;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
-import org.apache.tomcat.util.net.SocketStatus;
-import org.apache.tomcat.util.net.SocketWrapper;
-
-/**
- * Implementation note: The need to extend Http11Processor could probably be
- * removed if the Processor interface was expanded to cover all of the methods
- * required by the AbstractProtocol. That would simplify the code and further
- * reduce the size of instances of this class.
- */
-public class UpgradeBioProcessor extends Http11Processor
-     implements UpgradeProcessor{
-
-   private InputStream inputStream;
-   private OutputStream outputStream;
-
-   public UpgradeBioProcessor(SocketWrapper<Socket> wrapper,
-        UpgradeInbound inbound) throws IOException {
-     this.inputStream = wrapper.getSocket().getInputStream();
-     this.outputStream = wrapper.getSocket().getOutputStream();
-     this.upgradeInbound = inbound;
-     upgradeInbound.setUpgradeProcessor(this);
-     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
-     // Remove the default - no need for it here
-     this.compressableMimeTypes = null;
-   }
-
-
-   @Override
-   public SocketState upgradeDispatch() throws IOException {
-     return upgradeInbound.onData();
-   }
-
-
-   /*
-   * Output methods
-   */
-   @Override
-   public void flush() throws IOException {
-     outputStream.flush();
-   }
-
-
-   @Override
-   public void write(int b) throws IOException {
-     outputStream.write(b);
-   }
-
-
-   /*
-   * Input methods
-   */
-   @Override
-   public int read() throws IOException {
-     return inputStream.read();
-   }
-
-
-   @Override
-   public int read(byte[] bytes) throws IOException {
-     return inputStream.read(bytes);
-   }
-
-
-   /*
-   * None of the following NO-OP methods are strictly necessary - assuming the
-   * there are no bugs in the connector code that cause upgraded connections
-   * to be treated as Http11, Comet or Async. These NO-OP methods are here for
-   * safety and to aid debugging during development.
-   */
-
-   @Override
-   public SocketState event(SocketStatus status) throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState process(SocketWrapper<Socket> socketWrapper)
-        throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncDispatch(SocketStatus status) {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncPostProcess() {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http11.upgrade;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+
+import org.apache.tomcat.util.net.SocketWrapper;
+
+/**
+ * Implementation note: The need to extend Http11Processor could probably be
+ * removed if the Processor interface was expanded to cover all of the methods
+ * required by the AbstractProtocol. That would simplify the code and further
+ * reduce the size of instances of this class.
+ */
+public class UpgradeBioProcessor extends UpgradeProcessor<Socket> {
+
+   private InputStream inputStream;
+   private OutputStream outputStream;
+
+   public UpgradeBioProcessor(SocketWrapper<Socket> wrapper,
+        UpgradeInbound upgradeInbound) throws IOException {
+     super(upgradeInbound);
+
+     this.inputStream = wrapper.getSocket().getInputStream();
+     this.outputStream = wrapper.getSocket().getOutputStream();
+   }
+
+
+   /*
+   * Output methods
+   */
+   @Override
+   public void flush() throws IOException {
+     outputStream.flush();
+   }
+
+
+   @Override
+   public void write(int b) throws IOException {
+     outputStream.write(b);
+   }
+
+
+   /*
+   * Input methods
+   */
+   @Override
+   public int read() throws IOException {
+     return inputStream.read();
+   }
+
+
+   @Override
+   public int read(byte[] bytes) throws IOException {
+     return inputStream.read(bytes);
+   }
+}

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeNioProcessor.java Tue Feb 7 12:25:57 2012
@@(protected) @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.coyote.http11.upgrade;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.nio.channels.Selector;
-
-import org.apache.coyote.http11.Http11NioProcessor;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
-import org.apache.tomcat.util.net.NioChannel;
-import org.apache.tomcat.util.net.NioEndpoint;
-import org.apache.tomcat.util.net.NioSelectorPool;
-import org.apache.tomcat.util.net.SocketStatus;
-import org.apache.tomcat.util.net.SocketWrapper;
-
-/**
- * Implementation note: The need to extend Http11Processor could probably be
- * removed if the Processor interface was expanded to cover all of the methods
- * required by the AbstractProtocol. That would simplify the code and further
- * reduce the size of instances of this class.
- */
-public class UpgradeNioProcessor extends Http11NioProcessor
-     implements UpgradeProcessor {
-
-   private NioChannel nioChannel;
-   private NioSelectorPool pool;
-
-   public UpgradeNioProcessor(SocketWrapper<NioChannel> wrapper,
-        UpgradeInbound inbound, NioSelectorPool pool) {
-     this.nioChannel = wrapper.getSocket();
-     this.pool = pool;
-
-     this.upgradeInbound = inbound;
-     upgradeInbound.setUpgradeProcessor(this);
-     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
-     // Remove the default - no need for it here
-     this.compressableMimeTypes = null;
-   }
-
-
-   @Override
-   public SocketState upgradeDispatch() throws IOException {
-     return upgradeInbound.onData();
-   }
-
-
-   /*
-   * Output methods
-   */
-   @Override
-   public void flush() throws IOException {
-     NioEndpoint.KeyAttachment att =
-           (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
-     if (att == null) {
-        throw new IOException("Key must be cancelled");
-     }
-     long writeTimeout = att.getTimeout();
-     Selector selector = null;
-     try {
-        selector = pool.get();
-     } catch ( IOException x ) {
-        //ignore
-     }
-     try {
-        do {
-           if (nioChannel.flush(true, selector, writeTimeout)) {
-             break;
-           }
-        } while (true);
-     } finally {
-        if (selector != null) {
-           pool.put(selector);
-        }
-     }
-   }
-
-   @Override
-   public void write(int b) throws IOException {
-     writeToSocket(new byte[] {(byte) b});
-   }
-
-   /*
-   * Input methods
-   */
-   @Override
-   public int read() throws IOException {
-     byte[] bytes = new byte[1];
-     readSocket(true, bytes, 0, 1);
-     return bytes[0];
-   }
-
-   @Override
-   public int read(byte[] bytes) throws IOException {
-     return readSocket(true, bytes, 0, bytes.length);
-   }
-
-
-   /*
-   * Adapted from the NioInputBuffer.
-   */
-   private int readSocket(boolean block, byte[] bytes, int offset, int len)
-        throws IOException {
-
-     int nRead = 0;
-     nioChannel.getBufHandler().getReadBuffer().clear();
-     nioChannel.getBufHandler().getReadBuffer().limit(len);
-     if (block) {
-        Selector selector = null;
-        try {
-           selector = pool.get();
-        } catch ( IOException x ) {
-           // Ignore
-        }
-        try {
-           NioEndpoint.KeyAttachment att =
-                (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
-           if (att == null) {
-             throw new IOException("Key must be cancelled.");
-           }
-           nRead = pool.read(nioChannel.getBufHandler().getReadBuffer(),
-                nioChannel, selector, att.getTimeout());
-        } catch (EOFException eof) {
-           nRead = -1;
-        } finally {
-           if (selector != null) {
-             pool.put(selector);
-           }
-        }
-     } else {
-        nRead = nioChannel.read(nioChannel.getBufHandler().getReadBuffer());
-     }
-     if (nRead > 0) {
-        nioChannel.getBufHandler().getReadBuffer().flip();
-        nioChannel.getBufHandler().getReadBuffer().limit(nRead);
-        nioChannel.getBufHandler().getReadBuffer().get(bytes, offset, nRead);
-        return nRead;
-     } else if (nRead == -1) {
-        //return false;
-        throw new EOFException(sm.getString("iib.eof.error"));
-     } else {
-        return 0;
-     }
-   }
-
-
-   /*
-   * Adapted from the NioOutputBuffer
-   */
-   private synchronized int writeToSocket(byte[] bytes) throws IOException {
-
-     nioChannel.getBufHandler().getWriteBuffer().clear();
-     nioChannel.getBufHandler().getWriteBuffer().put(bytes);
-     nioChannel.getBufHandler().getWriteBuffer().flip();
-
-     int written = 0;
-     NioEndpoint.KeyAttachment att =
-           (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
-     if (att == null) {
-        throw new IOException("Key must be cancelled");
-     }
-     long writeTimeout = att.getTimeout();
-     Selector selector = null;
-     try {
-        selector = pool.get();
-     } catch ( IOException x ) {
-        //ignore
-     }
-     try {
-        written = pool.write(nioChannel.getBufHandler().getWriteBuffer(),
-             nioChannel, selector, writeTimeout, true);
-     } finally {
-        if (selector != null) {
-           pool.put(selector);
-        }
-     }
-     return written;
-   }
-
-   /*
-   * None of the following NO-OP methods are strictly necessary - assuming the
-   * there are no bugs in the connector code that cause upgraded connections
-   * to be treated as Http11, Comet or Async. These NO-OP methods are here for
-   * safety and to aid debugging during development.
-   */
-
-   @Override
-   public SocketState event(SocketStatus status) throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState process(SocketWrapper<NioChannel> socketWrapper)
-        throws IOException {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncDispatch(SocketStatus status) {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-
-
-   @Override
-   public SocketState asyncPostProcess() {
-     // TODO Log an error
-     return SocketState.CLOSED;
-   }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http11.upgrade;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.nio.channels.Selector;
+
+import org.apache.tomcat.util.net.NioChannel;
+import org.apache.tomcat.util.net.NioEndpoint;
+import org.apache.tomcat.util.net.NioSelectorPool;
+import org.apache.tomcat.util.net.SocketWrapper;
+
+/**
+ * Implementation note: The need to extend Http11Processor could probably be
+ * removed if the Processor interface was expanded to cover all of the methods
+ * required by the AbstractProtocol. That would simplify the code and further
+ * reduce the size of instances of this class.
+ */
+public class UpgradeNioProcessor extends UpgradeProcessor<NioChannel> {
+
+   private NioChannel nioChannel;
+   private NioSelectorPool pool;
+
+   public UpgradeNioProcessor(SocketWrapper<NioChannel> wrapper,
+        UpgradeInbound upgradeInbound, NioSelectorPool pool) {
+     super(upgradeInbound);
+
+     this.nioChannel = wrapper.getSocket();
+     this.pool = pool;
+   }
+
+
+   /*
+   * Output methods
+   */
+   @Override
+   public void flush() throws IOException {
+     NioEndpoint.KeyAttachment att =
+           (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
+     if (att == null) {
+        throw new IOException("Key must be cancelled");
+     }
+     long writeTimeout = att.getTimeout();
+     Selector selector = null;
+     try {
+        selector = pool.get();
+     } catch ( IOException x ) {
+        //ignore
+     }
+     try {
+        do {
+           if (nioChannel.flush(true, selector, writeTimeout)) {
+             break;
+           }
+        } while (true);
+     } finally {
+        if (selector != null) {
+           pool.put(selector);
+        }
+     }
+   }
+
+   @Override
+   public void write(int b) throws IOException {
+     writeToSocket(new byte[] {(byte) b});
+   }
+
+   /*
+   * Input methods
+   */
+   @Override
+   public int read() throws IOException {
+     byte[] bytes = new byte[1];
+     readSocket(true, bytes, 0, 1);
+     return bytes[0];
+   }
+
+   @Override
+   public int read(byte[] bytes) throws IOException {
+     return readSocket(true, bytes, 0, bytes.length);
+   }
+
+
+   /*
+   * Adapted from the NioInputBuffer.
+   */
+   private int readSocket(boolean block, byte[] bytes, int offset, int len)
+        throws IOException {
+
+     int nRead = 0;
+     nioChannel.getBufHandler().getReadBuffer().clear();
+     nioChannel.getBufHandler().getReadBuffer().limit(len);
+     if (block) {
+        Selector selector = null;
+        try {
+           selector = pool.get();
+        } catch ( IOException x ) {
+           // Ignore
+        }
+        try {
+           NioEndpoint.KeyAttachment att =
+                (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
+           if (att == null) {
+             throw new IOException("Key must be cancelled.");
+           }
+           nRead = pool.read(nioChannel.getBufHandler().getReadBuffer(),
+                nioChannel, selector, att.getTimeout());
+        } catch (EOFException eof) {
+           nRead = -1;
+        } finally {
+           if (selector != null) {
+             pool.put(selector);
+           }
+        }
+     } else {
+        nRead = nioChannel.read(nioChannel.getBufHandler().getReadBuffer());
+     }
+     if (nRead > 0) {
+        nioChannel.getBufHandler().getReadBuffer().flip();
+        nioChannel.getBufHandler().getReadBuffer().limit(nRead);
+        nioChannel.getBufHandler().getReadBuffer().get(bytes, offset, nRead);
+        return nRead;
+     } else if (nRead == -1) {
+        //return false;
+        throw new EOFException(sm.getString("nio.eof.error"));
+     } else {
+        return 0;
+     }
+   }
+
+
+   /*
+   * Adapted from the NioOutputBuffer
+   */
+   private synchronized int writeToSocket(byte[] bytes) throws IOException {
+
+     nioChannel.getBufHandler().getWriteBuffer().clear();
+     nioChannel.getBufHandler().getWriteBuffer().put(bytes);
+     nioChannel.getBufHandler().getWriteBuffer().flip();
+
+     int written = 0;
+     NioEndpoint.KeyAttachment att =
+           (NioEndpoint.KeyAttachment) nioChannel.getAttachment(false);
+     if (att == null) {
+        throw new IOException("Key must be cancelled");
+     }
+     long writeTimeout = att.getTimeout();
+     Selector selector = null;
+     try {
+        selector = pool.get();
+     } catch ( IOException x ) {
+        //ignore
+     }
+     try {
+        written = pool.write(nioChannel.getBufHandler().getWriteBuffer(),
+             nioChannel, selector, writeTimeout, true);
+     } finally {
+        if (selector != null) {
+           pool.put(selector);
+        }
+     }
+     return written;
+   }
+}

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java?rev=1241441&r1=1241440&r2=1241441&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java Tue Feb 7 12:25:57 2012
@@(protected) @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.coyote.http11.upgrade;
-
-import java.io.IOException;
-
-public interface UpgradeProcessor {
-
-   // Output methods
-   public void flush() throws IOException;
-   public void write(int b) throws IOException;
-
-   // Input methods
-   public int read() throws IOException;
-   public int read(byte[] bytes) throws IOException;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http11.upgrade;
+
+import java.io.IOException;
+import java.util.concurrent.Executor;
+
+import org.apache.coyote.Processor;
+import org.apache.coyote.Request;
+import org.apache.coyote.http11.Constants;
+import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
+import org.apache.tomcat.util.net.SSLSupport;
+import org.apache.tomcat.util.net.SocketStatus;
+import org.apache.tomcat.util.net.SocketWrapper;
+import org.apache.tomcat.util.res.StringManager;
+
+public abstract class UpgradeProcessor<S> implements Processor<S> {
+
+   protected static final StringManager sm =
+        StringManager.getManager(Constants.Package);
+
+   private final UpgradeInbound upgradeInbound;
+
+   protected UpgradeProcessor (UpgradeInbound upgradeInbound) {
+     this.upgradeInbound = upgradeInbound;
+     upgradeInbound.setUpgradeProcessor(this);
+     upgradeInbound.setUpgradeOutbound(new UpgradeOutbound(this));
+   }
+
+   // Output methods
+   public abstract void flush() throws IOException;
+   public abstract void write(int b) throws IOException;
+
+   // Input methods
+   public abstract int read() throws IOException;
+   public abstract int read(byte[] bytes) throws IOException;
+
+   @Override
+   public final UpgradeInbound getUpgradeInbound() {
+     return upgradeInbound;
+   }
+
+   @Override
+   public final SocketState upgradeDispatch() throws IOException {
+     return upgradeInbound.onData();
+   }
+
+   @Override
+   public final boolean isUpgrade() {
+     return true;
+   }
+
+   @Override
+   public final void recycle(boolean socketClosing) {
+     // Currently a NO-OP as upgrade processors are not recycled.
+   }
+
+   // NO-OP methods for upgrade
+   @Override
+   public final Executor getExecutor() {
+     return null;
+   }
+
+   @Override
+   public final SocketState process(SocketWrapper<S> socketWrapper)
+        throws IOException {
+     return null;
+   }
+
+   @Override
+   public final SocketState event(SocketStatus status) throws IOException {
+     return null;
+   }
+
+   @Override
+   public final SocketState asyncDispatch(SocketStatus status) {
+     return null;
+   }
+
+   @Override
+   public final SocketState asyncPostProcess() {
+     return null;
+   }
+
+   @Override
+   public final boolean isComet() {
+     return false;
+   }
+
+   @Override
+   public final boolean isAsync() {
+     return false;
+   }
+
+   @Override
+   public final Request getRequest() {
+     return null;
+   }
+
+   @Override
+   public final void setSslSupport(SSLSupport sslSupport) {
+     // NOOP
+   }
+}



©2008 junlu.com - Jax Systems, LLC, U.S.A.