Search in sources :

Example 11 with ImplementingTypeModelProperty

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

the class SoapServiceProviderDeclarer method declare.

/**
 * Declares a new connection provider for a configuration given a {@link SoapServiceProviderWrapper} declaration.
 *
 * @param configDeclarer      the configuration declarer that will own the provider
 * @param provider            a {@link SoapServiceProviderWrapper} that describes the {@link SoapServiceProvider} Type.
 * @param hasCustomTransports if declares custom transport or not.
 */
public void declare(ConfigurationDeclarer configDeclarer, SoapServiceProviderWrapper provider, boolean hasCustomTransports) {
    String description = provider.getDescription();
    // Declares the Service Provider as a Connection Provider.
    ConnectionProviderDeclarer providerDeclarer = configDeclarer.withConnectionProvider(provider.getAlias()).describedAs(description).withModelProperty(new ConnectionTypeModelProperty(ForwardingSoapClient.class)).withModelProperty(new ImplementingTypeModelProperty(provider.getDeclaringClass().get())).withConnectionManagementType(POOLING).supportsConnectivityTesting(provider.supportsConnectivityTesting());
    ParameterDeclarationContext context = new ParameterDeclarationContext("Service Provider", providerDeclarer.getDeclaration());
    parametersLoader.declare(providerDeclarer, provider.getParameters(), context);
    if (hasCustomTransports) {
        providerDeclarer.onParameterGroup(TRANSPORT_GROUP).withRequiredParameter(TRANSPORT_PARAM).withDisplayModel(DisplayModel.builder().displayName(TRANSPORT_GROUP).build()).ofType(typeLoader.load(MessageDispatcherProvider.class)).withLayout(LayoutModel.builder().order(1).tabName(TRANSPORT).build()).withExpressionSupport(NOT_SUPPORTED);
    }
}
Also used : ParameterDeclarationContext(org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext) ConnectionProviderDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclarer) ConnectionTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ConnectionTypeModelProperty) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty) MessageDispatcherProvider(org.mule.runtime.extension.api.soap.MessageDispatcherProvider)

Example 12 with ImplementingTypeModelProperty

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

the class JavaXmlDeclarationEnricherTestCase method enrich.

private XmlDslModel enrich(Class<?> type) {
    extensionDeclarer.withModelProperty(new ImplementingTypeModelProperty(type));
    declarationEnricher.enrich(new DefaultExtensionLoadingContext(extensionDeclarer, type.getClassLoader(), getDefault(emptySet())));
    return extensionDeclarer.getDeclaration().getXmlDslModel();
}
Also used : DefaultExtensionLoadingContext(org.mule.runtime.extension.internal.loader.DefaultExtensionLoadingContext) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)

Example 13 with ImplementingTypeModelProperty

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

the class DefaultJavaModelLoaderDelegate method declare.

/**
 * {@inheritDoc}
 */
@Override
public ExtensionDeclarer declare(ExtensionLoadingContext context) {
    ExtensionDeclarer declarer = context.getExtensionDeclarer().named(extensionElement.getName()).onVersion(version).fromVendor(extensionElement.getVendor()).withCategory(extensionElement.getCategory()).withModelProperty(new ExtensionTypeDescriptorModelProperty(extensionElement));
    // TODO MULE-14517: This workaround should be replaced for a better and more complete mechanism
    context.getParameter("COMPILATION_MODE").ifPresent(m -> declarer.withModelProperty(new CompileTimeModelProperty()));
    extensionElement.getDeclaringClass().ifPresent(extensionClass -> declarer.withModelProperty(new ImplementingTypeModelProperty(extensionClass)));
    processLicenseRequirements(declarer);
    parseExternalLibs(extensionElement, declarer);
    addExceptionEnricher(extensionElement, declarer);
    configLoaderDelegate.declareConfigurations(declarer, extensionElement);
    connectionProviderModelLoaderDelegate.declareConnectionProviders(declarer, extensionElement);
    if (!isEmpty(extensionElement.getConfigurations())) {
        operationLoaderDelegate.declareOperations(declarer, declarer, null, extensionElement.getOperations(), false);
        functionModelLoaderDelegate.declareFunctions(declarer, declarer, null, extensionElement.getFunctions());
        extensionElement.getSources().forEach(source -> sourceModelLoaderDelegate.declareMessageSource(declarer, declarer, source, false));
    }
    return declarer;
}
Also used : ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) CompileTimeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.CompileTimeModelProperty) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)

Example 14 with ImplementingTypeModelProperty

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

the class JavaDeclarationDelegateTestCase method assertModelProperties.

protected void assertModelProperties(ExtensionDeclaration extensionDeclaration) {
    ImplementingTypeModelProperty implementingTypeModelProperty = extensionDeclaration.getModelProperty(ImplementingTypeModelProperty.class).get();
    assertThat(implementingTypeModelProperty, is(notNullValue()));
    assertThat(HeisenbergExtension.class.isAssignableFrom(implementingTypeModelProperty.getType()), is(true));
}
Also used : HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)

Example 15 with ImplementingTypeModelProperty

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

the class JavaDeclarationDelegateTestCase method assertTestModuleConnectionProviders.

private void assertTestModuleConnectionProviders(ExtensionDeclaration extensionDeclaration) throws Exception {
    assertThat(extensionDeclaration.getConnectionProviders(), hasSize(2));
    ConnectionProviderDeclaration connectionProvider = extensionDeclaration.getConnectionProviders().get(0);
    assertThat(connectionProvider.getName(), is(DEFAULT_CONNECTION_PROVIDER_NAME));
    List<ParameterDeclaration> parameters = connectionProvider.getAllParameters();
    assertThat(parameters, hasSize(3));
    assertParameter(parameters, "saulPhoneNumber", "", STRING_TYPE, false, SUPPORTED, SAUL_OFFICE_NUMBER);
    ImplementingTypeModelProperty typeModelProperty = connectionProvider.getModelProperty(ImplementingTypeModelProperty.class).get();
    assertThat(typeModelProperty.getType(), equalTo(HeisenbergConnectionProvider.class));
    parameters = extensionDeclaration.getConnectionProviders().get(1).getAllParameters();
    assertParameter(parameters, TLS_PARAMETER_NAME, "", toMetadataType(TlsContextFactory.class), true, NOT_SUPPORTED, null);
}
Also used : TlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory) SecureHeisenbergConnectionProvider(org.mule.test.heisenberg.extension.SecureHeisenbergConnectionProvider) HeisenbergConnectionProvider(org.mule.test.heisenberg.extension.HeisenbergConnectionProvider) ConnectionProviderDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)

Aggregations

ImplementingTypeModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)15 ExtensionTypeDescriptorModelProperty (org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty)5 ParameterDeclarationContext (org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext)4 Field (java.lang.reflect.Field)2 ConfigurationDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclarer)2 ConnectionProviderDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclarer)2 ExtensionDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer)2 ParameterDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration)2 DefaultEncoding (org.mule.runtime.extension.api.annotation.param.DefaultEncoding)2 ExtensionParameter (org.mule.runtime.module.extension.api.loader.java.type.ExtensionParameter)2 Type (org.mule.runtime.module.extension.api.loader.java.type.Type)2 String.format (java.lang.String.format)1 Annotation (java.lang.annotation.Annotation)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 JAVA (org.mule.metadata.api.model.MetadataFormat.JAVA)1 MetadataType (org.mule.metadata.api.model.MetadataType)1 ObjectType (org.mule.metadata.api.model.ObjectType)1