001 /*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 * http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014 package org.apache.commons.classscan.spi;
015
016 import java.io.IOException;
017 import java.net.URL;
018 import java.util.ServiceLoader;
019
020 import org.apache.commons.classscan.MetaRegistry;
021 import org.apache.commons.classscan.spi.model.SpiClassPathElement;
022
023 /**
024 * Provider to create a ClassPathElement for a URL. Provider instances should
025 * be registered using the {@link ServiceLoader} facility. Each provider class
026 * should have a public default constructor. A single instance of each provider
027 * class will be instantiated.
028 */
029 public interface ClassPathElementFactory {
030 /**
031 * Create a ClassPathElement for a URL
032 *
033 * @param metaRegistry The registry
034 * @param url The url that is the base location of class files
035 * @return null, if the URL scheme cannot be supported; otherwise a ClassPathElement for the URL
036 */
037 SpiClassPathElement getClassPathElement(MetaRegistry metaRegistry, URL url) throws IOException;
038 }