use of org.mule.runtime.api.dsl.DslResolvingContext in project mule by mulesoft.
the class DefaultExtensionSchemaGeneratorTestCase method loadExtension.
public static ExtensionModel loadExtension(Class<?> clazz, ExtensionModelLoader loader) {
Map<String, Object> params = new HashMap<>();
params.put(TYPE_PROPERTY_NAME, clazz.getName());
params.put(VERSION, getProductVersion());
// TODO MULE-11797: as this utils is consumed from org.mule.runtime.module.extension.internal.capability.xml.schema.AbstractXmlResourceFactory.generateResource(org.mule.runtime.api.meta.model.ExtensionModel), this util should get dropped once the ticket gets implemented.
final DslResolvingContext dslResolvingContext = getDefault(new LinkedHashSet<>(extensionModels.values()));
return loader.loadExtensionModel(clazz.getClassLoader(), dslResolvingContext, params);
}
use of org.mule.runtime.api.dsl.DslResolvingContext in project mule by mulesoft.
the class AbstractXmlExtensionMuleArtifactFunctionalTestCase method addBuilders.
@Override
protected void addBuilders(List<ConfigurationBuilder> builders) {
super.addBuilders(builders);
builders.add(new AbstractConfigurationBuilder() {
@Override
protected void doConfigure(MuleContext muleContext) throws Exception {
ExtensionManager extensionManager;
if (muleContext.getExtensionManager() == null) {
extensionManager = createDefaultExtensionManager();
muleContext.setExtensionManager(extensionManager);
initialiseIfNeeded(extensionManager, muleContext);
}
extensionManager = muleContext.getExtensionManager();
registerXmlExtensions(extensionManager);
}
private void registerXmlExtensions(ExtensionManager extensionManager) {
// take all the plugins loaded by org.mule.test.runner.api.IsolatedClassLoaderExtensionsManagerConfigurationBuilder in the extension manager
final Set<ExtensionModel> extensions = new HashSet<>(extensionManager.getExtensions());
for (String modulePath : getModulePaths()) {
Map<String, Object> params = new HashMap<>();
params.put(XmlExtensionModelLoader.RESOURCE_XML, modulePath);
params.put(XmlExtensionModelLoader.VALIDATE_XML, shouldValidateXml());
operationsOutputPath().ifPresent(path -> params.put(XmlExtensionModelLoader.RESOURCE_DECLARATION, path));
final DslResolvingContext dslResolvingContext = getDefault(extensions);
final ExtensionModel extensionModel = new XmlExtensionModelLoader().loadExtensionModel(getClass().getClassLoader(), dslResolvingContext, params);
extensions.add(extensionModel);
}
for (ExtensionModel extension : extensions) {
extensionManager.registerExtension(extension);
}
}
});
}
use of org.mule.runtime.api.dsl.DslResolvingContext 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();
}
use of org.mule.runtime.api.dsl.DslResolvingContext 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);
}
use of org.mule.runtime.api.dsl.DslResolvingContext in project mule by mulesoft.
the class ExtensionModelJsonGeneratorTestCase method loadExtension.
public static ExtensionModel loadExtension(Class<?> clazz, ExtensionModelLoader loader) {
Map<String, Object> params = new HashMap<>();
params.put(TYPE_PROPERTY_NAME, clazz.getName());
params.put(VERSION, "4.0.0-SNAPSHOT");
// TODO MULE-11797: as this utils is consumed from
// org.mule.runtime.module.extension.internal.capability.xml.schema.AbstractXmlResourceFactory.generateResource(org.mule.runtime.api.meta.model.ExtensionModel),
// this util should get dropped once the ticket gets implemented.
final DslResolvingContext dslResolvingContext = getDefault(emptySet());
return loader.loadExtensionModel(clazz.getClassLoader(), dslResolvingContext, params);
}
Aggregations