當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。