[jboss-cvs] JBossAS SVN: r95748 - in projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann: scanner and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 29 08:07:42 EDT 2009
Author: alesj
Date: 2009-10-29 08:07:42 -0400 (Thu, 29 Oct 2009)
New Revision: 95748
Modified:
projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/repository/AbstractSettings.java
projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/repository/Settings.java
projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/scanner/AbstractAnnotationScanner.java
projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/scanner/DefaultAnnotationScanner.java
Log:
Check if we should ignore pre-index.
Modified: projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/repository/AbstractSettings.java
===================================================================
--- projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/repository/AbstractSettings.java 2009-10-29 11:56:42 UTC (rev 95747)
+++ projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/repository/AbstractSettings.java 2009-10-29 12:07:42 UTC (rev 95748)
@@ -32,6 +32,7 @@
*/
public abstract class AbstractSettings implements Settings
{
+ private boolean ignoreIndex;
private ResourceFilter resourceFilter = ClassFilter.INSTANCE;
private boolean forceAnnotations;
private boolean keepAnnotations;
@@ -52,6 +53,7 @@
if (settings == null)
throw new IllegalArgumentException("Null settings.");
+ setIgnoreIndex(settings.ignoreIndex());
setResourceFilter(settings.resourceFilter());
setForceAnnotations(settings.failOnError());
setKeepAnnotations(settings.keepAnnotations());
@@ -59,6 +61,11 @@
setCheckInterfaces(settings.checkInterfaces());
}
+ public boolean ignoreIndex()
+ {
+ return ignoreIndex;
+ }
+
public boolean isRelevant(ClassInfo classInfo)
{
return Object.class.getName().equals(classInfo.getName()) == false;
@@ -90,6 +97,16 @@
}
/**
+ * Set ignore index flag.
+ *
+ * @param ignoreIndex the ignore index flag
+ */
+ public void setIgnoreIndex(boolean ignoreIndex)
+ {
+ this.ignoreIndex = ignoreIndex;
+ }
+
+ /**
* Set the resource filter.
*
* @param resourceFilter the resource filter
Modified: projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/repository/Settings.java
===================================================================
--- projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/repository/Settings.java 2009-10-29 11:56:42 UTC (rev 95747)
+++ projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/repository/Settings.java 2009-10-29 12:07:42 UTC (rev 95748)
@@ -35,6 +35,13 @@
public interface Settings
{
/**
+ * Do we ignore pre-indexed results.
+ *
+ * @return true if we should ignore pre-indexed result, false otherwise
+ */
+ boolean ignoreIndex();
+
+ /**
* Is this class relevant for scanning.
*
* @param classInfo the class info
Modified: projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/scanner/AbstractAnnotationScanner.java
===================================================================
--- projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/scanner/AbstractAnnotationScanner.java 2009-10-29 11:56:42 UTC (rev 95747)
+++ projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/scanner/AbstractAnnotationScanner.java 2009-10-29 12:07:42 UTC (rev 95748)
@@ -33,6 +33,8 @@
import org.jboss.logging.Logger;
import org.jboss.mcann.AnnotationRepository;
import org.jboss.mcann.AnnotationScanner;
+import org.jboss.mcann.repository.Configuration;
+import org.jboss.mcann.repository.DefaultConfiguration;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
@@ -46,6 +48,13 @@
{
protected static final Logger log = Logger.getLogger(AnnotationScanner.class);
+ private Configuration configuration = new DefaultConfiguration();
+
+ protected final Configuration getConfiguration()
+ {
+ return configuration;
+ }
+
public AnnotationRepository scan(ClassLoader classLoader, URL... urls) throws Exception
{
if (urls == null)
@@ -58,19 +67,26 @@
Thread.currentThread().setContextClassLoader(classLoader);
try
{
- List<URL> list = new ArrayList<URL>();
- for (URL url : urls)
+ if (getConfiguration().ignoreIndex() == false)
{
- InputStream is = getMcAnnInputStream(url);
- if (is != null)
- reattach(repository, is);
- else
- list.add(url);
+ List<URL> list = new ArrayList<URL>();
+ for (URL url : urls)
+ {
+ InputStream is = getMcAnnInputStream(url);
+ if (is != null)
+ reattach(repository, is);
+ else
+ list.add(url);
+ }
+
+ // re-scan the rest
+ rescan(repository, list.toArray(new URL[list.size()]), classLoader);
}
+ else
+ {
+ rescan(repository, urls, classLoader);
+ }
- // re-scan the rest
- rescan(repository, list.toArray(new URL[list.size()]), classLoader);
-
return repository;
}
finally
@@ -130,4 +146,12 @@
protected abstract T createAnnotationRepository(ClassLoader classLoader);
protected abstract void rescan(T repo, URL[] urls, ClassLoader classLoader) throws Exception;
+
+ public void setConfiguration(Configuration configuration)
+ {
+ if (configuration == null)
+ throw new IllegalArgumentException("Null configuration");
+
+ this.configuration = configuration;
+ }
}
Modified: projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/scanner/DefaultAnnotationScanner.java
===================================================================
--- projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/scanner/DefaultAnnotationScanner.java 2009-10-29 11:56:42 UTC (rev 95747)
+++ projects/mc-ann/trunk/core/src/main/java/org/jboss/mcann/scanner/DefaultAnnotationScanner.java 2009-10-29 12:07:42 UTC (rev 95748)
@@ -27,10 +27,8 @@
import org.jboss.classloading.plugins.vfs.VFSResourceVisitor;
import org.jboss.classloading.spi.visitor.ResourceFilter;
import org.jboss.classloading.spi.visitor.ResourceVisitor;
-import org.jboss.mcann.repository.Configuration;
import org.jboss.mcann.repository.DefaultAnnotationRepository;
import org.jboss.mcann.repository.GenericAnnotationResourceVisitor;
-import org.jboss.mcann.repository.DefaultConfiguration;
import org.jboss.mcann.repository.TypeInfoProvider;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
@@ -42,7 +40,6 @@
*/
public class DefaultAnnotationScanner extends AbstractAnnotationScanner<DefaultAnnotationRepository>
{
- private Configuration configuration = new DefaultConfiguration();
private TypeInfoProvider typeInfoProvider;
protected VirtualFile[] excludedRoots;
@@ -57,12 +54,12 @@
protected void rescan(DefaultAnnotationRepository repo, URL[] urls, ClassLoader classLoader) throws Exception
{
- typeInfoProvider = configuration.createTypeInfoProvider();
+ typeInfoProvider = getConfiguration().createTypeInfoProvider();
if (typeInfoProvider == null)
throw new IllegalArgumentException("Null type info provider");
ResourceVisitor visitor = createResourceVisitor(repo);
- ResourceFilter filter = configuration.resourceFilter();
+ ResourceFilter filter = getConfiguration().resourceFilter();
if (filter == null)
filter = visitor.getFilter();
@@ -100,17 +97,9 @@
protected ResourceVisitor createResourceVisitor(DefaultAnnotationRepository repository)
{
- return new GenericAnnotationResourceVisitor(repository, configuration, typeInfoProvider);
+ return new GenericAnnotationResourceVisitor(repository, getConfiguration(), typeInfoProvider);
}
- public void setConfiguration(Configuration configuration)
- {
- if (configuration == null)
- throw new IllegalArgumentException("Null configuration");
-
- this.configuration = configuration;
- }
-
public void setExcludedRoots(VirtualFile[] excludedRoots)
{
this.excludedRoots = excludedRoots;
More information about the jboss-cvs-commits
mailing list