Author: indika
Date: Mon Dec  8 08:18:17 2008
New Revision: 26219
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=26219

Log:
Avoid Creating datasource information repo if there is one already

Modified:
   
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepository.java
   
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepositoryHelper.java
   
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/JNDIBasedDataSourceRepository.java
   
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/RepositoryBasedDataSourceFinder.java
   
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationRepositoryFactory.java

Modified: 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepository.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepository.java?rev=26219&r1=26218&r2=26219&view=diff
==============================================================================
--- 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepository.java
     (original)
+++ 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepository.java
     Mon Dec  8 08:18:17 2008
@@ -86,7 +86,8 @@
         assertNull(listener, "Provided 
'DataSourceInformationRepositoryListener' instance is null");
 
         if (this.listener != null) {
-            handleException("There is a 
'DataSourceInformationRepositoryListener' associated with 
'DataSourceInformationRepository'");
+            handleException("There is a 
'DataSourceInformationRepositoryListener' " +
+                    "associated with 'DataSourceInformationRepository'");
         }
         this.listener = listener;
     }

Modified: 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepositoryHelper.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepositoryHelper.java?rev=26219&r1=26218&r2=26219&view=diff
==============================================================================
--- 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepositoryHelper.java
       (original)
+++ 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/DataSourceInformationRepositoryHelper.java
       Mon Dec  8 08:18:17 2008
@@ -36,10 +36,26 @@
     private static final Log log = 
LogFactory.getLog(DataSourceInformationRepositoryHelper.class);
 
     public static void 
initializeDataSourceInformationRepository(AxisConfiguration axisConfiguration, 
Properties properties) {
-        DataSourceRepositoryManager listener = 
DataSourceRepositoryManager.getInstance();
-        RepositoryBasedDataSourceFinder finder = 
RepositoryBasedDataSourceFinder.getInstance();
-        finder.init(listener);
-        initializeDataSourceInformationRepository(axisConfiguration, 
properties, listener);
+
+        DataSourceInformationRepository repository = 
getDataSourceInformationRepository(axisConfiguration);
+        DataSourceInformationRepositoryListener listener = null;
+
+        if (repository != null) {
+            listener = repository.getRepositoryListener();
+        }
+
+        if (listener == null) {
+            listener = DataSourceRepositoryManager.getInstance();
+        }
+
+        if (listener instanceof DataSourceRepositoryManager) {
+            RepositoryBasedDataSourceFinder finder = 
RepositoryBasedDataSourceFinder.getInstance();
+            finder.init((DataSourceRepositoryManager) listener);
+        }
+
+        if (repository == null) {
+            initializeDataSourceInformationRepository(axisConfiguration, 
properties, listener);
+        }
     }
 
     public static void 
initializeDataSourceInformationRepository(AxisConfiguration axisConfiguration, 
Properties properties, DataSourceInformationRepositoryListener listener) {

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=26219&r1=26218&r2=26219&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
       Mon Dec  8 08:18:17 2008
@@ -57,7 +57,9 @@
 
         initialized = true;
         if (jndiEnv == null || jndiEnv.isEmpty()) {
-            log.warn("Provided global JNDI environment properties is empty or 
null.");
+            if (log.isDebugEnabled()) {
+                log.debug("Provided global JNDI environment properties is 
empty or null.");
+            }
             return;
         }
 

Modified: 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/RepositoryBasedDataSourceFinder.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/RepositoryBasedDataSourceFinder.java?rev=26219&r1=26218&r2=26219&view=diff
==============================================================================
--- 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/RepositoryBasedDataSourceFinder.java
     (original)
+++ 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/RepositoryBasedDataSourceFinder.java
     Mon Dec  8 08:18:17 2008
@@ -29,10 +29,11 @@
  */
 public class RepositoryBasedDataSourceFinder {
 
-    private final static Log log = 
LogFactory.getLog(InMemoryDataSourceRepository.class);
+    private final static Log log = 
LogFactory.getLog(RepositoryBasedDataSourceFinder.class);
     private DataSourceRepositoryManager dataSourceRepositoryManager;
     private boolean initialized;
-    private static final RepositoryBasedDataSourceFinder 
REPOSITORY_BASED_DATA_SOURCE_FINDER = new RepositoryBasedDataSourceFinder();
+    private static final RepositoryBasedDataSourceFinder
+            REPOSITORY_BASED_DATA_SOURCE_FINDER = new 
RepositoryBasedDataSourceFinder();
 
     private RepositoryBasedDataSourceFinder() {
     }
@@ -72,20 +73,10 @@
         throw new SynapseUtilException(msg);
     }
 
-    /**
-     * Helper methods for handle errors.
-     *
-     * @param msg The error message
-     * @param e   The exception
-     */
-    private static void handleException(String msg, Exception e) {
-        log.error(msg, e);
-        throw new SynapseUtilException(msg, e);
-    }
-
     private void assertInitialized() {
         if (!initialized) {
-            handleException("RepositoryBasedDataSourceFinder has not been 
initialized with a 'DataSourceRepositoryManager' instance ");
+            handleException("RepositoryBasedDataSourceFinder has not been " +
+                    "initialized with a 'DataSourceRepositoryManager' instance 
");
         }
     }
 

Modified: 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationRepositoryFactory.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationRepositoryFactory.java?rev=26219&r1=26218&r2=26219&view=diff
==============================================================================
--- 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationRepositoryFactory.java
      (original)
+++ 
branches/synapse/1.2.wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationRepositoryFactory.java
      Mon Dec  8 08:18:17 2008
@@ -41,7 +41,9 @@
         List<DataSourceInformation> sourceInformationList = 
DataSourceInformationListFactory.createDataSourceInformationList(properties);
         DataSourceInformationRepository repository = new 
DataSourceInformationRepository();
         repository.setRepositoryListener(listener);
-        repository.setConfigurationProperties(properties);
+        if (properties != null && !properties.isEmpty()) {
+            repository.setConfigurationProperties(properties);
+        }
         for (DataSourceInformation information : sourceInformationList) {
             if (information != null) {
                 repository.addDataSourceInformation(information);

_______________________________________________
Esb-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to