Skip to content

Commit

Permalink
Pull DBConnection into tosa-runtime, and include an explicit RuntimeB…
Browse files Browse the repository at this point in the history
…ridge class
  • Loading branch information
akeefer-guidewire committed Feb 9, 2012
1 parent f003080 commit 888c4d4
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 81 deletions.
13 changes: 0 additions & 13 deletions tosa-loader/.idea/libraries/Maven__com_h2database_h2_1_3_146.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions tosa-loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
</repositories>

<dependencies>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand All @@ -45,18 +40,6 @@
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.14</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.146</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
5 changes: 2 additions & 3 deletions tosa-loader/src/tosa/db/execution/QueryExecutor.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package tosa.db.execution;

import gw.lang.reflect.ReflectUtil;
import tosa.api.IDBColumn;
import tosa.api.IDBObject;
import tosa.api.IDBTable;
import tosa.impl.RuntimeBridge;
import tosa.loader.IDBType;

import java.sql.ResultSet;
Expand All @@ -21,8 +21,7 @@ public class QueryExecutor {
// TODO - AHK - Kill this/move it somewhere else

public static IDBObject buildObject(IDBType type, ResultSet resultSet) throws SQLException {
// TODO - AHK - This is cleeaarrrlly a hack
IDBObject obj = ReflectUtil.construct("tosa.CachedDBObject", type, false);
IDBObject obj = RuntimeBridge.createDBObject(type, false);
IDBTable table = type.getTable();
for (IDBColumn column : table.getColumns()) {
Object resultObject = column.getColumnType().readFromResultSet(resultSet, table.getName() + "." + column.getName());
Expand Down
6 changes: 3 additions & 3 deletions tosa-loader/src/tosa/dbmd/DatabaseImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import gw.fs.IFile;
import gw.lang.reflect.module.IModule;
import tosa.DBConnection;
import tosa.api.IDBColumn;
import tosa.api.IDBConnection;
import tosa.api.IDBExecutionKernel;
Expand All @@ -12,6 +11,7 @@
import tosa.api.IPreparedStatementParameter;
import tosa.db.execution.DBExecutionKernelImpl;
import tosa.db.execution.DBUpgraderImpl;
import tosa.impl.RuntimeBridge;
import tosa.impl.md.DBFkArrayImpl;
import tosa.impl.md.DBJoinArrayImpl;
import tosa.loader.data.DBData;
Expand All @@ -34,7 +34,7 @@ public class DatabaseImpl implements IDatabase {
private final String _namespace;
private final DBData _dbData;
private final Map<String, DBTableImpl> _tables;
private DBConnection _connection;
private IDBConnection _connection;
private final DBExecutionKernelImpl _executionKernel;
private String _jdbcUrl;
private IModule _module;
Expand Down Expand Up @@ -179,7 +179,7 @@ public void setJdbcUrl(String url) {
// TODO - AHK - Check for MySql ANSI_QUOTES string?
_jdbcUrl = url;
// TODO - AHK - Synchronization
_connection = new DBConnection(url, _module);
_connection = RuntimeBridge.createConnection(url, _module);
}

@Override
Expand Down
4 changes: 1 addition & 3 deletions tosa-loader/src/tosa/impl/QueryExecutorImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tosa.impl;

import gw.lang.reflect.ReflectUtil;
import org.slf4j.profiler.Profiler;
import tosa.api.IDBColumn;
import tosa.api.IDBObject;
Expand Down Expand Up @@ -133,8 +132,7 @@ public IDBObject processResult(ResultSet result) throws SQLException {
}

public static IDBObject buildObject(IDBType type, ResultSet resultSet) throws SQLException {
// TODO - AHK - This is cleeaarrrllly a horrendous hack
IDBObject obj = ReflectUtil.construct("tosa.CachedDBObject", type, false);
IDBObject obj = RuntimeBridge.createDBObject(type, false);
IDBTable table = type.getTable();
for (IDBColumn column : table.getColumns()) {
Object resultObject = column.getColumnType().readFromResultSet(resultSet, table.getName() + "." + column.getName());
Expand Down
31 changes: 31 additions & 0 deletions tosa-loader/src/tosa/impl/RuntimeBridge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package tosa.impl;

import gw.lang.reflect.ReflectUtil;
import gw.lang.reflect.module.IModule;
import tosa.api.IDBConnection;
import tosa.api.IDBObject;
import tosa.loader.DBTypeInfoDelegate;
import tosa.loader.IDBType;

/**
* Created by IntelliJ IDEA.
* User: akeefer
* Date: 2/9/12
* Time: 11:11 AM
* To change this template use File | Settings | File Templates.
*/
public class RuntimeBridge {

public static IDBConnection createConnection(String jdbcUrl, IModule module) {
return ReflectUtil.construct("tosa.DBConnection", jdbcUrl, module);
}

// TODO - AHK - Ideally we'd completely kill the need for this in tosa-loader
public static IDBObject createDBObject(IDBType type, boolean isNew) {
return ReflectUtil.construct("tosa.CachedDBObject", type, isNew);
}

public static DBTypeInfoDelegate createTypeInfoDelegate() {
return ReflectUtil.construct("tosa.impl.loader.DBTypeInfoDelegateImpl");
}
}
5 changes: 2 additions & 3 deletions tosa-loader/src/tosa/loader/DBTypeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
import gw.lang.reflect.IConstructorHandler;
import gw.lang.reflect.IMethodCallHandler;
import gw.lang.reflect.IPropertyInfo;
import gw.lang.reflect.IType;
import gw.lang.reflect.ITypeInfo;
import gw.lang.reflect.ReflectUtil;
import gw.lang.reflect.TypeSystem;
import gw.lang.reflect.java.JavaTypes;
import gw.util.concurrent.LockingLazyVar;
import tosa.api.IDBArray;
import tosa.api.IDBColumn;
import tosa.api.IDBObject;
import tosa.dbmd.DBColumnImpl;
import tosa.impl.RuntimeBridge;

import java.util.Map;

Expand All @@ -32,7 +31,7 @@ public class DBTypeInfo extends TosaBaseTypeInfo implements ITypeInfo {
private LockingLazyVar<DBTypeInfoDelegate> _delegate = new LockingLazyVar<DBTypeInfoDelegate>() {
@Override
protected DBTypeInfoDelegate init() {
return (DBTypeInfoDelegate) ReflectUtil.construct("tosa.impl.loader.DBTypeInfoDelegateImpl");
return RuntimeBridge.createTypeInfoDelegate();
}
};

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 888c4d4

Please sign in to comment.