[jboss-cvs] JBossAS SVN: r80190 - in projects/jboss-deployers/trunk/deployers-vfs/src: test/java/org/jboss/test/deployers/vfs/annotations/support/jar and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 29 09:19:25 EDT 2008
Author: alesj
Date: 2008-10-29 09:19:25 -0400 (Wed, 29 Oct 2008)
New Revision: 80190
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/DeploymentUnitClassPath.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClassSuper.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClassSuperAnnotated.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClassSuper.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClassSuperAnnotated.java
Modified:
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationEnvironmentDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClass.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClass.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.java
Log:
[JBDEPLOY-119]; add DU based Javassist ClassPath.
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java 2008-10-29 12:43:52 UTC (rev 80189)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -113,6 +113,7 @@
* @param classLoader the class loader
* @return javassist class pool
*/
+ @Deprecated
protected ClassPool createClassPool(ClassLoader classLoader)
{
ClassPool pool = new ClassPool();
@@ -122,6 +123,23 @@
}
/**
+ * Create class pool.
+ *
+ * @param unit the deployment unit
+ * @return javassist class pool
+ */
+ protected ClassPool createClassPool(VFSDeploymentUnit unit)
+ {
+ ClassPool pool = new ClassPool();
+ ClassPath deploymentPath = new DeploymentUnitClassPath(unit);
+ pool.appendClassPath(deploymentPath);
+ // fall back to classloader classpath
+ ClassPath classPath = new LoaderClassPath(unit.getClassLoader());
+ pool.appendClassPath(classPath);
+ return pool;
+ }
+
+ /**
* Visit module.
*
* Util method to add some behavior to Module
@@ -196,7 +214,7 @@
log.trace("Creating AnnotationEnvironment for " + unit.getName() + ", module: " + module + ", force annotations: " + forceAnnotations);
ClassLoader classLoader = unit.getClassLoader();
- ClassPool pool = createClassPool(classLoader);
+ ClassPool pool = createClassPool(unit);
GenericAnnotationResourceVisitor visitor = createGenericAnnotationResourceVisitor(unit, pool, classLoader);
// something in javassist uses TCL
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/DeploymentUnitClassPath.java (from rev 80026, projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/DeploymentUnitClassPath.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/DeploymentUnitClassPath.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -0,0 +1,124 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.deployers.vfs.plugins.annotations;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+
+import javassist.ClassPath;
+import javassist.NotFoundException;
+import org.jboss.classloader.plugins.ClassLoaderUtils;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Javassist ClassPath impl based on deployment unit
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DeploymentUnitClassPath implements ClassPath
+{
+ private VFSDeploymentUnit unit;
+ private Map<String, VirtualFile> cache;
+
+ public DeploymentUnitClassPath(VFSDeploymentUnit unit)
+ {
+ if (unit == null)
+ throw new IllegalArgumentException("Null deployment unit.");
+ this.unit = unit;
+ this.cache = new HashMap<String, VirtualFile>();
+ }
+
+ /**
+ * Find file.
+ *
+ * @param className the classname we're looking for
+ * @return virtual file or null if not found
+ * @throws IOException for any exception
+ */
+ protected VirtualFile findFile(String className) throws IOException
+ {
+ // ignore jdk classes
+ if (ClassFilter.JAVA_ONLY.matchesClassName(className))
+ return null;
+
+ VirtualFile file = cache.get(className);
+ if (file != null)
+ return file;
+
+ String path = ClassLoaderUtils.classNameToPath(className);
+ List<VirtualFile> classPath = unit.getClassPath();
+ if (classPath != null && classPath.isEmpty() == false)
+ {
+ for (VirtualFile cp : classPath)
+ {
+ file = cp.getChild(path);
+ if (file != null)
+ {
+ cache.put(className, file);
+ return file;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public InputStream openClassfile(String className) throws NotFoundException
+ {
+ try
+ {
+ VirtualFile file = findFile(className);
+ if (file != null)
+ return file.openStream();
+ }
+ catch (IOException e)
+ {
+ throw new NotFoundException("Exception finding file: " + className, e);
+ }
+ throw new NotFoundException("ClassName '" + className + "' not found in deployment unit: " + unit);
+ }
+
+ public URL find(String className)
+ {
+ try
+ {
+ VirtualFile file = findFile(className);
+ if (file != null)
+ return file.toURL();
+ }
+ catch (Exception ignored)
+ {
+ }
+ return null;
+ }
+
+ public void close()
+ {
+ cache.clear();
+ }
+}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationEnvironmentDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationEnvironmentDeployer.java 2008-10-29 12:43:52 UTC (rev 80189)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationEnvironmentDeployer.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -23,6 +23,7 @@
import javassist.ClassPool;
import javassist.scopedpool.ScopedClassPoolRepository;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
/**
* Scoped class pool usage annotation environment deployer.
@@ -59,4 +60,12 @@
return super.createClassPool(classLoader);
}
+
+ protected ClassPool createClassPool(VFSDeploymentUnit unit)
+ {
+ if (repository != null)
+ return repository.findClassPool(unit.getClassLoader());
+
+ return super.createClassPool(unit);
+ }
}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClass.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClass.java 2008-10-29 12:43:52 UTC (rev 80189)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClass.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -27,6 +27,6 @@
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
@Marked
-public class JarMarkOnClass
+public class JarMarkOnClass extends JarMarkOnClassSuper
{
}
\ No newline at end of file
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClassSuper.java (from rev 80026, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClass.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClassSuper.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClassSuper.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.deployers.vfs.annotations.support.jar;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JarMarkOnClassSuper extends JarMarkOnClassSuperAnnotated
+{
+}
\ No newline at end of file
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClassSuperAnnotated.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClassSuperAnnotated.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClassSuperAnnotated.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.deployers.vfs.annotations.support.jar;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Marked
+public class JarMarkOnClassSuperAnnotated
+{
+}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClass.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClass.java 2008-10-29 12:43:52 UTC (rev 80189)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClass.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -27,6 +27,6 @@
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
@Marked
-public class WebMarkOnClass
+public class WebMarkOnClass extends WebMarkOnClassSuper
{
}
\ No newline at end of file
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClassSuper.java (from rev 80026, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClass.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClassSuper.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClassSuper.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.deployers.vfs.annotations.support.war;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class WebMarkOnClassSuper extends WebMarkOnClassSuperAnnotated
+{
+}
\ No newline at end of file
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClassSuperAnnotated.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClassSuperAnnotated.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClassSuperAnnotated.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.deployers.vfs.annotations.support.war;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Marked
+public class WebMarkOnClassSuperAnnotated
+{
+}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.java 2008-10-29 12:43:52 UTC (rev 80189)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.java 2008-10-29 13:19:25 UTC (rev 80190)
@@ -70,9 +70,9 @@
try
{
DeploymentUnit jarUnit = assertChild(unit, "simple.jar");
- assertAnnotations(jarUnit, 1, 1, 1);
+ assertAnnotations(jarUnit, 2, 1, 1);
DeploymentUnit webUnit = assertChild(unit, "simple.war");
- assertAnnotations(webUnit, 1, 1, 1);
+ assertAnnotations(webUnit, 2, 1, 1);
}
finally
{
More information about the jboss-cvs-commits
mailing list