← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8653: Impl caching for configuration object. Made configuration object available to all responses.

 

------------------------------------------------------------
revno: 8653
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-10-23 10:01:42 +0200
message:
  Impl caching for configuration object. Made configuration object available to all responses.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml
  dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAccessSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAccessSettings.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2012-10-11 11:56:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2012-10-23 08:01:42 +0000
@@ -72,10 +72,11 @@
     final String KEY_TIME_FOR_SENDING_MESSAGE = "timeSendingMessage";
     final String KEY_SEND_MESSAGE_SCHEDULED_TASKS = "sendMessageScheduled";
     final String KEY_SCHEDULE_MESSAGE_TASKS = "scheduleMessage";
-    final String PHONE_NUMBER_AREA_CODE = "phoneNumberAreaCode";
+    final String KEY_PHONE_NUMBER_AREA_CODE = "phoneNumberAreaCode";
     final String KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS = "scheduleAggregateQueryBuilder";
     final String KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES = "keyScheduledAggregateQueryBuilderPeriodTypes";
     final String KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL = "aggQueryBuilderorgUnitGroupSetAggregationLevel";
+    final String KEY_CONFIGURATION = "keyConfig";
 
     final int DEFAULT_MAX_NUMBER_OF_ATTEMPTS = 20;
     final int DEFAULT_TIMEFRAME_MINUTES = 1;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-10-10 18:17:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-10-23 08:01:42 +0000
@@ -250,6 +250,7 @@
   <bean id="org.hisp.dhis.configuration.ConfigurationStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
     <property name="sessionFactory" ref="sessionFactory" />
     <property name="clazz" value="org.hisp.dhis.configuration.Configuration" />
+    <property name="cacheable" value="true" />
   </bean>
 
   <bean id="org.hisp.dhis.constant.ConstantStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml	2012-10-22 18:48:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml	2012-10-23 08:01:42 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.configuration.Configuration" table="configuration">
 
+    <cache usage="read-write" />
+
     <id name="id" column="configurationid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2012-09-22 14:37:38 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2012-10-23 08:01:42 +0000
@@ -12,6 +12,8 @@
 
   <!-- Hibernate entities -->
 
+  <cache name="org.hisp.dhis.configuration.Configuration" maxElementsInMemory="1" />
+
   <cache name="org.hisp.dhis.dataelement.DataElement" maxElementsInMemory="4000" />
 
   <cache name="org.hisp.dhis.dataelement.DataElementCategoryCombo" maxElementsInMemory="100" />

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2012-10-11 11:56:28 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2012-10-23 08:01:42 +0000
@@ -40,11 +40,13 @@
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART;
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_START_MODULE;
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_SYSTEM_IDENTIFIER;
-import static org.hisp.dhis.setting.SystemSettingManager.PHONE_NUMBER_AREA_CODE;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_PHONE_NUMBER_AREA_CODE;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_CONFIGURATION;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import org.hisp.dhis.configuration.ConfigurationService;
 import org.hisp.dhis.setting.SystemSettingManager;
 
 import com.opensymphony.xwork2.ActionInvocation;
@@ -68,6 +70,13 @@
         this.systemSettingManager = systemSettingManager;
     }
     
+    private ConfigurationService configurationService;
+
+    public void setConfigurationService( ConfigurationService configurationService )
+    {
+        this.configurationService = configurationService;
+    }
+
     // -------------------------------------------------------------------------
     // AroundInterceptor implementation
     // -------------------------------------------------------------------------
@@ -95,7 +104,9 @@
         map.put( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, systemSettingManager.getSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, false ) );
         map.put( KEY_FACTOR_OF_DEVIATION, systemSettingManager.getSystemSetting( KEY_FACTOR_OF_DEVIATION, DEFAULT_FACTOR_OF_DEVIATION ) );
         map.put( KEY_COMPLETENESS_OFFSET, systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET, DEFAULT_COMPLETENESS_OFFSET ) );
-        map.put( PHONE_NUMBER_AREA_CODE, systemSettingManager.getSystemSetting( PHONE_NUMBER_AREA_CODE, "" ) );
+        map.put( KEY_PHONE_NUMBER_AREA_CODE, systemSettingManager.getSystemSetting( KEY_PHONE_NUMBER_AREA_CODE, "" ) );
+        map.put( KEY_CONFIGURATION, configurationService.getConfiguration() );
+        
         invocation.getStack().push( map );
         
         return invocation.invoke();

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2012-10-16 13:26:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2012-10-23 08:01:42 +0000
@@ -551,7 +551,8 @@
   </bean>
 
   <bean id="org.hisp.dhis.interceptor.SystemSettingInterceptor" class="org.hisp.dhis.interceptor.SystemSettingInterceptor">
-    <property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
+    <property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />    
+    <property name="configurationService" ref="org.hisp.dhis.configuration.ConfigurationService" />
   </bean>
 
   <bean id="org.hisp.dhis.interceptor.ContextInterceptor" class="org.hisp.dhis.interceptor.ContextInterceptor">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAccessSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAccessSettingsAction.java	2012-10-22 18:48:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAccessSettingsAction.java	2012-10-23 08:01:42 +0000
@@ -32,8 +32,6 @@
 import java.util.List;
 
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
-import org.hisp.dhis.configuration.Configuration;
-import org.hisp.dhis.configuration.ConfigurationService;
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -47,22 +45,12 @@
     implements Action
 {
     @Autowired
-    private ConfigurationService configurationService;
-    
-    @Autowired
     private UserService userService;
 
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
 
-    private Configuration configuration;
-
-    public Configuration getConfiguration()
-    {
-        return configuration;
-    }
-    
     private List<UserAuthorityGroup> userRoles = new ArrayList<UserAuthorityGroup>();
 
     public List<UserAuthorityGroup> getUserRoles()
@@ -76,8 +64,6 @@
 
     public String execute()
     {
-        configuration = configurationService.getConfiguration();
-        
         userRoles = new ArrayList<UserAuthorityGroup>( userService.getAllUserAuthorityGroups() );
         
         Collections.sort( userRoles, IdentifiableObjectNameComparator.INSTANCE );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java	2012-10-03 18:12:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java	2012-10-23 08:01:42 +0000
@@ -185,7 +185,7 @@
             omitIndicatorsZeroNumeratorDataMart );
         systemSettingManager.saveSystemSetting( KEY_FACTOR_OF_DEVIATION, factorDeviation );
         systemSettingManager.saveSystemSetting( KEY_COMPLETENESS_OFFSET, completenessOffset );
-        systemSettingManager.saveSystemSetting( PHONE_NUMBER_AREA_CODE, phoneNumberAreaCode );
+        systemSettingManager.saveSystemSetting( KEY_PHONE_NUMBER_AREA_CODE, phoneNumberAreaCode );
 
         Configuration configuration = configurationService.getConfiguration();
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAccessSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAccessSettings.vm	2012-10-22 18:48:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAccessSettings.vm	2012-10-23 08:01:42 +0000
@@ -12,7 +12,7 @@
 } );    
 </script>
 
-#set( $curRole = $configuration.selfRegistrationRole )
+#set( $curRole = $keyConfig.selfRegistrationRole )
 
 <h3>$i18n.getString( "access_settings" )</h3>