Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 77019 invoked from network); 13 Jan 2011 17:18:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Jan 2011 17:18:13 -0000 Received: (qmail 36943 invoked by uid 500); 13 Jan 2011 17:18:13 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 36461 invoked by uid 500); 13 Jan 2011 17:18:11 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 36244 invoked by uid 99); 13 Jan 2011 17:18:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jan 2011 17:18:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jan 2011 17:18:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AADEB23888E7; Thu, 13 Jan 2011 17:17:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1058670 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/ apollo-web/src/main/resources/META-INF/ apollo-web/src/main/webapp/WEB-INF/ Date: Thu, 13 Jan 2011 17:17:41 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110113171741.AADEB23888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: chirino Date: Thu Jan 13 17:17:41 2011 New Revision: 1058670 URL: http://svn.apache.org/viewvc?rev=1058670&view=rev Log: Be smarter about auto detecting where the webapp module is located if the apollo.home system properties are not set. Added: activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/ activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/apollo-web.txt activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/apollo-web.txt Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala?rev=1058670&r1=1058669&r2=1058670&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala (original) +++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala Thu Jan 13 17:17:41 2011 @@ -59,15 +59,50 @@ object JettyWebServer extends Log { val webapp = { import FileSupport._ - val x = System.getProperty("apollo.webapp") - if( x != null ) { - new File(x) - } else { - (Option(System.getProperty("apollo.home")).flatMap { home=> + var rc:File = null + + Option(System.getProperty("apollo.webapp")).foreach{ x=> + rc = new File(x) + } + + if( rc==null ) { + Option(System.getProperty("apollo.home")).foreach { home=> val lib = new File(home) / "lib" - lib.list.find( _.matches("""apollo-web-.+-slim.war""")).map(lib / _) - }).getOrElse(null) + rc = lib.list.find( _.matches("""apollo-web-.+-slim.war""")).map(lib / _).getOrElse(null) + } } + + // the war might be on the classpath.. + if( rc==null ) { + val url = JettyWebServer.getClass.getClassLoader.getResource("WEB-INF/apollo-web.txt") + rc = if(url== null) { + null + } else { + val rc = new File( url.getFile.stripSuffix("!/WEB-INF/apollo-web.txt") ) + if( rc.isFile ) { + rc + } else { + null + } + } + } + + // the war project source module might be on the classpath (being run from an IDE) + if( rc==null ) { + val url = JettyWebServer.getClass.getClassLoader.getResource("META-INF/apollo-web.txt") + rc = if(url==null) { + null + } else { + val rc = new File( url.getFile.stripSuffix("/META-INF/apollo-web.txt") ) + if( rc.isDirectory ) { + rc/".."/".."/"src"/"main"/"webapp" + } else { + null + } + } + } + + rc } } Added: activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/apollo-web.txt URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/apollo-web.txt?rev=1058670&view=auto ============================================================================== --- activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/apollo-web.txt (added) +++ activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/apollo-web.txt Thu Jan 13 17:17:41 2011 @@ -0,0 +1 @@ +This is just a marker file so we can find the war if it's in the classpath. \ No newline at end of file Added: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/apollo-web.txt URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/apollo-web.txt?rev=1058670&view=auto ============================================================================== --- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/apollo-web.txt (added) +++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/apollo-web.txt Thu Jan 13 17:17:41 2011 @@ -0,0 +1 @@ +This is just a marker file so we can find the war if it's in the classpath. \ No newline at end of file