当前位置: 首页>>代码示例>>Java>>正文


Java MethodAnnotationsScanner类代码示例

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


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

示例1: fromConfigWithPackage

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
/**
 * Scans the specified packages for annotated classes, and applies Config values to them.
 * 
 * @param config the Config to derive values from
 * @param packageNamePrefix the prefix to limit scanning to - e.g. "com.github"
 * @return The constructed TypesafeConfigModule.
 */
public static TypesafeConfigModule fromConfigWithPackage(Config config, String packageNamePrefix) {
	 ConfigurationBuilder configBuilder = 
		 new ConfigurationBuilder()
         .filterInputsBy(new FilterBuilder().includePackage(packageNamePrefix))
         .setUrls(ClasspathHelper.forPackage(packageNamePrefix))
         .setScanners(
        	new TypeAnnotationsScanner(), 
        	new MethodParameterScanner(), 
        	new MethodAnnotationsScanner(), 
        	new FieldAnnotationsScanner()
         );
	Reflections reflections = new Reflections(configBuilder);
	
	return new TypesafeConfigModule(config, reflections);
}
 
开发者ID:racc,项目名称:typesafeconfig-guice,代码行数:23,代码来源:TypesafeConfigModule.java

示例2: generateReport

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
public void generateReport(String packageName,List<String> flagList) throws IOException
{

    URL testClassesURL = Paths.get("target/test-classes").toUri().toURL();

    URLClassLoader classLoader = URLClassLoader.newInstance(new URL[]{testClassesURL},
            ClasspathHelper.staticClassLoader());

    reflections = new Reflections(new ConfigurationBuilder()
            .setUrls(ClasspathHelper.forPackage(packageName,classLoader))
            .addClassLoader(classLoader)
            .filterInputsBy(new FilterBuilder().includePackage(packageName))
            .setScanners(new MethodAnnotationsScanner(), new TypeAnnotationsScanner(), new SubTypesScanner())
    );


    List<Map<String, TestClass>> list = new ArrayList<>();

    for (String flag : flagList)
    {
        list.add(printMethods(flag));
    }

    Gson gson = new Gson();
    String overviewTemplate = IOUtils.toString(getClass().getResourceAsStream("/index.tpl.html"));


    String editedTemplate = overviewTemplate.replace("##TEST_DATA##", gson.toJson(list));

    FileUtils.writeStringToFile(new File("target/test-list-html-report/index.html"), editedTemplate);
    logger.info("report file generated");
}
 
开发者ID:cyildirim,项目名称:Lahiya,代码行数:33,代码来源:LahiyaTestCaseReport.java

