All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.cxf.resource.ResourceManager Maven / Gradle / Ivy

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.cxf.resource;


import java.io.InputStream;
import java.util.List;


/**
 * Locates resources that are used at runtime.  The
 * ResourceManager queries registered
 * ResourceResolver to find resources.
 */
public interface ResourceManager {
    
    /**
     * Resolve a resource.  The ResourceManager will query all of the
     * registered ResourceResovler objects until one
     * manages to resolve the resource
     * 
     * @param name name of resource to resolve.
     * @param type type of resource to resolve.
     * @return the resolved resource or null if nothing found.
     */
     T resolveResource(String name, Class type);

    /** 
     * Resolve a resource with via a specified list of resovlers.  This allows 
     * resources to be specified with a locally defined list of resolvers.
     * 
     * @param name name of resource to resolve.
     * @param type type of resource to resolve.
     * @param resolvers list of ResourceResolvers to search.
     * @return the resolved resource or null if nothing found.
     */
     T resolveResource(String name, Class type, List resolvers);

    /**
     * Open stream to resource.  
     *
     * @param name name of resource to resolve. 
     * @return the InputStream to the resource or null if the resource
     * cannot be found.
     */
    InputStream getResourceAsStream(String name);

    /** 
     * Add a ResourceResolver.  The newly added resolver
     * is added at the head of the list so the most recently added
     * will be queried first.
     * @param resolver the ResourceResolver to
     * add. Duplicates will be ignored.
     */
    void addResourceResolver(ResourceResolver resolver);

    /** 
     * Remove a ResourceResolver.
     * @param resolver the ResourceResolver to remove.
     * If not previously registered, it is ignored.
     */
    void removeResourceResolver(ResourceResolver resolver);


    /**
     * Get all the currently registered resolvers.  This method should return 
     * a copy of the list of resolvers so that resolvers added after this method 
     * has been called will alter the list returned.
     */
    List getResourceResolvers();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy