01: // Copyright 2006 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.services;
16:
17: import java.net.URL;
18:
19: import org.apache.tapestry.internal.services.ClasspathAssetFactory;
20: import org.apache.tapestry.ioc.Resource;
21: import org.apache.tapestry.ioc.internal.util.ClasspathResource;
22:
23: /**
24: * Responsible for determining which classpath resources require checksums, and for generating
25: * checksums for such resources.
26: *
27: * @see ClasspathResource
28: * @see ClasspathAssetFactory
29: */
30: public interface ResourceDigestGenerator {
31: /**
32: * Examines the path (typically, the file name extension at the end of the path) to determine if
33: * a checksum is required for the path. The path is {@link Resource} style, without a leading
34: * slash.
35: */
36: boolean requiresDigest(String path);
37:
38: /**
39: * Reads the content of a URL (presumably, for a resource on the classpath) and generates a
40: * digest of its content. This digest will be incorporated into the URL provided to the
41: * client, to verify that the client has been "granted" access to this resource. This is only
42: * used for resources where {@link #requiresDigest(String)} is true.
43: *
44: * @param url
45: * @return the digest for the resource
46: */
47: String generateDigest(URL url);
48: }
|