• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AnnotationDetector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中eu.infomas.annotation.AnnotationDetector的典型用法代码示例。如果您正苦于以下问题:Java AnnotationDetector类的具体用法?Java AnnotationDetector怎么用?Java AnnotationDetector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AnnotationDetector类属于eu.infomas.annotation包,在下文中一共展示了AnnotationDetector类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: detect

import eu.infomas.annotation.AnnotationDetector; //导入依赖的package包/类
public static void detect(AnnotationDetector ANNOTATION_DETECTOR, String... packageNames) {
    try {
        String libLocation = "lib" + File.separator;
        File[] externalCommands = new File(libLocation + "commands").listFiles();
        if (externalCommands != null) {
            ANNOTATION_DETECTOR.detect(externalCommands);
        }
        if (SystemDefaults.getClassesFromJar.get()) {
            ANNOTATION_DETECTOR.detect(new File(FilePath.getEngineJarPath()));
        } else {
            ANNOTATION_DETECTOR.detect(packageNames);
        }
        ANNOTATION_DETECTOR.detect(new File(FilePath.getAppRoot(), "userdefined"));
    } catch (IOException ex) {
        Logger.getLogger(AnnontationUtil.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:18,代码来源:AnnontationUtil.java


示例2: process

import eu.infomas.annotation.AnnotationDetector; //导入依赖的package包/类
public void process(Collection<String> ... pkgs) {

		List<String> packages = Lists.newArrayList();

		for (Collection<String> p : pkgs) {
			packages.addAll(p);
		}

		final AnnotationDetector cf = new AnnotationDetector(new TaskAnnotationReporter());
		try {

			// Full classpath
			if (packages == null || packages.size() == 0) {
				logger.debug("Processing Sorcerer annotations in full classpath");
				cf.detect();
				return;
			}

			for (String pkg : packages) {
				logger.debug("Processing Sorcerer annotations in package " + pkg);
				cf.detect(pkg);
			}

		} catch (IOException e) {
			logger.error("Could not successfully process Annotations", e);
		}
	}
 
开发者ID:turn,项目名称:sorcerer,代码行数:28,代码来源:InfomasAnnotationProcessor.java


示例3: startScan

import eu.infomas.annotation.AnnotationDetector; //导入依赖的package包/类
private static Set<Class<?>> startScan(final Set<Class<?>> classes,
                                       final Reporter reporter, String... packageNames) {
    final AnnotationDetector cf = new AnnotationDetector(reporter);
    try {
        if (packageNames.length == 0) {
            // 解决在web容器下扫描不到类的问题.
            URL url = Thread.currentThread().getContextClassLoader()
                    .getResource("");
            File file = new File(url.getPath());
            File[] files = file.listFiles(new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    return pathname.isDirectory() && !pathname.isHidden();
                }
            });
            List<String> fileNames = new LinkedList<>();
            for (File one : files) {
                fileNames.add(one.getName());
            }
            LOG.debug("san path:{}", fileNames);
            cf.detect(ArrayUtils.toStringArray(fileNames));
            // FIXME 这里扫描全部可能会有性能问题
            // XXX 在java项目中可以扫描到jar文件中的类,在web项目中不行.
            cf.detect();
        } else {
            cf.detect(packageNames);
        }
    } catch (IOException e) {
        LOG.error("scan package error packages:{}",
                Arrays.toString(packageNames));
    }
    return classes;
}
 
开发者ID:fivesmallq,项目名称:web-data-extractor,代码行数:35,代码来源:AnnotationClassScanner.java


示例4: init

import eu.infomas.annotation.AnnotationDetector; //导入依赖的package包/类
/**
 * Scan the requested packages on the classpath for HK2 'Service' and 'Contract' annotated classes.
 * Load the metadata for those classes into the HK2 Service Locator.
 * 
 * This implementation should support all Annotations that are supported by HK2 - however - if you are using 
 * HK2 older than 2.3.0 - note that it is impacted by this bug:  https://java.net/jira/browse/HK2-187
 * 
 * For an implementation that is not impacted by that bug, see {@link HK2RuntimeInitializerCustom}
 * 
 * @see org.glassfish.hk2.api.ServiceLocatorFactory#create(String)
 * @see ServiceLocatorUtilities#createAndPopulateServiceLocator(String)
 * 
 * @param serviceLocatorName - The name of the ServiceLocator to find (or create if it doesn't yet exist)  
 * @param readInhabitantFiles - Read and process inhabitant files before doing the classpath scan.  Annotated items
 * found during the scan will override items found in the inhabitant files, if they collide.  
 * @param packageNames -- The set of package names to scan recursively - for example - new String[]{"org.foo", "com.bar"}
 * If not provided, the entire classpath is scanned 
 * @return - The created ServiceLocator (but in practice, you can lookup this ServiceLocator by doing:
 * <pre>
 * {@code
 * ServiceLocatorFactory.getInstance().create("SomeName");
 * }
 * </pre>
 * @throws IOException
 * @throws ClassNotFoundException
 */
public static ServiceLocator init(String serviceLocatorName, boolean readInhabitantFiles, String ... packageNames) throws IOException, ClassNotFoundException 
{
	AnnotatedClasses ac = new AnnotatedClasses();
	
	@SuppressWarnings("unchecked")
	AnnotationDetector cf = new AnnotationDetector(new AnnotationReporter(ac, new Class[]{Service.class}));
	if (packageNames == null || packageNames.length == 0)
	{
		cf.detect();
	}
	else
	{
		cf.detect(packageNames);
	}
	
	ServiceLocator locator = null;
	
	if (readInhabitantFiles)
	{
		locator = ServiceLocatorUtilities.createAndPopulateServiceLocator(serviceLocatorName);
	}
	else
	{
		ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance();
		locator = factory.create(serviceLocatorName);
	}

	for (ActiveDescriptor<?> ad : ServiceLocatorUtilities.addClasses(locator, ac.getAnnotatedClasses()))
	{
		log.debug("Added " + ad.toString());
	}
	
	return locator;
}
 
开发者ID:darmbrust,项目名称:HK2Utilities,代码行数:61,代码来源:HK2RuntimeInitializer.java


示例5: getPlugins

import eu.infomas.annotation.AnnotationDetector; //导入依赖的package包/类
private List<SimplePlugin> getPlugins() {
	try {
		@SuppressWarnings("unchecked")
		List<Class<?>> types = AnnotationDetector.scanClassPath().forAnnotations(Plugin.class)
				.collect(new ReporterFunction<Class<?>>() {
					@Override
					public Class<?> report(Cursor cursor) {
						return AnnotationDetector.loadClass(Thread.currentThread().getContextClassLoader(),
								cursor.getTypeName());
					}
				});

		List<SimplePlugin> list = new ArrayList<SimplePlugin>();

		for (Class<?> clazz : types) {
			SimplePlugin sp = (SimplePlugin) clazz.newInstance();

			if (!Bitmmo.PLUGIN_BLACKLIST.contains(sp.getName()))
				list.add(sp);
		}

		return list;
	} catch (Exception e) {
		e.printStackTrace();
		System.exit(-1);
	}

	return null;
}
 
开发者ID:8BitPlus,项目名称:BitPlus,代码行数:30,代码来源:PluginLoader.java


示例6: run

import eu.infomas.annotation.AnnotationDetector; //导入依赖的package包/类
@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {

    final CouchbaseClientFactory factory = strategy.getCouchbaseClientFactory(configuration);
    factory.start();

    log.info("Let's see if we can find any Resource classes ...");
    final AnnotationDetector.FieldReporter reporter = new AnnotationDetector.FieldReporter() {

        @Override
        public void reportFieldAnnotation(Class<? extends Annotation> annotation, String className, String fieldName) {
            log.info("Annotation: " + annotation.getSimpleName() + " ClassName: " + className + " FieldName: " + fieldName);
            Field field = null;
            try {
                field = Class.forName(className).getDeclaredField(fieldName);
                log.info("Field type is: " + field.getType().getSimpleName());
                AccessorFactory.getFactory().getAccessor(field.getType(), factory);
            } catch (Exception e) {
                log.error("Unable to retrieve annotated field.", e);
            }
        }

        @Override
        public Class<? extends Annotation>[] annotations() {
            return new Class[] {Accessor.class};
        }
    };

    final AnnotationDetector cf = new AnnotationDetector(reporter);
    cf.detect();

    factory.stop();

}
 
开发者ID:smartmachine,项目名称:dropwizard-couchbase,代码行数:35,代码来源:CouchbaseInitCommand.java


示例7: startScan

import eu.infomas.annotation.AnnotationDetector; //导入依赖的package包/类
private static Set<Class<?>> startScan(final Set<Class<?>> classes,
		final Reporter reporter, String... packageNames) {
	final AnnotationDetector cf = new AnnotationDetector(reporter);
	try {
		if (packageNames.length == 0) {
			// 解决在web容器下扫描不到类的问题.
			URL url = Thread.currentThread().getContextClassLoader()
					.getResource("");
			File file = new File(url.getPath());
			File[] files = file.listFiles(new FileFilter() {

				@Override
				public boolean accept(File pathname) {
					return pathname.isDirectory() && !pathname.isHidden();
				}
			});
			List<String> fileNames = new ArrayList<String>();
			for (File one : files) {
				fileNames.add(one.getName());
			}
			LOG.debug("san path:{}", fileNames);
			cf.detect(toStringArray(fileNames));
			// FIXME 这里扫描全部可能会有性能问题
			// XXX 在java项目中可以扫描到jar文件中的类,在web项目中不行.
			cf.detect();
		} else {
			cf.detect(packageNames);
		}
	} catch (IOException e) {
		LOG.error("scan package error packages:{}",
				Arrays.toString(packageNames));
	}
	return classes;
}
 
开发者ID:fivesmallq,项目名称:guice-ext,代码行数:35,代码来源:AnnotationClassScanner.java


示例8: MethodAnnotationRecognizer

import eu.infomas.annotation.AnnotationDetector; //导入依赖的package包/类
public MethodAnnotationRecognizer(AnnotatedMethodStore pms, ConfigSummary summary) {
   super(pms, summary);
   ad = new AnnotationDetector(this);
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:5,代码来源:MethodAnnotationRecognizer.java



注:本文中的eu.infomas.annotation.AnnotationDetector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MenuBarPeer类代码示例发布时间:2022-05-21
下一篇:
Java IntEncodedValue类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap