|
@@ -1,10 +1,12 @@
|
|
|
package hello.config;
|
|
|
|
|
|
+import hello.controller.DbMongodbController;
|
|
|
+import hello.controller.DbMysqlController;
|
|
|
import hello.controller.JsonController;
|
|
|
-import hello.controller.MongodbController;
|
|
|
-import hello.controller.MysqlController;
|
|
|
-import hello.controller.persistence.WorldsMongodbRepository;
|
|
|
import hello.controller.PlaintextController;
|
|
|
+import hello.controller.QueriesMongodbController;
|
|
|
+import hello.controller.QueriesMysqlController;
|
|
|
+import hello.controller.persistence.WorldsMongodbRepository;
|
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
@@ -13,9 +15,7 @@ import com.strategicgains.repoexpress.exception.InvalidObjectIdException;
|
|
|
import com.strategicgains.restexpress.Format;
|
|
|
import com.strategicgains.restexpress.util.Environment;
|
|
|
|
|
|
-public class Configuration
|
|
|
-extends Environment
|
|
|
-{
|
|
|
+public class Configuration extends Environment {
|
|
|
private static final String DEFAULT_EXECUTOR_THREAD_POOL_SIZE = "20";
|
|
|
|
|
|
private static final String PORT_PROPERTY = "port";
|
|
@@ -29,76 +29,78 @@ extends Environment
|
|
|
private int executorThreadPoolSize;
|
|
|
|
|
|
private JsonController jsonController;
|
|
|
- private MysqlController mysqlController;
|
|
|
- private MongodbController mongodbController;
|
|
|
- private PlaintextController plaintextController;
|
|
|
+ private DbMysqlController dbMysqlController;
|
|
|
+ private QueriesMysqlController queriesMysqlController;
|
|
|
+ private DbMongodbController dbMongodbController;
|
|
|
+ private QueriesMongodbController queriesMongodbController;
|
|
|
+ private PlaintextController plaintextController;
|
|
|
|
|
|
@Override
|
|
|
- protected void fillValues(Properties p)
|
|
|
- {
|
|
|
+ protected void fillValues(Properties p) {
|
|
|
this.port = Integer.parseInt(p.getProperty(PORT_PROPERTY, "8080"));
|
|
|
this.defaultFormat = p.getProperty(DEFAULT_FORMAT_PROPERTY, Format.JSON);
|
|
|
this.baseUrl = p.getProperty(BASE_URL_PROPERTY, "http://localhost:" + String.valueOf(port));
|
|
|
- this.executorThreadPoolSize = Integer.parseInt(p.getProperty(EXECUTOR_THREAD_POOL_SIZE, DEFAULT_EXECUTOR_THREAD_POOL_SIZE));
|
|
|
+ this.executorThreadPoolSize = Integer.parseInt(p.getProperty(EXECUTOR_THREAD_POOL_SIZE,
|
|
|
+ DEFAULT_EXECUTOR_THREAD_POOL_SIZE));
|
|
|
MongoConfig mongoSettings = new MongoConfig(p);
|
|
|
MysqlConfig mysqlSettings = new MysqlConfig(p);
|
|
|
initialize(mysqlSettings, mongoSettings);
|
|
|
}
|
|
|
|
|
|
- private void initialize(MysqlConfig mysqlSettings, MongoConfig mongo)
|
|
|
- {
|
|
|
+ private void initialize(MysqlConfig mysqlSettings, MongoConfig mongo) {
|
|
|
jsonController = new JsonController();
|
|
|
- plaintextController = new PlaintextController();
|
|
|
- mysqlController = new MysqlController(mysqlSettings.getDataSource());
|
|
|
- WorldsMongodbRepository worldMongodbRepository = new WorldsMongodbRepository(mongo.getClient(), mongo.getDbName());
|
|
|
- worldMongodbRepository.setIdentifierAdapter(new IdentiferAdapter<Long>()
|
|
|
- {
|
|
|
+ plaintextController = new PlaintextController();
|
|
|
+ dbMysqlController = new DbMysqlController(mysqlSettings.getDataSource());
|
|
|
+ queriesMysqlController = new QueriesMysqlController(mysqlSettings.getDataSource());
|
|
|
+ WorldsMongodbRepository worldMongodbRepository = new WorldsMongodbRepository(
|
|
|
+ mongo.getClient(), mongo.getDbName());
|
|
|
+ worldMongodbRepository.setIdentifierAdapter(new IdentiferAdapter<Long>() {
|
|
|
@Override
|
|
|
- public Long convert(String id) throws InvalidObjectIdException
|
|
|
- {
|
|
|
+ public Long convert(String id) throws InvalidObjectIdException {
|
|
|
return Long.valueOf(id);
|
|
|
}
|
|
|
});
|
|
|
- mongodbController = new MongodbController(worldMongodbRepository);
|
|
|
+ dbMongodbController = new DbMongodbController(worldMongodbRepository);
|
|
|
+ queriesMongodbController = new QueriesMongodbController(worldMongodbRepository);
|
|
|
}
|
|
|
|
|
|
- public String getDefaultFormat()
|
|
|
- {
|
|
|
+ public String getDefaultFormat() {
|
|
|
return defaultFormat;
|
|
|
}
|
|
|
|
|
|
- public int getPort()
|
|
|
- {
|
|
|
+ public int getPort() {
|
|
|
return port;
|
|
|
}
|
|
|
-
|
|
|
- public String getBaseUrl()
|
|
|
- {
|
|
|
+
|
|
|
+ public String getBaseUrl() {
|
|
|
return baseUrl;
|
|
|
}
|
|
|
-
|
|
|
- public int getExecutorThreadPoolSize()
|
|
|
- {
|
|
|
+
|
|
|
+ public int getExecutorThreadPoolSize() {
|
|
|
return executorThreadPoolSize;
|
|
|
}
|
|
|
|
|
|
- public JsonController getJsonController()
|
|
|
- {
|
|
|
+ public JsonController getJsonController() {
|
|
|
return jsonController;
|
|
|
}
|
|
|
|
|
|
- public MysqlController getMysqlController()
|
|
|
- {
|
|
|
- return mysqlController;
|
|
|
+ public DbMysqlController getDbMysqlController() {
|
|
|
+ return dbMysqlController;
|
|
|
}
|
|
|
|
|
|
- public MongodbController getMongodbController()
|
|
|
- {
|
|
|
- return mongodbController;
|
|
|
+ public QueriesMysqlController getQueriesMysqlController() {
|
|
|
+ return queriesMysqlController;
|
|
|
}
|
|
|
|
|
|
- public PlaintextController getPlaintextController()
|
|
|
- {
|
|
|
- return plaintextController;
|
|
|
- }
|
|
|
+ public DbMongodbController getDbMongodbController() {
|
|
|
+ return dbMongodbController;
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueriesMongodbController getQueriesMongodbController() {
|
|
|
+ return queriesMongodbController;
|
|
|
+ }
|
|
|
+
|
|
|
+ public PlaintextController getPlaintextController() {
|
|
|
+ return plaintextController;
|
|
|
+ }
|
|
|
}
|