use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance in project mule by mulesoft.
the class OAuthOperationMessageProcessor method getOAuthConnectionProvider.
private OAuthConnectionProviderWrapper getOAuthConnectionProvider(ExecutionContextAdapter operationContext) {
ConfigurationInstance config = ((ConfigurationInstance) operationContext.getConfiguration().get());
ConnectionProvider provider = unwrapProviderWrapper(config.getConnectionProvider().get(), OAuthConnectionProviderWrapper.class);
return provider instanceof OAuthConnectionProviderWrapper ? (OAuthConnectionProviderWrapper) provider : null;
}
use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance in project mule by mulesoft.
the class ConfigOverrideValueResolverWrapper method getParameterValueFromConfigField.
private Function<Object, Object> getParameterValueFromConfigField(ConfigurationInstance config, String fieldName) {
Field parameterField = getField(config.getValue().getClass(), fieldName, reflectionCache).orElseThrow(() -> new IllegalArgumentException("Missing field with name [" + fieldName + "] in config [" + config.getName() + "]"));
parameterField.setAccessible(true);
return (target) -> {
try {
return parameterField.get(target);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Failed to read field with name [" + parameterField.getName() + " in config [" + config.getName() + "]: " + e.getMessage());
}
};
}
use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance in project mule by mulesoft.
the class PetStoreConnectionTestCase method getPets.
@Test
public void getPets() throws Exception {
ConfigurationInstance config = muleContext.getExtensionManager().getConfiguration("petstore", testEvent());
assertThat(config, is(notNullValue()));
CoreEvent response = runFlow("getPets");
List<String> pets = (List<String>) response.getMessage().getPayload().getValue();
PetStoreConnector configValue = (PetStoreConnector) config.getValue();
assertThat(pets, containsInAnyOrder(configValue.getPets().toArray()));
}
use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance in project mule by mulesoft.
the class ConnectionlessMessageSourceTestCase method obtainDisconnectedSourceConfigParameters.
@Test
public void obtainDisconnectedSourceConfigParameters() throws Exception {
Component element = locator.find(Location.builder().globalName("source").addSourcePart().build()).get();
assertThat(element, is(instanceOf(ConfiguredComponent.class)));
final ConfigurationInstance configurationInstance = ((ConfiguredComponent) element).getConfigurationInstance().get();
ConfigurationState configurationState = configurationInstance.getState();
assertThat(configurationState.getConfigParameters().size(), is(0));
assertThat(configurationState.getConnectionParameters().size(), is(0));
}
use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance in project mule by mulesoft.
the class TransactionSourceBinder method bindToTransaction.
public <T extends TransactionalConnection> Optional<ConnectionHandler<T>> bindToTransaction(TransactionConfig transactionConfig, ConfigurationInstance configurationInstance, ConnectionHandler connectionHandler) throws ConnectionException, TransactionException {
if (!transactionConfig.isTransacted()) {
return empty();
}
Transaction tx = transactionConfig.getFactory().beginTransaction(muleContext);
tx.setTimeout(transactionConfig.getTimeout());
ConfigurationInstance configuration = ofNullable(configurationInstance).orElseThrow(() -> new IllegalStateException(format("Source '%s' of extension '%s' cannot participate in a transaction because it doesn't have a config", componentModel.getName(), extensionModel.getName())));
final ExtensionTransactionKey txKey = new ExtensionTransactionKey(configuration);
return Optional.of(transactionBindingDelegate.getBoundResource(transactionConfig, txKey, () -> connectionHandler));
}
Aggregations