01: /*
02: * ContentFactory.java December 2002
03: *
04: * Copyright (C) 2002, 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: /**
24: * The <code>ContentFactory</code> is used to create instances of
25: * the <code>Content</code> object. This is used in conjunction
26: * with the <code>FactoryContext</code> to create content objects
27: * from issued request URI strings. Because the instances are
28: * created by the <code>FactoryContext</code> a lifecycle must be
29: * obeyed by the produced implementations. This lifecycle states
30: * that the instance is loaded and used for a limited time.
31: * <p>
32: * This is required to return a <code>Content</code> instance if
33: * there is a suitable match for the issued request URI. If the
34: * issued request URI cannot be resolved <code>getInstance</code>
35: * must throw a <code>ContentException</code>. The request URI
36: * issued to the <code>getInstance</code> is the same as the URI
37: * issued to any of the <code>Context</code> methods.
38: *
39: * @author Niall Gallagher
40: *
41: * @see simple.http.serve.Context#getContent
42: */
43: public interface ContentFactory {
44:
45: /**
46: * This will return a <code>Content</code> instance for the
47: * request URI issued. If there is no match for the issued
48: * URI then this will throw a <code>ContentException</code>.
49: *
50: * @param target the request URI for the content required
51: * @param context this is the <code>Context</code> used
52: *
53: * @return this returns a <code>Content</code> instance
54: *
55: * @exception ContentException thrown if there is no match
56: */
57: public Content getInstance(Context context, String target)
58: throws ContentException;
59: }
|