X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fruntime%2Forg.argeo.eclipse.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fspring%2FApplicationContextTracker.java;h=7a5a71e39789e48328f9c515d8a77662b1c8add1;hb=c76283038c867fc0ef9eb6fa623040c58c6139bb;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..7a5a71e39 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(); } @@ -102,8 +115,9 @@ class ApplicationContextTracker { if (contributorBundle.getState() != Bundle.ACTIVE && contributorBundle.getState() != Bundle.STARTING) { try { - log.info("Starting bundle: " - + contributorBundle.getSymbolicName()); + if (log.isTraceEnabled()) + log.trace("Starting bundle: " + + contributorBundle.getSymbolicName()); contributorBundle.start(); } catch (BundleException e) { e.printStackTrace(); @@ -114,6 +128,7 @@ class ApplicationContextTracker { contributorBundle, contributorBundle.getBundleContext()); ApplicationContext applicationContext = null; try { + applicationContextTracker.open(); applicationContext = applicationContextTracker .getApplicationContext(); } finally {