Author: indika Date: Thu Jan 22 01:40:21 2009 New Revision: 29228 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=29228
Log: fix an minor isssue with finding datasources Modified: branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/JNDIBasedDataSourceRepository.java Modified: branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/JNDIBasedDataSourceRepository.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/JNDIBasedDataSourceRepository.java?rev=29228&r1=29227&r2=29228&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/JNDIBasedDataSourceRepository.java (original) +++ branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/JNDIBasedDataSourceRepository.java Thu Jan 22 01:40:21 2009 @@ -31,9 +31,7 @@ import javax.sql.DataSource; import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; +import java.util.*; /** * Keep all DataSources in the JNDI Tree @@ -47,6 +45,7 @@ private InitialContext initialContext; private Properties jndiProperties; private static final Map<String, InitialContext> perDataSourceICMap = new HashMap<String, InitialContext>(); + private static final List<String> cachedNameList = new ArrayList<String>(); private boolean initialized = false; public static JNDIBasedDataSourceRepository getInstance() { @@ -234,6 +233,7 @@ } else { handleException("Unsupported data source type : " + dsType); } + cachedNameList.add(dataSourceName); } public void unRegister(String name) { @@ -245,6 +245,7 @@ handleException("Error removing a Datasource with name : " + name + " from the JNDI context : " + initialContext, e); } + cachedNameList.remove(name); } /** @@ -256,6 +257,12 @@ validateInitialized(); validateDSName(dsName); + if (!cachedNameList.contains(dsName)) { + if (log.isDebugEnabled()) { + log.debug("There is no datasource with name " + dsName + " in the JNDI datasource repository."); + } + return null; + } if (log.isDebugEnabled()) { log.debug("Getting a DataSource with name : " + dsName + " from the JNDI tree."); } @@ -269,6 +276,7 @@ initialContext = null; jndiProperties.clear(); perDataSourceICMap.clear(); + cachedNameList.clear(); } private InitialContext getCachedInitialContext(String name) { _______________________________________________ Esb-java-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev
