Search in sources :

Example 1 with Configurable

use of org.revapi.configuration.Configurable in project revapi by revapi.

the class ConvertToXmlConfigMojo method getKnownExtensionSchemas.

private static Map<String, ModelNode> getKnownExtensionSchemas(AnalysisResult.Extensions extensions) throws IOException {
    List<Configurable> exts = extensions.stream().map(e -> (Configurable) e.getKey()).collect(Collectors.toList());
    Map<String, ModelNode> extensionSchemas = new HashMap<>();
    for (Configurable ext : exts) {
        String extensionId = ext.getExtensionId();
        if (extensionId == null || extensionSchemas.containsKey(extensionId)) {
            continue;
        }
        try (Reader schemaRdr = ext.getJSONSchema()) {
            if (schemaRdr == null) {
                continue;
            }
            ModelNode schema = ModelNode.fromJSONString(readFull(schemaRdr));
            extensionSchemas.put(extensionId, schema);
        }
    }
    return extensionSchemas;
}
Also used : HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) Parameter(org.apache.maven.plugins.annotations.Parameter) Configurable(org.revapi.configuration.Configurable) VTDGen(com.ximpleware.VTDGen) Mojo(org.apache.maven.plugins.annotations.Mojo) SimpleReporter(org.revapi.simple.SimpleReporter) PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) MavenProject(org.apache.maven.project.MavenProject) XMLModifier(com.ximpleware.XMLModifier) Map(java.util.Map) VTDNav(com.ximpleware.VTDNav) LifecyclePhase(org.apache.maven.plugins.annotations.LifecyclePhase) JSONUtil(org.revapi.configuration.JSONUtil) OutputStream(java.io.OutputStream) AnalysisContext(org.revapi.AnalysisContext) StringWriter(java.io.StringWriter) AutoPilot(com.ximpleware.AutoPilot) FileWriter(java.io.FileWriter) FileOutputStream(java.io.FileOutputStream) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) AnalysisResult(org.revapi.AnalysisResult) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Reader(java.io.Reader) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Collectors(java.util.stream.Collectors) Revapi(org.revapi.Revapi) File(java.io.File) MojoFailureException(org.apache.maven.plugin.MojoFailureException) List(java.util.List) Writer(java.io.Writer) ModelNode(org.jboss.dmr.ModelNode) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) Collections(java.util.Collections) InputStream(java.io.InputStream) HashMap(java.util.HashMap) Reader(java.io.Reader) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) Configurable(org.revapi.configuration.Configurable) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with Configurable

use of org.revapi.configuration.Configurable in project revapi by revapi.

the class Revapi method validate.

private ValidationResult validate(@Nonnull AnalysisContext analysisContext, ValidationResult validationResult, Iterator<? extends Configurable> configurables) {
    while (configurables.hasNext()) {
        Configurable c = configurables.next();
        ValidationResult partial = configurationValidator.validate(analysisContext.getConfiguration(), c);
        validationResult = validationResult.merge(partial);
    }
    return validationResult;
}
Also used : Configurable(org.revapi.configuration.Configurable) ValidationResult(org.revapi.configuration.ValidationResult)

Example 3 with Configurable

use of org.revapi.configuration.Configurable in project revapi by revapi.

the class Revapi method analyze.

/**
 * Performs the analysis configured by the given analysis context.
 * <p>
 * Make sure to call the {@link AnalysisResult#close()} method (or perform the analysis in try-with-resources
 * block).
 *
 * @param analysisContext describes the analysis to be performed
 * @return a result object that has to be closed for the analysis to conclude
 */
@SuppressWarnings("unchecked")
public AnalysisResult analyze(@Nonnull AnalysisContext analysisContext) {
    TIMING_LOG.debug("Analysis starts");
    AnalysisResult.Extensions extensions = prepareAnalysis(analysisContext);
    StreamSupport.stream(extensions.spliterator(), false).map(e -> (Map.Entry<Configurable, AnalysisContext>) e).forEach(e -> e.getKey().initialize(e.getValue()));
    TIMING_LOG.debug("Initialization complete.");
    matchingTransformsCache.clear();
    Exception error = null;
    try {
        for (ApiAnalyzer a : extensions.getAnalyzers().keySet()) {
            analyzeWith(a, analysisContext.getOldApi(), analysisContext.getNewApi(), extensions);
        }
    } catch (Exception t) {
        error = t;
    }
    return new AnalysisResult(error, extensions);
}
Also used : Arrays(java.util.Arrays) SortedSet(java.util.SortedSet) ListIterator(java.util.ListIterator) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Configurable(org.revapi.configuration.Configurable) Collections.emptySortedSet(java.util.Collections.emptySortedSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Map(java.util.Map) StreamSupport(java.util.stream.StreamSupport) Nonnull(javax.annotation.Nonnull) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Set(java.util.Set) ValidationResult(org.revapi.configuration.ValidationResult) InvocationTargetException(java.lang.reflect.InvocationTargetException) AbstractMap(java.util.AbstractMap) List(java.util.List) Stream(java.util.stream.Stream) ModelNode(org.jboss.dmr.ModelNode) Pattern(java.util.regex.Pattern) ConfigurationValidator(org.revapi.configuration.ConfigurationValidator) Comparator(java.util.Comparator) Collections(java.util.Collections) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Configurable (org.revapi.configuration.Configurable)3 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 ModelNode (org.jboss.dmr.ModelNode)2 ValidationResult (org.revapi.configuration.ValidationResult)2 AutoPilot (com.ximpleware.AutoPilot)1 VTDGen (com.ximpleware.VTDGen)1 VTDNav (com.ximpleware.VTDNav)1 XMLModifier (com.ximpleware.XMLModifier)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1