[jboss-cvs] JBossAS SVN: r105678 - trunk/server/src/main/java/org/jboss/web/deployers.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 3 16:11:36 EDT 2010
Author: alesj
Date: 2010-06-03 16:11:35 -0400 (Thu, 03 Jun 2010)
New Revision: 105678
Modified:
trunk/server/src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
Log:
Remove ScanningMD usage in new scanning, fix the old.
Modified: trunk/server/src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java 2010-06-03 17:23:15 UTC (rev 105677)
+++ trunk/server/src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java 2010-06-03 20:11:35 UTC (rev 105678)
@@ -24,15 +24,9 @@
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.annotations.ScanningMetaData;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
@@ -43,6 +37,8 @@
import org.jboss.metadata.annotation.finder.AnnotationFinder;
import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
import org.jboss.metadata.web.spec.WebMetaData;
+import org.jboss.scanning.spi.metadata.PathMetaData;
+import org.jboss.scanning.spi.metadata.ScanningMetaData;
import org.jboss.scanning.web.spi.ResourcesIndex;
import org.jboss.vfs.VirtualFile;
@@ -143,7 +139,7 @@
if (ri == null)
{
log.warn("Cannot scan classes, missing ResourcesIndex as attachment: " + unit.getName());
- processMetaData1(unit, classpath);
+ processMetaDataOld(unit, classpath);
return;
}
AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
@@ -159,79 +155,74 @@
annotations.addAll(annotationContext.getFieldAnnotations());
boolean metaData = false;
- ScanningMetaData scanningMetaData = unit.getAttachment(ScanningMetaData.class);
for (VirtualFile path : classpath)
{
- if (scanningMetaData == null
- || !(scanningMetaData.getPaths() == null
- || !scanningMetaData.getPaths().contains(path.getName())))
+ Set<Class<?>> annotatedClasses = new HashSet<Class<?>>();
+ for (Class<? extends Annotation> annotation : annotations)
{
- Set<Class<?>> annotatedClasses = new HashSet<Class<?>>();
- for (Class<? extends Annotation> annotation : annotations)
- {
- annotatedClasses.addAll(ri.getAnnotatedClasses(path, annotation));
- }
- WebMetaData annotationMetaData = creator.create(annotatedClasses);
- if (annotationMetaData != null)
- {
- unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME + ":" + path.getName(), annotationMetaData, WebMetaData.class);
- metaData = true;
- }
+ annotatedClasses.addAll(ri.getAnnotatedClasses(path, annotation));
}
+ WebMetaData annotationMetaData = creator.create(annotatedClasses);
+ if (annotationMetaData != null)
+ {
+ unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME + ":" + path.getName(), annotationMetaData, WebMetaData.class);
+ metaData = true;
+ }
}
if (metaData)
unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, Boolean.TRUE);
}
/**
- * Undeploy a vfs deployment
- *
- * @param unit the unit
- */
- protected void undeploy(VFSDeploymentUnit unit)
- {
- // Nothing
- }
-
- /**
* Process metadata.
*
* @param unit the deployment unit
* @param classpath the classpath
* @throws Exception for any error
- * @deprecated
+ * @deprecated the new scanning should be used
*/
- protected void processMetaData1(VFSDeploymentUnit unit, List<VirtualFile> classpath) throws Exception
+ protected void processMetaDataOld(VFSDeploymentUnit unit, List<VirtualFile> classpath) throws Exception
{
ScanningMetaData scanningMetaData = unit.getAttachment(ScanningMetaData.class);
Map<VirtualFile, Collection<Class<?>>> classesPerJar = new HashMap<VirtualFile, Collection<Class<?>>>();
- boolean foundAnnotations = false;
+ int foundAnnotations = 0;
for (VirtualFile path : classpath)
{
- if (scanningMetaData == null
- || !(scanningMetaData.getPaths() == null
- || !scanningMetaData.getPaths().contains(path.getName())))
+ if (doScan(scanningMetaData, path.getName()))
{
Collection<Class<?>> currentClasses = getClasses(unit, path);
classesPerJar.put(path, currentClasses);
- if (currentClasses.size() > 0)
- {
- foundAnnotations = true;
- }
+ foundAnnotations += currentClasses.size();
}
}
- if (foundAnnotations)
+ if (foundAnnotations > 0)
{
AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
processJBossWebMetaData(unit, finder, classesPerJar);
}
}
+ protected boolean doScan(ScanningMetaData smd, String name)
+ {
+ if (smd == null)
+ return true;
+
+ List<PathMetaData> paths = smd.getPaths();
+ if (paths == null)
+ return false;
+
+ for (PathMetaData pmd : paths)
+ {
+ if (pmd.getPathName().contains(name))
+ return true;
+ }
+ return false;
+ }
+
/**
* Get the classes we want to scan.
*
* @param unit the deployment unit
- * @param mainClassName the main class name
* @param classpath the classpath
* @return possible classes containing metadata annotations
* @throws IOException for any error
More information about the jboss-cvs-commits
mailing list