55import org .reactivecommons .async .rabbit .config .RabbitProperties ;
66import org .reactivecommons .async .rabbit .config .exceptions .InvalidConfigurationException ;
77import org .springframework .beans .factory .annotation .Value ;
8+ import org .springframework .util .StringUtils ;
89
910import java .util .HashMap ;
1011
1516public class AsyncPropsDomain extends HashMap <String , AsyncProps > {
1617 public AsyncPropsDomain (@ Value ("${spring.application.name}" ) String defaultAppName ,
1718 RabbitProperties defaultRabbitProperties ,
18- AsyncPropsDomainProperties configured ) {
19+ AsyncPropsDomainProperties configured ,
20+ SecretFiller secretFiller ) {
1921 super (configured );
2022 this .computeIfAbsent (DEFAULT_DOMAIN , k -> new AsyncProps ());
2123 super .forEach ((key , value ) -> { // To ensure that each domain has an appName
@@ -38,6 +40,9 @@ public AsyncPropsDomain(@Value("${spring.application.name}") String defaultAppNa
3840 if (value .getBrokerConfigProps () == null ) {
3941 value .setBrokerConfigProps (new BrokerConfigProps (value ));
4042 }
43+ if (StringUtils .hasText (value .getSecret ()) && secretFiller != null ) {
44+ secretFiller .fillWithSecret (value );
45+ }
4146 });
4247 }
4348
@@ -56,6 +61,7 @@ public static AsyncPropsDomainBuilder builder() {
5661 public static class AsyncPropsDomainBuilder {
5762 private String defaultAppName ;
5863 private RabbitProperties defaultRabbitProperties ;
64+ private SecretFiller secretFiller ;
5965 private final HashMap <String , AsyncProps > domains = new HashMap <>();
6066
6167
@@ -70,6 +76,12 @@ public AsyncPropsDomainBuilder withDefaultAppName(String defaultAppName) {
7076 return this ;
7177 }
7278
79+
80+ public AsyncPropsDomainBuilder withSecretFiller (SecretFiller secretFiller ) {
81+ this .secretFiller = secretFiller ;
82+ return this ;
83+ }
84+
7385 public AsyncPropsDomainBuilder withDomain (String domain , AsyncProps props ) {
7486 domains .put (domain , props );
7587 return this ;
@@ -80,9 +92,13 @@ public AsyncPropsDomain build() {
8092 if (defaultRabbitProperties == null ) {
8193 defaultRabbitProperties = new RabbitProperties ();
8294 }
83- return new AsyncPropsDomain (defaultAppName , defaultRabbitProperties , domainProperties );
95+ return new AsyncPropsDomain (defaultAppName , defaultRabbitProperties , domainProperties , secretFiller );
8496 }
8597
8698 }
8799
100+ public interface SecretFiller {
101+ void fillWithSecret (AsyncProps props );
102+ }
103+
88104}
0 commit comments