Search in sources :

Example 1 with NullDslResolvingContext

use of org.mule.runtime.internal.dsl.NullDslResolvingContext in project mule by mulesoft.

the class TestConnectionFailuresTestCase method mockedExtension.

private ExtensionModel mockedExtension(final String name, final String config, final String connectionProvider) {
    final ExtensionDeclarer extensionDeclarer = new ExtensionDeclarer();
    extensionDeclarer.named(name).onVersion("4.0.0").fromVendor("MuleSoft testcase").withCategory(Category.COMMUNITY).withConfig(config).withConnectionProvider(connectionProvider).withConnectionManagementType(ConnectionManagementType.NONE);
    return new ExtensionModelFactory().create(new DefaultExtensionLoadingContext(extensionDeclarer, currentThread().getContextClassLoader(), new NullDslResolvingContext()));
}
Also used : DefaultExtensionLoadingContext(org.mule.runtime.extension.internal.loader.DefaultExtensionLoadingContext) ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) NullDslResolvingContext(org.mule.runtime.internal.dsl.NullDslResolvingContext) ExtensionModelFactory(org.mule.runtime.extension.internal.loader.ExtensionModelFactory)

Example 2 with NullDslResolvingContext

use of org.mule.runtime.internal.dsl.NullDslResolvingContext 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)

Example 3 with NullDslResolvingContext

use of org.mule.runtime.internal.dsl.NullDslResolvingContext in project mule by mulesoft.

the class AbstractXmlResourceFactory method generateResource.

@Override
public Optional<GeneratedResource> generateResource(ExtensionModel extensionModel) {
    Set<ImportedTypeModel> importedTypes = extensionModel.getImportedTypes();
    DslResolvingContext dslContext = importedTypes.isEmpty() ? new NullDslResolvingContext() : new ClasspathBasedDslContext(extensionModel.getModelProperty(ImplementingTypeModelProperty.class).map(mp -> mp.getType().getClassLoader()).orElse(Thread.currentThread().getContextClassLoader()));
    return generateResource(extensionModel, dslContext);
}
Also used : Optional.empty(java.util.Optional.empty) NullDslResolvingContext(org.mule.runtime.internal.dsl.NullDslResolvingContext) Properties(java.util.Properties) ImportedTypeModel(org.mule.runtime.api.meta.model.ImportedTypeModel) Optional.of(java.util.Optional.of) GeneratedResource(org.mule.runtime.extension.api.resources.GeneratedResource) Set(java.util.Set) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) GeneratedResourceFactory(org.mule.runtime.extension.api.resources.spi.GeneratedResourceFactory) XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) DslResourceFactory(org.mule.runtime.extension.api.dsl.syntax.resources.spi.DslResourceFactory) Optional(java.util.Optional) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty) ImportedTypeModel(org.mule.runtime.api.meta.model.ImportedTypeModel) NullDslResolvingContext(org.mule.runtime.internal.dsl.NullDslResolvingContext) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) NullDslResolvingContext(org.mule.runtime.internal.dsl.NullDslResolvingContext)

Aggregations

NullDslResolvingContext (org.mule.runtime.internal.dsl.NullDslResolvingContext)3 Set (java.util.Set)2 DslResolvingContext (org.mule.runtime.api.dsl.DslResolvingContext)2 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)2 DslResourceFactory (org.mule.runtime.extension.api.dsl.syntax.resources.spi.DslResourceFactory)2 GeneratedResource (org.mule.runtime.extension.api.resources.GeneratedResource)2 GeneratedResourceFactory (org.mule.runtime.extension.api.resources.spi.GeneratedResourceFactory)2 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 Optional (java.util.Optional)1