[jboss-cvs] JBossAS SVN: r95463 - in projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org: ops4j/pax/web/extender/war/internal and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 23 01:54:50 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-23 01:54:50 -0400 (Fri, 23 Oct 2009)
New Revision: 95463
Modified:
projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppActivator.java
projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/ops4j/pax/web/extender/war/internal/WebAppPublisherExt.java
Log:
Gracefully wait 5000ms for the WebContainer to become available
Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppActivator.java 2009-10-23 05:45:19 UTC (rev 95462)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppActivator.java 2009-10-23 05:54:50 UTC (rev 95463)
@@ -50,7 +50,8 @@
webappParserInterceptor.start();
// Register the WebApp publisher interceptor
- webappPublishInterceptor = new WebAppPublisherInterceptor(context, new WebAppPublisherExt());
+ WebAppPublisherExt publisher = new WebAppPublisherExt(context);
+ webappPublishInterceptor = new WebAppPublisherInterceptor(context, publisher);
webappPublishInterceptor.start();
}
Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/ops4j/pax/web/extender/war/internal/WebAppPublisherExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/ops4j/pax/web/extender/war/internal/WebAppPublisherExt.java 2009-10-23 05:45:19 UTC (rev 95462)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/ops4j/pax/web/extender/war/internal/WebAppPublisherExt.java 2009-10-23 05:54:50 UTC (rev 95463)
@@ -21,6 +21,11 @@
*/
package org.ops4j.pax.web.extender.war.internal;
+import org.ops4j.pax.web.extender.war.internal.model.WebApp;
+import org.ops4j.pax.web.service.WebContainer;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
//$Id$
/**
@@ -31,4 +36,39 @@
*/
public class WebAppPublisherExt extends WebAppPublisher
{
+ private BundleContext context;
+
+ public WebAppPublisherExt(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ @Override
+ public void publish(WebApp webapp)
+ {
+ // Gracefully wait 5000ms for the WebContainer to become available
+ int timeout = 25;
+ ServiceReference sref = null;
+ while (sref == null && 0 < timeout--)
+ {
+ sref = context.getServiceReference(WebContainer.class.getName());
+ if (sref == null)
+ {
+ try
+ {
+ Thread.sleep(200);
+ }
+ catch (InterruptedException ex)
+ {
+ // ignore
+ }
+ }
+ }
+
+ if (sref == null)
+ throw new IllegalStateException("WebContainer not available");
+
+ // Publish the WebApp metadata
+ super.publish(webapp);
+ }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list