You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2014/12/08 18:06:52 UTC

jena git commit: Hunt for the webapp under FUSEKI_HOME

Repository: jena
Updated Branches:
  refs/heads/master 98602a0d1 -> f72a50696


Hunt for the webapp under FUSEKI_HOME


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

Branch: refs/heads/master
Commit: f72a506963e1629fdc3e4013be0d6ac9d0620922
Parents: 98602a0
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Dec 8 17:06:44 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Dec 8 17:06:44 2014 +0000

----------------------------------------------------------------------
 .../apache/jena/fuseki/jetty/JettyFuseki.java   | 41 +++++++++++++++-----
 1 file changed, 32 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/f72a5069/jena-fuseki2/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java b/jena-fuseki2/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
index 2c016e1..907c627 100644
--- a/jena-fuseki2/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
+++ b/jena-fuseki2/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
@@ -67,8 +67,11 @@ public class JettyFuseki {
     
     // webapp setup - standard maven layout
     public static       String contextpath     = "/" ;
-    public static final String resourceBase1   = "webapp" ;             // Standalone jar
-    public static final String resourceBase2   = "src/main/webapp" ;    // Development
+    // Standalone jar
+    public static final String resourceBase1   = "webapp" ;
+    // Development
+    public static final String resourceBase2   = "src/main/webapp" ;
+    
 
     /**
      * Default setup which requires a {@link org.apache.jena.fuseki.jetty.JettyServerConfig}
@@ -169,14 +172,26 @@ public class JettyFuseki {
     public static WebAppContext createWebApp(String contextPath) {
       WebAppContext webapp = new WebAppContext();
       webapp.getServletContext().getContextHandler().setMaxFormContentSize(10 * 1000 * 1000) ;
-      String resourceBase = null ;
-      if ( /*resourceBase == null &&*/ FileOps.exists(resourceBase1) )
-          resourceBase = resourceBase1 ;
-      if ( resourceBase == null && FileOps.exists(resourceBase2) )
-          resourceBase = resourceBase2 ;
-      if ( resourceBase == null )
-          Fuseki.serverLog.warn("Can't find resourceBase (tried "+resourceBase1+" and "+resourceBase2+")") ;
       
+      // Hunt for the webapp for the standalone jar (or development system). 
+      // Note that Path FUSEKI_HOME is not initialized until the webapp starts
+      // so it is not available here.
+      
+      String resourceBase3 = null ;
+      String resourceBase4 = null ;
+      if ( System.getenv("FUSEKI_HOME") != null ) {
+          resourceBase3 = System.getenv("FUSEKI_HOME")+"/"+resourceBase1 ;
+          resourceBase3 = System.getenv("FUSEKI_HOME")+"/"+resourceBase2 ;
+      }
+      
+      String resourceBase = tryResourceBase(resourceBase1, null) ;
+      resourceBase = tryResourceBase(resourceBase2, resourceBase) ;
+      resourceBase = tryResourceBase(resourceBase3, resourceBase) ;
+      resourceBase = tryResourceBase(resourceBase4, resourceBase) ;
+
+      if ( resourceBase == null )
+          Fuseki.serverLog.warn("Can't find resourceBase (tried "+resourceBase1+", "+resourceBase2+" and "+resourceBase3+")") ;
+
       webapp.setDescriptor(resourceBase+"/WEB-INF/web.xml");
       webapp.setResourceBase(resourceBase);
       webapp.setContextPath(contextPath);
@@ -193,6 +208,14 @@ public class JettyFuseki {
       return webapp ;
     }
     
+    private static String tryResourceBase(String maybeResourceBase, String currentResourceBase) {
+        if ( currentResourceBase != null )
+            return currentResourceBase ;
+        if ( maybeResourceBase != null && FileOps.exists(maybeResourceBase) )
+            return maybeResourceBase ;
+        return currentResourceBase ;
+    }
+    
     private void buildServerWebapp(String contextPath, String jettyConfig, boolean enableCompression) {
         if ( jettyConfig != null )
             // --jetty-config=jetty-fuseki.xml