From: Mathieu Baudier Date: Thu, 28 Apr 2011 04:50:08 +0000 (+0000) Subject: Increase application context tracker timeout and make it configurable X-Git-Tag: argeo-commons-2.1.30~1270 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=6dafb9a0b459e1a7f6418fd01123a8e08a04b617;p=lgpl%2Fargeo-commons.git Increase application context tracker timeout and make it configurable ASSIGNED - bug 17: Generalize agent management and registration beyond JMS https://bugzilla.argeo.org/show_bug.cgi?id=17 git-svn-id: https://svn.argeo.org/commons/trunk@4480 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/ApplicationContextTracker.java b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/ApplicationContextTracker.java index 805d11d8a..816edc1be 100644 --- a/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/ApplicationContextTracker.java +++ b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/ApplicationContextTracker.java @@ -30,6 +30,8 @@ import org.osgi.util.tracker.ServiceTracker; import org.springframework.context.ApplicationContext; /** + * Tracks Spring application context published as services. + * * @author Heiko Seeberger * @author Mathieu Baudier */ @@ -40,6 +42,11 @@ class ApplicationContextTracker { private static final String FILTER = "(&(objectClass=org.springframework.context.ApplicationContext)" //$NON-NLS-1$ + "(org.springframework.context.service.name={0}))"; //$NON-NLS-1$ + public final static String APPLICATION_CONTEXT_TRACKER_TIMEOUT = "org.argeo.eclipse.spring.applicationContextTrackerTimeout"; + + private static Long defaultTimeout = Long.parseLong(System.getProperty( + APPLICATION_CONTEXT_TRACKER_TIMEOUT, "30000")); + private ServiceTracker applicationContextServiceTracker; /** @@ -59,12 +66,18 @@ class ApplicationContextTracker { applicationContextServiceTracker = new ServiceTracker( factoryBundleContext, FrameworkUtil.createFilter(filter), null); - applicationContextServiceTracker.open(); + // applicationContextServiceTracker.open(); } catch (final InvalidSyntaxException e) { e.printStackTrace(); } } + public void open() { + if (applicationContextServiceTracker != null) { + applicationContextServiceTracker.open(); + } + } + public void close() { if (applicationContextServiceTracker != null) { applicationContextServiceTracker.close(); @@ -76,7 +89,7 @@ class ApplicationContextTracker { if (applicationContextServiceTracker != null) { try { applicationContext = (ApplicationContext) applicationContextServiceTracker - .waitForService(5000); + .waitForService(defaultTimeout); } catch (InterruptedException e) { e.printStackTrace(); } @@ -114,6 +127,7 @@ class ApplicationContextTracker { contributorBundle, contributorBundle.getBundleContext()); ApplicationContext applicationContext = null; try { + applicationContextTracker.open(); applicationContext = applicationContextTracker .getApplicationContext(); } finally {