01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.transformation.helpers;
18:
19: import java.io.IOException;
20:
21: import org.apache.avalon.framework.parameters.Parameters;
22: import org.apache.cocoon.xml.XMLConsumer;
23: import org.apache.excalibur.source.SourceException;
24: import org.xml.sax.SAXException;
25:
26: /**
27: * The include cache manager is a component that can manage included content.
28: * It can eiter load them in parallel or pre-emptive and cache the content
29: * for a given period of time.
30: *
31: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
32: * @version CVS $Id: IncludeCacheManager.java 433543 2006-08-22 06:22:54Z crossley $
33: * @since 2.1
34: */
35: public interface IncludeCacheManager {
36:
37: /** Avalon role */
38: String ROLE = IncludeCacheManager.class.getName();
39:
40: /**
41: * Create a session for this request.
42: * This should be invoked first and only one per request. It is required
43: * to terminate the session with {@link #terminateSession(IncludeCacheManagerSession)}
44: * @param pars The configuration
45: * @return CacheManagerSession The session that should be used with all other commands.
46: */
47: IncludeCacheManagerSession getSession(Parameters pars);
48:
49: /**
50: * This informs the manager that a URI should be "loaded".
51: * @param uri The URI to load (maybe relative)
52: * @param session The corresponding session created by {@link #getSession(Parameters)}
53: * @return String The absolute URI that must be used for {@link #stream(String, IncludeCacheManagerSession, XMLConsumer)}
54: * @throws IOException
55: * @throws SourceException
56: */
57: String load(String uri, IncludeCacheManagerSession session)
58: throws IOException, SourceException;
59:
60: /**
61: * Stream the content of the absolute URI.
62: * Depending on the configuration and state of the cache, the
63: * content is either taken from the cache, fetched etc.
64: * @param uri The absolute URI returned by {@link #load(String, IncludeCacheManagerSession)}
65: * @param session The current session
66: * @param handler The receiver of the SAX events
67: * @throws IOException
68: * @throws SourceException
69: * @throws SAXException
70: */
71: void stream(String uri, IncludeCacheManagerSession session,
72: XMLConsumer handler) throws IOException, SourceException,
73: SAXException;
74:
75: /**
76: * Terminate the session. This method must be executed at the end of the
77: * request.
78: * @param session The caching session.
79: */
80: void terminateSession(IncludeCacheManagerSession session);
81: }
|