Return-Path: X-Original-To: apmail-argus-commits-archive@minotaur.apache.org Delivered-To: apmail-argus-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 02163111F8 for ; Fri, 19 Sep 2014 20:34:11 +0000 (UTC) Received: (qmail 53624 invoked by uid 500); 19 Sep 2014 20:34:10 -0000 Delivered-To: apmail-argus-commits-archive@argus.apache.org Received: (qmail 53605 invoked by uid 500); 19 Sep 2014 20:34:10 -0000 Mailing-List: contact commits-help@argus.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@argus.incubator.apache.org Delivered-To: mailing list commits@argus.incubator.apache.org Received: (qmail 53596 invoked by uid 99); 19 Sep 2014 20:34:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Sep 2014 20:34:10 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 19 Sep 2014 20:34:09 +0000 Received: (qmail 53507 invoked by uid 99); 19 Sep 2014 20:33:49 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Sep 2014 20:33:49 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D0DEDA1D9A1; Fri, 19 Sep 2014 20:33:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sneethir@apache.org To: commits@argus.incubator.apache.org Message-Id: <6b59a02ff8e445c481d807cc6db9a552@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: ARGUS-71: Fixed to do Argus Configuration lookup on CLASSPATH Date: Fri, 19 Sep 2014 20:33:48 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org 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 Authored: Fri Sep 19 15:10:49 2014 -0400 Committer: sneethiraj 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 ; + + + + } }