001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.spi;
018
019import java.io.InputStream;
020import java.util.Set;
021
022import org.apache.camel.StaticService;
023
024/**
025 * A resolver that can find resources based on package scanning.
026 *
027 * OSGi is not supported as this is intended for standalone Camel runtimes such
028 * as Camel Main, or Camel Quarkus.
029 *
030 * @see PackageScanClassResolver
031 */
032public interface PackageScanResourceResolver extends StaticService {
033
034    /**
035     * Gets the ClassLoader instances that should be used when scanning for resources.
036     * <p/>
037     * This implementation will return a new unmodifiable set containing the classloaders.
038     * Use the {@link #addClassLoader(ClassLoader)} method if you want to add new classloaders
039     * to the class loaders list.
040     *
041     * @return the class loaders to use
042     */
043    Set<ClassLoader> getClassLoaders();
044
045    /**
046     * Adds the class loader to the existing loaders
047     *
048     * @param classLoader the loader to add
049     */
050    void addClassLoader(ClassLoader classLoader);
051
052    /**
053     * To specify a set of accepted schemas to use for loading resources as URL connections
054     * (besides http and https schemas)
055     */
056    void setAcceptableSchemes(String schemes);
057
058    /**
059     * Finds the resources from the given location.
060     *
061     * @param locations  the location (support ANT style patterns, eg routes/camel-*.xml)
062     * @return the found resources, or an empty set if no resources found
063     * @throws Exception can be thrown during scanning for resources.
064     */
065    Set<InputStream> findResources(String locations) throws Exception;
066
067}