use of org.mule.runtime.extension.api.loader.ExtensionModelLoader in project mule by mulesoft.
the class ExtensionModelJsonGeneratorTestCase method data.
@Parameterized.Parameters(name = "{1}")
public static Collection<Object[]> data() {
final ClassLoader classLoader = ExtensionModelJsonGeneratorTestCase.class.getClassLoader();
final ServiceRegistry serviceRegistry = mock(ServiceRegistry.class);
when(serviceRegistry.lookupProviders(DeclarationEnricher.class, classLoader)).thenReturn(asList(new JavaXmlDeclarationEnricher()));
List<ExtensionJsonGeneratorTestUnit> extensions;
extensions = asList(newTestUnit(javaLoader, VeganExtension.class, "vegan.json"), newTestUnit(javaLoader, PetStoreConnector.class, "petstore.json"), newTestUnit(javaLoader, MetadataExtension.class, "metadata.json"), newTestUnit(javaLoader, HeisenbergExtension.class, "heisenberg.json"), newTestUnit(javaLoader, SubstitutionGroupExtension.class, "substitutiongroup.json"), newTestUnit(javaLoader, TransactionalExtension.class, "tx-ext.json"), newTestUnit(javaLoader, SubTypesMappingConnector.class, "subtypes.json"), newTestUnit(javaLoader, MarvelExtension.class, "marvel.json"), newTestUnit(soapLoader, RickAndMortyExtension.class, "ram.json"), newTestUnit(javaLoader, TypedValueExtension.class, "typed-value.json"), newTestUnit(javaLoader, TestOAuthExtension.class, "test-oauth.json"), newTestUnit(javaLoader, WeaveFunctionExtension.class, "test-fn.json"), newTestUnit(javaLoader, ValuesExtension.class, "values.json"), newTestUnit(javaLoader, ReconnectionExtension.class, "reconnection-extension.json"));
BiFunction<Class<?>, ExtensionModelLoader, ExtensionModel> createExtensionModel = (extension, loader) -> {
ExtensionModel model = loadExtension(extension, loader);
if (extensionModels.put(model.getName(), model) != null) {
throw new IllegalArgumentException(format("Extension names must be unique. Name [%s] for extension [%s] was already used", model.getName(), extension.getName()));
}
return model;
};
return extensions.stream().map(e -> new Object[] { createExtensionModel.apply(e.getExtensionClass(), e.getLoader()), e.getFileName() }).collect(toList());
}
use of org.mule.runtime.extension.api.loader.ExtensionModelLoader in project mule by mulesoft.
the class ExtensionLoaderUtils method getLoaderById.
public static ExtensionModelLoader getLoaderById(String id) {
final SpiServiceRegistry spiServiceRegistry = new SpiServiceRegistry();
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final Collection<ExtensionModelLoader> extensionModelLoaders = spiServiceRegistry.lookupProviders(ExtensionModelLoader.class, classLoader);
return extensionModelLoaders.stream().filter(extensionModelLoader -> extensionModelLoader.getId().equals(id)).findAny().orElseThrow(() -> new RuntimeException("No loader found for id:{" + id + "}"));
}
Aggregations