Unload Derby on shutdown for #332
This commit is contained in:
parent
fe0824fd7c
commit
3f64340ec1
|
@ -3,6 +3,10 @@ package ca.uhn.fhirtest;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.sql.Driver;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.apache.derby.drda.NetworkServerControl;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
|
@ -18,8 +22,20 @@ public class DerbyNetworkServer implements InitializingBean, DisposableBean {
|
|||
try {
|
||||
ourLog.info("Shutting down derby");
|
||||
// DriverManager.getConnection("jdbc:derby:directory:" + System.getProperty("fhir.db.location") + ";shutdown=true");
|
||||
|
||||
Enumeration<Driver> drivers = DriverManager.getDrivers();
|
||||
while (drivers.hasMoreElements()) {
|
||||
Driver driver = drivers.nextElement();
|
||||
try {
|
||||
ourLog.error("Unregistering driver: {}", driver.getClass());
|
||||
DriverManager.deregisterDriver(driver);
|
||||
} catch (SQLException e) {
|
||||
ourLog.error("Failed to unregister driver", e);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
ourLog.info("Failed to create database: {}", e.getMessage());
|
||||
ourLog.info("Failed to shut down database: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,10 @@ import ca.uhn.fhirtest.config.TestDstu2Config;
|
|||
|
||||
public class TestRestfulServer extends RestfulServer {
|
||||
|
||||
public static final String FHIR_BASEURL_DSTU2 = "fhir.baseurl.dstu2";
|
||||
public static final String FHIR_BASEURL_DSTU3 = "fhir.baseurl.dstu3";
|
||||
public static final String FHIR_BASEURL_DSTU1 = "fhir.baseurl.dstu1";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TestRestfulServer.class);
|
||||
|
@ -85,7 +89,7 @@ public class TestRestfulServer extends RestfulServer {
|
|||
JpaConformanceProviderDstu1 confProvider = new JpaConformanceProviderDstu1(this, systemDao);
|
||||
confProvider.setImplementationDescription(implDesc);
|
||||
setServerConformanceProvider(confProvider);
|
||||
baseUrlProperty = "fhir.baseurl.dstu1";
|
||||
baseUrlProperty = FHIR_BASEURL_DSTU1;
|
||||
break;
|
||||
}
|
||||
case "DSTU2": {
|
||||
|
@ -102,7 +106,7 @@ public class TestRestfulServer extends RestfulServer {
|
|||
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, myAppCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription(implDesc);
|
||||
setServerConformanceProvider(confProvider);
|
||||
baseUrlProperty = "fhir.baseurl.dstu2";
|
||||
baseUrlProperty = FHIR_BASEURL_DSTU2;
|
||||
break;
|
||||
}
|
||||
case "DSTU3": {
|
||||
|
@ -119,7 +123,7 @@ public class TestRestfulServer extends RestfulServer {
|
|||
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription(implDesc);
|
||||
setServerConformanceProvider(confProvider);
|
||||
baseUrlProperty = "fhir.baseurl.dstu3";
|
||||
baseUrlProperty = FHIR_BASEURL_DSTU3;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -25,7 +25,9 @@ import ca.uhn.fhir.jpa.dao.DaoConfig;
|
|||
@EnableTransactionManagement()
|
||||
public class TestDstu1Config extends BaseJavaConfigDstu1 {
|
||||
|
||||
@Value("${fhir.db.location}")
|
||||
public static final String FHIR_DB_LOCATION = "${fhir.db.location}";
|
||||
|
||||
@Value(FHIR_DB_LOCATION)
|
||||
private String myFhirDbLocation;
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,10 +29,13 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
|||
@EnableTransactionManagement()
|
||||
public class TestDstu2Config extends BaseJavaConfigDstu2 {
|
||||
|
||||
@Value("${fhir.db.location.dstu2}")
|
||||
public static final String FHIR_LUCENE_LOCATION_DSTU2 = "${fhir.lucene.location.dstu2}";
|
||||
public static final String FHIR_DB_LOCATION_DSTU2 = "${fhir.db.location.dstu2}";
|
||||
|
||||
@Value(FHIR_DB_LOCATION_DSTU2)
|
||||
private String myFhirDbLocation;
|
||||
|
||||
@Value("${fhir.lucene.location.dstu2}")
|
||||
@Value(FHIR_LUCENE_LOCATION_DSTU2)
|
||||
private String myFhirLuceneLocation;
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,10 +34,13 @@ import ca.uhn.fhir.validation.ResultSeverityEnum;
|
|||
@EnableTransactionManagement()
|
||||
public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
||||
|
||||
@Value("${fhir.db.location.dstu3}")
|
||||
public static final String FHIR_LUCENE_LOCATION_DSTU3 = "${fhir.lucene.location.dstu3}";
|
||||
public static final String FHIR_DB_LOCATION_DSTU3 = "${fhir.db.location.dstu3}";
|
||||
|
||||
@Value(FHIR_DB_LOCATION_DSTU3)
|
||||
private String myFhirDbLocation;
|
||||
|
||||
@Value("${fhir.lucene.location.dstu3}")
|
||||
@Value(FHIR_LUCENE_LOCATION_DSTU3)
|
||||
private String myFhirLuceneLocation;
|
||||
|
||||
@Bean()
|
||||
|
|
Loading…
Reference in New Issue