01: /*
02: * Copyright (C) The Spice Group. All rights reserved.
03: *
04: * This software is published under the terms of the Spice
05: * Software License version 1.1, a copy of which has been included
06: * with this distribution in the LICENSE.txt file.
07: */
08: package org.codehaus.spice.netserve.connection.handlers;
09:
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 extends AbstractRequestHandler {
20: /**
21: * The underlying handler to delegate to.
22: */
23: private final RequestHandler m_handler;
24:
25: /**
26: * Create handler.
27: *
28: * @param handler the handler to delegate to
29: */
30: public DelegatingRequestHandler(final RequestHandler handler) {
31: if (null == handler) {
32: throw new NullPointerException("handler");
33: }
34: m_handler = handler;
35: }
36:
37: /**
38: * Delegate request to supplied handler.
39: *
40: * @param socket the socket
41: * @throws Exception on error
42: */
43: protected void doPerformRequest(final Socket socket)
44: throws Exception {
45: m_handler.handleConnection(socket);
46: }
47:
48: /**
49: * @see AbstractRequestHandler#shutdown
50: */
51: public void shutdown(final long timeout) {
52: m_handler.shutdown(timeout);
53: super.shutdown(timeout);
54: }
55: }
|