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


Java ConfigurationBuilder.setScanners方法代码示例

本文整理汇总了Java中org.reflections.util.ConfigurationBuilder.setScanners方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationBuilder.setScanners方法的具体用法?Java ConfigurationBuilder.setScanners怎么用?Java ConfigurationBuilder.setScanners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.reflections.util.ConfigurationBuilder的用法示例。


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

示例1: ReflectionsServiceDiscovery

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public ReflectionsServiceDiscovery(String resourceSearchPackages, JsonServiceLocator locator) {
	this.locator = locator;

	ConfigurationBuilder builder = new ConfigurationBuilder();

	PreconditionUtil.assertNotNull("no resourceSearchPackage configured", resourceSearchPackages);

	FilterBuilder filter = new FilterBuilder();
	for (String resourceSearchPackage : resourceSearchPackages.split(",")) {
		builder = builder.addUrls(ClasspathHelper.forPackage(resourceSearchPackage));
		filter.includePackage(resourceSearchPackage);
	}
	filter.includePackage(Repository.class.getPackage().getName());
	filter.includePackage(ResourceRepository.class.getPackage().getName());
	builder = builder.filterInputsBy(filter);

	builder = builder.addUrls(ClasspathHelper.forClass(Repository.class));
	builder = builder.addUrls(ClasspathHelper.forClass(ResourceRepository.class));
	builder = builder.addUrls(ClasspathHelper.forClass(ResourceRepositoryV2.class));

	builder = builder.setScanners(new SubTypesScanner(false), new TypeAnnotationsScanner());
	reflections = new Reflections(builder);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:24,代码来源:ReflectionsServiceDiscovery.java

示例2: BeanScanner

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public BeanScanner(final BeanManagerImpl beanManager, final ClassLoader classLoader, final String packageToScan)
{
    this.beanManager = beanManager;
    final ConfigurationBuilder config = new ConfigurationBuilder();

    config.setClassLoaders(new ClassLoader[] {classLoader});
    config.setUrls(ClasspathHelper.forPackage(packageToScan, classLoader));
    if (StringUtils.isNotEmpty(packageToScan))
    {
        config.filterInputsBy(new FilterBuilder().includePackage(packageToScan));
    }
    config.useParallelExecutor();
    config.setScanners(new SubTypesScanner(false));

    this.reflections = new Reflections(config);
}
 
开发者ID:Diorite,项目名称:Diorite-old,代码行数:17,代码来源:BeanScanner.java

示例3: initialize

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public static void initialize() {
	// Scan for json configuration files on the classpath
	ConfigurationBuilder builder = new ConfigurationBuilder();
	builder.setScanners(new ResourcesScanner());
	builder.setUrls(ClasspathHelper.forClassLoader(
			ClasspathHelper.contextClassLoader(),
			ClasspathHelper.staticClassLoader()));

	reflections = new Reflections(builder);
	json = new Json();
	for (String path : reflections.getResources(Pattern.compile(".*\\.json"))) {
		if (!path.startsWith("items") && !path.startsWith("tiles") && !path.startsWith("walls"))
			continue;

		FileHandle file = Gdx.files.internal(path);
		Type type = json.fromJson(null, file);
		registerType(type);
	}

	airItem = getItem("airItem");
	airTile = getTile("airTile");
	airWall = getWall("airWall");
}
 
开发者ID:antag99,项目名称:aquarria,代码行数:24,代码来源:GameRegistry.java

示例4: RegisterActors

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private static void RegisterActors(Binder binder) {
	Logger.debug("Actor Scanner Started...");
	final Map<String, ActorHolder> map = new HashMap<>();		
	final ConfigurationBuilder configBuilder = build();
	final Reflections reflections = new Reflections(configBuilder.setScanners(new SubTypesScanner()));
	final Set<Class<? extends UntypedActor>> actors = reflections.getSubTypesOf(UntypedActor.class);
       final Set<Class<? extends AbstractActor>> abstractActors = reflections.getSubTypesOf(AbstractActor.class);
       loopOnActors(map, actors);
       loopOnAbstractActors(map, abstractActors);
       if(!map.isEmpty()) Logger.debug("Registering actors: ");
	for(final String key : map.keySet()) {
		final ActorHolder actorHolder = map.get(key);
		final Class<? extends Actor> actor = actorHolder.getActor();
		if(actorHolder.isSingleton()) {
			Logger.debug("Binding class " + actor.getSimpleName() + " to name: " + key + " Singleton Scoped.");
			binder.bind(ActorRef.class).annotatedWith(Names.named(key)).toProvider(new ActorRefProvider(actor, key, true)).in(Singleton.class);
		} else {
			Logger.debug("Binding class " + actor.getSimpleName() + " to name: " + key + " Request Scoped.");
			binder.bind(ActorRef.class).annotatedWith(Names.named(key)).toProvider(new ActorRefProvider(actor, key, false));
			PropsContext.put(key, actorHolder);
		}
	}
}
 
开发者ID:chanan,项目名称:AkkaGuice,代码行数:24,代码来源:AkkaGuiceModule.java

示例5: retrieveVirtualIpsResource

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
@Path("virtualips")
public Object retrieveVirtualIpsResource() throws IllegalAccessException, InstantiationException {
    String enabledExtension = PluginConfiguration.getExtensionPrefix();
    ConfigurationBuilder configBuilder = new ConfigurationBuilder();
    configBuilder.addUrls(ClasspathHelper.forPackage("org.daylight.pathweaver." + enabledExtension + ".api"));

    // TODO: Decompose this out and dynamically resolve sub-resource base off of extensions prefix
    Reflections reflections = new Reflections(configBuilder.setScanners(new SubTypesScanner()));
    Set<Class<? extends VirtualIpsResource>> subTypes = reflections.getSubTypesOf(VirtualIpsResource.class);

    if (subTypes.iterator().hasNext()) {
        final Class<? extends VirtualIpsResource> subClass = subTypes.iterator().next();
        final VirtualIpsResource bean = PluginContextLoaderListener.getCurrentWebApplicationContext().getBean(subClass);
        bean.setLoadBalancerId(id);
        bean.setAccountId(accountId);
        return bean;
    } else {
        virtualIpsResource.setLoadBalancerId(id);
        virtualIpsResource.setAccountId(accountId);
        return  virtualIpsResource;
    }
}
 
开发者ID:citrixsystems,项目名称:pathweaver,代码行数:23,代码来源:LoadBalancerResource.java

示例6: configure

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的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

示例7: getClassesWithAnnotation

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public static Set<Class<?>> getClassesWithAnnotation(final Class<? extends Annotation> annotation, final String[] packageNames) {
    final Reflections reflections;
    final Set<Class<?>> classes = new HashSet<>();
    final ConfigurationBuilder builder = new ConfigurationBuilder();
    for (final String packageName : packageNames) {
        builder.addUrls(ClasspathHelper.forPackage(packageName));
    }
    builder.setScanners(new SubTypesScanner(), new TypeAnnotationsScanner());
    reflections = new Reflections(builder);
    classes.addAll(reflections.getTypesAnnotatedWith(annotation));
    return classes;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:13,代码来源:ReflectUtil.java

示例8: getDataMapperNames

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
@Override
public List<String> getDataMapperNames() {

    List<ClassLoader> classLoadersList = new LinkedList<>();
    classLoadersList.add(ClasspathHelper.contextClassLoader());
    classLoadersList.add(ClasspathHelper.staticClassLoader());

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner());
    cb.setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])));

    FilterBuilder fb = new FilterBuilder();

    for (Package aPackage : getSearchPackages()) {
        fb.include(FilterBuilder.prefix(aPackage.getName()));
    }
    cb.filterInputsBy(fb);
    Reflections reflections = new Reflections(cb);

    Set<Class<?>> subTypesOf =
            reflections.getSubTypesOf(Object.class);

    ArrayList<String> collected = subTypesOf.stream()
            .map(Class::getSimpleName)
            .collect(Collectors.toCollection(ArrayList::new));

    return collected;

}
 
