Author: keith Date: Tue Jul 29 10:16:57 2008 New Revision: 20119 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=20119
Log: Cashing the configuration context created to improve performance Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java?rev=20119&r1=20118&r2=20119&view=diff ============================================================================== --- trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java (original) +++ trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java Tue Jul 29 10:16:57 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
