01: package org.apache.velocity.runtime.resource;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import org.apache.velocity.runtime.RuntimeServices;
23:
24: import org.apache.velocity.exception.ResourceNotFoundException;
25: import org.apache.velocity.exception.ParseErrorException;
26:
27: /**
28: * Class to manage the text resource for the Velocity
29: * Runtime.
30: *
31: * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
32: * @author <a href="mailto:paulo.gaspar@krankikom.de">Paulo Gaspar</a>
33: * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
34: * @version $Id: ResourceManager.java 463298 2006-10-12 16:10:32Z henning $
35: */
36: public interface ResourceManager {
37: /**
38: * A template resources.
39: */
40: public static final int RESOURCE_TEMPLATE = 1;
41:
42: /**
43: * A static content resource.
44: */
45: public static final int RESOURCE_CONTENT = 2;
46:
47: /**
48: * Initialize the ResourceManager.
49: * @param rs
50: * @throws Exception
51: */
52: public void initialize(RuntimeServices rs) throws Exception;
53:
54: /**
55: * Gets the named resource. Returned class type corresponds to specified type
56: * (i.e. <code>Template</code> to <code>RESOURCE_TEMPLATE</code>).
57: *
58: * @param resourceName The name of the resource to retrieve.
59: * @param resourceType The type of resource (<code>RESOURCE_TEMPLATE</code>,
60: * <code>RESOURCE_CONTENT</code>, etc.).
61: * @param encoding The character encoding to use.
62: * @return Resource with the template parsed and ready.
63: * @throws ResourceNotFoundException if template not found
64: * from any available source.
65: * @throws ParseErrorException if template cannot be parsed due
66: * to syntax (or other) error.
67: * @throws Exception if a problem in parse
68: */
69: public Resource getResource(String resourceName, int resourceType,
70: String encoding) throws ResourceNotFoundException,
71: ParseErrorException, Exception;
72:
73: /**
74: * Determines is a template exists, and returns name of the loader that
75: * provides it. This is a slightly less hokey way to support
76: * the Velocity.templateExists() utility method, which was broken
77: * when per-template encoding was introduced. We can revisit this.
78: *
79: * @param resourceName Name of template or content resource
80: * @return class name of loader than can provide it
81: */
82: public String getLoaderNameForResource(String resourceName);
83:
84: }
|