Compare commits

...

1 Commits

Author SHA1 Message Date
Dmytro Chmyga
8f8db02af9 feat(TCOMP-612): support shared connections
* Add raw DataSources to globalMap

* Add SharedConnectionPool implementation to globalMap
2017-10-12 15:49:41 +03:00
2 changed files with 33 additions and 0 deletions

View File

@@ -256,6 +256,36 @@
public String status= "";
<%
boolean containGenericComponents = false;
for(INode node : process.getGeneratingNodes()) {
IComponent component = node.getComponent();
if(EComponentType.GENERIC.equals(component.getComponentType())) {
containGenericComponents = true;
break;
}
}
if(containGenericComponents) {
%>
private final org.talend.components.common.runtime.SharedConnectionsPool connectionPool = new org.talend.components.common.runtime.SharedConnectionsPool() {
public java.sql.Connection getDBConnection(String dbDriver, String url, String userName, String password, String dbConnectionName)
throws ClassNotFoundException, java.sql.SQLException {
return SharedDBConnection.getDBConnection(dbDriver, url, userName, password, dbConnectionName);
}
public java.sql.Connection getDBConnection(String dbDriver, String url, String dbConnectionName)
throws ClassNotFoundException, java.sql.SQLException {
return SharedDBConnection.getDBConnection(dbDriver, url, dbConnectionName);
}
};
private static final String GLOBAL_CONNECTION_POOL_KEY = "GLOBAL_CONNECTION_POOL";
{
globalMap.put(GLOBAL_CONNECTION_POOL_KEY, connectionPool);
}
<%}%>
public static void main(String[] args){
final <%=className %> <%=className %>Class = new <%=className %>();

View File

@@ -373,12 +373,15 @@ private RunTrace runTrace = new RunTrace();
// OSGi DataSource
private final static String KEY_DB_DATASOURCES = "KEY_DB_DATASOURCES";
private final static String KEY_DB_DATASOURCES_RAW = "KEY_DB_DATASOURCES_RAW";
public void setDataSources(java.util.Map<String, javax.sql.DataSource> dataSources) {
java.util.Map<String, routines.system.TalendDataSource> talendDataSources = new java.util.HashMap<String, routines.system.TalendDataSource>();
for (java.util.Map.Entry<String, javax.sql.DataSource> dataSourceEntry : dataSources.entrySet()) {
talendDataSources.put(dataSourceEntry.getKey(), new routines.system.TalendDataSource(dataSourceEntry.getValue()));
}
globalMap.put(KEY_DB_DATASOURCES, talendDataSources);
globalMap.put(KEY_DB_DATASOURCES_RAW, new java.util.HashMap<String, javax.sql.DataSource>(dataSources));
}
<%