本文整理汇总了Java中org.reflections.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于org.reflections包,在下文中一共展示了Configuration类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scan
import org.reflections.Configuration; //导入依赖的package包/类
Set<Class<? extends T>> scan(Class<? extends T> aClass) {
Configuration configuration = ConfigurationBuilder.build((Object[]) packages).addClassLoaders(classLoaders)
.addScanners(new AssignableScanner(aClass));
Reflections reflections = new Reflections(configuration);
Predicate<Class<? extends T>> classPredicate = klass ->
Modifier.isPublic(klass.getModifiers()) &&
(!klass.isMemberClass() || (klass.isMemberClass() && Modifier
.isStatic(klass.getModifiers()))) &&
!Modifier.isInterface(klass.getModifiers()) &&
!Modifier.isAbstract(klass.getModifiers());
HashSet<Class<? extends T>> subtypes = Sets.newHashSet(
ReflectionUtils.forNames(
reflections.getStore()
.getAll(AssignableScanner.class.getSimpleName(),
Collections.singletonList(aClass.getName())), classLoaders));
return subtypes.stream().filter(classPredicate).collect(Collectors.toSet());
}
示例2: getAllDocStrings0
import org.reflections.Configuration; //导入依赖的package包/类
private Map<String, String> getAllDocStrings0(ClassLoader classLoader) {
final Configuration configuration = new ConfigurationBuilder()
.filterInputsBy(new FilterBuilder().includePackage(path))
.setUrls(ClasspathHelper.forPackage(path))
.addClassLoader(classLoader)
.setScanners(new ResourcesScanner());
if (configuration.getUrls() == null || configuration.getUrls().isEmpty()) {
return Collections.emptyMap();
}
Map<String, byte[]> files = new Reflections(configuration)
.getResources(this::acceptFile).stream()
.map(f -> {
try {
URL url = classLoader.getResource(f);
if (url == null) {
throw new IllegalStateException("not found: " + f);
}
return new SimpleImmutableEntry<>(f, Resources.toByteArray(url));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
})
.collect(toImmutableMap(Entry::getKey, Entry::getValue));
return getDocStringsFromFiles(files);
}
示例3: getHookOrdering
import org.reflections.Configuration; //导入依赖的package包/类
/**
* creates a sortedset of all hook implementations found for the given hook. Ordering is done through
* {@link com.github.cherimojava.orchidae.hook.HookHandler.HookComparator} in reverse order
*
* @param hook to find all implementations from
* @param url where to search for hook implementations
* @param <H> Hook type
* @return sortedset with all found hook implementation
*/
public static <H> SortedSet<? extends H> getHookOrdering( Class<H> hook, URL url )
{
Configuration config = new ConfigurationBuilder().addUrls( url )
.addUrls( ClasspathHelper.forPackage( HookHandler.class.getPackage().getName() ) )
.setScanners( new SubTypesScanner() );
Reflections reflect = new Reflections( config );
SortedSet<H> hooks = Sets.newTreeSet( new ReverseComparator( comparator ) );
LOG.info( "Searching for hooks of {}", hook );
for ( Class<? extends H> c : reflect.getSubTypesOf( hook ) )
{
try
{
LOG.info( "Found hook {}", c );
hooks.add( c.newInstance() );
}
catch ( IllegalAccessException | InstantiationException e )
{
LOG.error( "Failed to instantiate {} please make sure it has a no param Constructor. {}", c, e );
}
}
return hooks;
}
示例4: getMutations
import org.reflections.Configuration; //导入依赖的package包/类
@Override public Collection<GraphQLFieldDefinition> getMutations() {
Configuration configuration = ConfigurationBuilder.build((Object[]) packages).addClassLoaders(classLoaders);
Reflections reflections = new Reflections(configuration);
return reflections.getSubTypesOf(StandardCommand.class).stream()
.filter(classPredicate)
.map(this::getMutation)
.collect(Collectors.toSet());
}
示例5: HookHandler
import org.reflections.Configuration; //导入依赖的package包/类
/**
* creates a new HookHandler containing all Hooks found
*
* @param config
* @param pluginURL
*/
public HookHandler( Configuration config, URL pluginURL )
{
hooks = Maps.newHashMap();
Reflections r = new Reflections( config );
Set<Class<?>> hookTypes = r.getTypesAnnotatedWith( Hook.class );
for ( Class<?> c : hookTypes )
{
hooks.put( c, ImmutableSortedSet.copyOf( HookHandler.getHookOrdering( c, pluginURL ) ) );
}
}
示例6: getConfigurationBuilder
import org.reflections.Configuration; //导入依赖的package包/类
private static Configuration getConfigurationBuilder() {
ConfigurationBuilder configurationBuilder= ConfigurationBuilder.build("org.apache.gobblin.metastore.database",
effectiveClassPathUrls(DatabaseJobHistoryStore.class.getClassLoader()));
List<URL> filteredUrls = Lists.newArrayList(Iterables.filter(configurationBuilder.getUrls(), new Predicate<URL>() {
@Override
public boolean apply(@Nullable URL input) {
return input != null && (!input.getProtocol().equals("file") || new File(input.getFile()).exists());
}
}));
configurationBuilder.setUrls(filteredUrls);
return configurationBuilder;
}
示例7: scan
import org.reflections.Configuration; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private Map<Class<?>, Converter<?>> scan(ClassLoader... classloaders) {
if (log.isDebugEnabled())
log.debug("scan <-");
Collection<URL> urls = ClasspathHelper.forPackage("play.utils.meta.convert", classloaders);
if (log.isDebugEnabled())
log.debug("urls : " + urls);
Configuration configs = new ConfigurationBuilder().setUrls(
urls).addClassLoaders(classloaders).setScanners(new SubTypesScanner(false));
final Reflections reflections = new Reflections(configs);
Map<Class<?>, Converter<?>> map = Maps.newHashMap();
Set<Class<? extends Converter>> converterClasses = reflections.getSubTypesOf(Converter.class);
if (log.isDebugEnabled())
log.debug("converterClasses : " + converterClasses);
for (Class<? extends Converter> converterClass : converterClasses) {
try {
if (log.isDebugEnabled())
log.debug("converterClass : " + converterClass);
Converter converter = converterClass.newInstance();
if (converter != null) {
Class<?> keyClass = converter.typeClass();
log.info("Converter:" + keyClass + " : " + converter);
map.put(keyClass, converter);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return map;
}
示例8: setConfiguration
import org.reflections.Configuration; //导入依赖的package包/类
@Override
public void setConfiguration(final Configuration configuration) {
this.configuration = configuration;
}
示例9: constructContext
import org.reflections.Configuration; //导入依赖的package包/类
private static FudgeContext constructContext() {
FudgeContext fudgeContext = new FudgeContext();
ExtendedFudgeBuilderFactory.init(fudgeContext.getObjectDictionary());
InnerClassFudgeBuilderFactory.init(fudgeContext.getObjectDictionary());
// hack to handle non-existent classpath directory entries
List<UrlType> urlTypes = Lists.newArrayList(Vfs.getDefaultUrlTypes());
urlTypes.add(0, new OGFileUrlType());
Vfs.setDefaultURLTypes(urlTypes);
// init annotation reflector, which needs this class loader
Set<ClassLoader> loaders = new HashSet<>();
loaders.add(OpenGammaFudgeContext.class.getClassLoader());
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader != null) {
loaders.add(loader);
}
} catch (Exception ex) {
// ignore
}
int availableProcessors = Runtime.getRuntime().availableProcessors();
ThreadFactory factory = new ThreadFactoryBuilder().setNameFormat("Reflections-scan-%d").build();
ExecutorService executorService = Executors.newFixedThreadPool(availableProcessors, factory);
try {
Configuration config = new ConfigurationBuilder()
.setUrls(ClasspathHelper.forManifest(ClasspathHelper.forJavaClassPath()))
.setScanners(new TypeAnnotationsScanner(), new FieldAnnotationsScanner(), new SubTypesScanner(false))
.filterInputsBy(FilterBuilder.parse(AnnotationReflector.DEFAULT_ANNOTATION_REFLECTOR_FILTER))
.addClassLoaders(loaders)
.setExecutorService(executorService);
AnnotationReflector.initDefaultReflector(new AnnotationReflector(config));
AnnotationReflector reflector = AnnotationReflector.getDefaultReflector();
fudgeContext.getObjectDictionary().addAllAnnotatedBuilders(reflector);
fudgeContext.getTypeDictionary().addAllAnnotatedSecondaryTypes(reflector);
} finally {
executorService.shutdown();
}
FudgeTypeDictionary td = fudgeContext.getTypeDictionary();
td.registerClassRename("com.opengamma.util.timeseries.zoneddatetime.ArrayZonedDateTimeDoubleTimeSeries", ImmutableZonedDateTimeDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.timeseries.zoneddatetime.ArrayZonedDateTimeDoubleTimeSeries", ImmutableZonedDateTimeDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.util.timeseries.zoneddatetime.ListZonedDateTimeDoubleTimeSeries", ImmutableZonedDateTimeDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.timeseries.zoneddatetime.ListZonedDateTimeDoubleTimeSeries", ImmutableZonedDateTimeDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.util.timeseries.localdate.ArrayLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.timeseries.localdate.ArrayLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.util.timeseries.localdate.ListLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.timeseries.localdate.ListLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.util.timeseries.localdate.MapLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.timeseries.localdate.MapLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.id.Identifier", ExternalId.class);
td.registerClassRename("com.opengamma.id.IdentifierBundleWithDates", ExternalIdBundleWithDates.class);
td.registerClassRename("com.opengamma.id.IdentifierBundle", ExternalIdBundle.class);
td.registerClassRename("com.opengamma.id.IdentifierWithDates", ExternalIdWithDates.class);
td.registerClassRename("com.opengamma.id.ObjectIdentifier", ObjectId.class);
td.registerClassRename("com.opengamma.id.UniqueIdentifier", UniqueId.class);
return fudgeContext;
}
示例10: getConfiguration
import org.reflections.Configuration; //导入依赖的package包/类
public Configuration getConfiguration() {
return configuration;
}
示例11: setConfiguration
import org.reflections.Configuration; //导入依赖的package包/类
public void setConfiguration(final Configuration configuration) {
this.configuration = configuration;
}
示例12: setConfiguration
import org.reflections.Configuration; //导入依赖的package包/类
void setConfiguration(Configuration configuration);