X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=eclipse%2Fruntime%2Forg.argeo.eclipse.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fspring%2FApplicationContextTracker.java;h=816edc1be864edc0173b187b342907c5e66208d3;hb=21a7775f246e442c5fa73f16c8e108d81aa0ffd8;hp=805d11d8a580632bc71acc7eb72bc2e19f8e35fc;hpb=92daeb190be66653f39544ae9b5a2f2c31a60797;p=lgpl%2Fargeo-commons.git 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 {