View Javadoc

1   // ========================================================================
2   // Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  /**
15   * 
16   */
17  package org.eclipse.jetty.server.nio;
18  
19  import org.eclipse.jetty.io.Buffers.Type;
20  import org.eclipse.jetty.server.AbstractConnector;
21  
22  /* ------------------------------------------------------------ */
23  /**
24   * 
25   *
26   */
27  public abstract class AbstractNIOConnector extends AbstractConnector implements NIOConnector
28  {
29      {
30          setRequestBufferType(Type.DIRECT);
31          setRequestHeaderType(Type.INDIRECT);
32          setResponseBufferType(Type.DIRECT);
33          setResponseHeaderType(Type.INDIRECT);
34      }
35   
36      /* ------------------------------------------------------------------------------- */
37      public boolean getUseDirectBuffers()
38      {
39          return getRequestBufferType()==Type.DIRECT;
40      }
41  
42      /* ------------------------------------------------------------------------------- */
43      /**
44       * @param direct If True (the default), the connector can use NIO direct buffers.
45       * Some JVMs have memory management issues (bugs) with direct buffers.
46       */
47      public void setUseDirectBuffers(boolean direct)
48      {
49          setRequestBufferType(direct?Type.DIRECT:Type.INDIRECT);
50          setResponseBufferType(direct?Type.DIRECT:Type.INDIRECT);
51      }
52  
53  }