本文整理汇总了Java中com.buschmais.jqassistant.core.scanner.api.ScannerContext类的典型用法代码示例。如果您正苦于以下问题:Java ScannerContext类的具体用法?Java ScannerContext怎么用?Java ScannerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScannerContext类属于com.buschmais.jqassistant.core.scanner.api包,在下文中一共展示了ScannerContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
示例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()));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}