示例3: AlgorithmServiceImpl

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
public AlgorithmServiceImpl() {
	map = new HashMap<>();
	List<URL> urlList = new ArrayList<>();
	for(String f:System.getProperty("java.class.path").split(":")){
		System.err.println(f);
		try {
			urlList.add(new File(f).toURI().toURL());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	URL[] urls = urlList.toArray(new URL[0]);
	Reflections reflections = new Reflections("jobreading.algorithm.experiment",new MethodAnnotationsScanner(),urls);
	for(Method method : reflections.getMethodsAnnotatedWith(Algorithm.class)){
		final Algorithm my = method.getAnnotation(Algorithm.class);
		Class<?> clazz = method.getDeclaringClass();
		if (null != my) {
			map.put(my.name(), clazz);
		}
	}
}
 
开发者ID:kaichao,项目名称:algorithm.annotation,代码行数:22,代码来源:AlgorithmServiceImpl.java

示例4: scanTypes

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
private Set<Class<?>> scanTypes(String packageName) {
    Reflections reflections = new Reflections(packageName,
            new MethodAnnotationsScanner());
    Set<Class<?>> types = new HashSet<>();
    types.addAll(typesAnnotatedWith(reflections, Given.class));
    types.addAll(typesAnnotatedWith(reflections, When.class));
    types.addAll(typesAnnotatedWith(reflections, Then.class));
    types.addAll(typesAnnotatedWith(reflections, Before.class));
    types.addAll(typesAnnotatedWith(reflections, After.class));
    types.addAll(typesAnnotatedWith(reflections, BeforeScenario.class));
    types.addAll(typesAnnotatedWith(reflections, AfterScenario.class));
    types.addAll(typesAnnotatedWith(reflections, BeforeStory.class));
    types.addAll(typesAnnotatedWith(reflections, AfterStory.class));
    types.addAll(typesAnnotatedWith(reflections, BeforeStories.class));
    types.addAll(typesAnnotatedWith(reflections, AfterStories.class));
    types.addAll(typesAnnotatedWith(reflections, AsParameterConverter
            .class));
    return types;
}
 
开发者ID:tapack,项目名称:satisfy,代码行数:20,代码来源:ScanningStepsFactory.java

示例5: scan

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
public void scan(String base) {
	Reflections reflections = new Reflections(new ConfigurationBuilder()
		.setUrls(ClasspathHelper.forPackage(base))
		.setScanners(new MethodAnnotationsScanner())
	);

	Set<Method> predicateMethods = reflections.getMethodsAnnotatedWith(Predicate.class);

	for (Method method : predicateMethods) {
		String name = method.getAnnotation(Predicate.class).name();

		if (name.isEmpty()) {
			name = method.getName();
		}

		this.register(method, name);
	}
}
 
开发者ID:alpha-asp,项目名称:Alpha,代码行数:19,代码来源:Alpha.java

示例6: getKeywordClassList

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
private String getKeywordClassList(URLClassLoader cl) throws Exception {
	URL url = cl.getURLs()[0];
	try {
		Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(url)
				.addClassLoader(cl).setScanners(new MethodAnnotationsScanner()));
		Set<Method> methods = reflections.getMethodsAnnotatedWith(Keyword.class);
		Set<String> kwClasses = new HashSet<>();
		for(Method method:methods) {
			kwClasses.add(method.getDeclaringClass().getName());
		}
		StringBuilder kwClassnamesBuilder = new StringBuilder();
		kwClasses.forEach(kwClassname->kwClassnamesBuilder.append(kwClassname+";"));
		return kwClassnamesBuilder.toString();
	} catch (Exception e) {
		String errorMsg = "Error while looking for methods annotated with @Keyword in "+url.toString();
		throw new Exception(errorMsg, e);
	}
}
 
开发者ID:denkbar,项目名称:step,代码行数:19,代码来源:JavaJarHandler.java

示例7: getReflected

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
private static Set<Class<?>> getReflected() {
    synchronized (LOCK) {
        if (reflected != null) {
            return reflected;
        }
        Reflections reflections = new Reflections(new ConfigurationBuilder()
                .setUrls(ClasspathHelper.forPackage("com.jivesoftware"))
                .setScanners(new MethodAnnotationsScanner(), new TypeAnnotationsScanner()));
        Set<Class<?>> result = reflections.getTypesAnnotatedWith(Path.class);
        Set<Method> methods = reflections.getMethodsAnnotatedWith(Path.class);
        for (Method method : methods) {
            result.add(method.getDeclaringClass());
        }
        reflected = Collections.unmodifiableSet(result);
        return reflected;
    }
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:18,代码来源:RestfulHelpEndpoints.java

示例8: test

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
public void test()
{
	final Reflections reflections = new Reflections(new ConfigurationBuilder()
			.addUrls(ClasspathHelper.forClassLoader())
			.setScanners(new MethodAnnotationsScanner())
			);

	final Set<Method> methods = reflections.getMethodsAnnotatedWith(Cached.class);
	System.out.println("Found " + methods.size() + " methods annotated with " + Cached.class);

	for (final Method method : methods)
	{
		testMethod(method);
	}

	assertNoExceptions();
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:18,代码来源:ClasspathCachedMethodsTester.java

示例9: getActionContext

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
private Set<ActionData> getActionContext(String controllerPackageScan) {
    Set<ActionData> resourceContext = new HashSet<ActionData>();

    if (controllerPackageScan.isEmpty()) return resourceContext;

    Reflections reflections = new Reflections(new ConfigurationBuilder()
            .addUrls(ClasspathHelper.forPackage(controllerPackageScan))
            .setScanners(new MethodAnnotationsScanner()));

    Set<Method> methodSet = reflections.getMethodsAnnotatedWith(Action.class);

    for (Method method : methodSet) {
        Secured authenticated = (Secured)method.getAnnotation(Secured.class);
        Action action = (Action)method.getAnnotation(Action.class);

        if (null != action) {
            resourceContext.add(new ActionData(action.uri(), action.method(), authenticated != null, method));
        }
    }

    return resourceContext;
}
 
开发者ID:hasanozgan,项目名称:flex,代码行数:23,代码来源:FlexUrlResolver.java

示例10: invokeAnnotatedMethods

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
public void invokeAnnotatedMethods( Object inObject, Class<? extends Annotation> inAnnotation ) throws InvokeAnnotatedMethodException
{
	// Retrieve all methods annotated with the given annotation
	Reflections reflections = new Reflections( inObject.getClass().getName(), new MethodAnnotationsScanner() );
	Set<Method> methods = reflections.getMethodsAnnotatedWith( inAnnotation );
	
	// Invoke them
	for( Method method : methods )
	{
		try {
			method.invoke( inObject, new Object[]{} );
		} catch (IllegalAccessException | IllegalArgumentException
				| InvocationTargetException e) {
			throw new InvokeAnnotatedMethodException( method );
		}
	}
}
 
开发者ID:jbouny,项目名称:EJBContainer,代码行数:18,代码来源:DynamicHelper.java

示例11: addUrlsTo

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
@Override
public void addUrlsTo(WebSitemapGenerator generator) {
  String baseUrl = configuration.getString("sitemap.baseUrl");

  ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
  Reflections reflections = new Reflections("controllers", new MethodAnnotationsScanner());

  Set<Method> actions = reflections.getMethodsAnnotatedWith(SitemapItem.class);
  for(Method method : actions) {
    String actionUrl = actionUrl(classLoader, method);
    SitemapItem annotation = method.getAnnotation(SitemapItem.class);
    if(annotation != null) {
      WebSitemapUrl url = webSitemapUrl(baseUrl, actionUrl, annotation);
      generator.addUrl(url);
    }
  }
}
 
开发者ID:edulify,项目名称:play-sitemap-module.edulify.com,代码行数:18,代码来源:AnnotationUrlProvider.java

示例12: init

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
private void init(String packageName) {
  FilterBuilder filters = new FilterBuilder().includePackage(packageName);

  Scanner[] scanners = {
      new TypeAnnotationsScanner(),
      new MethodAnnotationsScanner(),
      new MethodParameterScanner(),
      new FieldAnnotationsScanner(),
      new SubTypesScanner().filterResultsBy(filters)
  };

  reflections = new ConfigurationBuilder()
      .addUrls(ClasspathHelper.forPackage(packageName))
      .addScanners(scanners)
      .filterInputsBy(filters)
      .build();
}
 
开发者ID:hawky-4s-,项目名称:restapidoc,代码行数:18,代码来源:ClassPathScanner.java

示例13: reflections

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
/**
 * {@link Reflections} bean.
 *
 * @return bean
 */
@Bean
public Reflections reflections() {
    return new Reflections(new ConfigurationBuilder()
                               .setUrls(ClasspathHelper.forPackage(SCAN_PACKAGE))
                               .setScanners(new MethodAnnotationsScanner()));
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:12,代码来源:ReflectionConfig.java

示例14: findFunctions

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
@Override
public Set<Method> findFunctions(final URL url) {
    return new Reflections(
            new ConfigurationBuilder()
                    .addUrls(url)
                    .setScanners(new MethodAnnotationsScanner())
                    .addClassLoader(getClassLoader(url)))
            .getMethodsAnnotatedWith(FunctionName.class);
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:10,代码来源:AnnotationHandlerImpl.java

示例15: configure

import org.reflections.scanners.MethodAnnotationsScanner; //导入依赖的package包/类
@Override
    public ReflectionsWrapper configure() {
        reflections = (Reflections) cache.get(Reflections.class.getName());

        if (reflections == null) {
            ConfigurationBuilder cb = new ConfigurationBuilder();

            Set<URL> classLocations = new LinkedHashSet<>();

            try {
                List<URL> urls = Collections.list(Thread.currentThread().getContextClassLoader().getResources(""));

                for (URL url : urls) {
                    if (url.getPath().contains("/geemvc/target/")) {
                        classLocations.add(url);
                    }
                }
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }

            cb = cb.addUrls(classLocations).addClassLoader(Thread.currentThread().getContextClassLoader());
            cb = cb.setScanners(new ResourcesScanner(), new TypeAnnotationsScanner(), new MethodAnnotationsScanner(), new SubTypesScanner());
            reflections = cb.build();

//            Reflections cachedReflections = (Reflections)
              cache.putIfAbsent(Reflections.class.getName(), reflections);

//            if (cachedReflections != null)
//                reflections = cachedReflections;
        }

        return this;
    }
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:35,代码来源:TestReflectionsWrapper.java


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