开发者ID:virtualdataset,项目名称:metagen-java,代码行数:30,代码来源:FunctionalDataMappingLibrary.java

示例9: findDynaObjects

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private void findDynaObjects() throws IOException {
  ConfigurationBuilder configuration = new ConfigurationBuilder();

  List<URL> urls = new ArrayList<>();
  for (String element : classpath) {
    urls.add(new File(element).toURI().toURL());
  }

  ClassLoader contextClassLoader =
      URLClassLoader.newInstance(
          urls.toArray(new URL[urls.size()]), Thread.currentThread().getContextClassLoader());
  Thread.currentThread().setContextClassLoader(contextClassLoader);
  configuration.setUrls(ClasspathHelper.forClassLoader(contextClassLoader));
  configuration.setScanners(new SubTypesScanner(), new TypeAnnotationsScanner());
  Reflections reflection = new Reflections(configuration);

  Set<Class<?>> classes = reflection.getTypesAnnotatedWith(DynaObject.class);
  for (Class clazz : classes) {
    // accept only classes
    if (clazz.isEnum() || clazz.isInterface() || clazz.isAnnotation()) {
      continue;
    }
    dynaClasses.add(new ClassModel(clazz));
    System.out.println(String.format("New Dyna Object Found: %s", clazz.getCanonicalName()));
  }
  System.out.println(String.format("Found: %d Dyna Objects", dynaClasses.size()));
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:DynaProviderGenerator.java

示例10: configureReflection

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private static Reflections configureReflection(Bundle bundle, ClassLoader classLoader, Scanner... scanners) {
    ConfigurationBuilder configuration = new ConfigurationBuilder();
    configuration.addUrls(resolveLocation(bundle));
    configuration.setScanners(scanners);

    // we add the ability to load classes from the bundle
    configuration.addClassLoader(classLoader);

    LOGGER.debug("Initialized Reflections configuration");

    return new Reflections(configuration);
}
 
开发者ID:motech,项目名称:motech,代码行数:13,代码来源:ReflectionsUtil.java

示例11: registerHealthChecks

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private void registerHealthChecks(Binder binder) {
	Logger.debug("registerHealthChecks");
	final ConfigurationBuilder configBuilder = build(namespaces);
	final Reflections reflections = new Reflections(configBuilder.setScanners(new SubTypesScanner()));
	Set<Class<? extends HealthCheck>> checks = reflections.getSubTypesOf(HealthCheck.class);
	for(Class<? extends HealthCheck> check : checks) {
		Logger.debug("Heathcheck bound: " + check.getName());
		binder.bind(HealthCheck.class).annotatedWith(Names.named("PlayGuiceStatsD-HealthCheck-" + check.getName())).to(check);
	}
	binder.bind(ActorRef.class).annotatedWith(Names.named("PlayGuiceStatsD-HealthCheckActor")).toProvider(new ActorRefProvider(checks)).in(Singleton.class);
}
 
开发者ID:chanan,项目名称:PlayGuiceStatsD,代码行数:12,代码来源:PlayGuiceStatsDModule.java

示例12: searchClasses

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
/**
 * This is not entirely reliable method.
 * Maybe it would be better to rely on Spring ClassPathScanningCandidateComponentProvider
 */
public static void searchClasses(String packageName, Consumer<Class> consumer) {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setScanners(new SubTypesScanner(false));
    builder.setUrls(ClasspathHelper.forPackage(packageName, LOGGER.getClass().getClassLoader()));
    builder.setInputsFilter(new FilterBuilder().includePackage(packageName));

    Reflections reflections = new Reflections(builder);

    Multimap<String, String> map = reflections.getStore().get(SubTypesScanner.class.getSimpleName());
    Set<String> types = new HashSet<>();

    for (String key : map.keySet()) {
        Collection<String> col = map.get(key);
        if (col == null) {
            continue;
        }

        for (String c : col) {
            String simpleName = c.replaceFirst(packageName + "\\.", "");
            if (simpleName.contains(".")) {
                continue;
            }

            types.add(c);
        }
    }

    for (String type : types) {
        try {
            Class clazz = Class.forName(type);
            consumer.accept(clazz);
        } catch (ClassNotFoundException e) {
            LOGGER.error("Error during loading class {}. ", type);
        }
    }
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:41,代码来源:ClassPathUtil.java

示例13: ScheduleOnceActors

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static void ScheduleOnceActors() {
	final ConfigurationBuilder configBuilder = build();
	final Reflections reflections = new Reflections(configBuilder.setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()));
	final Set<Class<?>> schedules = reflections.getTypesAnnotatedWith(ScheduleOnce.class);
	if(!schedules.isEmpty()) Logger.debug("Scheduling actors once:");
	for(final Class<?> scheduleOnce : schedules) {
		final ActorRef actor = Akka.system().actorOf(GuiceProvider.get(Akka.system()).props((Class<? extends Actor>) scheduleOnce));
		final ScheduleOnce annotation = scheduleOnce.getAnnotation(ScheduleOnce.class);
		long initialDelay = 0;
		TimeUnit timeUnit = TimeUnit.MILLISECONDS;
		String configName = scheduleOnce.getName() + ".initialDelay";
		String configEnabled = scheduleOnce.getName() + ".enabled";
		if(config.getString(configEnabled) != null && !config.getBoolean(configEnabled)) continue;
		if(config.getString(configName) != null) {
			initialDelay = getTime(config.getString(configName));
			timeUnit = getTimeUnit(config.getString(configName));
		} else {
			initialDelay = annotation.initialDelay();
			timeUnit = annotation.timeUnit();
		}
		Akka.system().scheduler().scheduleOnce(
				Duration.apply(initialDelay, timeUnit),
				actor,
				"tick",
				Akka.system().dispatcher(),
				null);
		Logger.debug(scheduleOnce + " on delay: " + initialDelay + " " + timeUnit);
	}
}
 
开发者ID:chanan,项目名称:AkkaGuice,代码行数:31,代码来源:ActorScanner.java

示例14: getClassesWithAnnotation

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public static Set<Class<?>> getClassesWithAnnotation(Class<? extends Annotation> annotation, String[] packageNames) {
    Reflections reflections;
    Set<Class<?>> classes = new HashSet<Class<?>>();
    ConfigurationBuilder builder=new ConfigurationBuilder();
    for (String packageName : packageNames) {
         builder.addUrls(ClasspathHelper.forPackage(packageName));
    }
    builder.setScanners(new SubTypesScanner(),new TypeAnnotationsScanner());
    reflections = new Reflections(builder);
    classes.addAll(reflections.getTypesAnnotatedWith(annotation));
    return classes;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:13,代码来源:ReflectUtil.java

示例15: findEntities

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private List<String> findEntities() {
	final ConfigurationBuilder c = new ConfigurationBuilder();
	c.setUrls(ClasspathHelper.forPackage(PACKAGE));
	c.setScanners(new TypeAnnotationsScanner());
	final Reflections reflections = new Reflections(c);
	final Set<Class<?>> entities = reflections.getTypesAnnotatedWith(Entity.class);
	final List<String> entityClassNameList = new ArrayList<String>(entities.size());
	for (final Class<?> entity : entities) {
		entityClassNameList.add(entity.getName());
	}
	return entityClassNameList;
}
 
开发者ID:ValtechTechno,项目名称:dbdiff,代码行数:13,代码来源:SchemaFromScratchTest.java


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