Search in sources :

Example 1 with ConfigurationFactoryModelProperty

use of org.mule.runtime.module.extension.internal.loader.java.property.ConfigurationFactoryModelProperty in project mule by mulesoft.

the class ConfigModelLoaderDelegate method declareConfiguration.

private void declareConfiguration(ExtensionDeclarer declarer, ExtensionElement extensionType, ComponentElement configType) {
    checkConfigurationIsNotAnOperation(extensionType, configType);
    ConfigurationDeclarer configurationDeclarer;
    Optional<Configuration> configurationAnnotation = configType.getAnnotation(Configuration.class);
    if (configurationAnnotation.isPresent()) {
        final Configuration configuration = configurationAnnotation.get();
        String configName = isBlank(configuration.name()) ? DEFAULT_CONFIG_NAME : configuration.name();
        configurationDeclarer = declarer.withConfig(configName);
    } else {
        configurationDeclarer = declarer.withConfig(DEFAULT_CONFIG_NAME).describedAs(DEFAULT_CONFIG_DESCRIPTION);
    }
    Class<?> extensionClass = extensionType.getDeclaringClass().orElse(Object.class);
    Class<?> configClass = configType.getDeclaringClass().orElse(Object.class);
    ClassLoader classLoader = extensionClass.getClassLoader() != null ? extensionClass.getClassLoader() : Thread.currentThread().getContextClassLoader();
    TypeAwareConfigurationFactory typeAwareConfigurationFactory = new TypeAwareConfigurationFactory(configClass, classLoader);
    configurationDeclarer.withModelProperty(new ConfigurationFactoryModelProperty(typeAwareConfigurationFactory)).withModelProperty(new ImplementingTypeModelProperty(configClass));
    configurationDeclarer.withModelProperty(new ExtensionTypeDescriptorModelProperty(configType));
    loader.parseExternalLibs(configType, configurationDeclarer);
    ParameterDeclarationContext context = new ParameterDeclarationContext(CONFIGURATION, configurationDeclarer.getDeclaration());
    loader.getFieldParametersLoader().declare(configurationDeclarer, configType.getParameters(), context);
    getOperationLoaderDelegate().declareOperations(declarer, configurationDeclarer, configType);
    getSourceModelLoaderDelegate().declareMessageSources(declarer, configurationDeclarer, configType);
    getFunctionModelLoaderDelegate().declareFunctions(declarer, configurationDeclarer, configType);
    getConnectionProviderModelLoaderDelegate().declareConnectionProviders(configurationDeclarer, configType);
}
Also used : ParameterDeclarationContext(org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext) Configuration(org.mule.runtime.extension.api.annotation.Configuration) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) ConfigurationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclarer) ConfigurationFactoryModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ConfigurationFactoryModelProperty) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)

Example 2 with ConfigurationFactoryModelProperty

use of org.mule.runtime.module.extension.internal.loader.java.property.ConfigurationFactoryModelProperty in project mule by mulesoft.

the class ExtensionsTestUtils method mockConfigurationInstance.

public static void mockConfigurationInstance(ConfigurationModel configurationModel, Object config) {
    ConfigurationFactory configurationFactory = mock(ConfigurationFactory.class);
    when(configurationFactory.newInstance()).thenReturn(config);
    when(configurationFactory.getObjectType()).thenReturn((Class) config.getClass());
    when(configurationModel.getModelProperty(any())).thenAnswer(invocationOnMock -> {
        Class<? extends ModelProperty> propertyType = (Class<? extends ModelProperty>) invocationOnMock.getArguments()[0];
        if (ConfigurationFactoryModelProperty.class.equals(propertyType)) {
            return of(new ConfigurationFactoryModelProperty(configurationFactory));
        }
        return empty();
    });
}
Also used : ConfigurationFactory(org.mule.runtime.extension.api.runtime.config.ConfigurationFactory) InterceptorsModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.InterceptorsModelProperty) ModelProperty(org.mule.runtime.api.meta.model.ModelProperty) ConfigTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ConfigTypeModelProperty) MetadataResolverFactoryModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.MetadataResolverFactoryModelProperty) ConfigurationFactoryModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ConfigurationFactoryModelProperty) ComponentExecutorModelProperty(org.mule.runtime.module.extension.api.loader.java.property.ComponentExecutorModelProperty) ParameterGroupModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty) ConnectivityModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ConnectivityModelProperty) ExceptionHandlerModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ExceptionHandlerModelProperty) ClassLoaderModelProperty(org.mule.runtime.extension.api.property.ClassLoaderModelProperty) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty) ConfigurationFactoryModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ConfigurationFactoryModelProperty)

Example 3 with ConfigurationFactoryModelProperty

use of org.mule.runtime.module.extension.internal.loader.java.property.ConfigurationFactoryModelProperty in project mule by mulesoft.

the class SoapModelLoaderDelegate method getConfigDeclarer.

private ConfigurationDeclarer getConfigDeclarer(ExtensionDeclarer declarer, SoapExtensionTypeWrapper<?> extension, Set<ErrorModel> soapErrors) {
    // TODO - MULE-14311 - Make loader work in compile time
    Class<?> clazz = extension.getDeclaringClass().get();
    TypeAwareConfigurationFactory configurationFactory = new TypeAwareConfigurationFactory(clazz, clazz.getClassLoader());
    ConfigurationDeclarer configDeclarer = declarer.withConfig(DEFAULT_CONFIG_NAME).describedAs(DEFAULT_CONFIG_DESCRIPTION).withModelProperty(new ConfigurationFactoryModelProperty(configurationFactory)).withModelProperty(new ImplementingTypeModelProperty(clazz));
    operationDeclarer.declare(configDeclarer, typeLoader, soapErrors);
    return configDeclarer;
}
Also used : ConfigurationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclarer) TypeAwareConfigurationFactory(org.mule.runtime.module.extension.internal.loader.java.TypeAwareConfigurationFactory) ConfigurationFactoryModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ConfigurationFactoryModelProperty) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)

Aggregations

ConfigurationFactoryModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ConfigurationFactoryModelProperty)3 ImplementingTypeModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)3 ConfigurationDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclarer)2 ModelProperty (org.mule.runtime.api.meta.model.ModelProperty)1 Configuration (org.mule.runtime.extension.api.annotation.Configuration)1 ClassLoaderModelProperty (org.mule.runtime.extension.api.property.ClassLoaderModelProperty)1 ConfigurationFactory (org.mule.runtime.extension.api.runtime.config.ConfigurationFactory)1 ComponentExecutorModelProperty (org.mule.runtime.module.extension.api.loader.java.property.ComponentExecutorModelProperty)1 TypeAwareConfigurationFactory (org.mule.runtime.module.extension.internal.loader.java.TypeAwareConfigurationFactory)1 ConfigTypeModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ConfigTypeModelProperty)1 ConnectivityModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ConnectivityModelProperty)1 ExceptionHandlerModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ExceptionHandlerModelProperty)1 InterceptorsModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.InterceptorsModelProperty)1 MetadataResolverFactoryModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.MetadataResolverFactoryModelProperty)1 ParameterGroupModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty)1 ExtensionTypeDescriptorModelProperty (org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty)1 ParameterDeclarationContext (org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext)1