Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 403628 | Differences between
and this patch

Collapse All | Expand All

(-)a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java (-11 / +17 lines)
Lines 271-295 class LifecycleManager implements DisposableBean { Link Here
271
	 * @param bundle
271
	 * @param bundle
272
	 */
272
	 */
273
	protected void maybeCloseApplicationContextFor(Bundle bundle) {
273
	protected void maybeCloseApplicationContextFor(Bundle bundle) {
274
		final ConfigurableOsgiBundleApplicationContext context =
274
		final ConfigurableOsgiBundleApplicationContext context = managedContexts.remove(bundle.getBundleId());
275
				(ConfigurableOsgiBundleApplicationContext) managedContexts.remove(Long.valueOf(bundle.getBundleId()));
276
		if (context == null) {
275
		if (context == null) {
277
			return;
276
			return;
278
		}
277
		}
279
278
280
		RunnableTimedExecution.execute(new Runnable() {
279
        Runnable shutdownTask = new Runnable() {
281
280
282
			private final String toString = "Closing runnable for context " + context.getDisplayName();
281
            private final String toString = "Closing runnable for context " + context.getDisplayName();
283
282
284
			public void run() {
283
            public void run() {
285
				closeApplicationContext(context);
284
                closeApplicationContext(context);
286
			}
285
            }
287
286
288
			public String toString() {
287
            public String toString() {
289
				return toString;
288
                return toString;
290
			}
289
            }
290
291
        };
292
293
        if (extenderConfiguration.shouldShutdownAsynchronously()) {
294
            RunnableTimedExecution.execute(shutdownTask, extenderConfiguration.getShutdownWaitTime(), shutdownTaskExecutor);
295
        } else {
296
            shutdownTask.run();
297
        }
291
298
292
		}, extenderConfiguration.getShutdownWaitTime(), shutdownTaskExecutor);
293
	}
299
	}
294
300
295
	/**
301
	/**
(-)a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfiguration.java (-4 / +31 lines)
Lines 42-48 import org.springframework.util.ObjectUtils; Link Here
42
import java.io.UnsupportedEncodingException;
42
import java.io.UnsupportedEncodingException;
43
import java.net.URL;
43
import java.net.URL;
44
import java.net.URLDecoder;
44
import java.net.URLDecoder;
45
import java.util.*;
45
import java.util.ArrayList;
46
import java.util.Collections;
47
import java.util.Enumeration;
48
import java.util.List;
49
import java.util.Properties;
50
import java.util.Timer;
46
51
47
/**
52
/**
48
 * Configuration class for the extender. Takes care of locating the extender specific configurations and merging the
53
 * Configuration class for the extender. Takes care of locating the extender specific configurations and merging the
Lines 67-72 public class ExtenderConfiguration implements BundleActivator { Link Here
67
72
68
	private static final String PROPERTIES_NAME = "extenderProperties";
73
	private static final String PROPERTIES_NAME = "extenderProperties";
69
74
75
    private static final String SHUTDOWN_ASYNCHRONOUS_KEY = "shutdown.asynchronously";
76
70
	private static final String SHUTDOWN_WAIT_KEY = "shutdown.wait.time";
77
	private static final String SHUTDOWN_WAIT_KEY = "shutdown.wait.time";
71
78
72
	private static final String PROCESS_ANNOTATIONS_KEY = "process.annotations";
79
	private static final String PROCESS_ANNOTATIONS_KEY = "process.annotations";
Lines 91-97 public class ExtenderConfiguration implements BundleActivator { Link Here
91
	// default dependency wait time (in milliseconds)
98
	// default dependency wait time (in milliseconds)
92
	private static final long DEFAULT_DEP_WAIT = ConfigUtils.DIRECTIVE_TIMEOUT_DEFAULT * 1000;
99
	private static final long DEFAULT_DEP_WAIT = ConfigUtils.DIRECTIVE_TIMEOUT_DEFAULT * 1000;
93
	private static final boolean DEFAULT_NS_BUNDLE_STATE = true;
100
	private static final boolean DEFAULT_NS_BUNDLE_STATE = true;
94
	private static final long DEFAULT_SHUTDOWN_WAIT = 10 * 1000;
101
	private static final boolean DEFAULT_SHUTDOWN_ASYNCHRONOUS = true;
102
    private static final long DEFAULT_SHUTDOWN_WAIT = 10 * 1000;
103
95
	private static final boolean DEFAULT_PROCESS_ANNOTATION = false;
104
	private static final boolean DEFAULT_PROCESS_ANNOTATION = false;
96
105
97
	private ConfigurableOsgiBundleApplicationContext extenderConfiguration;
106
	private ConfigurableOsgiBundleApplicationContext extenderConfiguration;
Lines 106-111 public class ExtenderConfiguration implements BundleActivator { Link Here
106
115
107
	private long shutdownWaitTime, dependencyWaitTime;
116
	private long shutdownWaitTime, dependencyWaitTime;
108
117
118
    private boolean shutdownAsynchronously;
119
109
	private boolean processAnnotation, nsBundledResolved;
120
	private boolean processAnnotation, nsBundledResolved;
110
121
111
	private OsgiBundleApplicationContextEventMulticaster eventMulticaster;
122
	private OsgiBundleApplicationContextEventMulticaster eventMulticaster;
Lines 128-134 public class ExtenderConfiguration implements BundleActivator { Link Here
128
	// fields reading/writing lock
139
	// fields reading/writing lock
129
	private final Object lock = new Object();
140
	private final Object lock = new Object();
130
141
131
	/**
142
    /**
132
	 * Constructs a new <code>ExtenderConfiguration</code> instance. Locates the extender configuration, creates an
143
	 * Constructs a new <code>ExtenderConfiguration</code> instance. Locates the extender configuration, creates an
133
	 * application context which will returned the extender items.
144
	 * application context which will returned the extender items.
134
	 * 
145
	 * 
Lines 209-215 public class ExtenderConfiguration implements BundleActivator { Link Here
209
220
210
		synchronized (lock) {
221
		synchronized (lock) {
211
			shutdownWaitTime = getShutdownWaitTime(properties);
222
			shutdownWaitTime = getShutdownWaitTime(properties);
212
			dependencyWaitTime = getDependencyWaitTime(properties);
223
			shutdownAsynchronously = getShutdownAsynchronously(properties);
224
            dependencyWaitTime = getDependencyWaitTime(properties);
213
			processAnnotation = getProcessAnnotations(properties);
225
			processAnnotation = getProcessAnnotations(properties);
214
		}
226
		}
215
227
Lines 302-307 public class ExtenderConfiguration implements BundleActivator { Link Here
302
	private Properties createDefaultProperties() {
314
	private Properties createDefaultProperties() {
303
		Properties properties = new Properties();
315
		Properties properties = new Properties();
304
		properties.setProperty(SHUTDOWN_WAIT_KEY, "" + DEFAULT_SHUTDOWN_WAIT);
316
		properties.setProperty(SHUTDOWN_WAIT_KEY, "" + DEFAULT_SHUTDOWN_WAIT);
317
        properties.setProperty(SHUTDOWN_ASYNCHRONOUS_KEY, "" + DEFAULT_SHUTDOWN_ASYNCHRONOUS);
305
		properties.setProperty(PROCESS_ANNOTATIONS_KEY, "" + DEFAULT_PROCESS_ANNOTATION);
318
		properties.setProperty(PROCESS_ANNOTATIONS_KEY, "" + DEFAULT_PROCESS_ANNOTATION);
306
		properties.setProperty(WAIT_FOR_DEPS_TIMEOUT_KEY, "" + DEFAULT_DEP_WAIT);
319
		properties.setProperty(WAIT_FOR_DEPS_TIMEOUT_KEY, "" + DEFAULT_DEP_WAIT);
307
320
Lines 388-393 public class ExtenderConfiguration implements BundleActivator { Link Here
388
		return Long.parseLong(properties.getProperty(SHUTDOWN_WAIT_KEY));
401
		return Long.parseLong(properties.getProperty(SHUTDOWN_WAIT_KEY));
389
	}
402
	}
390
403
404
    private boolean getShutdownAsynchronously(Properties properties) {
405
        return Boolean.valueOf(properties.getProperty(SHUTDOWN_ASYNCHRONOUS_KEY));
406
    }
407
391
	private long getDependencyWaitTime(Properties properties) {
408
	private long getDependencyWaitTime(Properties properties) {
392
		return Long.parseLong(properties.getProperty(WAIT_FOR_DEPS_TIMEOUT_KEY));
409
		return Long.parseLong(properties.getProperty(WAIT_FOR_DEPS_TIMEOUT_KEY));
393
	}
410
	}
Lines 452-457 public class ExtenderConfiguration implements BundleActivator { Link Here
452
		}
469
		}
453
	}
470
	}
454
471
472
    /**
473
     * @return whether the application context shutdown during the bundle stop phase shall be
474
     *         performed asynchronously.
475
     */
476
    public boolean shouldShutdownAsynchronously() {
477
        synchronized (lock) {
478
            return this.shutdownAsynchronously;
479
        }
480
    }
481
455
	/**
482
	/**
456
	 * Returns the dependencyWaitTime.
483
	 * Returns the dependencyWaitTime.
457
	 * 
484
	 * 
(-)a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationCustomSettingsTest.java (-1 / +5 lines)
Lines 80-86 public class ExtenderConfigurationCustomSettingsTest extends TestCase { Link Here
80
		assertEquals(300, config.getShutdownWaitTime());
80
		assertEquals(300, config.getShutdownWaitTime());
81
	}
81
	}
82
82
83
	public void testShouldProcessAnnotation() throws Exception {
83
    public void testShutdownAsynchronously() throws Exception {
84
        assertFalse(config.shouldShutdownAsynchronously());
85
    }
86
87
    public void testShouldProcessAnnotation() throws Exception {
84
		assertTrue(config.shouldProcessAnnotation());
88
		assertTrue(config.shouldProcessAnnotation());
85
	}
89
	}
86
90
(-)a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfigurationDefaultSettingsTest.java (-1 / +5 lines)
Lines 66-72 public class ExtenderConfigurationDefaultSettingsTest extends TestCase { Link Here
66
		assertEquals(10 * 1000, config.getShutdownWaitTime());
66
		assertEquals(10 * 1000, config.getShutdownWaitTime());
67
	}
67
	}
68
68
69
	public void testShouldProcessAnnotation() throws Exception {
69
    public void testShutdownAsynchronously() throws Exception {
70
        assertTrue(config.shouldShutdownAsynchronously());
71
    }
72
73
    public void testShouldProcessAnnotation() throws Exception {
70
		assertFalse(config.shouldProcessAnnotation());
74
		assertFalse(config.shouldProcessAnnotation());
71
	}
75
	}
72
76
(-)a/extender/src/test/resources/org/eclipse/gemini/blueprint/extender/internal/support/extender-custom-config.xml (-1 / +1 lines)
Lines 24-29 Link Here
24
		<prop key="smth">bla</prop>
24
		<prop key="smth">bla</prop>
25
		<prop key="dependencies.wait.time">200</prop>
25
		<prop key="dependencies.wait.time">200</prop>
26
		<prop key="shutdown.wait.time">300</prop>
26
		<prop key="shutdown.wait.time">300</prop>
27
        <prop key="shutdown.asynchronously">false</prop>
27
		<prop key="process.annotations">true</prop>
28
		<prop key="process.annotations">true</prop>
28
	</util:properties>
29
	</util:properties>
29
</beans>
30
</beans>
30
- 

Return to bug 403628