    001// Copyright 2011, 2012, 2022 The Apache Software Foundation
    002//
    003// Licensed under the Apache License, Version 2.0 (the "License");
    004// you may not use this file except in compliance with the License.
    005// You may obtain a copy of the License at
    006//
    007// http://www.apache.org/licenses/LICENSE-2.0
    008//
    009// Unless required by applicable law or agreed to in writing, software
    010// distributed under the License is distributed on an "AS IS" BASIS,
    011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012// See the License for the specific language governing permissions and
    013// limitations under the License.
    014
    015package org.apache.tapestry5.internal.services.assets;
    016
    017import org.apache.tapestry5.commons.Resource;
    018import org.apache.tapestry5.commons.services.InvalidationEventHub;
    019import org.apache.tapestry5.commons.services.InvalidationListener;
    020import org.apache.tapestry5.ioc.internal.util.URLChangeTracker;
    021import org.apache.tapestry5.ioc.services.UpdateListener;
    022import org.apache.tapestry5.services.assets.ResourceDependencies;
    023
    024/**
    025 * Tracks resources (at least, resources that can change because they are on the file system) and
    026 * acts as an {@link UpdateListener} to check for changes and notify its listeners.
    027 *
    028 * @since 5.3
    029 */
    030public interface ResourceChangeTracker extends InvalidationEventHub, ResourceDependencies
    031{
    032    /**
    033     * Start tracking the resource (or return the last modified time of an already tracked resource). Only file system
    034     * resources are tracked. Resources are tracked until <em>any</em> resource changes, at which points
    035     * {@linkplain InvalidationListener listeners} are notified and the internal state
    036     * is cleared.
    037     *
    038     * @param resource
    039     *         to track
    040     * @return last modified time, to nearest second
    041     * @see URLChangeTracker
    042     */
    043    long trackResource(Resource resource);
    044
    045    /**
    046     * Forces an invalidation event. This is required in a rare case, to clear out a {@link org.apache.tapestry5.services.assets.StreamableResource}
    047     * generated from the component message catalog; there are some walls in place that prevent the message catalog's underlying
    048     * {@link Resource}s from being exposed.
    049     *
    050     * @see org.apache.tapestry5.internal.util.MessageCatalogResource
    051     * @since 5.4
    052     */
    053    void forceInvalidationEvent();
    054
    055    /**
    056     * Informs this service that the resources being loaded are associated with a given Tapestry
    057     * component (i.e. component, page, mixin and base) component class.
    058     *
    059     * @param className The fully classified class name of the component or page associated with
    060     * the current resources being processed.
    061     * @since 5.8.3
    062     */
    063    void setCurrentClassName(String className);
    064
    065    /**
    066     * Informs this service that no component class is associated with the resources being loaded.
    067     * @since 5.8.3
    068     */
    069    void clearCurrentClassName();
    070
    071}