• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ScannerContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.buschmais.jqassistant.core.scanner.api.ScannerContext的典型用法代码示例。如果您正苦于以下问题:Java ScannerContext类的具体用法?Java ScannerContext怎么用?Java ScannerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScannerContext类属于com.buschmais.jqassistant.core.scanner.api包,在下文中一共展示了ScannerContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public void execute(MavenProject mavenProject, Store store) throws MojoExecutionException, MojoFailureException {
    ScannerConfiguration configuration = new ScannerConfiguration();
    configuration.setContinueOnError(continueOnError);
    ScannerContext scannerContext = new ScannerContextImpl(store);
    ScannerPluginRepository scannerPluginRepository = pluginRepositoryProvider.getScannerPluginRepository();
    Map<String, ScannerPlugin<?, ?>> scannerPlugins;
    try {
        scannerPlugins = scannerPluginRepository.getScannerPlugins(scannerContext, getPluginProperties());
    } catch (PluginRepositoryException e) {
        throw new MojoExecutionException("Cannot determine scanner plugins.", e);
    }
    ScopePluginRepository scopePluginRepository = pluginRepositoryProvider.getScopePluginRepository();
    Scanner scanner = new ScannerImpl(configuration, scannerContext, scannerPlugins, scopePluginRepository.getScopes());
    store.beginTransaction();
    try {
        scanner.scan(mavenProject, mavenProject.getFile().getAbsolutePath(), MavenScope.PROJECT);
    } finally {
        store.commitTransaction();
    }
}
 
开发者ID:buschmais,项目名称:jqa-maven-plugin,代码行数:22,代码来源:ScanMojo.java


