use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.
the class DslScriptExecutingMessageProcessor method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
if (StringUtils.hasText(this.location)) {
this.script = this.applicationContext.getResource(this.location);
}
ScriptSource scriptSource = new RefreshableResourceScriptSource(this.script, this.refreshCheckDelay);
if (!StringUtils.hasText(this.lang)) {
String filename = this.script.getFilename();
int index = filename.lastIndexOf(".") + 1;
if (index < 1) {
throw new BeanCreationException("'lang' isn't provided and there is 'file extension' for script " + "resource: " + this.script);
}
this.lang = filename.substring(index);
}
if (this.applicationContext.containsBean(ScriptExecutingProcessorFactory.BEAN_NAME)) {
ScriptExecutingProcessorFactory processorFactory = this.applicationContext.getBean(ScriptExecutingProcessorFactory.BEAN_NAME, ScriptExecutingProcessorFactory.class);
this.delegate = processorFactory.createMessageProcessor(this.lang, scriptSource, this.variableGenerator);
} else {
this.delegate = new ScriptExecutingMessageProcessor(scriptSource, this.variableGenerator, ScriptExecutorFactory.getScriptExecutor(this.lang));
}
this.delegate.setBeanFactory(this.applicationContext);
this.delegate.setBeanClassLoader(this.applicationContext.getClassLoader());
}
use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.
the class ConsoleOutboundChannelAdapterParserTests method stdoutAdapterWithInvalidCharset.
@Test
public void stdoutAdapterWithInvalidCharset() {
BeanCreationException beanCreationException = null;
try {
new ClassPathXmlApplicationContext("invalidConsoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class).close();
} catch (BeanCreationException e) {
beanCreationException = e;
}
Throwable rootCause = beanCreationException.getRootCause();
assertEquals(UnsupportedEncodingException.class, rootCause.getClass());
}
use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.
the class ConsoleInboundChannelAdapterParserTests method testConsoleSourceWithInvalidCharset.
@Test
public void testConsoleSourceWithInvalidCharset() {
BeanCreationException beanCreationException = null;
try {
new ClassPathXmlApplicationContext("invalidConsoleInboundChannelAdapterParserTests.xml", ConsoleInboundChannelAdapterParserTests.class).close();
} catch (BeanCreationException e) {
beanCreationException = e;
}
Throwable rootCause = beanCreationException.getRootCause();
assertEquals(UnsupportedEncodingException.class, rootCause.getClass());
}
use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.
the class SyslogReceivingChannelAdapterParserTests method testUdpChildWithTcp.
@Test
public void testUdpChildWithTcp() {
try {
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail3-context.xml", this.getClass()).close();
fail("Expected exception");
} catch (BeanCreationException e) {
e.printStackTrace();
assertEquals("Cannot specify 'udp-attributes' when the protocol is 'tcp'", e.getCause().getMessage());
}
}
use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.
the class DefaultSftpSessionFactory method initJschSession.
private com.jcraft.jsch.Session initJschSession() throws Exception {
if (this.port <= 0) {
this.port = 22;
}
if (StringUtils.hasText(this.knownHosts)) {
this.jsch.setKnownHosts(this.knownHosts);
}
// private key
if (this.privateKey != null) {
byte[] keyByteArray = StreamUtils.copyToByteArray(this.privateKey.getInputStream());
String passphrase = this.userInfoWrapper.getPassphrase();
if (StringUtils.hasText(passphrase)) {
this.jsch.addIdentity(this.user, keyByteArray, null, passphrase.getBytes());
} else {
this.jsch.addIdentity(this.user, keyByteArray, null, null);
}
}
com.jcraft.jsch.Session jschSession = this.jsch.getSession(this.user, this.host, this.port);
if (this.sessionConfig != null) {
jschSession.setConfig(this.sessionConfig);
}
String password = this.userInfoWrapper.getPassword();
if (StringUtils.hasText(password)) {
jschSession.setPassword(password);
}
jschSession.setUserInfo(this.userInfoWrapper);
try {
if (this.proxy != null) {
jschSession.setProxy(this.proxy);
}
if (this.socketFactory != null) {
jschSession.setSocketFactory(this.socketFactory);
}
if (this.timeout != null) {
jschSession.setTimeout(this.timeout);
}
if (StringUtils.hasText(this.clientVersion)) {
jschSession.setClientVersion(this.clientVersion);
}
if (StringUtils.hasText(this.hostKeyAlias)) {
jschSession.setHostKeyAlias(this.hostKeyAlias);
}
if (this.serverAliveInterval != null) {
jschSession.setServerAliveInterval(this.serverAliveInterval);
}
if (this.serverAliveCountMax != null) {
jschSession.setServerAliveCountMax(this.serverAliveCountMax);
}
if (this.enableDaemonThread != null) {
jschSession.setDaemonThread(this.enableDaemonThread);
}
} catch (Exception e) {
throw new BeanCreationException("Attempt to set additional properties of " + "the com.jcraft.jsch.Session resulted in error: " + e.getMessage(), e);
}
return jschSession;
}
Aggregations