View Javadoc

1   /*
2    * Copyright (C) The Spice Group. All rights reserved.
3    *
4    * This software is published under the terms of the Spice
5    * Software License version 1.1, a copy of which has been included
6    * with this distribution in the LICENSE.txt file.
7    */
8   package org.codehaus.spice.netserve.connection.handlers;
9   
10  import java.net.Socket;
11  import org.codehaus.spice.netserve.connection.RequestHandler;
12  
13  /***
14   * A simple handler that delegates to another handler.
15   *
16   * @author Peter Donald
17   * @version $Revision: 1.2 $ $Date: 2004/03/21 23:42:58 $
18   */
19  public class DelegatingRequestHandler
20      extends AbstractRequestHandler
21  {
22      /***
23       * The underlying handler to delegate to.
24       */
25      private final RequestHandler m_handler;
26  
27      /***
28       * Create handler.
29       *
30       * @param handler the handler to delegate to
31       */
32      public DelegatingRequestHandler( final RequestHandler handler )
33      {
34          if( null == handler )
35          {
36              throw new NullPointerException( "handler" );
37          }
38          m_handler = handler;
39      }
40  
41      /***
42       * Delegate request to supplied handler.
43       *
44       * @param socket the socket
45       * @throws Exception on error
46       */
47      protected void doPerformRequest( final Socket socket )
48          throws Exception
49      {
50          m_handler.handleConnection( socket );
51      }
52  
53      /***
54       * @see AbstractRequestHandler#shutdown
55       */
56      public void shutdown( final long timeout )
57      {
58          m_handler.shutdown( timeout );
59          super.shutdown( timeout );
60      }
61  }