← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22152: DefaultSchemaService. Using ApplicationListener instead of @PostConstruct as transactions are use...

 

------------------------------------------------------------
revno: 22152
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-03-07 15:09:22 +0100
message:
  DefaultSchemaService. Using ApplicationListener instead of @PostConstruct as transactions are used in init method
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java


--
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-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2016-01-27 07:18:12 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2016-03-07 14:09:22 +0000
@@ -37,10 +37,11 @@
 import org.hisp.dhis.system.util.ReflectionUtils;
 import org.hisp.dhis.translation.TranslationService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
 import org.springframework.core.OrderComparator;
 import org.springframework.util.StringUtils;
 
-import javax.annotation.PostConstruct;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -50,7 +51,8 @@
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
-public class DefaultSchemaService implements SchemaService
+public class DefaultSchemaService 
+    implements ApplicationListener<ContextRefreshedEvent>, SchemaService
 {
     private Map<Class<?>, Schema> classSchemaMap = new HashMap<>();
 
@@ -72,8 +74,7 @@
     @Autowired
     private TranslationService translationService;
 
-    @PostConstruct
-    public void init()
+    public void onApplicationEvent( ContextRefreshedEvent contextRefreshedEvent )
     {
         for ( SchemaDescriptor descriptor : descriptors )
         {
@@ -99,7 +100,7 @@
             updateSelf( schema );
         }
     }
-
+    
     @Override
     public Schema getSchema( Class<?> klass )
     {