From c5bdc019a2b7bfedd606b9531b4cd0aad66291e9 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Tue, 11 Jun 2013 18:39:15 +1000 Subject: [PATCH] 409801 Jetty should allow webdefault to be specified using a relative location when running in OSGi --- .../osgi/boot/AbstractWebAppProvider.java | 26 +++++++++++++++---- .../src/test/config}/etc/webdefault.xml | 0 2 files changed, 21 insertions(+), 5 deletions(-) rename jetty-osgi/{jetty-osgi-boot/jettyhome => test-jetty-osgi/src/test/config}/etc/webdefault.xml (100%) diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java index 03d3dcc0e32..5e3d5b6658c 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java @@ -272,8 +272,13 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement if (tmp != null) { File defaultWebXml = getFile (tmp, bundleInstallLocation); - if (defaultWebXml != null && defaultWebXml.exists()) - _webApp.setDefaultsDescriptor(defaultWebXml.getAbsolutePath()); + if (defaultWebXml != null) + { + if (defaultWebXml.exists()) + _webApp.setDefaultsDescriptor(defaultWebXml.getAbsolutePath()); + else + LOG.warn(defaultWebXml.getAbsolutePath()+" does not exist"); + } } //Handle Require-TldBundle @@ -377,6 +382,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement HashMap properties = new HashMap(); properties.put("Server", getDeploymentManager().getServer()); properties.put(OSGiWebappConstants.JETTY_BUNDLE_ROOT, rootResource.toString()); + properties.put(OSGiServerConstants.JETTY_HOME, getDeploymentManager().getServer().getAttribute(OSGiServerConstants.JETTY_HOME)); xmlConfiguration.getProperties().putAll(properties); xmlConfiguration.configure(_webApp); } @@ -390,11 +396,21 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement { if (file == null) return null; - - if (file.startsWith("/") || file.startsWith("file:/")) + + if (file.startsWith("/") || file.startsWith("file:/")) //absolute location return new File(file); else - return new File(bundleInstall, file); + { + //relative location + //try inside the bundle first + File f = new File (bundleInstall, file); + if (f.exists()) return f; + String jettyHome = (String)getDeploymentManager().getServer().getAttribute(OSGiServerConstants.JETTY_HOME); + if (jettyHome != null) + return new File(jettyHome, file); + } + + return null; } } diff --git a/jetty-osgi/jetty-osgi-boot/jettyhome/etc/webdefault.xml b/jetty-osgi/test-jetty-osgi/src/test/config/etc/webdefault.xml similarity index 100% rename from jetty-osgi/jetty-osgi-boot/jettyhome/etc/webdefault.xml rename to jetty-osgi/test-jetty-osgi/src/test/config/etc/webdefault.xml