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