<groupId>org.scannotation</groupId>
<artifactId>scannotation</artifactId>
<packaging>jar</packaging>
- <version>1.0.2</version>
+ <version>1.0.3</version>
<name>scannotation</name>
<url>http://maven.apache.org</url>
+
+ <distributionManagement>
+ <repository>
+ <id>jboss-releases-repository</id>
+ <name>JBoss Releases Repository</name>
+ <url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url>
+ </repository>
+ </distributionManagement>
+
<repositories>
<repository>
<id>jboss</id>
- <url>http://repository.jboss.org/maven2</url>
+ <url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
- <version>3.6.0.GA</version>
+ <version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
protected transient boolean scanParameterAnnotations = true;
protected transient boolean scanFieldAnnotations = true;
protected transient String[] ignoredPackages = {"javax", "java", "sun", "com.sun", "javassist"};
+ protected transient String[] scanPackages = null;
public class CrossReferenceException extends Exception
{
}
}
+ public String[] getScanPackages()
+ {
+ return scanPackages;
+ }
+
+ /**
+ * Set explicit packages to scan.
+ * Set to null to enable ignore list.
+ *
+ * @param scanPackages packages to scan or null
+ */
+ public void setScanPackages(String[] scanPackages)
+ {
+ this.scanPackages = scanPackages;
+ }
+
public String[] getIgnoredPackages()
{
return ignoredPackages;
int i = 0;
for (String ign : ignoredPackages) tmp[i++] = ign;
for (String ign : ignored) tmp[i++] = ign;
+ this.ignoredPackages = tmp;
}
/**
private boolean ignoreScan(String intf)
{
+ if (scanPackages != null)
+ {
+ for (String scan : scanPackages)
+ {
+ // do not ignore if on packages to scan list
+ if (intf.startsWith(scan + "."))
+ {
+ return false;
+ }
+ }
+ return true; // didn't match whitelist, ignore
+ }
for (String ignored : ignoredPackages)
{
if (intf.startsWith(ignored + "."))
{
if (filename.endsWith(".class"))
{
- if (filename.startsWith("/")) filename = filename.substring(1);
- if (!ignoreScan(filename.replace('/', '.'))) return true;
+ if (filename.startsWith("/") || filename.startsWith("\\"))
+ filename = filename.substring(1);
+ if (!ignoreScan(filename.replace('/', '.')))
+ return true;
//System.out.println("IGNORED: " + filename);
}
return false;
{
cf = new ClassFile(dstream);
classIndex.put(cf.getName(), new HashSet<String>());
- if (scanClassAnnotations) ;
- scanClass(cf);
+ if (scanClassAnnotations)
+ scanClass(cf);
if (scanMethodAnnotations || scanParameterAnnotations) scanMethods(cf);
if (scanFieldAnnotations) scanFields(cf);
{
ArrayList<URL> list = new ArrayList<URL>();
Set libJars = servletContext.getResourcePaths("/WEB-INF/lib");
+ if (libJars == null)
+ {
+ URL[] empty = {};
+ return empty;
+ }
+
+
for (Object jar : libJars)
{
try
throw new RuntimeException(e);
}
}
-
- protected static void create(List list, File dir, Filter filter) throws Exception
+ protected static void create(List list, File dir, Filter filter) throws Exception
+ {
+ create(list, dir, filter, dir.getCanonicalPath());
+ }
+ protected static void create(List list, File dir, Filter filter, String prefix) throws Exception
{
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++)
{
if (files[i].isDirectory())
{
- create(list, files[i], filter);
+ create(list, files[i], filter, prefix);
}
else
{
- if (filter == null || filter.accepts(files[i].getAbsolutePath()))
+ String path = files[i].getCanonicalPath();
+ String relativePath = path.substring(prefix.length() + 1);
+ if (File.separatorChar == '\\')
+ relativePath = relativePath.replace('\\', '/');
+ if (filter == null || filter.accepts(relativePath))
{
list.add(files[i]);
}
package org.scannotation.test;
-import com.titan.domain.Address;
+//import com.titan.domain.Address;
import org.junit.Assert;
import org.junit.Test;
import org.scannotation.AnnotationDB;
public class TestSmoke
{
+/*
@Test
public void testFindResourceBase() throws Exception
{
Assert.assertNotNull(url);
verify(url);
}
+*/
+/*
@Test
public void testFindResourceBases() throws Exception
{
Assert.assertNotNull(urls);
verify(urls);
}
+*/
@Test
public void testFindClasspaths() throws Exception
}
+/*
@Test
public void testByClass() throws Exception
{
Assert.assertNotNull(url);
verify(url);
}
+*/
private AnnotationDB verify(URL... urls)