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   */
18  package org.apache.bcel.util;
19  
20  import org.apache.bcel.classfile.JavaClass;
21  
22  /**
23   * Abstract definition of a class repository. Instances may be used to load classes from different sources and may be
24   * used in the Repository.setRepository method.
25   *
26   * @see org.apache.bcel.Repository
27   */
28  public interface Repository {
29  
30      /**
31       * Stores the provided class under "clazz.getClassName()"
32       */
33      void storeClass(JavaClass clazz);
34  
35      /**
36       * Removes class from repository
37       */
38      void removeClass(JavaClass clazz);
39  
40      /**
41       * Finds the class with the name provided, if the class isn't there, return NULL.
42       */
43      JavaClass findClass(String className);
44  
45      /**
46       * Finds the class with the name provided, if the class isn't there, make an attempt to load it.
47       */
48      JavaClass loadClass(String className) throws java.lang.ClassNotFoundException;
49  
50      /**
51       * Finds the JavaClass instance for the given run-time class object
52       */
53      JavaClass loadClass(Class<?> clazz) throws java.lang.ClassNotFoundException;
54  
55      /**
56       * Clears all entries from cache.
57       */
58      void clear();
59  
60      /**
61       * Gets the ClassPath associated with this Repository
62       */
63      ClassPath getClassPath();
64  }