airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patanac...@apache.org
Subject svn commit: r1166915 - in /incubator/airavata/trunk/modules/gfac-core: ./ src/main/java/org/apache/airavata/core/gfac/factory/ src/main/java/org/apache/airavata/core/gfac/services/impl/ src/main/resources/ src/test/resources/
Date Thu, 08 Sep 2011 21:33:41 GMT
Author: patanachai
Date: Thu Sep  8 21:33:41 2011
New Revision: 1166915

URL: http://svn.apache.org/viewvc?rev=1166915&view=rev
Log:
Change to Apache Commons Configuration

Modified:
    incubator/airavata/trunk/modules/gfac-core/pom.xml
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/PropertyServiceFactory.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
    incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties
    incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties

Modified: incubator/airavata/trunk/modules/gfac-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/pom.xml?rev=1166915&r1=1166914&r2=1166915&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/pom.xml (original)
+++ incubator/airavata/trunk/modules/gfac-core/pom.xml Thu Sep  8 21:33:41 2011
@@ -54,6 +54,12 @@
             <artifactId>bcprov-jdk15</artifactId>
             <version>143</version>
         </dependency>
+        
+        <dependency>
+            <groupId>commons-configuration</groupId>
+            <artifactId>commons-configuration</artifactId>
+            <version>1.6</version>
+        </dependency>
 
         <!-- Logging -->
         <dependency>

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/PropertyServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/PropertyServiceFactory.java?rev=1166915&r1=1166914&r2=1166915&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/PropertyServiceFactory.java
(original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/PropertyServiceFactory.java
Thu Sep  8 21:33:41 2011
@@ -21,29 +21,27 @@
 
 package org.apache.airavata.core.gfac.factory;
 
-import java.util.Properties;
-
 import org.apache.airavata.core.gfac.services.GenericService;
 import org.apache.airavata.core.gfac.services.impl.PropertiesBasedServiceImpl;
 
 public class PropertyServiceFactory extends AbstractServiceFactory {
 
     private GenericService service;
-    private Properties properties;
+    private String fileName;
 
     public PropertyServiceFactory(){        
     }
     
-    public PropertyServiceFactory(Properties prop){
-        this.properties = prop;
+    public PropertyServiceFactory(String fileName){
+        this.fileName = fileName;
     }
     
     public GenericService getGenericService() {
         if (service == null) {
-            if(this.properties == null){
+            if(this.fileName == null){
                 service = new PropertiesBasedServiceImpl();
             }else{
-                service = new PropertiesBasedServiceImpl(this.properties);
+                service = new PropertiesBasedServiceImpl(this.fileName);
             }
         }
         return service;

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java?rev=1166915&r1=1166914&r2=1166915&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
(original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
Thu Sep  8 21:33:41 2011
@@ -21,10 +21,9 @@
 
 package org.apache.airavata.core.gfac.services.impl;
 
-import java.io.IOException;
 import java.lang.reflect.Array;
-import java.net.URL;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
@@ -42,6 +41,9 @@ import org.apache.airavata.core.gfac.ext
 import org.apache.airavata.core.gfac.extension.PreExecuteChain;
 import org.apache.airavata.core.gfac.scheduler.Scheduler;
 import org.apache.airavata.core.gfac.utils.LogUtils;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,7 +60,7 @@ public class PropertiesBasedServiceImpl 
     /*
      * default properties file location
      */
-    private static final String FILENAME = "service.properties";
+    private static final String DEFAULT_FILENAME = "service.properties";
 
     /*
      * context name
@@ -96,13 +98,15 @@ public class PropertiesBasedServiceImpl 
     public static final String MYPROXY_PASS = "myproxy.pass";
     public static final String MYPROXY_LIFE = "myproxy.life";
 
-    private Properties properties;
+    
     private Scheduler scheduler;
     private PreExecuteChain[] preChain;
     private PostExecuteChain[] postChain;
     private DataServiceChain[] dataChain;
-
     private Registry registryService;
+    
+    private String fileName = DEFAULT_FILENAME;
+    private Configuration config;
 
     /**
      * Default constructor
@@ -112,14 +116,13 @@ public class PropertiesBasedServiceImpl 
     }
 
     /**
-     * Constructor with passing properties
+     * Constructor with passing file
      * 
      * @param prop
      */
-    public PropertiesBasedServiceImpl(Properties prop) {
-        this.properties = prop;
-        log.debug("Create PropertiesBasedServiceImpl with Properties");
-        LogUtils.displayProperties(log, prop);
+    public PropertiesBasedServiceImpl(String fileName) {
+        this.fileName = fileName;
+        log.debug("Create PropertiesBasedServiceImpl with Filename");
     }
 
     /*
@@ -135,17 +138,13 @@ public class PropertiesBasedServiceImpl 
             /*
              * Load properties only it is not loaded
              */
-            if (this.properties == null) {
-                log.info("try to load default properties: " + FILENAME);
-                URL url = this.getClass().getClassLoader().getResource(FILENAME);
-
-                this.properties = new Properties();
-                this.properties.load(url.openStream());
+            if (this.config == null || this.config.isEmpty()) {
+                this.config = new PropertiesConfiguration(this.fileName);
 
                 log.info("Properties loaded");
-                LogUtils.displayProperties(log, properties);
+                LogUtils.displayProperties(log, getProperties());
             }
-        } catch (IOException e) {
+        } catch (ConfigurationException e) {
             throw new GfacException("Error initialize the PropertiesBasedServiceImpl", e);
         }
     }
@@ -214,7 +213,7 @@ public class PropertiesBasedServiceImpl 
                 /*
                  * Remove unnecessary key
                  */
-                Map<String, String> map = new HashMap<String, String>((Map) this.properties);
+                Map<String, String> map = new HashMap<String, String>((Map)getProperties());
                 map.remove(JCR_CLASS);
                 map.remove(JCR_USER);
                 map.remove(JCR_PASS);
@@ -334,6 +333,16 @@ public class PropertiesBasedServiceImpl 
         return dataChain;
     }
 
+    private Properties getProperties(){
+        Properties prop = new Properties();
+        for (Iterator iterator = this.config.getKeys(); iterator.hasNext();) {
+            String key = (String) iterator.next();
+            prop.put(key, this.config.getString(key));            
+        }
+        return prop;
+    }
+    
+    
     /**
      * 
      * @param propertyName
@@ -342,7 +351,7 @@ public class PropertiesBasedServiceImpl 
      * @throws GfacException
      */
     private String loadFromProperty(String propertyName, boolean required) throws ServiceException
{
-        String propValue = this.properties.getProperty(propertyName);
+        String propValue = this.config.getString(propertyName);
         if (propValue == null) {
             if (required)
                 throw new ServiceException("Property \"" + propertyName + "\" is not found");
@@ -367,7 +376,7 @@ public class PropertiesBasedServiceImpl 
         /*
          * get class names
          */
-        String classNames[] = this.properties.getProperty(propertyName).split(",");
+        String classNames[] = this.config.getStringArray(propertyName);
 
         /*
          * init instance of that class

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties?rev=1166915&r1=1166914&r2=1166915&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties Thu Sep
 8 21:33:41 2011
@@ -26,9 +26,13 @@ jcr.user=admin
 jcr.pass=admin
 
 scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
-datachain.classes=org.apache.airavata.core.gfac.extension.data.RegistryDataService
-prechain.classes=org.apache.airavata.core.gfac.extension.pre.GridFtpInputStaging, org.apache.airavata.core.gfac.extension.pre.HttpInputStaging
-postchain.classes=org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
+
+datachain.classes= org.apache.airavata.core.gfac.extension.data.RegistryDataService
+
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.GridFtpInputStaging 
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.HttpInputStaging
+
+postchain.classes= org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
 
 #SSH key
 #ssh.key=/home/user/.ssh/id_rsa

Modified: incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties?rev=1166915&r1=1166914&r2=1166915&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties Thu Sep
 8 21:33:41 2011
@@ -21,17 +21,18 @@
 
 jcr.class=org.apache.jackrabbit.core.RepositoryFactoryImpl
 #jcr.class=org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory
-#org.apache.jackrabbit.repository.uri=http://localhost:8081/rmi
+#org.apache.jackrabbit.repository.uri=http://localhost:8080/rmi
 jcr.user=admin
 jcr.pass=admin
 
 scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
 
-datachain.classes=org.apache.airavata.core.gfac.extension.data.RegistryDataService
+datachain.classes= org.apache.airavata.core.gfac.extension.data.RegistryDataService
 
-prechain.classes=org.apache.airavata.core.gfac.extension.pre.GridFtpInputStaging, org.apache.airavata.core.gfac.extension.pre.HttpInputStaging
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.GridFtpInputStaging 
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.HttpInputStaging
 
-postchain.classes=org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
+postchain.classes= org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
 
 #SSH key
 #ssh.key=/home/user/.ssh/id_rsa



Mime
View raw message