本文整理汇总了Java中org.scannotation.AnnotationDB类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationDB类的具体用法?Java AnnotationDB怎么用?Java AnnotationDB使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationDB类属于org.scannotation包,在下文中一共展示了AnnotationDB类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findSetupTeardownClasses
import org.scannotation.AnnotationDB; //导入依赖的package包/类
/**
* Search classpath and init TestSetupTeardown classes.
*/
private static void findSetupTeardownClasses() {
AnnotationDB db = new AnnotationDB();
try {
URL[] urls = ClasspathUrlFinder.findClassPaths();
db.scanArchives(urls);
Map<String, Set<String>> annotationIndex = db.getAnnotationIndex();
for (String cls : annotationIndex.get(FeatureSetupTeardown.class.getName())) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class<?> setup = cl.loadClass(cls);
FeatureSetupTeardown anno = setup.getAnnotation(FeatureSetupTeardown.class);
if (setupTeardownRegistry.get(anno.value().getName()) != null) {
if (!cls.toLowerCase().contains("default")) {
setupTeardownRegistry.put(anno.value().getName(), setup);
}
} else {
setupTeardownRegistry.put(anno.value().getName(), setup);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: index
import org.scannotation.AnnotationDB; //导入依赖的package包/类
private synchronized Map<String, Set<String>> index() {
if (index == null) {
final AnnotationDB db = new AnnotationDB();
try {
db.scanArchives(urls);
} catch (final IOException e) {
throw new TestEEfiException("Failed to perform annotation scanning", e);
}
index = db.getAnnotationIndex();
}
return index;
}
示例3: createDB
import org.scannotation.AnnotationDB; //导入依赖的package包/类
/**
* Create the annotation database from the given URLs.
* @param urls the urls to use
*/
protected synchronized void createDB(URL[] urls) {
try {
long start = System.currentTimeMillis();
annotationDB = new AnnotationDB();
annotationDB.scanArchives(urls);
long time = System.currentTimeMillis() - start;
logger.warning("Scanned classes in " + time + " ms.");
} catch (IOException ioe) {
logger.log(Level.WARNING, "Error scanning " +
Arrays.toString(urls) + " for annotation", ioe);
}
}
示例4: discover
import org.scannotation.AnnotationDB; //导入依赖的package包/类
/**
* Discovers available plug-ins using a given array of URLs.
*
* @param urls URLs where the {@link PluginManager} should look for URLs
* @return Number of plug-ins discovered
*/
public int discover(URL... urls) {
for (URL url : urls) {
LOG.log(Level.INFO, "Discovering plug-ins in {0}", url.toString());
}
int discoveredPlugins = 0;
AnnotationDB db = new AnnotationDB();
try {
db.scanArchives(urls);
LOG.log(Level.INFO, "{0} different annotations found", db.getAnnotationIndex().size());
for (String key : db.getAnnotationIndex().keySet()) {
LOG.log(Level.INFO, "Annotation: {0} of {1} found", new Object[]{db.getAnnotationIndex().get(key).size(), key});
}
discoveredPlugins += discoverPlugins(db, dk.i2m.converge.core.annotations.NewswireDecoder.class, newswireDecoders);
discoveredPlugins += discoverPlugins(db, dk.i2m.converge.core.annotations.WorkflowAction.class, workflowActions);
discoveredPlugins += discoverPlugins(db, dk.i2m.converge.core.annotations.OutletAction.class, outletActions);
discoveredPlugins += discoverPlugins(db, dk.i2m.converge.core.annotations.WorkflowValidator.class, workflowValidators);
discoveredPlugins += discoverPlugins(db, dk.i2m.converge.core.annotations.CatalogueAction.class, catalogueActions);
discoveredPlugins += discoverPlugins(db, dk.i2m.converge.core.annotations.NewsItemAction.class, newsItemActions);
LOG.log(Level.INFO, "{0} {0, choice, 0#plugins|1#plugin|2#plugins} discovered", discoveredPlugins);
} catch (IOException ex) {
LOG.log(Level.SEVERE, "Could not discover plug-ins. {0}", ex.getMessage());
LOG.log(Level.FINEST, "", ex);
}
return discoveredPlugins;
}
示例5: findEntityClassNames
import org.scannotation.AnnotationDB; //导入依赖的package包/类
private Set<String> findEntityClassNames() throws IOException {
AnnotationDB annotationDB = new AnnotationDB();
annotationDB.setScanClassAnnotations(true);
annotationDB.scanArchives(ClasspathUrlFinder.findClassPaths());
Map<String, Set<String>> map = annotationDB.getAnnotationIndex();
Set<String> classNames = map.get(Entity.class.getName());
return classNames;
}
示例6: scanForAnnotations
import org.scannotation.AnnotationDB; //导入依赖的package包/类
private static Entries scanForAnnotations(URL[] urls) {
AnnotationDB db = new AnnotationDB();
try {
db.scanArchives(urls);
} catch (IOException e) {
throw Throwables.propagate(e);
}
Map<String,Set<String>> annotationIndex = db.getAnnotationIndex();
Set<String> types = annotationIndex.get(Stable.class.getName());
return new Entries(types, Collections.<String>emptyList());
}
示例7: findAnnotatedClassFiles
import org.scannotation.AnnotationDB; //导入依赖的package包/类
protected List<JarFileAnnotationPlugin> findAnnotatedClassFiles( String annotationClassName ) {
JarFileCache jarFileCache = JarFileCache.getInstance();
List<JarFileAnnotationPlugin> classFiles = new ArrayList<>();
// We want to scan the plugins folder for plugin.xml files...
//
for ( PluginFolderInterface pluginFolder : getPluginFolders() ) {
if ( pluginFolder.isPluginAnnotationsFolder() ) {
try {
// Get all the jar files in the plugin folder...
//
FileObject[] fileObjects = jarFileCache.getFileObjects( pluginFolder );
if ( fileObjects != null ) {
for ( FileObject fileObject : fileObjects ) {
// These are the jar files : find annotations in it...
//
AnnotationDB annotationDB = jarFileCache.getAnnotationDB( fileObject );
Set<String> impls = annotationDB.getAnnotationIndex().get( annotationClassName );
if ( impls != null ) {
for ( String fil : impls ) {
classFiles.add( new JarFileAnnotationPlugin( fil, fileObject.getURL(), fileObject
.getParent().getURL() ) );
}
}
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
return classFiles;
}
示例8: getDescriptor
import org.scannotation.AnnotationDB; //导入依赖的package包/类
@Override
public FixedPropertyDescriptor getDescriptor () throws EsfingeAOMException
{
try
{
FixedPropertyDescriptor descriptor = new FixedPropertyDescriptor();
URL[] urls = ClasspathUrlFinder.findClassPaths();
AnnotationDB db = new AnnotationDB();
db.setScanFieldAnnotations(true);
db.setScanClassAnnotations(false);
db.setScanMethodAnnotations(false);
db.setScanParameterAnnotations(false);
db.scanArchives(urls);
Map<String, Set<String>> annotations = db.getAnnotationIndex();
for (String clazz : annotations.get(FixedEntityProperty.class.getName()))
{
Class<?> c = Class.forName(clazz);
if (c.isAnnotationPresent(Entity.class))
{
Class<?> type = null;
List<Field> fixedProperties = new ArrayList<Field>();
for (Field f : c.getDeclaredFields())
{
if (f.isAnnotationPresent(EntityType.class))
{
type = f.getType();
}
else if (f.isAnnotationPresent(FixedEntityProperty.class))
{
fixedProperties.add(f);
}
}
if (type != null && fixedProperties.size() > 0)
{
descriptor.addFixedProperty(type, fixedProperties);
}
}
}
return descriptor;
}
catch (Exception e)
{
throw new EsfingeAOMException(e);
}
}
示例9: ScannotationDB
import org.scannotation.AnnotationDB; //导入依赖的package包/类
/**
* Constructor.
*/
public ScannotationDB( )
{
_db = new AnnotationDB( );
}
示例10: findAnnotatedClassFiles
import org.scannotation.AnnotationDB; //导入依赖的package包/类
protected List<JarFileAnnotationPlugin> findAnnotatedClassFiles(String annotationClassName) {
List<JarFileAnnotationPlugin> classFiles = new ArrayList<JarFileAnnotationPlugin>();
// We want to scan the plugins folder for plugin.xml files...
//
for (PluginFolderInterface pluginFolder : getPluginFolders()) {
if (pluginFolder.isPluginAnnotationsFolder()) {
try {
// Get all the jar files in the plugin folder...
//
FileObject[] fileObjects = pluginFolder.findJarFiles();
if (fileObjects!=null) {
for (FileObject fileObject : fileObjects) {
// These are the jar files : find annotations in it...
//
AnnotationDB annotationDB = new AnnotationDB();
annotationDB.scanArchives(fileObject.getURL());
// These are the jar files : find annotations in it...
//
Set<String> impls = annotationDB.getAnnotationIndex().get(annotationClassName);
if(impls != null){
for(String fil : impls)
classFiles.add(new JarFileAnnotationPlugin(fil, fileObject.getURL(),fileObject.getParent().getURL()));
}
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
return classFiles;
}
示例11: JarFileCache
import org.scannotation.AnnotationDB; //导入依赖的package包/类
private JarFileCache() {
annotationMap = new HashMap<FileObject, AnnotationDB>();
}
示例12: addEntry
import org.scannotation.AnnotationDB; //导入依赖的package包/类
public void addEntry(FileObject fileObject, AnnotationDB annotationDb) {
annotationMap.put(fileObject, annotationDb);
}
示例13: getEntry
import org.scannotation.AnnotationDB; //导入依赖的package包/类
public AnnotationDB getEntry(FileObject fileObject) {
return annotationMap.get(fileObject);
}