1/*
2 * Javassist, a Java-bytecode translator toolkit.
3 * Copyright (C) 1999-2007 Shigeru Chiba. All Rights Reserved.
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License.  Alternatively, the contents of this file may be used under
8 * the terms of the GNU Lesser General Public License Version 2.1 or later.
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 */
15
16package javassist.scopedpool;
17
18import java.util.Map;
19
20import javassist.ClassPool;
21
22/**
23 * An interface to <code>ScopedClassPoolRepositoryImpl</code>.
24 *
25 * @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
26 * @version $Revision: 1.4 $
27 */
28public interface ScopedClassPoolRepository {
29    /**
30     * Records a factory.
31     */
32    void setClassPoolFactory(ScopedClassPoolFactory factory);
33
34    /**
35     * Obtains the recorded factory.
36     */
37    ScopedClassPoolFactory getClassPoolFactory();
38
39    /**
40     * Returns whether or not the class pool is pruned.
41     *
42     * @return the prune.
43     */
44    boolean isPrune();
45
46    /**
47     * Sets the prune flag.
48     *
49     * @param prune     a new value.
50     */
51    void setPrune(boolean prune);
52
53    /**
54     * Create a scoped classpool.
55     *
56     * @param cl    the classloader.
57     * @param src   the original classpool.
58     * @return the classpool.
59     */
60    ScopedClassPool createScopedClassPool(ClassLoader cl, ClassPool src);
61
62    /**
63     * Finds a scoped classpool registered under the passed in classloader.
64     *
65     * @param cl    the classloader.
66     * @return the classpool.
67     */
68    ClassPool findClassPool(ClassLoader cl);
69
70    /**
71     * Register a classloader.
72     *
73     * @param ucl   the classloader.
74     * @return the classpool.
75     */
76    ClassPool registerClassLoader(ClassLoader ucl);
77
78    /**
79     * Get the registered classloaders.
80     *
81     * @return the registered classloaders.
82     */
83    Map getRegisteredCLs();
84
85    /**
86     * This method will check to see if a register classloader has been
87     * undeployed (as in JBoss).
88     */
89    void clearUnregisteredClassLoaders();
90
91    /**
92     * Unregisters a classpool and unregisters its classloader.
93     *
94     * @param cl    the classloader the pool is stored under.
95     */
96    void unregisterClassLoader(ClassLoader cl);
97}
98