[jboss-cvs] JBossAS SVN: r57974 - in trunk/aspects/src/main/org/jboss/aop: deployers deployment
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 1 16:21:31 EST 2006
Author: kabir.khan at jboss.com
Date: 2006-11-01 16:21:28 -0500 (Wed, 01 Nov 2006)
New Revision: 57974
Added:
trunk/aspects/src/main/org/jboss/aop/deployment/TempJBossClassPool.java
Modified:
trunk/aspects/src/main/org/jboss/aop/deployers/AspectDeployer.java
trunk/aspects/src/main/org/jboss/aop/deployment/JBossClassPoolFactory.java
trunk/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java
Log:
Improve handling of scoped classloader domains.
Modified: trunk/aspects/src/main/org/jboss/aop/deployers/AspectDeployer.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployers/AspectDeployer.java 2006-11-01 21:00:23 UTC (rev 57973)
+++ trunk/aspects/src/main/org/jboss/aop/deployers/AspectDeployer.java 2006-11-01 21:21:28 UTC (rev 57974)
@@ -66,7 +66,6 @@
public void deploy(DeploymentUnit unit) throws DeploymentException
{
List<VirtualFile> files = unit.getMetaDataFiles(null, AOP_DD_SUFFIX);
- ClassLoader scl = getScopedClassLoader(unit);
if (isAopArchiveOrFolder(unit))
{
@@ -123,7 +122,7 @@
{
loader.setManager(AspectManager.instance());
}
- loader.deployXML(doc, vf.toURL(), unit.getClassLoader());
+ loader.deployXML(doc, vf.toURL(), scl);
}
finally
{
@@ -139,6 +138,8 @@
private void undeployXml(DeploymentUnit unit, List<VirtualFile> files)
{
+ ClassLoader scl = getScopedClassLoader(unit);
+
for (VirtualFile vf : files)
{
try
@@ -149,7 +150,10 @@
{
Document doc = AspectXmlLoader.loadDocument(is);
AspectXmlLoader loader = new AspectXmlLoader();
- loader.setManager(AspectManager.instance());
+
+ AspectManager manager = (scl != null) ? AspectManager.instance(scl) : AspectManager.instance();
+
+ loader.setManager(manager);
loader.undeployXML(doc, vf.toURL());
}
finally
@@ -175,9 +179,7 @@
log.info("AOP deployment is scoped using classloader " + scl);
}
- AspectManager manager = (scl != null) ? AspectManager.instance(scl) : AspectManager.instance();
- AspectAnnotationLoader loader = new AspectAnnotationLoader(manager);
- loader.setClassLoader(scl);
+ AspectAnnotationLoader loader = getAnnotationLoader(scl);
List<VirtualFile> files = getClasses(unit);
for(VirtualFile file : files)
{
@@ -197,7 +199,8 @@
private void undeployAnnotations(DeploymentUnit unit)
{
- AspectAnnotationLoader loader = new AspectAnnotationLoader(AspectManager.instance());
+ ClassLoader scl = getScopedClassLoader(unit);
+ AspectAnnotationLoader loader = getAnnotationLoader(scl);
List<VirtualFile> files = getClasses(unit);
for(VirtualFile file : files)
{
@@ -214,6 +217,14 @@
}
}
}
+
+ private AspectAnnotationLoader getAnnotationLoader(ClassLoader scl)
+ {
+ AspectManager manager = (scl != null) ? AspectManager.instance(scl) : AspectManager.instance();
+ AspectAnnotationLoader loader = new AspectAnnotationLoader(manager);
+ loader.setClassLoader(scl);
+ return loader;
+ }
private ClassFile loadClassFile(VirtualFile file)
{
@@ -315,16 +326,4 @@
}
}
- private static class RecurseAOPFilter implements VirtualFileFilter
- {
- public boolean accepts(VirtualFile file)
- {
- if (file.getName().endsWith(".aop"))
- {
- return true;
- }
- return false;
- }
- }
-
}
Modified: trunk/aspects/src/main/org/jboss/aop/deployment/JBossClassPoolFactory.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployment/JBossClassPoolFactory.java 2006-11-01 21:00:23 UTC (rev 57973)
+++ trunk/aspects/src/main/org/jboss/aop/deployment/JBossClassPoolFactory.java 2006-11-01 21:21:28 UTC (rev 57974)
@@ -74,7 +74,7 @@
public ScopedClassPool create(ClassPool src, ScopedClassPoolRepository repository)
{
- return new JBossClassPool(src, repository);
+ return new TempJBossClassPool(src, repository);
}
public File createTempDir(ClassLoader cl) throws IOException
Modified: trunk/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java 2006-11-01 21:00:23 UTC (rev 57973)
+++ trunk/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java 2006-11-01 21:21:28 UTC (rev 57974)
@@ -25,6 +25,7 @@
import org.jboss.aop.AspectManager;
import org.jboss.aop.Domain;
+import org.jboss.aop.InterceptionMarkers;
import org.jboss.aop.advice.AspectDefinition;
import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
import org.jboss.mx.loading.LoaderRepository;
@@ -45,6 +46,7 @@
boolean parentDelegation;
ConcurrentReaderHashMap myPerVMAspects = new ConcurrentReaderHashMap();
ConcurrentReaderHashMap notMyPerVMAspects = new ConcurrentReaderHashMap();
+ InterceptionMarkers interceptionMarkers = new InterceptionMarkers();
public ScopedClassLoaderDomain(ClassLoader loader, String name, boolean parentDelegation, AspectManager manager, boolean parentFirst)
{
@@ -68,6 +70,12 @@
return getPerVMAspect(def.getName());
}
+ @Override
+ public InterceptionMarkers getInterceptionMarkers()
+ {
+ return interceptionMarkers;
+ }
+
public Object getPerVMAspect(String def)
{
if (parentDelegation == true)
Added: trunk/aspects/src/main/org/jboss/aop/deployment/TempJBossClassPool.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployment/TempJBossClassPool.java 2006-11-01 21:00:23 UTC (rev 57973)
+++ trunk/aspects/src/main/org/jboss/aop/deployment/TempJBossClassPool.java 2006-11-01 21:21:28 UTC (rev 57974)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.aop.deployment;
+
+import org.jboss.aop.classpool.AOPClassPool;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * The temporary classpool used by the instrumentor. It's main job is to delegate to the parent classpool
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TempJBossClassPool extends AOPClassPool
+{
+ boolean isParentPoolAOP;
+ public TempJBossClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+ {
+ super(cl, src, repository);
+ if (src instanceof AOPClassPool)
+ {
+ isParentPoolAOP = true;
+ }
+ }
+
+ public TempJBossClassPool(ClassPool src, ScopedClassPoolRepository repository)
+ {
+ super(src, repository);
+ if (src instanceof AOPClassPool)
+ {
+ isParentPoolAOP = true;
+ }
+ }
+
+ public CtClass getCached(String classname)
+ {
+ CtClass clazz = null;
+ if (isParentPoolAOP)
+ {
+ clazz = ((AOPClassPool)parent).getCached(classname);
+ }
+ if (clazz == null)
+ {
+ clazz = super.getCached(classname);
+ }
+ return clazz;
+ }
+
+}
More information about the jboss-cvs-commits
mailing list