+ 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;
+ }
+
+ /**
+ * Override/overwrite any ignored packages
+ *
+ * @param ignoredPackages cannot be null
+ */
+ public void setIgnoredPackages(String[] ignoredPackages)
+ {
+ this.ignoredPackages = ignoredPackages;
+ }
+
+ public void addIgnoredPackages(String... ignored)
+ {
+ String[] tmp = new String[ignoredPackages.length + ignored.length];
+ int i = 0;
+ for (String ign : ignoredPackages) tmp[i++] = ign;
+ for (String ign : ignored) tmp[i++] = ign;
+ this.ignoredPackages = tmp;
+ }
+
+ /**
+ * This method will cross reference annotations in the annotation index with any meta-annotations that they have
+ * and create additional entries as needed. For example:
+ *
+ * @HttpMethod("GET") public @interface GET {}
+ * <p/>
+ * The HttpMethod index will have additional classes added to it for any classes annotated with annotations that
+ * have the HttpMethod meta-annotation.
+ * <p/>
+ * WARNING: If the annotation class has not already been scaned, this method will load all annotation classes indexed
+ * as a resource so they must be in your classpath
+ */
+ public void crossReferenceMetaAnnotations() throws CrossReferenceException
+ {
+ Set<String> unresolved = new HashSet<String>();
+
+ Set<String> index = new HashSet<String>();
+ index.addAll(annotationIndex.keySet());
+
+ for (String annotation : index)
+ {
+ if (ignoreScan(annotation))
+ {
+ continue;
+ }
+ if (classIndex.containsKey(annotation))
+ {
+ for (String xref : classIndex.get(annotation))
+ {
+ annotationIndex.get(xref).addAll(annotationIndex.get(annotation));
+ }
+ continue;
+ }
+ InputStream bits = Thread.currentThread().getContextClassLoader().getResourceAsStream(annotation.replace('.', '/') + ".class");
+ if (bits == null)
+ {
+ unresolved.add(annotation);
+ continue;
+ }
+ try
+ {
+ scanClass(bits);
+ }
+ catch (IOException e)
+ {
+ unresolved.add(annotation);
+ }
+ for (String xref : classIndex.get(annotation))
+ {
+ annotationIndex.get(xref).addAll(annotationIndex.get(annotation));
+ }
+
+ }
+ if (unresolved.size() > 0) throw new CrossReferenceException(unresolved);
+ }
+