Browse Source

Added ActiveMqCredentials (optional)

Fixes gh-618
pull/607/head
Jean Detoeuf 12 years ago committed by Dave Syer
parent
commit
5077b6cc65
  1. 20
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/ActiveMQProperties.java
  2. 19
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsTemplateAutoConfiguration.java

20
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/ActiveMQProperties.java

@ -32,6 +32,10 @@ public class ActiveMQProperties { @@ -32,6 +32,10 @@ public class ActiveMQProperties {
private boolean pooled = false;
private String user;
private String password;
// Will override brokerURL if inMemory is set to true
public String getBrokerUrl() {
if (this.inMemory) {
@ -60,4 +64,20 @@ public class ActiveMQProperties { @@ -60,4 +64,20 @@ public class ActiveMQProperties {
this.pooled = pooled;
}
public String getUser() {
return this.user;
}
public void setUser(String user) {
this.user = user;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
}

19
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsTemplateAutoConfiguration.java

@ -64,15 +64,26 @@ public class JmsTemplateAutoConfiguration { @@ -64,15 +64,26 @@ public class JmsTemplateAutoConfiguration {
@Bean
public ConnectionFactory jmsConnectionFactory() {
ConnectionFactory connectionFactory;
if (this.config.getUser() != null && !"".equals(this.config.getUser())
&& this.config.getPassword() != null
&& !"".equals(this.config.getPassword())) {
connectionFactory = new ActiveMQConnectionFactory(this.config.getUser(),
this.config.getPassword(), this.config.getBrokerUrl());
}
else {
connectionFactory = new ActiveMQConnectionFactory(
this.config.getBrokerUrl());
}
if (this.config.isPooled()) {
PooledConnectionFactory pool = new PooledConnectionFactory();
pool.setConnectionFactory(new ActiveMQConnectionFactory(this.config
.getBrokerUrl()));
pool.setConnectionFactory(connectionFactory);
return pool;
}
return new ActiveMQConnectionFactory(this.config.getBrokerUrl());
else {
return connectionFactory;
}
}
}
}

Loading…
Cancel
Save