Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first release of the ActiveJDBC Micro extension

  • Loading branch information...
commit 24be6dca2e5dcf4219e40fa49ed358b06075bc58 1 parent d158280
@florinpatrascu authored
View
BIN  activejdbc_m/lib/activejdbc-1.4.7-SNAPSHOT.jar
Binary file not shown
View
BIN  activejdbc_m/lib/activejdbc-instrumentation-1.4.7-SNAPSHOT.jar
Binary file not shown
View
BIN  activejdbc_m/lib/activejdbc_m-0.1.1.jar
Binary file not shown
View
BIN  activejdbc_m/lib/h2-1.3.170.jar
Binary file not shown
View
25 activejdbc_m/src/ca/simplegames/micro/extensions/ActivejdbcExtension.java
@@ -52,17 +52,16 @@ public Extension register(String name, SiteContext site, Map<String, Object> con
this.site = site;
site.with(name, this); //<- set a global attribute that can access this Extension by name
File appPath = site.getApplicationPath();
- File extensionPath = new File(appPath, "/extensions/" + name);
+ //File extensionPath = new File(appPath, "/extensions/" + name);
File appConfigPath = site.getApplicationConfigPath();
Map<String, Object> options = (Map<String, Object>) configuration.get("options");
File dbConfigFile = new File(appConfigPath, (String) options.get("db"));
- File modelsDir = new File(appConfigPath, (String) options.get("models"));
+ //File modelsDir = new File(appConfigPath, (String) options.get("models"));
debug = (Boolean) options.get("debug");
if (dbConfigFile.exists()) {
Map<String, Object> dbConfigForAll = (Map<String, Object>) new Yaml().load(new FileInputStream(dbConfigFile));
Map<String, Object> dbConfig = (Map<String, Object>) dbConfigForAll.get(site.getMicroEnv());
- //todo: check if jdbc/jndi and implement each case
if (dbConfig != null) {
String driver = (String) dbConfig.get("driver");
@@ -77,11 +76,9 @@ public Extension register(String name, SiteContext site, Map<String, Object> con
Integer maxConnections = dbConfig.get("pool") != null ? (Integer) dbConfig.get("pool") : 5;
int minConnections = (int) Math.max(1, Math.ceil(maxConnections / 3)); // todo let the user configure it
- ds.setMaxConnectionsPerPartition(minConnections);
-
- ds.setMinConnectionsPerPartition(maxConnections / 3); // todo let the user configure it
+ ds.setMaxConnectionsPerPartition(maxConnections);
+ ds.setMinConnectionsPerPartition(minConnections);
ds.setPartitionCount(1);
-
this.name = name;
} else {
throw new ExceptionInInitializerError(
@@ -115,11 +112,14 @@ public void after() {
}
public void after(boolean manageTransaction) {
- if (manageTransaction) {
- Base.commitTransaction();
- }
if (Base.hasConnection()) {
- Base.close();
+ try {
+ if (manageTransaction) {
+ Base.commitTransaction();
+ }
+ } finally {
+ Base.close();
+ }
}
}
@@ -131,14 +131,13 @@ public void onException(boolean manageTransaction) {
if (manageTransaction) {
Base.rollbackTransaction();
}
- Base.close();
}
public boolean isDebug() {
return debug;
}
- public Base getBase(){
+ public Base getBase() {
return new Base();
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.