01: /*
02: * ProtocolHandlerFactory.java February 2001
03: *
04: * Copyright (C) 2001, Niall Gallagher <niallg@users.sf.net>
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General
16: * Public License along with this library; if not, write to the
17: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18: * Boston, MA 02111-1307 USA
19: */
20:
21: package simple.http.serve;
22:
23: import simple.http.ProtocolHandler;
24:
25: /**
26: * The <code>ProtocolHandlerFactory</code> is used to retrieve a
27: * <code>ProtocolHandler</code> to handle HTTP transactions. The
28: * <code>ProtocolHandler</code> retrieved uses the implementation
29: * of the <code>ResourceEngine</code> to produce delegate handlers
30: * for the HTTP transaction.
31: * <p>
32: * A useful purpose for the <code>ProtocolHandlerFactory</code>
33: * is also to tie the <code>ProtocolHandler</code> implementation
34: * to an interface rather than an object implementation that may
35: * become obsolete due to new requirements.
36: *
37: * @author Niall Gallagher
38: */
39: public class ProtocolHandlerFactory {
40:
41: /**
42: * This will produce a <code>ProtocolHandler</code> that uses
43: * the <code>ResourceEngine</code> to retrieve delegate handlers
44: * for processing HTTP transactions. The delegate handlers will
45: * be given the <code>Request</code> and <code>Response</code>
46: * objects given to the <code>ProtocolHandler</code> interface.
47: *
48: * @param engine this is the <code>ResourceEngine</code> that
49: * produces the delegate handlers
50: *
51: * @return this returns a <code>ProtocolHandler</code> that
52: * can be used to process HTTP transactions
53: */
54: public static ProtocolHandler getInstance(ResourceEngine engine) {
55: return new ResourceProcessor(engine);
56: }
57: }
|