ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject git commit: ARGUS-71: Fixed to do Argus Configuration lookup on CLASSPATH
Date Fri, 19 Sep 2014 20:33:48 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master daac1c6de -> a9a959919


ARGUS-71: Fixed to do Argus Configuration lookup on CLASSPATH

Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/a9a95991
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/a9a95991
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/a9a95991

Branch: refs/heads/master
Commit: a9a959919aa939e15d2bdada155da22720422420
Parents: daac1c6
Author: sneethiraj <sneethir@apache.org>
Authored: Fri Sep 19 15:10:49 2014 -0400
Committer: sneethiraj <sneethir@apache.org>
Committed: Fri Sep 19 15:10:49 2014 -0400

----------------------------------------------------------------------
 .../xasecure/server/tomcat/EmbededServer.java   | 46 ++++++++++++++++++--
 1 file changed, 43 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a9a95991/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
----------------------------------------------------------------------
diff --git a/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
b/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
index 72f60c6..1b3373b 100644
--- a/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
+++ b/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
@@ -24,6 +24,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URL;
 import java.util.Properties;
 import java.util.logging.Logger;
 
@@ -59,18 +60,23 @@ public class EmbededServer {
 	
 	
 	private void initConfig() {
+		
+		String cfgFile =  getResourceFileName(configFile) ;
+		
 		serverConfigProperties.clear() ;
+		
 		InputStream in = null ;
 		try {
-			in = new FileInputStream(configFile) ;
+			
+			in = new FileInputStream(cfgFile) ;
 			serverConfigProperties.load(in);
 		}
 		catch(FileNotFoundException fnf) {
-			LOG.severe("Unable to find config  file [" + configFile + "]");
+			LOG.severe("Unable to find config  file [" + cfgFile + "]");
 			fnf.printStackTrace(); 
 		}
 		catch(IOException ioe) {
-			LOG.severe("Unable to load config  file [" + configFile + "]");
+			LOG.severe("Unable to load config  file [" + cfgFile + "]");
 			ioe.printStackTrace(); 
 		}
 		serverConfigProperties.list(System.out);
@@ -175,5 +181,39 @@ public class EmbededServer {
 		}
 		return ret;
 	}
+	
+	private String getResourceFileName(String aResourceName) {
+		
+		String ret = aResourceName ;
+		
+		ClassLoader cl = getClass().getClassLoader() ;
+		
+		for (String path : new String[] { aResourceName, "/" + aResourceName }) {
+			
+			try {
+				URL lurl = cl.getResource(path) ;
+		
+				if (lurl != null) {
+					ret = lurl.getFile() ;
+				}
+			}
+			catch(Throwable t) {
+				ret = null;
+			}
+			if (ret != null) {
+				break ;
+			}
+
+		}
+		
+		if (ret == null) {
+			ret = aResourceName ;
+		}
+		
+		return ret ;
+		
+		
+		
+	}
 
 }


Mime
View raw message