You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by he...@apache.org on 2012/10/19 18:00:03 UTC

svn commit: r1400145 - /airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/RegistryListener.java

Author: heshan
Date: Fri Oct 19 16:00:03 2012
New Revision: 1400145

URL: http://svn.apache.org/viewvc?rev=1400145&view=rev
Log:
Reading the gateway from a properties file rather than hardcoding.

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

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=1400145&r1=1400144&r2=1400145&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:00:03 2012
@@ -8,24 +8,28 @@ import org.apache.airavata.registry.api.
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
+import java.io.IOException;
+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;
-//    private static Axis2Registry axis2Registry;
-//    private static DataRegistry dataRegistry;
 
     public void contextInitialized(ServletContextEvent servletContextEvent) {
         try{
-        ServletContext servletContext = servletContextEvent.getServletContext();
-//        URI url = new URI("http://localhost:8081/rmi");
-//        String username = "admin";
-//        String password = "admin";
-//        HashMap<String, String> map = new HashMap<String, String>();
-//        map.put("org.apache.jackrabbit.repository.uri", url.toString());
+            ServletContext servletContext = servletContextEvent.getServletContext();
 
+            URL url = this.getClass().getClassLoader().getResource(AIRAVATA_SERVER_PROPERTIES);
+            Properties properties = new Properties();
+            try {
+                properties.load(url.openStream());
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            String gatewayID = properties.getProperty("gateway.id");
 
-        airavataRegistry = AiravataRegistryFactory.getRegistry(new Gateway("default"), new AiravataUser("admin"));
+        airavataRegistry = AiravataRegistryFactory.getRegistry(new Gateway(gatewayID), new AiravataUser("admin"));
         servletContext.setAttribute("airavataRegistry", airavataRegistry);
         }catch (Exception e) {
             e.printStackTrace();