本文整理汇总了Java中org.reflections.scanners.Scanner类的典型用法代码示例。如果您正苦于以下问题:Java Scanner类的具体用法?Java Scanner怎么用?Java Scanner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Scanner类属于org.reflections.scanners包,在下文中一共展示了Scanner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseScanners
import org.reflections.scanners.Scanner; //导入依赖的package包/类
private Scanner[] parseScanners() throws MojoExecutionException {
Set<Scanner> scannersSet = new HashSet<Scanner>(0);
if (StringUtils.isNotEmpty(scanners)) {
String[] scannerClasses = scanners.split(",");
for (String scannerClass : scannerClasses) {
try {
scannersSet.add((Scanner) forName(scannerClass.trim(), "org.reflections.scanners").newInstance());
} catch (Exception e) {
throw new MojoExecutionException(String.format("error getting scanner %s or org.reflections.scanners.%s", scannerClass.trim(), scannerClass.trim()), e);
}
}
}
return scannersSet.toArray(new Scanner[scannersSet.size()]);
}
开发者ID:ronmamo,项目名称:reflections-maven,代码行数:17,代码来源:ReflectionsMojo.java
示例2: init
import org.reflections.scanners.Scanner; //导入依赖的package包/类
private void init(String packageName) {
FilterBuilder filters = new FilterBuilder().includePackage(packageName);
Scanner[] scanners = {
new TypeAnnotationsScanner(),
new MethodAnnotationsScanner(),
new MethodParameterScanner(),
new FieldAnnotationsScanner(),
new SubTypesScanner().filterResultsBy(filters)
};
reflections = new ConfigurationBuilder()
.addUrls(ClasspathHelper.forPackage(packageName))
.addScanners(scanners)
.filterInputsBy(filters)
.build();
}
开发者ID:hawky-4s-,项目名称:restapidoc,代码行数:18,代码来源:ClassPathScanner.java
示例3: Reflections
import org.reflections.scanners.Scanner; //导入依赖的package包/类
/**
* constructs a Reflections instance and scan according to given {@link org.reflections.Configuration}
* <p>it is preferred to use {@link org.reflections.util.ConfigurationBuilder}
*/
public Reflections(final Configuration configuration) {
this.configuration = configuration;
store = new Store(configuration);
if (configuration.getScanners() != null && !configuration.getScanners().isEmpty()) {
//inject to scanners
for (Scanner scanner : configuration.getScanners()) {
scanner.setConfiguration(configuration);
scanner.setStore(store.getOrCreate(index(scanner.getClass())));
}
scan();
if (configuration.shouldExpandSuperTypes()) {
expandSuperTypes();
}
}
}
开发者ID:ronmamo,项目名称:reflections,代码行数:23,代码来源:Reflections.java
示例4: init
import org.reflections.scanners.Scanner; //导入依赖的package包/类
public static void init() throws InstantiationException, IllegalAccessException {
ModuleManager.MODULE_EMPTY.name = "null";
final Reflections reflections = new Reflections("client.modules", new Scanner[0]);
final Set<Class<? extends Module>> classes = (Set<Class<? extends Module>>)reflections.getSubTypesOf((Class)Module.class);
for (final Class<? extends Module> clazz : classes) {
try {
final Module loadedModule = (Module)clazz.newInstance();
if (!clazz.isAnnotationPresent(Mod.class)) {
continue;
}
final Mod modAnnotation = clazz.getAnnotation(Mod.class);
loadedModule.realName = clazz.getSimpleName();
loadedModule.name = (modAnnotation.name().equalsIgnoreCase("null") ? clazz.getSimpleName() : modAnnotation.name());
loadedModule.keyBind = modAnnotation.keybind();
loadedModule.shown = modAnnotation.shown();
loadedModule.suffix = modAnnotation.suffix();
final String categoryString = clazz.getPackage().getName().split("modules.")[1];
loadedModule.category = Category.valueOf(categoryString.toUpperCase());
if (modAnnotation.enabled()) {
loadedModule.onEnable();
}
loadedModule.preInit();
ModuleManager.moduleList.add(loadedModule);
}
catch (Exception ex) {}
}
load();
save();
ModuleManager.moduleList.sort(new Comparator<Module>() {
@Override
public int compare(final Module m1, final Module m2) {
final String s1 = m1.name;
final String s2 = m2.name;
return s1.compareTo(s2);
}
});
EventManager.register(new ModuleManager());
}
开发者ID:SkidJava,项目名称:BaseClient,代码行数:39,代码来源:ModuleManager.java
示例5: init
import org.reflections.scanners.Scanner; //导入依赖的package包/类
public static void init() throws InstantiationException, IllegalAccessException {
final Reflections reflections = new Reflections("obsidian.commands", new Scanner[0]);
final Set<Class<? extends Command>> classes = (Set<Class<? extends Command>>)reflections.getSubTypesOf((Class)Command.class);
for (final Class<? extends Command> clazz : classes) {
final Command loadedCommand = (Command)clazz.newInstance();
if (clazz.isAnnotationPresent(Com.class)) {
final Com comAnnotation = clazz.getAnnotation(Com.class);
loadedCommand.names = comAnnotation.names();
CommandManager.commandList.add(loadedCommand);
}
}
CommandManager.commandList.add(CommandManager.optionCommand);
}
开发者ID:SkidJava,项目名称:BaseClient,代码行数:14,代码来源:CommandManager.java
示例6: configureReflection
import org.reflections.scanners.Scanner; //导入依赖的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
示例7: scan
import org.reflections.scanners.Scanner; //导入依赖的package包/类
protected void scan(URL url) {
Vfs.Dir dir = Vfs.fromURL(url);
try {
for (final Vfs.File file : dir.getFiles()) {
// scan if inputs filter accepts file relative path or fqn
Predicate<String> inputsFilter = configuration.getInputsFilter();
String path = file.getRelativePath();
String fqn = path.replace('/', '.');
if (inputsFilter == null || inputsFilter.apply(path) || inputsFilter.apply(fqn)) {
Object classObject = null;
for (Scanner scanner : configuration.getScanners()) {
try {
if (scanner.acceptsInput(path) || scanner.acceptsInput(fqn)) {
classObject = scanner.scan(file, classObject);
}
} catch (Exception e) {
if (log != null) {
// SLF4J will filter out Throwables from the format string arguments.
log.debug("could not scan file {} in url {} with scanner {}", file.getRelativePath(), url.toExternalForm(), scanner.getClass().getSimpleName(), e);
}
}
}
}
}
} finally {
dir.close();
}
}
开发者ID:ronmamo,项目名称:reflections,代码行数:30,代码来源:Reflections.java
示例8: filterResultsBy
import org.reflections.scanners.Scanner; //导入依赖的package包/类
@Override
public Scanner filterResultsBy(Predicate<String> filter) {
//NO op
return this;
}
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:6,代码来源:DataVecSubTypesScanner.java
示例9: execute
import org.reflections.scanners.Scanner; //导入依赖的package包/类
public void execute() throws MojoExecutionException, MojoFailureException {
//
if (StringUtils.isEmpty(destinations)) {
destinations = resolveOutputDirectory() + "/META-INF/reflections/" + getProject().getArtifactId() + "-reflections.xml";
}
String outputDirectory = resolveOutputDirectory();
if (!new File(outputDirectory).exists()) {
getLog().warn(String.format("Reflections plugin is skipping because %s was not found", outputDirectory));
return;
}
//
ConfigurationBuilder config = new ConfigurationBuilder();
config.setUrls(parseUrls());
if (!isEmpty(includeExclude)) {
config.filterInputsBy(FilterBuilder.parse(includeExclude));
}
config.setScanners(!isEmpty(scanners) ? parseScanners() : new Scanner[]{new SubTypesScanner(), new TypeAnnotationsScanner()});
if (!isEmpty(serializer)) {
try {
Serializer serializerInstance = (Serializer) forName(serializer, "org.reflections.serializers").newInstance();
config.setSerializer(serializerInstance);
if (serializerInstance instanceof JavaCodeSerializer) {
int size = config.getScanners().size();
config.addScanners(new TypeElementsScanner());
if (size != config.getScanners().size()) {
getLog().info("added type scanners for JavaCodeSerializer");
}
}
} catch (Exception ex) {
throw new ReflectionsException("could not create serializer instance", ex);
}
}
if (parallel != null && parallel.equals(Boolean.TRUE)) {
config.useParallelExecutor();
}
//
if (Reflections.log == null) {
try {
Reflections.log = new MavenLogAdapter(getLog());
} catch (Error e) {
//ignore
}
}
Reflections reflections = new Reflections(config);
reflections.save(destinations.trim());
}
开发者ID:ronmamo,项目名称:reflections-maven,代码行数:57,代码来源:ReflectionsMojo.java
示例10: getScanners
import org.reflections.scanners.Scanner; //导入依赖的package包/类
/** the scanner instances used for scanning different metadata */
Set<Scanner> getScanners();
开发者ID:ronmamo,项目名称:reflections,代码行数:3,代码来源:Configuration.java
示例11: ConfigurationBuilder
import org.reflections.scanners.Scanner; //导入依赖的package包/类
public ConfigurationBuilder() {
scanners = Sets.<Scanner>newHashSet(new TypeAnnotationsScanner(), new SubTypesScanner());
urls = Sets.newHashSet();
}
开发者ID:ronmamo,项目名称:reflections,代码行数:5,代码来源:ConfigurationBuilder.java
示例12: getScanners
import org.reflections.scanners.Scanner; //导入依赖的package包/类
@Nonnull
public Set<Scanner> getScanners() {
return scanners;
}
开发者ID:ronmamo,项目名称:reflections,代码行数:5,代码来源:ConfigurationBuilder.java
示例13: setScanners
import org.reflections.scanners.Scanner; //导入依赖的package包/类
/** set the scanners instances for scanning different metadata */
public ConfigurationBuilder setScanners(@Nonnull final Scanner... scanners) {
this.scanners.clear();
return addScanners(scanners);
}
开发者ID:ronmamo,项目名称:reflections,代码行数:6,代码来源:ConfigurationBuilder.java
示例14: addScanners
import org.reflections.scanners.Scanner; //导入依赖的package包/类
/** set the scanners instances for scanning different metadata */
public ConfigurationBuilder addScanners(final Scanner... scanners) {
this.scanners.addAll(Sets.newHashSet(scanners));
return this;
}
开发者ID:ronmamo,项目名称:reflections,代码行数:6,代码来源:ConfigurationBuilder.java
示例15: index
import org.reflections.scanners.Scanner; //导入依赖的package包/类
public static String index(Class<? extends Scanner> scannerClass) { return scannerClass.getSimpleName(); }
开发者ID:ronmamo,项目名称:reflections,代码行数:2,代码来源:Utils.java
注:本文中的org.reflections.scanners.Scanner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论