001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
004//
005// http://www.apache.org/licenses/LICENSE-2.0
006//
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
012
013package org.apache.tapestry5.internal.services;
014
015import org.apache.tapestry5.ioc.Resource;
016import org.apache.tapestry5.services.InvalidationEventHub;
017import org.apache.tapestry5.services.ResourceDigestGenerator;
018
019/**
020 * Caches information about resources on the classpath. In addition, acts as an invalidation hub for any resources for
021 * which information is obtained (when any of the resources are changed, invalidation listeners are notified so they can
022 * clear their caches).
023 *
024 * Note that the name and role of this class changed (and diminished) quite a bit in Tapestry 5.3. It is now focused on
025 * determining which files require a digest, and which what the digests are for resources.
026 *
027 * Further, in 5.4, this service has been stripped down to an unused placeholder; it only present to prevent
028 * errors where modules have contributed a String extension to protected (even though the service is internal). As of
029 * 5.4, all assets have a built-in checksum in the URL directly (in 5.3 and earlier, the URL included the application
030 * version number).
031 *
032 * @deprecated Deprecated in 5.4 with no replacement; see release notes about classpath assets moving to /META-INF/assets/.
033 *             To be removed in 5.5.
034 */
035public interface ResourceDigestManager extends InvalidationEventHub
036{
037    /**
038     * Returns true if the path requires that the client URL for the resource include a digest to validate that the
039     * client is authorized to access the resource.
040     *
041     * As of 5.4, simply returns false.
042     *
043     * @param resource
044     * @return true if digest is required for the resource
045     * @see ResourceDigestGenerator#requiresDigest(String)
046     */
047    boolean requiresDigest(Resource resource);
048
049    /**
050     * Returns the digest for the given path.
051     *
052     * As of 5.4, simple returns null.
053     *
054     * @param resource
055     * @return the digest, or null if the resource does not exist
056     */
057    String getDigest(Resource resource);
058}