示例2: resolve

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public CachedType<TypeDescriptor> resolve(String fullQualifiedName, ScannerContext context) {
    CachedType<TypeDescriptor> cachedType = typeCache.get(fullQualifiedName);
    if (cachedType == null) {
        TypeDescriptor typeDescriptor = findInArtifact(fullQualifiedName, context);
        if (typeDescriptor == null) {
            typeDescriptor = findInDependencies(fullQualifiedName, context);
        }
        if (typeDescriptor == null) {
            String requiredFileName = "/" + fullQualifiedName.replace(".", "/") + ".class";
            String containedFileName = getContainedFileName(requiredFileName);
            typeDescriptor = context.peek(FileResolver.class).require(requiredFileName, containedFileName, ClassFileDescriptor.class, context);
            setTypeProperties(typeDescriptor, fullQualifiedName);
            addRequiredType(fullQualifiedName, typeDescriptor);
        }
        cachedType = getCachedType(fullQualifiedName, typeDescriptor);
    }
    return cachedType;
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:20,代码来源:AbstractTypeResolver.java


示例3: scan

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public ManifestFileDescriptor scan(FileResource item, String path, Scope scope, Scanner scanner) throws IOException {
    try (InputStream stream = item.createStream()) {
        Manifest manifest = new Manifest(stream);
        ScannerContext context = scanner.getContext();
        Store store = context.getStore();
        FileDescriptor fileDescriptor = context.getCurrentDescriptor();
        ManifestFileDescriptor manifestFileDescriptor = store.addDescriptorType(fileDescriptor, ManifestFileDescriptor.class);
        ManifestSectionDescriptor mainSectionDescriptor = store.create(ManifestSectionDescriptor.class);
        mainSectionDescriptor.setName(SECTION_MAIN);
        manifestFileDescriptor.setMainSection(mainSectionDescriptor);
        readSection(manifest.getMainAttributes(), mainSectionDescriptor, store);
        for (Map.Entry<String, Attributes> sectionEntry : manifest.getEntries().entrySet()) {
            ManifestSectionDescriptor sectionDescriptor = store.create(ManifestSectionDescriptor.class);
            sectionDescriptor.setName(sectionEntry.getKey());
            readSection(sectionEntry.getValue(), sectionDescriptor, store);
            manifestFileDescriptor.getManifestSections().add(sectionDescriptor);
        }
        return manifestFileDescriptor;
    }
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:22,代码来源:ManifestFileScannerPlugin.java


示例4: scan

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public PropertyFileDescriptor scan(FileResource item, String path, Scope scope, Scanner scanner) throws IOException {
    ScannerContext context = scanner.getContext();
    Store store = context.getStore();
    FileDescriptor fileDescriptor = context.getCurrentDescriptor();
    PropertyFileDescriptor propertyFileDescriptor = store.addDescriptorType(fileDescriptor, PropertyFileDescriptor.class);
    Properties properties = new Properties();
    try (InputStream stream = item.createStream()) {
        properties.load(stream);
    } catch (IllegalArgumentException e) {
        LOGGER.warn("Cannot load properties from '" + path + "': " + e.getMessage());
    }
    for (String name : properties.stringPropertyNames()) {
        String value = properties.getProperty(name);
        PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class);
        propertyDescriptor.setName(name);
        propertyDescriptor.setValue(value);
        propertyFileDescriptor.getProperties().add(propertyDescriptor);
    }
    return propertyFileDescriptor;
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:22,代码来源:PropertyFileScannerPlugin.java


示例5: scan

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public ServiceLoaderDescriptor scan(FileResource item, String path, Scope scope, Scanner scanner) throws IOException {
    Matcher matcher = PATTERN.matcher(path);
    if (!matcher.matches()) {
        throw new IOException("Cannot match path name: " + path);
    }
    String serviceInterface = matcher.group(2);
    ScannerContext context = scanner.getContext();
    FileDescriptor fileDescriptor = context.getCurrentDescriptor();
    ServiceLoaderDescriptor serviceLoaderDescriptor = context.getStore().addDescriptorType(fileDescriptor, ServiceLoaderDescriptor.class);
    TypeDescriptor interfaceTypeDescriptor = getTypeDescriptor(serviceInterface, context);
    serviceLoaderDescriptor.setType(interfaceTypeDescriptor);

    try (InputStream stream = item.createStream()) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
        String serviceImplementation;
        while ((serviceImplementation = reader.readLine()) != null) {
            if (!isEmptyOrComment(serviceImplementation)) {
                TypeDescriptor implementationTypeDescriptor = getTypeDescriptor(serviceImplementation, context);
                serviceLoaderDescriptor.getContains().add(implementationTypeDescriptor);
            }
        }
    }
    return serviceLoaderDescriptor;
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:26,代码来源:ServiceLoaderFileScannerPlugin.java


示例6: scan

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public PackageDescriptor scan(DirectoryResource item, String path, Scope scope, Scanner scanner) throws IOException {
    ScannerContext context = scanner.getContext();
    DirectoryDescriptor directoryDescriptor = context.getCurrentDescriptor();
    PackageDescriptor descriptor = context.getStore().addDescriptorType(directoryDescriptor, PackageDescriptor.class);
    String packageName = path.substring(1).replaceAll("/", ".");
    String name;
    int separatorIndex = packageName.lastIndexOf('.');
    if (separatorIndex != -1) {
        name = packageName.substring(separatorIndex + 1);
    } else {
        name = packageName;
    }
    descriptor.setName(name);
    descriptor.setFullQualifiedName(packageName);
    return descriptor;
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:18,代码来源:PackageDirectoryScannerPlugin.java


示例7: scan

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public PropertyFileDescriptor scan(FileResource item, String path, Scope scope, Scanner scanner) throws IOException {
    ScannerContext context = scanner.getContext();
    Store store = context.getStore();
    FileDescriptor fileDescriptor = context.getCurrentDescriptor();
    Class<XmlPropertyFileDescriptor> descriptorType = XmlPropertyFileDescriptor.class;
    PropertyFileDescriptor propertyFileDescriptor = store.addDescriptorType(fileDescriptor, descriptorType);
    Properties properties = new Properties();
    try (InputStream stream = item.createStream()) {
        properties.loadFromXML(stream);
    } catch (IllegalArgumentException e) {
        LOGGER.warn("Cannot load properties from '" + path + "': " + e.getMessage());
    }

    for (String name : properties.stringPropertyNames()) {
        String value = properties.getProperty(name);
        PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class);
        propertyDescriptor.setName(name);
        propertyDescriptor.setValue(value);
        propertyFileDescriptor.getProperties().add(propertyDescriptor);
    }
    return propertyFileDescriptor;
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:24,代码来源:XmlPropertyFileScannerPlugin.java


示例8: execute

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
/**
 * Executes the given scan operation.
 * 
 * @param artifactId
 *            The artifact id of the artifact to push on the context.
 * @param operation
 *            The operation.
 */
protected List<? extends FileDescriptor> execute(String artifactId, ScanClassPathOperation operation) {
    Scanner scanner = getScanner();
    ScannerContext context = scanner.getContext();
    store.beginTransaction();
    JavaArtifactFileDescriptor artifact = getArtifactDescriptor(artifactId);
    artifact.setFullQualifiedName(artifactId);
    context.push(JavaArtifactFileDescriptor.class, artifact);
    ContainerFileResolver fileResolverStrategy = new ContainerFileResolver(artifact);
    context.push(FileResolver.class, fileResolverStrategy);

    List<? extends FileDescriptor> descriptors = execute(artifact, operation, scanner);
    for (FileDescriptor descriptor : descriptors) {
        fileResolverStrategy.put(descriptor.getFileName(), descriptor);
    }

    context.pop(JavaArtifactFileDescriptor.class);
    context.pop(FileResolver.class);
    fileResolverStrategy.flush();
    store.commitTransaction();
    return descriptors;
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:30,代码来源:AbstractJavaPluginIT.java


示例9: repositories

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Test
public void repositories() throws PluginRepositoryException {
    PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl(PluginRepositoryTest.class.getClassLoader());
    PluginRepository pluginRepository = new PluginRepositoryImpl(pluginConfigurationReader);
    // Scanner plugins
    ScannerContext scannerContext = mock(ScannerContext.class);
    Map<String, ScannerPlugin<?, ?>> scannerPlugins = pluginRepository.getScannerPluginRepository().getScannerPlugins(scannerContext, Collections.<String, Object>emptyMap());
    assertThat(scannerPlugins.size(), equalTo(2));
    assertThat(scannerPlugins.get(TestScannerPlugin.class.getSimpleName()), notNullValue());
    assertThat(scannerPlugins.get("testScanner"), notNullValue());
    // Report plugins
    Map<String, ReportPlugin> reportPlugins = pluginRepository.getReportPluginRepository().getReportPlugins(Collections.<String, Object>emptyMap());
    assertThat(reportPlugins.size(), equalTo(2));
    assertThat(reportPlugins.get(TestReportPlugin.class.getSimpleName()), notNullValue());
    assertThat(reportPlugins.get("testReport"), notNullValue());
}
 
开发者ID:buschmais,项目名称:jqa-core-framework,代码行数:17,代码来源:PluginRepositoryTest.java


示例10: create

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public <T extends ClassFileDescriptor> CachedType<T> create(String fullQualifiedName, FileDescriptor fileDescriptor, Class<T> descriptorType,
                                                            ScannerContext context) {
    T typeDescriptor = context.getStore().migrate(fileDescriptor, descriptorType);
    setTypeProperties(typeDescriptor, fullQualifiedName);
    removeRequiredType(fullQualifiedName, typeDescriptor);
    addContainedType(fullQualifiedName, typeDescriptor);
    return getCachedType(fullQualifiedName, typeDescriptor);
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:10,代码来源:AbstractTypeResolver.java


示例11: getContainerDescriptor

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
protected JavaClassesDirectoryDescriptor getContainerDescriptor(File classPathDirectory, ScannerContext scannerContext) {
    JavaArtifactFileDescriptor javaArtifactDescriptor = scannerContext.peekOrDefault(JavaArtifactFileDescriptor.class, null);
    Store store = scannerContext.getStore();
    if (javaArtifactDescriptor == null) {
        return store.create(JavaClassesDirectoryDescriptor.class);
    }
    if (JavaClassesDirectoryDescriptor.class.isAssignableFrom(javaArtifactDescriptor.getClass())) {
        return JavaClassesDirectoryDescriptor.class.cast(javaArtifactDescriptor);
    }
    throw new IllegalStateException("Expected an instance of " + JavaClassesDirectoryDescriptor.class.getName() + " but got "
            + Arrays.asList(javaArtifactDescriptor.getClass().getInterfaces()));
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:14,代码来源:JavaClassesDirectoryScannerPlugin.java


示例12: getScannerPlugins

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public Map<String, ScannerPlugin<?, ?>> getScannerPlugins(ScannerContext scannerContext, Map<String, Object> properties) throws PluginRepositoryException {
    for (ScannerPlugin<?, ?> scannerPlugin : scannerPlugins.values()) {
        scannerPlugin.configure(scannerContext, new HashMap<>(properties));
    }
    return scannerPlugins;
}
 
开发者ID:buschmais,项目名称:jqa-core-framework,代码行数:8,代码来源:ScannerPluginRepositoryImpl.java


示例13: getScannerPluginProperties

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
private Map<String, Object> getScannerPluginProperties(PluginRepository pluginRepository, Map<String, Object> properties) throws PluginRepositoryException {
    ScannerPluginRepository scannerPluginRepository = pluginRepository.getScannerPluginRepository();
    ScannerContext scannerContext = mock(ScannerContext.class);
    Map<String, ScannerPlugin<?, ?>> scannerPlugins = scannerPluginRepository.getScannerPlugins(scannerContext, properties);
    assertThat(scannerPlugins.size(), greaterThan(0));
    for (ScannerPlugin<?, ?> scannerPlugin : scannerPlugins.values()) {
        if (scannerPlugin instanceof TestScannerPlugin) {
            return ((TestScannerPlugin) scannerPlugin).getProperties();
        }
    }
    return null;
}
 
开发者ID:buschmais,项目名称:jqa-core-framework,代码行数:13,代码来源:PluginRepositoryTest.java


示例14: start

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public final Collection<Injectable<?>> start(GraphDatabaseService graphDatabaseService, Configuration config) {
    Set<Injectable<?>> injectables = new HashSet<>();

    PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl(AbstractPluginInitializer.class.getClassLoader());

    try {
        ScopePluginRepository scopePluginRepository = new ScopePluginRepositoryImpl(pluginConfigurationReader);
        injectables.add(new SimpleInjectable<>(scopePluginRepository, ScopePluginRepository.class));

        ScannerPluginRepository scannerPluginRepository = new ScannerPluginRepositoryImpl(pluginConfigurationReader);
        injectables.add(new SimpleInjectable<>(scannerPluginRepository, ScannerPluginRepository.class));

        ModelPluginRepository modelPluginRepository = new ModelPluginRepositoryImpl(pluginConfigurationReader);
        injectables.add(new SimpleInjectable<>(modelPluginRepository, ModelPluginRepository.class));

        store = new GraphDbStore(graphDatabaseService);
        store.start(modelPluginRepository.getDescriptorTypes());
        injectables.add(new SimpleInjectable<>(store, Store.class));

        ScannerContext context = new ScannerContextImpl(store);
        List<ScannerPlugin<?, ?>> scannerPlugins = scannerPluginRepository.getScannerPlugins(context, Collections.<String, Object> emptyMap());

        Scanner scanner = new ScannerImpl(context, scannerPlugins, scopePluginRepository.getScopes());
        injectables.add(new SimpleInjectable<>(scanner, Scanner.class));

    } catch (PluginRepositoryException e) {
        throw new RuntimeException("Setting up plugin repositories failed.", e);
    }
    injectables.addAll(getInjectables(store, config));
    return injectables;
}
 
开发者ID:buschmais,项目名称:jqassistant-server,代码行数:33,代码来源:AbstractPluginInitializer.java


示例15: execute

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
public Descriptor execute(Scanner scanner) throws IOException {
    String url = artifactCoordinates.getRepositoryUrl();
    ScannerContext context = scanner.getContext();
    ArtifactProvider artifactProvider = getArtifactProvider(url, getMavenRepoDescriptor(url, context.getStore()));
    try {
        context.push(ArtifactProvider.class, artifactProvider);
        context.push(ArtifactResolver.class, new MavenArtifactResolver());
        ArtifactInfo info = createArtifactInfo();
        return scanner.scan(info, info.toString(), MavenScope.REPOSITORY);
    } finally {
        context.pop(ArtifactResolver.class);
        context.pop(ArtifactProvider.class);
    }
}
 
开发者ID:buschmais,项目名称:jqassistant-server,代码行数:16,代码来源:ScanArtifactJob.java


示例16: findInArtifact

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
protected TypeDescriptor findInArtifact(String fullQualifiedName, ScannerContext context) {
    return artifactTypes.get(fullQualifiedName);
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:5,代码来源:AbstractArtifactScopedTypeResolver.java


示例17: findInDependencies

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
protected TypeDescriptor findInDependencies(String fullQualifiedName, ScannerContext context) {
    return hasDependencies ? getArtifact().resolveRequiredType(fullQualifiedName) : null;
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:5,代码来源:AbstractArtifactScopedTypeResolver.java


示例18: getTypeDescriptor

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
private TypeDescriptor getTypeDescriptor(String fqn, ScannerContext scannerContext) {
    TypeResolver typeResolver = scannerContext.peek(TypeResolver.class);
    return typeResolver.resolve(fqn, scannerContext).getTypeDescriptor();
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:5,代码来源:ServiceLoaderFileScannerPlugin.java


示例19: createScope

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
protected Scope createScope(Scope currentScope, JarArchiveDescriptor archiveDescriptor, ScannerContext scannerContext) {
    scannerContext.push(TypeResolver.class, new ArtifactScopedTypeResolver(archiveDescriptor));
    return JavaScope.CLASSPATH;
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:6,代码来源:JarScannerPlugin.java


示例20: destroyScope

import com.buschmais.jqassistant.core.scanner.api.ScannerContext; //导入依赖的package包/类
@Override
protected void destroyScope(ScannerContext scannerContext) {
    scannerContext.pop(TypeResolver.class);
}
 
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:5,代码来源:JarScannerPlugin.java



注:本文中的com.buschmais.jqassistant.core.scanner.api.ScannerContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Fail类代码示例发布时间:2022-05-22
下一篇:
Java HIT类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap