airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hes...@apache.org
Subject svn commit: r1400146 - in /airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest: resources/RestServicesConstants.java utils/RegistryListener.java
Date Fri, 19 Oct 2012 16:06:54 GMT
Author: heshan
Date: Fri Oct 19 16:06:54 2012
New Revision: 1400146

URL: http://svn.apache.org/viewvc?rev=1400146&view=rev
Log:
Reading configurations through properties. Introduced a Constant class.

Added:
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RestServicesConstants.java
Modified:
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/RegistryListener.java

Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RestServicesConstants.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RestServicesConstants.java?rev=1400146&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RestServicesConstants.java
(added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RestServicesConstants.java
Fri Oct 19 16:06:54 2012
@@ -0,0 +1,8 @@
+package org.apache.airavata.services.registry.rest.resources;
+
+public class RestServicesConstants {
+    public static final String AIRAVATA_SERVER_PROPERTIES = "airavata-server.properties";
+    public static final String GATEWAY_ID = "gateway.id";
+    public static final String REGISTRY_USER = "registry.user";
+    public static final String AIRAVATA_REGISTRY = "airavataRegistry";
+}

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/RegistryListener.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/RegistryListener.java?rev=1400146&r1=1400145&r2=1400146&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/RegistryListener.java
(original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/RegistryListener.java
Fri Oct 19 16:06:54 2012
@@ -4,6 +4,7 @@ import org.apache.airavata.registry.api.
 import org.apache.airavata.registry.api.AiravataRegistryFactory;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
+import org.apache.airavata.services.registry.rest.resources.RestServicesConstants;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
@@ -13,24 +14,26 @@ import java.net.URL;
 import java.util.Properties;
 
 public class RegistryListener implements ServletContextListener {
-    public static final String AIRAVATA_SERVER_PROPERTIES = "airavata-server.properties";
     private static AiravataRegistry2 airavataRegistry;
 
     public void contextInitialized(ServletContextEvent servletContextEvent) {
         try{
             ServletContext servletContext = servletContextEvent.getServletContext();
 
-            URL url = this.getClass().getClassLoader().getResource(AIRAVATA_SERVER_PROPERTIES);
+            URL url = this.getClass().getClassLoader().
+                    getResource(RestServicesConstants.AIRAVATA_SERVER_PROPERTIES);
             Properties properties = new Properties();
             try {
                 properties.load(url.openStream());
             } catch (IOException e) {
                 e.printStackTrace();
             }
-            String gatewayID = properties.getProperty("gateway.id");
+            String gatewayID = properties.getProperty(RestServicesConstants.GATEWAY_ID);
+            String airavataUser = properties.getProperty(RestServicesConstants.REGISTRY_USER);
 
-        airavataRegistry = AiravataRegistryFactory.getRegistry(new Gateway(gatewayID), new
AiravataUser("admin"));
-        servletContext.setAttribute("airavataRegistry", airavataRegistry);
+        airavataRegistry = AiravataRegistryFactory.
+                getRegistry(new Gateway(gatewayID), new AiravataUser(airavataUser));
+        servletContext.setAttribute(RestServicesConstants.AIRAVATA_REGISTRY, airavataRegistry);
         }catch (Exception e) {
             e.printStackTrace();
         }



Mime
View raw message