Author: keith
Date: Tue Jul 29 10:17:00 2008
New Revision: 20120
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=20120

Log:
Cashing the configuration context created to improve performance



Modified:
   
branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java

Modified: 
branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
URL: 
http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java?rev=20120&r1=20119&r2=20120&view=diff
==============================================================================
--- 
branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
       (original)
+++ 
branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
       Tue Jul 29 10:17:00 2008
@@ -132,6 +132,8 @@
 public class MashupUtils {
 
     private static final Log log = LogFactory.getLog(MashupUtils.class);
+    private static ConfigurationContext configurationContextWithRepo = null;
+    private static ConfigurationContext configurationContextWithoutRepo = null;
 
     /**
      * Given a object obtained from javascript this method can be used to 
figure out whether the value if true or false.
@@ -1516,26 +1518,37 @@
 
     /**
      * Cretes a new ConfigurationContext with an empty repository
+     *
+     * @return A new ConfigurationContext
      * @throws AxisFault Thrown in case an exception occurs
      */
     public static ConfigurationContext createNewConfigurationContext() throws 
AxisFault {
         String wso2wsasHome = 
System.getProperty(MashupConstants.WSO2WSAS_HOME);
-            return 
ConfigurationContextFactory.createConfigurationContextFromFileSystem(
-                                wso2wsasHome + File.separator + 
MashupConstants.WORK_DIRECTORY +
-                                File.separator + 
MashupConstants.REPO_DIRECTORY + File.separator +
-                                        MashupConstants.REPO_DIRECTORY, null);
+        if (configurationContextWithoutRepo == null) {
+            configurationContextWithoutRepo = ConfigurationContextFactory
+                    .createConfigurationContextFromFileSystem(wso2wsasHome + 
File.separator +
+                            MashupConstants.WORK_DIRECTORY + File.separator + 
MashupConstants
+                            .REPO_DIRECTORY + File.separator + 
MashupConstants.REPO_DIRECTORY,
+                                                              null);
+        }
+        return configurationContextWithoutRepo;
     }
 
     /**
      * Cretes a new ConfigurationContext with the repository as 
Mashup_Home/.work/repo.
      * This repo will have addressing and rampart as mosules.
+     *
      * @return A new ConfigurationContext
      * @throws AxisFault Thrown in case an exception occurs
      */
     public static ConfigurationContext createNewConfigurationContextWithRepo() 
throws AxisFault {
         String wso2wsasHome = 
System.getProperty(MashupConstants.WSO2WSAS_HOME);
-            return 
ConfigurationContextFactory.createConfigurationContextFromFileSystem(
-                                wso2wsasHome + File.separator + 
MashupConstants.WORK_DIRECTORY +
-                                File.separator + 
MashupConstants.REPO_DIRECTORY, null);
+        if (configurationContextWithRepo == null) {
+            configurationContextWithRepo = ConfigurationContextFactory
+                    .createConfigurationContextFromFileSystem(wso2wsasHome + 
File.separator +
+                            MashupConstants.WORK_DIRECTORY + File.separator + 
MashupConstants
+                            .REPO_DIRECTORY, null);
+        }
+        return configurationContextWithRepo;
     }
 }

_______________________________________________
Mashup-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to