    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.bcel.util;
    018
    019import org.apache.bcel.classfile.JavaClass;
    020
    021/**
    022 * Abstract definition of a class repository. Instances may be used to load classes from different sources and may be
    023 * used in the Repository.setRepository method.
    024 *
    025 * @see org.apache.bcel.Repository
    026 */
    027public interface Repository {
    028
    029    /**
    030     * Clears all entries from cache.
    031     */
    032    void clear();
    033
    034    /**
    035     * Finds the class with the name provided, if the class isn't there, return NULL.
    036     */
    037    JavaClass findClass(String className);
    038
    039    /**
    040     * Gets the ClassPath associated with this Repository
    041     */
    042    ClassPath getClassPath();
    043
    044    /**
    045     * Finds the JavaClass instance for the given run-time class object.
    046     *
    047     * @throws ClassNotFoundException if the class can't be found.
    048     */
    049    JavaClass loadClass(Class<?> clazz) throws ClassNotFoundException;
    050
    051    /**
    052     * Finds the class with the name provided, if the class isn't there, make an attempt to load it.
    053     *
    054     * @throws ClassNotFoundException if the class can't be found.
    055     */
    056    JavaClass loadClass(String className) throws ClassNotFoundException;
    057
    058    /**
    059     * Removes class from repository
    060     */
    061    void removeClass(JavaClass clazz);
    062
    063    /**
    064     * Stores the provided class under "clazz.getClassName()"
    065     */
    066    void storeClass(JavaClass clazz);
    067}