View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.bcel.util;
18  
19  import org.apache.bcel.classfile.JavaClass;
20  
21  /**
22   * Abstract definition of a class repository. Instances may be used to load classes from different sources and may be
23   * used in the Repository.setRepository method.
24   *
25   * @see org.apache.bcel.Repository
26   */
27  public interface Repository {
28  
29      /**
30       * Clears all entries from cache.
31       */
32      void clear();
33  
34      /**
35       * Finds the class with the name provided, if the class isn't there, return NULL.
36       */
37      JavaClass findClass(String className);
38  
39      /**
40       * Gets the ClassPath associated with this Repository
41       */
42      ClassPath getClassPath();
43  
44      /**
45       * Finds the JavaClass instance for the given run-time class object.
46       *
47       * @throws ClassNotFoundException if the class can't be found.
48       */
49      JavaClass loadClass(Class<?> clazz) throws ClassNotFoundException;
50  
51      /**
52       * Finds the class with the name provided, if the class isn't there, make an attempt to load it.
53       *
54       * @throws ClassNotFoundException if the class can't be found.
55       */
56      JavaClass loadClass(String className) throws ClassNotFoundException;
57  
58      /**
59       * Removes class from repository
60       */
61      void removeClass(JavaClass clazz);
62  
63      /**
64       * Stores the provided class under "clazz.getClassName()"
65       */
66      void storeClass(JavaClass clazz);
67  }