Package org.scannotation

Examples of org.scannotation.AnnotationDB


    }
  }

  private Map<String, Set<String>> scanBasePackages(List<String> basePackages, ClasspathResolver resolver) {
    try {
      AnnotationDB db = createAnnotationDB();

      for (String basePackage : basePackages) {
        scanPackage(basePackage, db, resolver);
      }

      return db.getAnnotationIndex();
    } catch (IOException e) {
      throw new ScannerException("Could not scan base packages", e);
    }
  }
View Full Code Here


  private <T> Set<T> nullToEmpty(Set<T> set) {
    return firstNonNull(set, Collections.<T>emptySet());
  }

  private AnnotationDB createAnnotationDB() {
    AnnotationDB db = new AnnotationDB();
    db.setScanClassAnnotations(true);
    db.setScanFieldAnnotations(false);
    db.setScanMethodAnnotations(false);
    db.setScanParameterAnnotations(false);
    return db;
  }
View Full Code Here

    return results;
  }

  private Map<String, Set<String>> scanWebInfClasses(URL webInfClasses) {
    try {
      AnnotationDB db = createAnnotationDB();
      db.scanArchives(webInfClasses);
      return db.getAnnotationIndex();
    } catch (IOException e) {
      throw new ScannerException("Could not scan WEB-INF/classes", e);
    }
  }
View Full Code Here

    }
  }

  private Map<String, Set<String>> scanBasePackages(List<String> basePackages) {
    try {
      AnnotationDB db = createAnnotationDB();

      for (String basePackage : basePackages) {
        String resource = basePackage.replace('.', '/');
        Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(resource);
        if (!urls.hasMoreElements()) {
          logger.error("There's no occurence of package {} in classpath", basePackage);
          continue;
        }
        do {
          URL url = urls.nextElement();

          String file = url.getFile();
          file = file.substring(0, file.length() - resource.length() - 1);
          if (file.charAt(file.length() - 1) == '!') {
            file = file.substring(0, file.length() - 1);
          }
          if (!file.startsWith("file:")) {
            file = "file:" + file;
          }

          db.scanArchives(new URL(file));
        } while (urls.hasMoreElements());
      }

      return db.getAnnotationIndex();
    } catch (IOException e) {
      throw new ScannerException("Could not scan base packages", e);
    }
  }
View Full Code Here

      }
    }
  }

  private AnnotationDB createAnnotationDB() {
    AnnotationDB db = new AnnotationDB();
    db.setScanClassAnnotations(true);
    db.setScanFieldAnnotations(false);
    db.setScanMethodAnnotations(false);
    db.setScanParameterAnnotations(false);
    return db;
  }
View Full Code Here

*/
public class AnnotationTests {
    @Test
    public void findAnnotations() throws IOException {
        URL[] urls = ClasspathUrlFinder.findClassPaths(); // scan java.class.path
        AnnotationDB db = new AnnotationDB();
        db.scanArchives(urls);
        Set<String> entities = db.getAnnotationIndex().get(Entity.class.getName());
        for (String entity : entities) {
            System.out.println("entity=" + entity);
        }
    }
View Full Code Here

                logger.fine("classpath urls:");
                for (URL url : urls) {
                    logger.fine(url.toString());
                }
            }
            AnnotationDB annotationDB = new AnnotationDB();
            annotationDB.scanArchives(urls);
            entities = annotationDB.getAnnotationIndex().get(Entity.class.getName());
            if (entities != null) {
                for (String entity : entities) {
                    initEntity(entity);
                }
            }
View Full Code Here

        for (URL url : urls) {
          if (!url.toString().endsWith(".jar"))
            location += url.toString() + ", ";
        }
        _log.info("Scanning files at " + location);
        db = new AnnotationDB();
        db.scanArchives(urls);
    }
View Full Code Here

            } else {
              toAdd.add(url);
            }
          }
          finalUrls.addAll(toAdd);
      AnnotationDB db = new AnnotationDB();
      db.scanArchives(finalUrls.toArray(new URL[finalUrls.size()]));
      Set<String> entityClasses = db.getAnnotationIndex().get(
          javax.persistence.Entity.class.getName());
      for (String entityClass : entityClasses) {
        Class clazz = Class.forName(entityClass);
        if (UserDefinable.class.isAssignableFrom(clazz))
          udfClasses.put(clazz, clazz.getSimpleName());
View Full Code Here

          LOGGER.debug("URL full path: [" + url.toString() +"]");
            LOGGER.debug("Final URL is : [" + url.getPath() +
                "] with protocol: [" + url.getProtocol() +
                "] with file: [" + url.getFile() + "]");
          }
          AnnotationDB db = new AnnotationDB();
          db.scanArchives(finalUrls.toArray(new URL[finalUrls.size()]));
          Set<String> entityClasses = db.getAnnotationIndex().get(javax.persistence.Entity.class.getName());
            // Create the SessionFactory
          Configuration ac =  new Configuration();
          Properties properties = XMLPersistenceUtil.getProperties(persistenceFile, persistenceUnitName);
          ac.setProperties(properties);
          if (StringUtil.isEmpty(jndiName)) {
View Full Code Here

TOP

Related Classes of org.scannotation.AnnotationDB

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.