[jboss-cvs] JBossAS SVN: r94893 - projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 14 17:09:03 EDT 2009
Author: flavia.rainone at jboss.com
Date: 2009-10-14 17:09:03 -0400 (Wed, 14 Oct 2009)
New Revision: 94893
Modified:
projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/AbstractClassPool.java
projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/AbstractClassPoolFactory.java
projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/ClassPoolRepository.java
projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/ClassPoolRepositoryCallback.java
projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/SecurityActions.java
Log:
[JBREFLECT-57]Added javadocs and cleaned up code of org.jboss.classpool.spi classes.
Modified: projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/AbstractClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/AbstractClassPool.java 2009-10-14 20:40:21 UTC (rev 94892)
+++ projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/AbstractClassPool.java 2009-10-14 21:09:03 UTC (rev 94893)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.classpool.spi;
import java.util.Iterator;
@@ -14,6 +35,8 @@
import org.jboss.logging.Logger;
/**
+ * A ClassPool tailored for usage with JBoss AS.
+ *
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
* @version $Revision$
@@ -149,37 +172,12 @@
child.close();
}
}
-// for (Iterator<AbstractClassPool> it = children.keySet().iterator() ; it.hasNext() ; )
-// {
-// AbstractClassPool child = it.next();
-// it.remove();
-// ClassLoader loader = child.getClassLoader();
-// if (loader != null)
-// {
-// AspectManager.instance().unregisterClassLoader(loader);
-// }
-// }
}
public CtClass getCached(String classname)
{
return searchStrategy.getCached(classname);
}
-
- /**
- * Make createCtClass public so that we can override it
- */
-// @Override
-// public CtClass createCtClass(String classname, boolean useCache)
-// {
-// boolean trace = logger.isTraceEnabled();
-//
-// if (trace) logger.trace(this + " attempting to create CtClass " + classname);
-// CtClass clazz = super.createCtClass(classname, useCache);
-// if (trace) logger.trace(this + " created CtClass " + getClassPoolLogStringForClass(clazz));
-//
-// return clazz;
-// }
@Override
public void cacheCtClass(String classname, CtClass c, boolean dynamic)
@@ -229,63 +227,7 @@
{
return getClassLoader().getResource(classResourceName) != null;
}
-
-// @Override
-// public synchronized CtClass getLocally(String classname)
-// throws NotFoundException
-// {
-// boolean trace = logger.isTraceEnabled();
-// if (trace) logger.trace(this + " attempting local get for " + classname);
-// softcache.remove(classname);
-// CtClass clazz = (CtClass) classes.get(classname);
-// if (trace && clazz != null)
-// {
-// logger.trace(this + " found " + classname + " in cache");
-// }
-// if (clazz == null)
-// {
-// clazz = createCtClass(classname, true);
-// if (clazz == null) throw new NotFoundException(classname);
-// lockInCache(clazz);//Avoid use of the softclasscache
-// }
-//
-// return clazz;
-// }
-// @Override
-// protected CtClass getCachedLocally(String classname)
-// {
-// if (logger.isTraceEnabled()) logger.trace(this + " checking local cache for " + classname);
-// return super.getCachedLocally(classname);
-// }
-
-// @Override
-// public void lockInCache(CtClass c)
-// {
-// if (logger.isTraceEnabled()) logger.trace(this + " locking in cache " + c.getName());
-// super.lockInCache(c);
-// }
-
-// public void setClassLoadedButNotWoven(String classname)
-// {
-// loadedButNotWovenClasses.put(classname, Boolean.TRUE);
-// }
-//
-// public boolean isClassLoadedButNotWoven(String classname)
-// {
-// return loadedButNotWovenClasses.get(classname) == Boolean.TRUE;
-// }
-
-// public static AbstractClassPool createAOPClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
-// {
-// return (AbstractClassPool)AspectManager.getClassPoolFactory().create(cl, src, repository);
-// }
-//
-// public static AbstractClassPool createAOPClassPool(ClassPool src, ScopedClassPoolRepository repository)
-// {
-// return (AbstractClassPool)AspectManager.getClassPoolFactory().create(src, repository);
-// }
-
public String toString()
{
ClassLoader cl = null;
@@ -298,38 +240,7 @@
}
return this.getClass().getName() + "@" + System.identityHashCode(this) + " " + super.toString() + " - dcl:" + cl;
}
-
- /* public CtClass getClass(String classname) {
- CtClass clazz;
- if (classname.charAt(0) == '[')
- {
- try
- {
- return Descriptor.toCtClass(classname, this);
- }
- catch (NotFoundException nfe)
- {
- throw new UnreachableStatementException(nfe.getMessage());
- }
- }
- if (classname == null)
- return null;
- else
- clazz = get0(classname, true);
-
- if (clazz != null)
- {
- //clazz.incGetCounter();
- }
- return clazz;
- }*/
-
-// public CtClass internalGet0(String classname, boolean useCache) throws NotFoundException
-// {
-// return super.get0(classname, useCache);
-// }
-
protected String getClassPoolLogStringForClass(CtClass clazz)
{
if (clazz == null)
@@ -360,6 +271,7 @@
// NOTE: identical to ScopedClassPoolRepository, with two differences:
// 1. This method uses the shortcuts isLocalResource and getResourceName
// 2. This method uses the Repository.includeInGlobalSearch method
+ @SuppressWarnings("unchecked")
private class SearchAllRegisteredLoadersSearchStrategy implements ClassPoolSearchStrategy
{
Logger logger = Logger.getLogger(this.getClass());
Modified: projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/AbstractClassPoolFactory.java
===================================================================
--- projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/AbstractClassPoolFactory.java 2009-10-14 20:40:21 UTC (rev 94892)
+++ projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/AbstractClassPoolFactory.java 2009-10-14 21:09:03 UTC (rev 94893)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.classpool.spi;
import javassist.ClassPool;
@@ -4,7 +25,13 @@
import javassist.scopedpool.ScopedClassPoolFactory;
import javassist.scopedpool.ScopedClassPoolRepository;
-// TODO: check why ScopedClassPoolRepository and not AbstractClassPoolRepository
+/**
+ * A factory that creates ClassPool instances based on a corresponding ClassLoader.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
public class AbstractClassPoolFactory implements ScopedClassPoolFactory
{
Modified: projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/ClassPoolRepository.java
===================================================================
--- projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/ClassPoolRepository.java 2009-10-14 20:40:21 UTC (rev 94892)
+++ projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/ClassPoolRepository.java 2009-10-14 21:09:03 UTC (rev 94893)
@@ -31,75 +31,70 @@
/**
- * Singleton classpool repository
+ * Singleton classpool repository.
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision$
*/
public class ClassPoolRepository implements ScopedClassPoolRepository
{
- //private static final Logger logger = Logger.getLogger(ClassPoolRepository.class);
-
private final static ClassPoolRepository instance = new ClassPoolRepository();
- /** The classes per classppol */
- //protected final HashMap<ClassLoader, HashSet<Class<?>>> ucl2classes = new HashMap<ClassLoader, HashSet<Class<?>>>();
-
private ScopedClassPoolRepository delegate;
private ClassPoolRepositoryCallback callback;
+ /**
+ * Returns the singleton instance.
+ *
+ * @return the singleton repository instance
+ */
public static ClassPoolRepository getInstance()
{
return instance;
}
+ /**
+ * Constructor.
+ */
private ClassPoolRepository()
{
this.delegate = ScopedClassPoolRepositoryImpl.getInstance();
- //This was needed when jboss-aop.jar was deployed in the jboss/lib directory since the AspectManager bean had no chance to initialise it
+ //TODO: This was needed when jboss-aop.jar was deployed in the jboss/lib directory since the AspectManager bean had no chance to initialise it
delegate.setClassPoolFactory(new AbstractClassPoolFactory());
- // if (!setJBossSpecificStartupVariables())
-// {
-// delegate.setClassPoolFactory(new AbstractClassPoolFactory());
-// }
}
-
-// private boolean setJBossSpecificStartupVariables()
-// {
-// //We are running within JBoss 5, let's default to the JBossClassPoolFactory and set the ScopedClassPoolHelper
-// //so that we get correct behaviour before the AspectManager service has been deployed
-// try
-// {
-// Class jbcpf = Class.forName("org.jboss.aop.deployment.JBossClassPoolFactory");
-// ScopedClassPoolFactory factory = (ScopedClassPoolFactory)jbcpf.newInstance();
-//
-// Class hlpr = Class.forName("org.jboss.aop.deployment.JBossScopedClassLoaderHelper");
-// AOPScopedClassLoaderHelper helper = (AOPScopedClassLoaderHelper)hlpr.newInstance();
-// delegate.setClassPoolFactory(factory);
-// AspectManager.scopedCLHelper = helper;
-// return true;
-// }
-// catch (Exception e)
-// {
-// }
-// return false;//Not running in JBoss probably
-// }
+ /**
+ * Sets the classpool factory that should be used. This method should always
+ * be called before the repository is used.
+ */
public void setClassPoolFactory(ScopedClassPoolFactory factory)
{
delegate.setClassPoolFactory(factory);
}
+ /**
+ * Returns the classpool factory.
+ */
public ScopedClassPoolFactory getClassPoolFactory()
{
return delegate.getClassPoolFactory();
}
+ /**
+ * Sets a callback object for notifications on classloader registration.
+ *
+ * @param callback the callback object
+ * @see ClassPoolRepositoryCallback
+ */
public void setClassPoolRepositoryCallback(ClassPoolRepositoryCallback callback)
{
this.callback = callback;
}
+ /**
+ * Returns the callback object.
+ * @return the callback object. May be {@code null}
+ */
public ClassPoolRepositoryCallback getClassPoolRepositoryCallback()
{
return this.callback;
@@ -115,14 +110,27 @@
delegate.setPrune(prune);
}
- public ScopedClassPool createScopedClassPool(ClassLoader cl, ClassPool src)
+ /**
+ * Creates a ClassPool corresponding to {@code classLoader}.
+ *
+ * @param classLoader the classLoader corresponding to the created ClassPool
+ * @param parent the parent of the class pool to be created.
+ * @return the created ClassPool.
+ */
+ public ScopedClassPool createScopedClassPool(ClassLoader classLoader, ClassPool parent)
{
- return delegate.createScopedClassPool(cl, src);
+ return delegate.createScopedClassPool(classLoader, parent);
}
- public ClassPool findClassPool(ClassLoader cl)
+ /**
+ * Finds the ClassPool corresponding to {@code classLoader}
+ *
+ * @param classLoader the classLoader
+ * @return the ClassPoool that corresponds to {@classLoader}
+ */
+ public ClassPool findClassPool(ClassLoader classLoader)
{
- return delegate.findClassPool(cl);
+ return delegate.findClassPool(classLoader);
}
/**
@@ -130,6 +138,7 @@
*
* @return the registered classloaders
*/
+ @SuppressWarnings("unchecked")
public Map<ClassLoader, ClassPool> getRegisteredCLs()
{
return delegate.getRegisteredCLs();
@@ -143,6 +152,12 @@
delegate.clearUnregisteredClassLoaders();
}
+ /**
+ * Registers {@code classLoader} and returns the corresponding {@code ClassPool}.
+ *
+ * @param classLoader the ClassLoader to be added to this repository
+ * @return the ClassPool corresponding to {@code classLoader}
+ */
public ClassPool registerClassLoader(ClassLoader classLoader)
{
if (classLoader == null)
@@ -157,6 +172,11 @@
return classPool;
}
+ /**
+ * Unregisters {@code classLoader}.
+ *
+ * @param classLoader the ClassLoader to be removed from this repository
+ */
public void unregisterClassLoader(ClassLoader classLoader)
{
delegate.unregisterClassLoader(classLoader);
@@ -165,21 +185,4 @@
callback.classLoaderUnregistered(classLoader);
}
}
-
- /*public void registerClass(Class<?> clazz)
- {
- ClassLoader classLoader = SecurityActions.getClassLoader(clazz);
- HashSet<Class<?>> classes = ucl2classes.get(classLoader);
- if (classes == null)
- {
- classes = new HashSet<Class<?>>();
- ucl2classes.put(classLoader, classes);
- }
- classes.add(clazz);
- }*/
-
- /*public void perfomUnregisterClassLoader(ClassLoader cl)
- {
- ucl2classes.remove(cl);
- }*/
-}
+}
\ No newline at end of file
Modified: projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/ClassPoolRepositoryCallback.java
===================================================================
--- projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/ClassPoolRepositoryCallback.java 2009-10-14 20:40:21 UTC (rev 94892)
+++ projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/ClassPoolRepositoryCallback.java 2009-10-14 21:09:03 UTC (rev 94893)
@@ -23,12 +23,29 @@
/**
- * Singleton classpool repository
+ * ClassPoolRepository callback.
*
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
* @version $Revision$
+ * @see ClassPoolRepository#setClassPoolRepositoryCallback(ClassPoolRepositoryCallback)
*/
public interface ClassPoolRepositoryCallback {
+
+ /**
+ * Notifies that {@code classLoader} has been registered to the
+ * {@code ClassPoolRepository}.
+ *
+ * @param classLoader a newly registered ClassLoader.
+ * @see ClassPoolRepository#registerClassLoader(ClassLoader)
+ */
public void classLoaderRegistered(ClassLoader classLoader);
+
+ /**
+ * Notifies that {@code classLoader} has been unregistered to the
+ * {@code ClassPoolRepository}.
+ *
+ * @param classLoader a newly unregistered ClassLoader.
+ * @see ClassPoolRepository#unregisterClassLoader(ClassLoader)
+ */
public void classLoaderUnregistered(ClassLoader classLoader);
}
\ No newline at end of file
Modified: projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/SecurityActions.java
===================================================================
--- projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/SecurityActions.java 2009-10-14 20:40:21 UTC (rev 94892)
+++ projects/jboss-classpool/trunk/src/main/java/org/jboss/classpool/spi/SecurityActions.java 2009-10-14 21:09:03 UTC (rev 94893)
@@ -25,6 +25,7 @@
import java.security.PrivilegedAction;
/**
+ * Package-protected class for performing security actions.
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision$
More information about the jboss-cvs-commits
mailing list