169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal/*
269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Javassist, a Java-bytecode translator toolkit.
369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Copyright (C) 1999-2007 Shigeru Chiba. All Rights Reserved.
469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal *
569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * The contents of this file are subject to the Mozilla Public License Version
669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 1.1 (the "License"); you may not use this file except in compliance with
769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * the License.  Alternatively, the contents of this file may be used under
869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * the terms of the GNU Lesser General Public License Version 2.1 or later.
969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal *
1069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Software distributed under the License is distributed on an "AS IS" basis,
1169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * for the specific language governing rights and limitations under the
1369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * License.
1469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal */
1569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
1669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalpackage javassist.scopedpool;
1769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
1869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalimport java.util.Map;
1969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
2069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalimport javassist.ClassPool;
2169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
2269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal/**
2369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * An interface to <code>ScopedClassPoolRepositoryImpl</code>.
2469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal *
2569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
2669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @version $Revision: 1.4 $
2769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal */
2869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalpublic interface ScopedClassPoolRepository {
2969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
3069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * Records a factory.
3169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
3269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    void setClassPoolFactory(ScopedClassPoolFactory factory);
3369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
3469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
3569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * Obtains the recorded factory.
3669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
3769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    ScopedClassPoolFactory getClassPoolFactory();
3869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
3969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
4069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * Returns whether or not the class pool is pruned.
4169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     *
4269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @return the prune.
4369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
4469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    boolean isPrune();
4569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
4669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
4769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * Sets the prune flag.
4869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     *
4969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @param prune     a new value.
5069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
5169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    void setPrune(boolean prune);
5269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
5369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
5469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * Create a scoped classpool.
5569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     *
5669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @param cl    the classloader.
5769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @param src   the original classpool.
5869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @return the classpool.
5969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
6069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    ScopedClassPool createScopedClassPool(ClassLoader cl, ClassPool src);
6169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
6269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
6369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * Finds a scoped classpool registered under the passed in classloader.
6469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     *
6569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @param cl    the classloader.
6669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @return the classpool.
6769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
6869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    ClassPool findClassPool(ClassLoader cl);
6969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
7069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
7169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * Register a classloader.
7269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     *
7369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @param ucl   the classloader.
7469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @return the classpool.
7569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
7669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    ClassPool registerClassLoader(ClassLoader ucl);
7769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
7869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
7969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * Get the registered classloaders.
8069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     *
8169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @return the registered classloaders.
8269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
8369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    Map getRegisteredCLs();
8469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
8569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
8669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * This method will check to see if a register classloader has been
8769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * undeployed (as in JBoss).
8869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
8969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    void clearUnregisteredClassLoaders();
9069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
9169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    /**
9269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * Unregisters a classpool and unregisters its classloader.
9369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     *
9469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     * @param cl    the classloader the pool is stored under.
9569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal     */
9669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal    void unregisterClassLoader(ClassLoader cl);
9769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal}
98