    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.services.assets;
    014
    015import org.apache.tapestry5.ioc.Resource;
    016import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
    017import org.apache.tapestry5.services.Context;
    018
    019/**
    020 * Used to determine the MIME content type for a resource. The service configuration is the first step,
    021 * followed by {@link Context#getMimeType(String)}, and then (finally) "application/octet-stream"
    022 * as a stop-gap.
    023 *
    024 * The service configuration maps the file extension (e.g., "png") to its corresponding MIME type (e.g., "image/png");
    025 */
    026@UsesMappedConfiguration(String.class)
    027public interface ContentTypeAnalyzer
    028{
    029    /**
    030     * Analyze the resource to determine its content type.
    031     *
    032     * @param resource
    033     *            to analyze
    034     * @return a MIME content type
    035     */
    036    String getContentType(Resource resource);
    037}