Search in sources :

Example 1 with DslResolvingContext.getDefault

use of org.mule.runtime.api.dsl.DslResolvingContext.getDefault in project mule by mulesoft.

the class ExtensionsTestInfrastructureDiscoverer method generateDslResources.

public List<GeneratedResource> generateDslResources(File generatedResourcesDirectory, ExtensionModel forExtensionModel) {
    DslResolvingContext context;
    if (extensionManager.getExtensions().stream().anyMatch(e -> !e.getImportedTypes().isEmpty())) {
        HashSet<ExtensionModel> models = new HashSet<>(extensionManager.getExtensions());
        models.add(MuleExtensionModelProvider.getExtensionModel());
        context = DslResolvingContext.getDefault(models);
    } else {
        context = new NullDslResolvingContext();
    }
    ExtensionsTestDslResourcesGenerator dslResourceGenerator = new ExtensionsTestDslResourcesGenerator(getDslResourceFactories(), generatedResourcesDirectory, context);
    extensionManager.getExtensions().stream().filter(runtimeExtensionModel -> forExtensionModel != null ? runtimeExtensionModel.equals(forExtensionModel) : true).forEach(dslResourceGenerator::generateFor);
    return dslResourceGenerator.dumpAll();
}
Also used : Manifest(java.util.jar.Manifest) MuleManifest.getProductVersion(org.mule.runtime.core.api.config.MuleManifest.getProductVersion) GeneratedResource(org.mule.runtime.extension.api.resources.GeneratedResource) HashMap(java.util.HashMap) Thread.currentThread(java.lang.Thread.currentThread) MuleManifest(org.mule.runtime.core.api.config.MuleManifest) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) GeneratedResourceFactory(org.mule.runtime.extension.api.resources.spi.GeneratedResourceFactory) HashSet(java.util.HashSet) Collections.singleton(java.util.Collections.singleton) ByteArrayInputStream(java.io.ByteArrayInputStream) TYPE_PROPERTY_NAME(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader.TYPE_PROPERTY_NAME) Map(java.util.Map) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) ServiceRegistry(org.mule.runtime.core.api.registry.ServiceRegistry) ExtensionModelLoader(org.mule.runtime.extension.api.loader.ExtensionModelLoader) NullDslResolvingContext(org.mule.runtime.internal.dsl.NullDslResolvingContext) FileOutputStream(java.io.FileOutputStream) Set(java.util.Set) IOException(java.io.IOException) ImmutableList.copyOf(com.google.common.collect.ImmutableList.copyOf) String.format(java.lang.String.format) File(java.io.File) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) List(java.util.List) ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) VERSION(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader.VERSION) ExtensionSchemaGenerator(org.mule.runtime.extension.api.dsl.syntax.resources.spi.ExtensionSchemaGenerator) FileUtils(org.mule.runtime.core.api.util.FileUtils) DslResourceFactory(org.mule.runtime.extension.api.dsl.syntax.resources.spi.DslResourceFactory) ResourcesGenerator(org.mule.runtime.extension.api.resources.ResourcesGenerator) MuleExtensionModelProvider(org.mule.runtime.core.api.extension.MuleExtensionModelProvider) DslResolvingContext.getDefault(org.mule.runtime.api.dsl.DslResolvingContext.getDefault) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) NullDslResolvingContext(org.mule.runtime.internal.dsl.NullDslResolvingContext) NullDslResolvingContext(org.mule.runtime.internal.dsl.NullDslResolvingContext) HashSet(java.util.HashSet)

Aggregations

ImmutableList.copyOf (com.google.common.collect.ImmutableList.copyOf)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 Thread.currentThread (java.lang.Thread.currentThread)1 Collections.singleton (java.util.Collections.singleton)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Manifest (java.util.jar.Manifest)1 DslResolvingContext (org.mule.runtime.api.dsl.DslResolvingContext)1 DslResolvingContext.getDefault (org.mule.runtime.api.dsl.DslResolvingContext.getDefault)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 MuleManifest (org.mule.runtime.core.api.config.MuleManifest)1 MuleManifest.getProductVersion (org.mule.runtime.core.api.config.MuleManifest.getProductVersion)1 ExtensionManager (org.mule.runtime.core.api.extension.ExtensionManager)1