001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Anahide Tchertchian
018 */
019package org.nuxeo.ecm.web.resources.api.service;
020
021import java.util.List;
022
023import org.nuxeo.ecm.web.resources.api.Processor;
024import org.nuxeo.ecm.web.resources.api.Resource;
025import org.nuxeo.ecm.web.resources.api.ResourceBundle;
026import org.nuxeo.ecm.web.resources.api.ResourceContext;
027
028/**
029 * Service for web resources retrieval.
030 *
031 * @since 7.3
032 */
033public interface WebResourceManager {
034
035    /**
036     * Returns a registered resource with given name, or null if not found.
037     * <p>
038     * Referenced resource can either be a static resource or a style.
039     */
040    Resource getResource(String name);
041
042    /**
043     * Returns a registered resource bundle with given name, or null if not found.
044     */
045    ResourceBundle getResourceBundle(String name);
046
047    /**
048     * Returns all resource bundles registered on the service.
049     */
050    List<ResourceBundle> getResourceBundles();
051
052    /**
053     * Returns the corresponding processor with given name, or null if not found.
054     */
055    Processor getProcessor(String name);
056
057    /**
058     * Returns all processors registered on the service, ordered.
059     */
060    List<Processor> getProcessors();
061
062    /**
063     * Returns all processors registered on the service, ordered, for given type.
064     */
065    List<Processor> getProcessors(String type);
066
067    /**
068     * Returns the ordered list of resources for given bundle name, filtered using given type.
069     * <p>
070     */
071    List<Resource> getResources(ResourceContext context, String bundleName, String type);
072
073    /**
074     * Allows to dynamically register a bundle.
075     *
076     * @since 7.4
077     */
078    void registerResourceBundle(ResourceBundle bundle);
079
080    /**
081     * Allows to dynamically unregister a bundle.
082     *
083     * @since 7.4
084     */
085    void unregisterResourceBundle(ResourceBundle bundle);
086
087    /**
088     * Allows to dynamically register a resource.
089     *
090     * @since 7.4
091     */
092    void registerResource(Resource resource);
093
094    /**
095     * Allows to dynamically unregister a resource.
096     *
097     * @since 7.4
098     */
099    void unregisterResource(Resource resource);
100
101}