Skip to content

Commit

Permalink
DatabaseConnnector allows null connection (when running without it)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfries committed Oct 25, 2023
1 parent 041658d commit ebc6bf4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.io.IOException;
Expand All @@ -27,7 +26,6 @@
* @author Luca Bressan
*/
@Service
@Profile("database")
public class DatabaseConnector {


Expand All @@ -52,7 +50,9 @@ public void init() {
databaseConnectionProperties.getProperty("PASSWORD"));
logger.info("Connected to the PostgreSQL server successfully.");
} catch (SQLException | IOException e) {
throw new IllegalStateException("Failed to autowire the database connector.", e);
// Allow connection to be null - if we run without database
logger.warn("Could not establish a connection to a database. Running without.");
// throw new IllegalStateException("Failed to autowire the database connector.", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ProblemDetail;
Expand Down Expand Up @@ -72,7 +71,7 @@ public class PlainSwapEditorController implements PlainSwapEditorApi {
};
private final String schemaPath = "schemas/sdc-schemas/sdcml-contract.xsd";
//may be changed to allow for different versions of the schema
@Autowired @Lazy
@Autowired
private DatabaseConnector databaseConnector;

@Autowired
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ serviceUrl: 'http://localhost:4200'

#hostname: localhost:8080

# If these values are not set, the service will start without market database connection
storage:
basedir: 'C:\Users\xn85719\GitHub\finmath-smart-derivative-contract\serverstorage'
importdir: 'C:\Users\Public'
basedir: "."
importdir: "."
internals:
refinitivConnectionPropertiesFile: 'Q:\refinitiv_connect.properties'
databaseConnectionPropertiesFile: 'Q:\database_connect.properties'

refinitivConnectionPropertiesFile:
databaseConnectionPropertiesFile:

0 comments on commit ebc6bf4

Please sign in to comment.