From 511165b595653b051e498d76938e25c08847229a Mon Sep 17 00:00:00 2001 From: Hugues Malphettes Date: Wed, 20 Apr 2011 08:22:39 +0000 Subject: [PATCH] bug 343352 git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3024 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 1 + .../osgi/boot/JettyBootstrapActivator.java | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 128c39b3f3d..75e6f56be6b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,6 +1,7 @@ jetty-7.4.1-SNAPSHOT + 343083 Set nested dispatch type. + 343277 add support for a context white list + + 343352 make sure that jetty.osgi.boot is activated when a WAB is registered jetty-7.4.0.v20110414 + 342504 Scanner Listener diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java index 2c84984c187..74c910c525a 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java @@ -29,6 +29,8 @@ import org.eclipse.jetty.webapp.WebAppContext; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; +import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceRegistration; import org.osgi.util.tracker.BundleTracker; @@ -207,7 +209,8 @@ public class JettyBootstrapActivator implements BundleActivator */ public static void registerWebapplication(Bundle contributor, String webappFolderPath, String contextPath) throws Exception { - WebAppContext contextHandler = new WebAppContext(); + checkBundleActivated(); + WebAppContext contextHandler = new WebAppContext(); Dictionary dic = new Hashtable(); dic.put(OSGiWebappConstants.SERVICE_PROP_WAR,webappFolderPath); dic.put(OSGiWebappConstants.SERVICE_PROP_CONTEXT_PATH,contextPath); @@ -236,6 +239,7 @@ public class JettyBootstrapActivator implements BundleActivator */ public static void registerWebapplication(Bundle contributor, String webappFolderPath, String contextPath, Dictionary dic) throws Exception { + checkBundleActivated(); WebAppContext contextHandler = new WebAppContext(); dic.put(OSGiWebappConstants.SERVICE_PROP_WAR,webappFolderPath); dic.put(OSGiWebappConstants.SERVICE_PROP_CONTEXT_PATH,contextPath); @@ -275,6 +279,7 @@ public class JettyBootstrapActivator implements BundleActivator */ public static void registerContext(Bundle contributor, String contextFilePath, Dictionary dic) throws Exception { + checkBundleActivated(); ContextHandler contextHandler = new ContextHandler(); dic.put(OSGiWebappConstants.SERVICE_PROP_CONTEXT_FILE_PATH,contextFilePath); dic.put(IWebBundleDeployerHelper.INTERNAL_SERVICE_PROP_UNKNOWN_CONTEXT_HANDLER_TYPE,Boolean.TRUE.toString()); @@ -286,5 +291,25 @@ public class JettyBootstrapActivator implements BundleActivator // todo } + /** + * Since org.eclipse.jetty.osgi.boot does not have a lazy activation policy + * when one fo the static methods to register a webapp is called we should make sure that + * the bundle is started. + */ + private static void checkBundleActivated() + { + if (INSTANCE == null) { + Bundle thisBundle = FrameworkUtil.getBundle(JettyBootstrapActivator.class); + try + { + thisBundle.start(); + } + catch (BundleException e) + { + //nevermind. + } + } + } + } \ No newline at end of file