add things (there are bugs, this is unstable!)
This commit is contained in:
@@ -55,6 +55,13 @@
|
||||
<version>2.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/io.quarkus/quarkus-agroal -->
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-agroal</artifactId>
|
||||
<version>3.19.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -61,6 +61,14 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
public String getJdbcUrl() {
|
||||
return String.format("%s://%s:%s/%s",
|
||||
config.getProperty("db.protocol"),
|
||||
config.getProperty("db.host"),
|
||||
config.getProperty("db.port"),
|
||||
config.getProperty("db.name"));
|
||||
}
|
||||
|
||||
public String getStringProperty(String key) {
|
||||
return config.getProperty(key);
|
||||
}
|
||||
|
||||
@@ -18,22 +18,27 @@ import net.miarma.contaminus.common.Constants;
|
||||
|
||||
public class DatabaseManager {
|
||||
private final JDBCPool pool;
|
||||
private final Vertx vertx = Vertx.vertx();
|
||||
|
||||
public DatabaseManager(Vertx vertx) {
|
||||
private static DatabaseManager instance;
|
||||
|
||||
public static DatabaseManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new DatabaseManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private DatabaseManager() {
|
||||
ConfigManager config = ConfigManager.getInstance();
|
||||
|
||||
JDBCConnectOptions jdbcOptions = new JDBCConnectOptions()
|
||||
.setJdbcUrl(config.getStringProperty("db.protocol") + "//" +
|
||||
config.getStringProperty("db.host") + ":" +
|
||||
config.getStringProperty("db.port") + "/" +
|
||||
config.getStringProperty("db.name"))
|
||||
pool = JDBCPool.pool(vertx,
|
||||
new JDBCConnectOptions()
|
||||
.setJdbcUrl(config.getJdbcUrl())
|
||||
.setUser(config.getStringProperty("db.user"))
|
||||
.setPassword(config.getStringProperty("db.pwd"));
|
||||
|
||||
PoolOptions poolOptions = new PoolOptions()
|
||||
.setMaxSize(Integer.parseInt(config.getStringProperty("db.poolSize")));
|
||||
|
||||
pool = JDBCPool.pool(vertx, jdbcOptions, poolOptions);
|
||||
.setPassword(config.getStringProperty("db.pwd")),
|
||||
new PoolOptions()
|
||||
.setMaxSize(5)
|
||||
);
|
||||
}
|
||||
|
||||
public Future<RowSet<Row>> testConnection() {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DataLayerAPIVerticle extends AbstractVerticle {
|
||||
|
||||
configManager = ConfigManager.getInstance();
|
||||
gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
|
||||
dbManager = new DatabaseManager(vertx);
|
||||
dbManager = DatabaseManager.getInstance();
|
||||
|
||||
Router router = Router.router(vertx);
|
||||
Set<HttpMethod> allowedMethods = new HashSet<>(
|
||||
|
||||
@@ -32,7 +32,7 @@ public class LogicLayerAPIVerticle extends AbstractVerticle {
|
||||
|
||||
configManager = ConfigManager.getInstance();
|
||||
gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
|
||||
dbManager = new DatabaseManager(vertx);
|
||||
dbManager = DatabaseManager.getInstance();
|
||||
|
||||
Router router = Router.router(vertx);
|
||||
Set<HttpMethod> allowedMethods = new HashSet<>(
|
||||
|
||||
@@ -12,17 +12,9 @@ public class MainVerticle extends AbstractVerticle {
|
||||
final DeploymentOptions options = new DeploymentOptions();
|
||||
options.setThreadingModel(ThreadingModel.WORKER);
|
||||
|
||||
String enabledVerticles = System.getProperty("vertx.options", "");
|
||||
|
||||
if (enabledVerticles.contains("data")) {
|
||||
getVertx().deployVerticle(new DataLayerAPIVerticle(), options);
|
||||
}
|
||||
if (enabledVerticles.contains("business")) {
|
||||
getVertx().deployVerticle(new LogicLayerAPIVerticle(), options);
|
||||
}
|
||||
if (enabledVerticles.contains("web")) {
|
||||
getVertx().deployVerticle(new HttpServerVerticle());
|
||||
}
|
||||
//getVertx().deployVerticle(new LogicLayerAPIVerticle(), options);
|
||||
//getVertx().deployVerticle(new HttpServerVerticle());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,10 +22,4 @@ public class MainVerticle extends AbstractVerticle {
|
||||
getVertx().deploymentIDs()
|
||||
.forEach(v -> getVertx().undeploy(v));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("vertx.options", String.join(",", args));
|
||||
io.vertx.core.Launcher.executeCommand("run", MainVerticle.class.getName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,9 +7,9 @@ public class SystemUtil {
|
||||
static ConfigManager configManager = ConfigManager.getInstance();
|
||||
static String host = configManager.getStringProperty("inet.host");
|
||||
static String origin = configManager.getStringProperty("inet.origin");
|
||||
static int dataApiPort = configManager.getIntProperty("data-api.port");
|
||||
static int logicApiPort = configManager.getIntProperty("logic-api.port");
|
||||
static int webserverPort = configManager.getIntProperty("webserver.port");
|
||||
static int dataApiPort = 8081;
|
||||
static int logicApiPort = 8082;
|
||||
static int webserverPort = 8080;
|
||||
|
||||
public static String getHost() {
|
||||
return host;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"appConfig": {
|
||||
"endpoints": {
|
||||
"BASE_URL": "http://localhost:8081/api/v1",
|
||||
"BASE_URL": "http://localhost:3001/api/v1",
|
||||
"GET_GROUPS": "/groups",
|
||||
"GET_GROUP_BY_ID": "/groups/{0}",
|
||||
"GET_GROUP_DEVICES": "/groups/{0}/devices",
|
||||
|
||||
Reference in New Issue
Block a user