providerDeclarer = declarer.withConnectionProvider(name).describedAs(description); ConnectionProviderDeclarer finalProviderDeclarer = providerDeclarer; providerType.getDeclaringClass().ifPresent(clazz -> finalProviderDeclarer .withModelProperty(new ConnectionProviderFactoryModelProperty(new DefaultConnectionProviderFactory<>(clazz, getExtensionClassLoader()))) .withModelProperty(new ImplementingTypeModelProperty(clazz))); .withModelProperty(new ConnectionTypeModelProperty(providerGenerics.get(0))) .withModelProperty(new ExtensionTypeDescriptorModelProperty(providerType)); providerDeclarer.withConnectionManagementType(managementType); providerDeclarer.supportsConnectivityTesting(!providerType.isAssignableTo(NoConnectivityTest.class)); connectionProviderDeclarers.put(providerType, providerDeclarer); ParameterDeclarationContext context = new ParameterDeclarationContext(CONNECTION_PROVIDER, providerDeclarer.getDeclaration()); loader.getFieldParametersLoader().declare(providerDeclarer, providerType.getParameters(), context);
configurationDeclarer.withConnectionProvider(MODULE_CONNECTION_GLOBAL_ELEMENT_NAME); connectionProviderDeclarer .withConnectionManagementType(ConnectionManagementType.NONE); connectionProperties.stream().forEach(param -> extractProperty(connectionProviderDeclarer, param)); .getParameters().get(GLOBAL_ELEMENT_NAME_ATTRIBUTE); connectionProviderDeclarer .withModelProperty(new TestConnectionGlobalElementModelProperty(testConnectionGlobalElementName)); });
private ExtensionModel mockedExtension(final String name, final String config, final String connectionProvider, boolean supportsConnectivityTesting) { final ExtensionDeclarer extensionDeclarer = new ExtensionDeclarer(); extensionDeclarer.named(name) .onVersion("4.0.0") .fromVendor("MuleSoft testcase") .withCategory(Category.COMMUNITY) .withConfig(config) .withConnectionProvider(connectionProvider) .supportsConnectivityTesting(supportsConnectivityTesting) .withConnectionManagementType(ConnectionManagementType.NONE); return new ExtensionModelFactory() .create(new DefaultExtensionLoadingContext(extensionDeclarer, currentThread().getContextClassLoader(), new NullDslResolvingContext())); }
private void parseOAuthGrantType(ConnectionProviderElement providerType, ConnectionProviderDeclarer providerDeclarer) { providerType.getAnnotation(AuthorizationCode.class).ifPresent(a -> { AuthorizationCodeGrantType grantType = new AuthorizationCodeGrantType(a.accessTokenUrl(), a.authorizationUrl(), a.accessTokenExpr(), a.expirationExpr(), a.refreshTokenExpr(), a.defaultScopes()); providerDeclarer.withModelProperty(new OAuthModelProperty(asList(grantType))); }); } }
private void parseOAuthGrantType(ConnectionProviderElement providerType, ConnectionProviderDeclarer providerDeclarer) { providerType.getAnnotation(AuthorizationCode.class).ifPresent(a -> { AuthorizationCodeGrantType grantType = new AuthorizationCodeGrantType(a.accessTokenUrl(), a.authorizationUrl(), a.accessTokenExpr(), a.expirationExpr(), a.refreshTokenExpr(), a.defaultScopes()); providerDeclarer.withModelProperty(new OAuthModelProperty(asList(grantType))); }); } }
/** * 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)) //TODO - MULE-14311 - Make loader work in compile time .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); } }
providerDeclarer = declarer.withConnectionProvider(name).describedAs(description); ConnectionProviderDeclarer finalProviderDeclarer = providerDeclarer; providerType.getDeclaringClass().ifPresent(clazz -> finalProviderDeclarer .withModelProperty(new ConnectionProviderFactoryModelProperty(new DefaultConnectionProviderFactory<>(clazz, getExtensionClassLoader()))) .withModelProperty(new ImplementingTypeModelProperty(clazz))); .withModelProperty(new ConnectionTypeModelProperty(providerGenerics.get(0))) .withModelProperty(new ExtensionTypeDescriptorModelProperty(providerType)); providerDeclarer.withConnectionManagementType(managementType); providerDeclarer.supportsConnectivityTesting(!providerType.isAssignableTo(NoConnectivityTest.class)); connectionProviderDeclarers.put(providerType, providerDeclarer); ParameterDeclarationContext context = new ParameterDeclarationContext(CONNECTION_PROVIDER, providerDeclarer.getDeclaration()); loader.getFieldParametersLoader().declare(providerDeclarer, providerType.getParameters(), context);