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


Java ConfigurationBuilder.addUrls方法代码示例

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


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

示例1: GuiceApplication

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
protected GuiceApplication(String... basePackages) {
  final ConfigurationBuilder confBuilder = new ConfigurationBuilder();
  final FilterBuilder filterBuilder = new FilterBuilder();

  if (basePackages.length == 0) {
    basePackages = new String[] {};
  }

  logger.info("op=create, auto_scan_packages={}", (Object[]) basePackages);

  for (String pkg : basePackages) {
    confBuilder.addUrls(ClasspathHelper.forPackage(pkg));
    filterBuilder.include(FilterBuilder.prefix(pkg));
  }

  confBuilder.filterInputsBy(filterBuilder)
      .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner());

  this.reflections = new Reflections(confBuilder);
}
 
开发者ID:dehora,项目名称:outland,代码行数:21,代码来源:GuiceApplication.java

示例2: 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

示例3: createReflections

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
/**
 * Creates a {@link org.reflections.Reflections} with the given packages (configuration)
 *
 * @param scanPackages
 */
private void createReflections(String[] scanPackages) {
    if (scanPackages.length < 1) {
        LOGGER.warn("No package defined in configuration (scanPackages)!");
        return;
    }
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
    FilterBuilder filterBuilder = new FilterBuilder();
    for (String packageName : scanPackages) {
        configurationBuilder.addUrls(ClasspathHelper.forPackage(packageName));
        filterBuilder.include(FilterBuilder.prefix(packageName));
    }

    configurationBuilder.filterInputsBy(filterBuilder).setScanners(new SubTypesScanner(), new TypeAnnotationsScanner());
    this.reflections = new Reflections(configurationBuilder);

}
 
开发者ID:robeio,项目名称:robe,代码行数:22,代码来源:GuiceBundle.java

示例4: createReflections

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
/**
 * Builds a {@link Reflections} instance that will scan for classes in, and
 * load them from, the given class loader.
 *
 * @param classLoader The class loader to scan and load from.
 * @return A new {@link Reflections} instance.
 */
static Reflections createReflections(ClassLoader classLoader, String packagePrefix) {

    // We set up reflections to use the classLoader for loading classes
    // and also to use the classLoader to determine the list of URLs:
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder().addClassLoader(classLoader);
    if (StringUtils.isNotBlank(packagePrefix)) {
        configurationBuilder.addUrls(ClasspathHelper.forPackage(packagePrefix, classLoader));
    } else {
        configurationBuilder.addUrls(ClasspathHelper.forClassLoader(classLoader));
    }
    Reflections reflections = new Reflections(configurationBuilder);

    log.info("Reflections URLs: " + reflections.getConfiguration().getUrls());
    if (Main.configuration.classesReloadable && reflections.getConfiguration().getUrls().size() == 0 && StringUtils.isNotEmpty(Main.configuration.packagePrefix)) {
        log.info("It looks like no reloadable classes were found. Is '" + Main.configuration.packagePrefix + "' the correct package prefix for your app?");
    }
    return reflections;
}
 
开发者ID:davidcarboni,项目名称:restolino,代码行数:26,代码来源:ClassFinder.java

示例5: init

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
@PostConstruct
public void init() {
    String[] basePackages = ScannerHelper.findBasePackagesOnClasspath(applicationContext.getClassLoader());
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

    for (String basePackage : basePackages) {
        configurationBuilder.addUrls(ClasspathHelper.forPackage(basePackage));
    }

    Reflections reflections = new Reflections(configurationBuilder);

    Set<Class<?>> messageClasses = reflections.getTypesAnnotatedWith(Message.class);

    for (Class<?> messageClass : messageClasses) {
        Message messageAnnotation = messageClass.getAnnotation(Message.class);
        // get the serialization framework
        SerializationFramework framework = applicationContext.getBean(messageAnnotation.serializationFramework());
        if(framework != null) {
            framework.register(messageClass);
        } else {
            logger.error(String.format("Could not find framework %s for message class %s",
                                       messageAnnotation.serializationFramework().getSimpleName(),
                                       messageClass.getName()));
        }
    }
}
 
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:27,代码来源:MessagesScanner.java

示例6: 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

