Skip to content

Commit

Permalink
Remove code changes to load config.properties from Tomcat in REMReM-P…
Browse files Browse the repository at this point in the history
…ublish. (#160)

Remove code changes to load config.properties from Tomcat in REMReM-Publish.
  • Loading branch information
durga-vasaadi authored and Umadevi-Kapu committed Sep 4, 2019
1 parent 43ccfef commit 17eab61
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 74 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.0.7
- Remove code changes to load config.properties from Tomcat in REMReM-Publish.

## 2.0.6
- Uplifted eiffel-remrem-parent version from 2.0.1 to 2.0.2.
- Uplifted eiffel-remrem-shared version from 2.0.1 to 2.0.2.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<version>2.0.2</version>
</parent>
<properties>
<eiffel-remrem-publish.version>2.0.6</eiffel-remrem-publish.version>
<eiffel-remrem-publish.version>2.0.7</eiffel-remrem-publish.version>
<eiffel-remrem-shared.version>2.0.2</eiffel-remrem-shared.version>
<eiffel-remrem-semantics.version>2.0.6</eiffel-remrem-semantics.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class RabbitMqPropertiesConfig {
@Autowired
private GenerateURLTemplate generateURLTemplate;
private static final String GENERATE_SERVER_URI = "generate.server.uri";
private static final String GENERATE_SERVER_PATH = "generate.server.path";
private static final String GENERATE_SERVER_PATH = "generate.server.contextpath";

/***
* This method is used to give RabbitMq properties based on protocol
Expand All @@ -64,39 +64,15 @@ public class RabbitMqPropertiesConfig {
*/
public Map<String, RabbitMqProperties> getRabbitMqProperties() {
Map<String, Object> map = new HashMap<String, Object>();
readCatalinaProperties(map);

if (map.isEmpty()) {
log.info("Catalina Properties configuration not provided. Trying to initiate Spring properties instead.");
readSpringProperties();
} else {
log.info("Catalina Properties configuration provided. Populating Rabbitmq properties to rabbitMqPropertiesMap object.");
populateConfigurationsBasedOnCatalinaProperties(map);
}
readSpringProperties();

loadGenerateConfigurationBasedOnSystemProperties();
return rabbitMqPropertiesMap;
}

/***
* Reads catalina properties to a map object.
*
* @param map
* RabbitMq instances map object.
*/
private void readCatalinaProperties(Map<String, Object> map) {
String catalina_home = System.getProperty("catalina.home").replace('\\', '/');
for (Iterator it = ((AbstractEnvironment) env).getPropertySources().iterator(); it.hasNext();) {
PropertySource propertySource = (PropertySource) it.next();
if (propertySource instanceof MapPropertySource) {
if (propertySource.getName().contains("[file:" + catalina_home + "/conf/config.properties]")) {
map.putAll(((MapPropertySource) propertySource).getSource());
}
}
}
}

/***
* Reads Spring Properties and writes RabbitMq properties to RabbitMq instances properties map object.
* Reads Spring Properties and writes RabbitMq properties to RabbitMq
* instances properties map object.
*/
private void readSpringProperties() {
JsonNode rabbitmqInstancesJsonListJsonArray = null;
Expand Down Expand Up @@ -126,48 +102,6 @@ private void readSpringProperties() {
}
}

/***
* Writes RabbitMq catalina properties to RabbitMq instances properties map object and set Generate server properties.
*
* @param map
* RabbitMq instances map object.
*/
private void populateConfigurationsBasedOnCatalinaProperties(Map<String, Object> map) {
final String jasyptSecretPassword = (String) map.get("jasypt.encryptor.password");
for (Entry<String, Object> entry : map.entrySet()) {
final String key = entry.getKey();
if (key.contains("rabbitmq")) {
String protocol = key.split("\\.")[0];
if (rabbitMqPropertiesMap.get(protocol) == null) {
rabbitMqPropertiesMap.put(protocol, new RabbitMqProperties());
}
if (key.contains("rabbitmq.host")) {
rabbitMqPropertiesMap.get(protocol).setHost(entry.getValue().toString());
} else if (key.contains("rabbitmq.port")) {
rabbitMqPropertiesMap.get(protocol).setPort(Integer.getInteger(entry.getValue().toString()));
} else if (key.contains("rabbitmq.username")) {
rabbitMqPropertiesMap.get(protocol).setUsername(entry.getValue().toString());
} else if (key.contains("rabbitmq.password")) {
rabbitMqPropertiesMap.get(protocol).setPassword(DecryptionUtils.decryptString(entry.getValue().toString(), jasyptSecretPassword));
} else if (key.contains("rabbitmq.tls")) {
rabbitMqPropertiesMap.get(protocol).setTlsVer(entry.getValue().toString());
} else if (key.contains("rabbitmq.exchangeName")) {
rabbitMqPropertiesMap.get(protocol).setExchangeName(entry.getValue().toString());
} else if (key.contains("rabbitmq.domainId")) {
rabbitMqPropertiesMap.get(protocol).setDomainId(entry.getValue().toString());
}
else if (key.contains("rabbitmq.createExchangeIfNotExisting")) {
rabbitMqPropertiesMap.get(protocol).setCreateExchangeIfNotExisting(Boolean.parseBoolean(entry.getValue().toString()));
}
}
}
final String generateServerUri = (String) map.get(GENERATE_SERVER_URI);
generateURLTemplate.setGenerateServerUri(generateServerUri);

final String generateServerPath = (String) map.get(GENERATE_SERVER_PATH);
generateURLTemplate.setGenerateServerPath(generateServerPath);
}

/***
* This method is used to load generate server configuration from JAVA_OPTS.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;

import com.ericsson.eiffel.remrem.publish.config.SpringLoggingInitializer;

@SpringBootApplication
@ComponentScan("com.ericsson.eiffel.remrem")
@EnableAutoConfiguration(exclude = { JacksonAutoConfiguration.class })
@PropertySource(value = "file:${catalina.home}/conf/config.properties", ignoreResourceNotFound = true)
public class App extends SpringBootServletInitializer {

public static void main(String[] args) {
Expand Down

0 comments on commit 17eab61

Please sign in to comment.