use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.
the class JdbcMessageHandlerParser method parseConsumer.
@Override
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(JdbcMessageHandler.class);
String dataSourceRef = element.getAttribute("data-source");
String jdbcOperationsRef = element.getAttribute("jdbc-operations");
boolean refToDataSourceSet = StringUtils.hasText(dataSourceRef);
boolean refToJdbcOperationsSet = StringUtils.hasText(jdbcOperationsRef);
if ((refToDataSourceSet && refToJdbcOperationsSet) || (!refToDataSourceSet && !refToJdbcOperationsSet)) {
parserContext.getReaderContext().error("Exactly one of the attributes data-source or " + "simple-jdbc-operations should be set for the JDBC outbound-channel-adapter", source);
}
String query = IntegrationNamespaceUtils.getTextFromAttributeOrNestedElement(element, "query", parserContext);
if (!StringUtils.hasText(query)) {
throw new BeanCreationException("The query attribute is required");
}
if (!StringUtils.hasText(query)) {
throw new BeanCreationException("The query attribute is required");
}
if (refToDataSourceSet) {
builder.addConstructorArgReference(dataSourceRef);
} else {
builder.addConstructorArgReference(jdbcOperationsRef);
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "sql-parameter-source-factory");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "prepared-statement-setter");
builder.addConstructorArgValue(query);
return builder.getBeanDefinition();
}
use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.
the class InboundChannelAdapterParserTests method pop3WithSearchTermStrategy.
@Test
public void pop3WithSearchTermStrategy() {
try {
new ClassPathXmlApplicationContext("org/springframework/integration/mail/config/InboundChannelAdapterParserTests-pop3Search-context.xml").close();
fail("expected a parser error");
} catch (BeanCreationException e) {
assertTrue(e.getMessage().contains("searchTermStrategy is only allowed with imap"));
}
}
use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.
the class AbstractXmppInboundChannelAdapterParser method doParse.
@Override
protected AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(getBeanClassName(element));
IntegrationNamespaceUtils.configureHeaderMapper(element, builder, parserContext, DefaultXmppHeaderMapper.class, null);
String connectionName = element.getAttribute("xmpp-connection");
if (StringUtils.hasText(connectionName)) {
builder.addConstructorArgReference(connectionName);
} else if (parserContext.getRegistry().containsBeanDefinition(XmppNamespaceHandler.XMPP_CONNECTION_BEAN_NAME)) {
builder.addConstructorArgReference(XmppNamespaceHandler.XMPP_CONNECTION_BEAN_NAME);
} else {
throw new BeanCreationException("You must either explicitly define which XMPP connection to use via " + "'xmpp-connection' attribute or have default XMPP connection bean registered under the name 'xmppConnection'" + "(e.g., <int-xmpp:xmpp-connection .../>). If 'id' is not provided the default will be 'xmppConnection'.");
}
builder.addPropertyReference("outputChannel", channelName);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "error-channel");
this.postProcess(element, parserContext, builder);
return builder.getBeanDefinition();
}
use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.
the class AbstractXmppOutboundChannelAdapterParser method parseConsumer.
@Override
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(this.getHandlerClassName());
IntegrationNamespaceUtils.configureHeaderMapper(element, builder, parserContext, DefaultXmppHeaderMapper.class, null);
String connectionName = element.getAttribute("xmpp-connection");
if (StringUtils.hasText(connectionName)) {
builder.addConstructorArgReference(connectionName);
} else if (parserContext.getRegistry().containsBeanDefinition(XmppNamespaceHandler.XMPP_CONNECTION_BEAN_NAME)) {
builder.addConstructorArgReference(XmppNamespaceHandler.XMPP_CONNECTION_BEAN_NAME);
} else {
throw new BeanCreationException("You must either explicitly define which XMPP connection to use via " + "'xmpp-connection' attribute or have default XMPP connection bean registered under the name 'xmppConnection'" + "(e.g., <int-xmpp:xmpp-connection .../>). If 'id' is not provided the default will be 'xmppConnection'.");
}
return builder.getBeanDefinition();
}
use of org.springframework.beans.factory.BeanCreationException in project syndesis by syndesisio.
the class SwaggerConnectorConnectorAutoConfiguration method postConstructSwaggerConnectorComponent.
@PostConstruct
public void postConstructSwaggerConnectorComponent() {
Map<String, Object> parameters = new HashMap<>();
for (Map.Entry<String, SwaggerConnectorConnectorConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
parameters.clear();
SwaggerConnectorComponent connector = new SwaggerConnectorComponent(entry.getKey());
connector.setCamelContext(camelContext);
try {
IntrospectionSupport.getProperties(entry.getValue(), parameters, null, false);
CamelPropertiesHelper.setCamelProperties(camelContext, connector, parameters, false);
connector.setOptions(parameters);
if (ObjectHelper.isNotEmpty(customizers)) {
for (ConnectorCustomizer<SwaggerConnectorComponent> customizer : customizers) {
boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.swagger-operation." + entry.getKey() + ".customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.swagger-operation." + entry.getKey() + ".customizer");
if (useCustomizer) {
LOGGER.debug("Configure connector {}, with customizer {}", connector, customizer);
customizer.customize(connector);
}
}
}
camelContext.addComponent(entry.getKey(), connector);
} catch (Exception e) {
throw new BeanCreationException(entry.getKey(), e.getMessage(), e);
}
}
}
Aggregations