Commits

Raza Ali committed 68388d5

Making ModelFileFormatService stateless

Service variables moved to a bean. Hopefully this fixes the
issue.

Comments (0)

Files changed (5)

grails-app/conf/spring/resources.groovy

 			bean.autowire = "byName"
 			bean.singleton = true
     }
+    modelFileFormatConfig(net.biomodels.jummp.core.ModelFileFormatConfig) { bean ->
+			bean.autowire = "byName"
+			bean.singleton = true
+    }
     ontologyLookupServiceResolver(net.biomodels.jummp.core.miriam.OntologyLookupResolver) { bean ->
         bean.scope = "prototype"
         supportedIdentifiers = [

grails-app/jobs/net/biomodels/jummp/core/RegistrationCheckerJob.groovy

  */
 class RegistrationCheckerJob {
     
-    def modelFileFormatService
     def grailsApplication
 	
     static triggers = {
     }
   
     def execute() {
-    	    System.out.println(modelFileFormatService.status())
+    	    grailsApplication.mainContext.getBean("modelFileFormatConfig").status()
     	    grailsApplication.mainContext.getBean("searchEngine").refreshIndex()
     }
 

grails-app/services/net/biomodels/jummp/core/ModelFileFormatService.groovy

     @SuppressWarnings("GrailsStatelessService")
     def grailsApplication
 
-    /**
-    * The registered services to handle ModelFormats
-    */
-    private final Map<String, String> services = new HashMap()
+    private Map<String,String> getServices() {
+    	    grailsApplication.mainContext.getBean("modelFileFormatConfig").getServices()
+    }
 
-    
-    /**
-    * The registered plugins to handle ModelFormats visualisations
-    */
-    private final Map<String, String> plugins = new HashMap()
-      
-    
-    public void status() {
-    	    System.out.println("MODEL FILE FORMAT SERVICE STATUS:")
-    	    System.out.println("SERVICES: "+services.inspect())
-    	    System.out.println("PLUGINS: "+plugins.inspect())
+    private Map<String,String> getControllers() {
+    	    grailsApplication.mainContext.getBean("modelFileFormatConfig").getControllers()
     }
+
     
     /**
      * Extracts the format of the supplied @p modelFiles.
         if (!modelFiles) {
             return null
         }
+        Map<String, String> services=getServices()
+
         String match = services.keySet().find {
             if (it == "UNKNOWN") return false
             String serviceName = services.getAt(it)
      * @throws IllegalArgumentException if the @p format has not been registered yet
      */
     @Profiled(tag = "modelFileFormatService.handleModelFormat")
-    void handleModelFormat(ModelFormatTransportCommand format, String service, String plugin) {
+    void handleModelFormat(ModelFormatTransportCommand format, String service, String controller) {
         ModelFormat modelFormat = ModelFormat.findByIdentifierAndFormatVersion(format.identifier, "")
         if (!modelFormat) {
             throw new IllegalArgumentException("ModelFormat ${format.properties} not registered in database")
         }
-        services.put(format.identifier, service)
-        plugins.put(format.identifier, plugin)
+        getServices().put(format.identifier, service)
+        getControllers().put(format.identifier, controller)
     }
 
     boolean validate(final List<File> model, String formatId) {
      * @return The folder where template for the model display can be found
      */
     String getPluginForFormat(final ModelFormatTransportCommand format) {
-    	    return plugins.get(format.identifier)
+    	    return getControllers().get(format.identifier)
     }
     
     /**
      */
     private FileFormatService serviceForFormat(final def format) {
         if (format) {
-             if (services.containsKey(format.identifier)) {
+            Map<String,String> services=getServices() 
+            if (services.containsKey(format.identifier)) {
                 return grailsApplication.mainContext.getBean((String)services.getAt(format.identifier))
             }
         } else {

src/groovy/net/biomodels/jummp/core/ModelFileFormatConfig.groovy

+package net.biomodels.jummp.core
+
+class ModelFileFormatConfig {
+    /**
+    * The registered services to handle ModelFormats
+    */
+    static final Map<String, String> services = new HashMap()
+
+    
+    /**
+    * The registered plugins to handle ModelFormats visualisations
+    */
+    static final Map<String, String> controllers = new HashMap()
+    
+    public Map<String,String> getServices() {
+    	    services
+    }
+    
+    public Map<String,String> getControllers() {
+    	    controllers
+    }
+
+    public void status() {
+    	    System.out.println("MODEL FILE FORMAT CONFIG STATUS:")
+    	    System.out.println("SERVICES: "+services.inspect())
+    	    System.out.println("PLUGINS: "+controllers.inspect())
+    }
+    
+    
+}

src/groovy/net/biomodels/jummp/core/ReferenceTracker.groovy

     	    weakRefs.put(folder,ref)
     }
     
+    
 }