本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
示例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()));
}
}
}
示例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;
}
}
示例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)
);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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()));
}