[Ds-java-dev] svn commit r14400 - in trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice: . beans

svn at wso2.org svn at wso2.org
Sat Mar 1 20:38:54 PST 2008


Author: sumedha
Date: Sat Mar  1 20:38:46 2008
New Revision: 14400

Log:

null check for config id & check for config id when creating connection to database

Modified:
   trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/DBDeployer.java
   trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/DBUtils.java
   trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Config.java

Modified: trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/DBDeployer.java
==============================================================================
--- trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/DBDeployer.java	(original)
+++ trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/DBDeployer.java	Sat Mar  1 20:38:46 2008
@@ -298,7 +298,14 @@
     						log.error("Pooling manager could not establish a connection to database.", e);
     						throw new AxisFault("Pooling manager could not establish a connection to database.",e);
     					}
-                		axisService.addParameter(DBConstants.DB_CONNECTION, dbcpConnectionManager.getDatasource());
+    					String connectionPropertyName = "";
+    					if(config.getId() != null && config.getId().trim().length() > 0){
+    						connectionPropertyName = DBConstants.DB_CONNECTION+"_"+config.getId();
+    					}else{
+    						//config section can be present with no id
+    						connectionPropertyName = DBConstants.DB_CONNECTION;
+    					}
+                		axisService.addParameter(connectionPropertyName, dbcpConnectionManager.getDatasource());
                 	}else {
                       throw new AxisFault("Pooling manager could not establish a connection to database.");
                     }            	

Modified: trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/DBUtils.java
==============================================================================
--- trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/DBUtils.java	(original)
+++ trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/DBUtils.java	Sat Mar  1 20:38:46 2008
@@ -222,7 +222,9 @@
 	 * @param configToUse - id of the config section to be used. Introduced with multiple data source 
 	 * support from single data service 
 	 */
-	private static Connection checkDBConnectionStatus(AxisService axisService,Connection conn,String configToUse) 
+	private static Connection checkDBConnectionStatus(AxisService axisService
+			,Connection conn
+			,String configToUse) 
 	throws AxisFault{
 	    if(log.isDebugEnabled()){
 	        log.debug("checking database connection status");
@@ -1279,9 +1281,18 @@
 			
 			if(config.getPropertyValue(DBConstants.MIN_POOL_SIZE) != null 
 					|| config.getPropertyValue(DBConstants.MAX_POOL_SIZE) != null){
+				
+				String connectionPropertyName = "";
+				if(config.getId() != null && config.getId().trim().length() > 0){
+					connectionPropertyName = DBConstants.DB_CONNECTION+"_"+config.getId();
+				}else{
+					//config section can be present with no id
+					connectionPropertyName = DBConstants.DB_CONNECTION;
+				}
+				
 				//user has set connection pool size(s). Get connection from pooling manager
 				DataSource dataSource =
-					(DataSource)axisService.getParameterValue(DBConstants.DB_CONNECTION);
+					(DataSource)axisService.getParameterValue(connectionPropertyName);
 				conn = dataSource.getConnection();				
 			}else{
 				//Try to load the JDBC driver class. If class not found throw an error.

Modified: trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Config.java
==============================================================================
--- trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Config.java	(original)
+++ trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Config.java	Sat Mar  1 20:38:46 2008
@@ -4,7 +4,7 @@
 import java.util.Iterator;
 
 public class Config {
-	String id = "";
+	String id = null;
 	ArrayList properties = new ArrayList();
 
 	public ArrayList getProperties() {



More information about the Ds-java-dev mailing list