示例7: scanPluginPath

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private PluginScanResult scanPluginPath(
        ClassLoader loader,
        URL[] urls
) throws InstantiationException, IllegalAccessException {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setClassLoaders(new ClassLoader[]{loader});
    builder.addUrls(urls);
    Reflections reflections = new Reflections(builder);

    return new PluginScanResult(
            getPluginDesc(reflections, Connector.class, loader),
            getPluginDesc(reflections, Converter.class, loader),
            getPluginDesc(reflections, Transformation.class, loader)
    );
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:16,代码来源:DelegatingClassLoader.java

示例8: 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

示例9: 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

示例10: build

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private static ConfigurationBuilder build(String... namespaces) {
	final ConfigurationBuilder configBuilder = new ConfigurationBuilder();
	for(final String namespace : namespaces) {
		configBuilder.addUrls(ClasspathHelper.forPackage(namespace));
	}
	return configBuilder;
}
 
开发者ID:chanan,项目名称:PlayGuiceStatsD,代码行数:8,代码来源:PlayGuiceStatsDModule.java

示例11: 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

示例12: configureReflections

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private Reflections configureReflections() throws MalformedURLException {
	ConfigurationBuilder config = new ConfigurationBuilder();
	config.addClassLoaders(ClassLoader.getSystemClassLoader());
	LinkedList<URL> urls = new LinkedList<URL>();
	urls.add(new URL(RT_LIB));
	config.addUrls(urls);

	Reflections reflections = new Reflections(config);
	return reflections;
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:11,代码来源:Reflect2DSL.java

示例13: init

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
@PostConstruct
public void init() {
    String[] basePackages = ScannerHelper.findBasePackagesOnClasspath(applicationContext.getClassLoader());
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

    for (String basePackage : basePackages) {
        configurationBuilder.addUrls(ClasspathHelper.forPackage(basePackage));
    }

    Reflections reflections = new Reflections(configurationBuilder);

    Set<Class<?>> handlerClasses = reflections.getTypesAnnotatedWith(PluggableMessageHandlers.class);

    for (Class<?> handlerClass : handlerClasses) {
        PluggableMessageHandlers handlerAnnotation = handlerClass.getAnnotation(PluggableMessageHandlers.class);
        registry.put(handlerAnnotation.value(),handlerClass);
    }

    Set<Class<? extends ActorLifecycleListener>> listenerClasses = reflections.getSubTypesOf(ActorLifecycleListener.class);
    for (Class<? extends ActorLifecycleListener> listenerClass : listenerClasses) {
        try {
            ActorLifecycleListener lifeCycleListener = listenerClass.newInstance();
            // ensure that the lifeCycle listener handles the correct state class
            lifecycleListeners.put(lifeCycleListener.getActorClass(), lifeCycleListener);
        } catch(Exception e) {
            logger.error("Exception while instantiating ActorLifeCycleListener",e);
        }
    }
}
 
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:30,代码来源:PluggableMessageHandlersScanner.java

示例14: addUrls

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public void addUrls(URL... urls) {
	Reflections reflections_url;
	ConfigurationBuilder config = new ConfigurationBuilder();
	Set<URL>filteredUrls = GoogleReflectionsUtil.fixURLs(new HashSet<URL>(Arrays.<URL>asList(urls))); //jboss compatibility hack
	config.addUrls(filteredUrls);
	reflections_url =  new Reflections(config);
	reflections.merge(reflections_url);
	refresh();
}
 
开发者ID:java-prolog-connectivity,项目名称:logicobjects,代码行数:10,代码来源:ClassPathContext.java

示例15: getExtensionFiles

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public static Set<String> getExtensionFiles(String enabledExtension, String format) {
    ConfigurationBuilder configBuilder = new ConfigurationBuilder();
    configBuilder.addUrls(ClasspathHelper.forPackage("org.daylight.pathweaver." + enabledExtension + ".extensions"));

    Reflections reflections = new Reflections(configBuilder.setScanners(new ResourcesScanner(), new TypeAnnotationsScanner(), new SubTypesScanner()));
    return reflections.getResources(Pattern.compile("extension." + format.toLowerCase()));
}
 
开发者ID:citrixsystems,项目名称:pathweaver,代码行数:8,代码来源:JsonExtensionDefinitionReader.java


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