diff options
Diffstat (limited to 'vid-ext-services-simulator/src/main/java')
-rw-r--r-- | vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java index 3845c7419..b6cc6759f 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java @@ -1,11 +1,13 @@ package org.onap.simulator.controller; +import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.mockserver.integration.ClientAndServer.startClientAndServer; import static org.mockserver.matchers.Times.exactly; import static org.mockserver.model.JsonBody.json; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import java.io.BufferedInputStream; import java.io.DataInputStream; @@ -21,6 +23,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Enumeration; import java.util.List; import java.util.Map; @@ -107,11 +110,20 @@ public class SimulatorController { private void initJPA() { if (enableJPA) { - entityManagerFactory = Persistence.createEntityManagerFactory("vid"); + entityManagerFactory = Persistence.createEntityManagerFactory("vid", overrideConnectionUrl()); entityManager = entityManagerFactory.createEntityManager(); } } + private Map<Object, Object> overrideConnectionUrl() { + final String connectionUrlEnvProperty = "hibernate.connection.url"; + if (isEmpty(System.getProperty(connectionUrlEnvProperty))) { + return Collections.emptyMap(); + } else { + return ImmutableMap.of(connectionUrlEnvProperty, System.getProperty(connectionUrlEnvProperty)); + } + } + @PreDestroy public void tearDown(){ logger.info("Stopping VID Simulator...."); |