use of org.springframework.beans.factory.BeanCreationException in project syndesis by syndesisio.
the class ODataCreateEntityConnectorAutoConfiguration method postConstructODataCreateEntityComponent.
@PostConstruct
public void postConstructODataCreateEntityComponent() {
Map<String, Object> parameters = new HashMap<>();
for (Map.Entry<String, ODataCreateEntityConnectorConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
parameters.clear();
ODataCreateEntityComponent connector = new ODataCreateEntityComponent(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<ODataCreateEntityComponent> customizer : customizers) {
boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-create-entity." + entry.getKey() + ".customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-create-entity." + 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);
}
}
}
use of org.springframework.beans.factory.BeanCreationException in project syndesis by syndesisio.
the class ODataDeleteEntityConnectorAutoConfiguration method postConstructODataDeleteEntityComponent.
@PostConstruct
public void postConstructODataDeleteEntityComponent() {
Map<String, Object> parameters = new HashMap<>();
for (Map.Entry<String, ODataDeleteEntityConnectorConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
parameters.clear();
ODataDeleteEntityComponent connector = new ODataDeleteEntityComponent(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<ODataDeleteEntityComponent> customizer : customizers) {
boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-delete-entity." + entry.getKey() + ".customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-delete-entity." + 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);
}
}
}
use of org.springframework.beans.factory.BeanCreationException in project ma-core-public by infiniteautomation.
the class DwrSpringServlet method init.
/* (non-Javadoc)
* @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
*/
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
ServletContext servletContext = servletConfig.getServletContext();
try {
WebApplicationContext webappContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
container = new SpringContainer();
container.setBeanFactory(webappContext);
ContainerUtil.setupDefaults(container, servletConfig);
ContainerUtil.setupFromServletConfig(container, servletConfig);
container.setupFinished();
webContextBuilder = StartupUtil.initWebContext(servletConfig, servletContext, container);
StartupUtil.initServerContext(servletConfig, servletContext, container);
ContainerUtil.prepareForWebContextFilter(servletContext, servletConfig, container, webContextBuilder, this);
// retrieve the configurators from Spring (loaded by the ContextLoaderListener)
try {
configurators.add(webappContext.getBean(DwrNamespaceHandler.DEFAULT_SPRING_CONFIGURATOR_ID));
} catch (NoSuchBeanDefinitionException ex) {
throw new ServletException("No DWR configuration was found in your application context, make sure to define one", ex);
}
if (includeDefaultConfig) {
ContainerUtil.configureFromSystemDwrXml(container);
}
ContainerUtil.configureFromInitParams(container, servletConfig);
ContainerUtil.configure(container, configurators);
ContainerUtil.publishContainer(container, servletConfig);
} catch (InstantiationException ex) {
throw new BeanCreationException("Failed to instansiate", ex);
} catch (IllegalAccessException ex) {
throw new BeanCreationException("Access error", ex);
} catch (Exception ex) {
log.fatal("init failed", ex);
throw new ServletException(ex);
} finally {
webContextBuilder.unset();
}
}
use of org.springframework.beans.factory.BeanCreationException in project spring-integration-aws by spring-projects.
the class SqsMessageDrivenChannelAdapter method onInit.
@Override
protected void onInit() {
super.onInit();
this.listenerContainer = this.simpleMessageListenerContainerFactory.createSimpleMessageListenerContainer();
if (this.queueStopTimeout != null) {
this.listenerContainer.setQueueStopTimeout(this.queueStopTimeout);
}
this.listenerContainer.setMessageHandler(new IntegrationQueueMessageHandler());
try {
this.listenerContainer.afterPropertiesSet();
} catch (Exception e) {
throw new BeanCreationException("Cannot instantiate 'SimpleMessageListenerContainer'", e);
}
}
use of org.springframework.beans.factory.BeanCreationException in project BroadleafCommerce by BroadleafCommerce.
the class AbstractMergeBeanPostProcessor method processPackage.
protected Object processPackage(BeanPackage beanPackage, Object bean, String beanName) {
String sourceRef = beanPackage.getSourceRef();
String targetRef = beanPackage.getTargetRef();
Placement placement = beanPackage.getPlacement();
int position = beanPackage.getPosition();
MergeBeanStatusProvider statusProvider = beanPackage.getStatusProvider();
Object sourceItem = null;
Object targetItem = null;
if (beanName.equals(targetRef)) {
targetItem = bean;
if (!StringUtils.isEmpty(sourceRef)) {
sourceItem = applicationContext.getBean(sourceRef);
} else {
throw new IllegalArgumentException("Must declare an source reference value. See #setCollectionRef()");
}
}
if (sourceItem != null && targetItem != null) {
if (statusProvider != null && !statusProvider.isProcessingEnabled(targetItem, beanName, applicationContext)) {
if (LOG.isTraceEnabled()) {
LOG.trace(String.format("Not performing post-processing on targetRef [%s] because the registered " + "status provider [%s] returned false", targetRef, statusProvider.getClass().getSimpleName()));
}
return bean;
}
if (targetItem instanceof ListFactoryBean || targetItem instanceof List) {
try {
if (sourceItem instanceof List) {
addListToList(targetItem, sourceItem, placement, position);
} else {
if (sourceItem instanceof Collection) {
throw new IllegalArgumentException(String.format("Attempting to merge a collection of type " + "%s into a target list. Only source collections of type ListFactoryBean or List " + "may be used.", sourceItem.getClass().getName()));
}
addItemToList(targetItem, sourceItem, placement, position);
}
} catch (Exception e) {
throw new BeanCreationException(e.getMessage());
}
} else if (targetItem instanceof SetFactoryBean || targetItem instanceof Set) {
try {
if (sourceItem instanceof Set) {
addSetToSet(targetItem, sourceItem, placement, position);
} else {
if (sourceItem instanceof Collection) {
throw new IllegalArgumentException(String.format("Attempting to merge a collection of type " + "%s into a target set. Only source collections of type SetFactoryBean or Set " + "may be used.", sourceItem.getClass().getName()));
}
addItemToSet(targetItem, sourceItem, placement, position);
}
} catch (Exception e) {
throw new BeanCreationException(e.getMessage());
}
} else if (targetItem instanceof MapFactoryBean || targetItem instanceof Map) {
try {
if (sourceItem instanceof Map) {
addMapToMap(targetItem, (Map) sourceItem, placement, position);
} else {
throw new IllegalArgumentException(String.format("Attempting to merge an item of type " + "%s into a target map. Only source items of type MapFactoryBean or Map " + "may be used.", sourceItem.getClass().getName()));
}
} catch (Exception e) {
throw new BeanCreationException(e.getMessage());
}
} else {
throw new IllegalArgumentException("Bean (" + beanName + ") is specified as a merge target, " + "but is not" + " of type ListFactoryBean, SetFactoryBean or MapFactoryBean");
}
}
return bean;
}
Aggregations