Search in sources :

Example 6 with DefaultJavaExtensionModelLoader

use of org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader in project mule by mulesoft.

the class MuleExtensionUtils method loadExtension.

/**
 * Loads a extension model
 *
 * @param clazz fully qualified name of the class to load.
 * @param params a set of attributes to work with in each concrete implementation of {@link ExtensionModelLoader}, which will be
 *        responsible of extracting the mandatory parameters (while casting, if needed).
 * @return an {@link ExtensionModel} that represents the class being loaded
 * @throws IllegalArgumentException if there are missing entries in {@code attributes} or the type of any of them does not apply
 *         to the expected one.
 */
public static ExtensionModel loadExtension(Class<?> clazz, Map<String, Object> params) {
    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(emptySet());
    return new DefaultJavaExtensionModelLoader().loadExtensionModel(clazz.getClassLoader(), dslResolvingContext, params);
}
Also used : DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader)

Example 7 with DefaultJavaExtensionModelLoader

use of org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader in project mule by mulesoft.

the class MuleExtensionUtils method loadExtension.

public static ExtensionModel loadExtension(Class<?> clazz, Map<String, Object> params) {
    params.put(TYPE_PROPERTY_NAME, clazz.getName());
    params.put(VERSION, "4.0.0-SNAPSHOT");
    final DslResolvingContext dslResolvingContext = getDefault(emptySet());
    return new DefaultJavaExtensionModelLoader().loadExtensionModel(clazz.getClassLoader(), dslResolvingContext, params);
}
Also used : DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader)

Aggregations

DefaultJavaExtensionModelLoader (org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader)7 HashMap (java.util.HashMap)3 Test (org.junit.Test)2 DslResolvingContext (org.mule.runtime.api.dsl.DslResolvingContext)2 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)2 SmallTest (org.mule.tck.size.SmallTest)2 ByteSource (com.google.common.io.ByteSource)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 ExtensionLoadingContext (org.mule.runtime.extension.api.loader.ExtensionLoadingContext)1 DefaultDslResolvingContext (org.mule.runtime.internal.dsl.DefaultDslResolvingContext)1 DescriptionDeclarationEnricher (org.mule.runtime.module.extension.internal.capability.xml.description.DescriptionDeclarationEnricher)1 TestExtensionWithDocumentationAndMultipleConfig (org.mule.runtime.module.extension.internal.capability.xml.extension.multiple.config.TestExtensionWithDocumentationAndMultipleConfig)1 DefaultExtensionSchemaGenerator (org.mule.runtime.module.extension.internal.capability.xml.schema.DefaultExtensionSchemaGenerator)1 ExportedPackagesValidator (org.mule.runtime.module.extension.internal.resources.validator.ExportedPackagesValidator)1 HeisenbergExtension (org.mule.test.heisenberg.extension.HeisenbergExtension)1