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 */
017 package org.apache.camel.spi;
018
019 /**
020 * A class resolver for loading classes in a loosly coupled manner to cater for different platforms such
021 * as standalone, web container, j2ee container and OSGi platforms.
022 */
023 public interface ClassResolver {
024
025 /**
026 * Resolves the given class by its name
027 *
028 * @param name full qualified name of class
029 * @return the class if resolved, <tt>null</tt> if not found.
030 */
031 Class resolveClass(String name);
032
033 /**
034 * Resolves the given class by its name
035 *
036 * @param name full qualified name of class
037 * @param type the expected type of the class
038 * @return the class if resolved, <tt>null</tt> if not found.
039 */
040 <T> Class<T> resolveClass(String name, Class<T> type);
041
042 /**
043 * Resolves the given class by its name
044 *
045 * @param name full qualified name of class
046 * @param loader use the provided class loader
047 * @return the class if resolved, <tt>null</tt> if not found.
048 */
049 Class resolveClass(String name, ClassLoader loader);
050
051 /**
052 * Resolves the given class by its name
053 *
054 * @param name full qualified name of class
055 * @param type the expected type of the class
056 * @param loader use the provided class loader
057 * @return the class if resolved, <tt>null</tt> if not found.
058 */
059 <T> Class<T> resolveClass(String name, Class<T> type, ClassLoader loader);
060
061 /**
062 * Resolves the given class by its name
063 *
064 * @param name full qualified name of class
065 * @return the class if resolved, <tt>null</tt> if not found.
066 * @throws ClassNotFoundException is thrown if class not found
067 */
068 Class resolveMandatoryClass(String name) throws ClassNotFoundException;
069
070 /**
071 * Resolves the given class by its name
072 *
073 * @param name full qualified name of class
074 * @param type the expected type of the class
075 * @return the class if resolved, <tt>null</tt> if not found.
076 * @throws ClassNotFoundException is thrown if class not found
077 */
078 <T> Class<T> resolveMandatoryClass(String name, Class<T> type) throws ClassNotFoundException;
079
080 /**
081 * Resolves the given class by its name
082 *
083 * @param name full qualified name of class
084 * @return the class if resolved, <tt>null</tt> if not found.
085 * @param loader use the provided class loader
086 * @throws ClassNotFoundException is thrown if class not found
087 */
088 Class resolveMandatoryClass(String name, ClassLoader loader) throws ClassNotFoundException;
089
090 /**
091 * Resolves the given class by its name
092 *
093 * @param name full qualified name of class
094 * @param type the expected type of the class
095 * @param loader use the provided class loader
096 * @return the class if resolved, <tt>null</tt> if not found.
097 * @throws ClassNotFoundException is thrown if class not found
098 */
099 <T> Class<T> resolveMandatoryClass(String name, Class<T> type, ClassLoader loader) throws ClassNotFoundException;
100
101 }