|
Lines 1-541
Link Here
|
| 1 |
/****************************************************************************** |
1 |
/****************************************************************************** |
| 2 |
* Copyright (c) 2006, 2010 VMware Inc. |
2 |
* Copyright (c) 2006, 2010 VMware Inc. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* and Apache License v2.0 which accompanies this distribution. |
5 |
* and Apache License v2.0 which accompanies this distribution. |
| 6 |
* The Eclipse Public License is available at |
6 |
* The Eclipse Public License is available at |
| 7 |
* http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 |
7 |
* http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 |
| 8 |
* is available at http://www.opensource.org/licenses/apache2.0.php. |
8 |
* is available at http://www.opensource.org/licenses/apache2.0.php. |
| 9 |
* You may elect to redistribute this code under either of these licenses. |
9 |
* You may elect to redistribute this code under either of these licenses. |
| 10 |
* |
10 |
* |
| 11 |
* Contributors: |
11 |
* Contributors: |
| 12 |
* VMware Inc. |
12 |
* VMware Inc. |
| 13 |
*****************************************************************************/ |
13 |
*****************************************************************************/ |
| 14 |
|
14 |
|
| 15 |
package org.eclipse.gemini.blueprint.extender.internal.support; |
15 |
package org.eclipse.gemini.blueprint.extender.internal.support; |
| 16 |
|
16 |
|
| 17 |
import java.io.UnsupportedEncodingException; |
17 |
import org.apache.commons.logging.Log; |
| 18 |
import java.net.URL; |
18 |
import org.apache.commons.logging.LogFactory; |
| 19 |
import java.net.URLDecoder; |
19 |
import org.eclipse.gemini.blueprint.context.ConfigurableOsgiBundleApplicationContext; |
| 20 |
import java.util.ArrayList; |
20 |
import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextEventMulticaster; |
| 21 |
import java.util.Collections; |
21 |
import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextEventMulticasterAdapter; |
| 22 |
import java.util.Enumeration; |
22 |
import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextListener; |
| 23 |
import java.util.List; |
23 |
import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext; |
| 24 |
import java.util.Properties; |
24 |
import org.eclipse.gemini.blueprint.extender.OsgiApplicationContextCreator; |
| 25 |
import java.util.Timer; |
25 |
import org.eclipse.gemini.blueprint.extender.OsgiBeanFactoryPostProcessor; |
| 26 |
|
26 |
import org.eclipse.gemini.blueprint.extender.OsgiServiceDependencyFactory; |
| 27 |
import org.apache.commons.logging.Log; |
27 |
import org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.MandatoryImporterDependencyFactory; |
| 28 |
import org.osgi.framework.Bundle; |
28 |
import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils; |
| 29 |
import org.osgi.framework.BundleContext; |
29 |
import org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader; |
| 30 |
import org.springframework.beans.BeanUtils; |
30 |
import org.osgi.framework.Bundle; |
| 31 |
import org.springframework.beans.factory.DisposableBean; |
31 |
import org.osgi.framework.BundleActivator; |
| 32 |
import org.springframework.context.event.SimpleApplicationEventMulticaster; |
32 |
import org.osgi.framework.BundleContext; |
| 33 |
import org.springframework.core.task.SimpleAsyncTaskExecutor; |
33 |
import org.springframework.beans.BeanUtils; |
| 34 |
import org.springframework.core.task.TaskExecutor; |
34 |
import org.springframework.beans.factory.DisposableBean; |
| 35 |
import org.eclipse.gemini.blueprint.context.ConfigurableOsgiBundleApplicationContext; |
35 |
import org.springframework.context.event.SimpleApplicationEventMulticaster; |
| 36 |
import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextEventMulticaster; |
36 |
import org.springframework.core.task.SimpleAsyncTaskExecutor; |
| 37 |
import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextEventMulticasterAdapter; |
37 |
import org.springframework.core.task.TaskExecutor; |
| 38 |
import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextListener; |
38 |
import org.springframework.scheduling.timer.TimerTaskExecutor; |
| 39 |
import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext; |
39 |
import org.springframework.util.Assert; |
| 40 |
import org.eclipse.gemini.blueprint.extender.OsgiApplicationContextCreator; |
40 |
import org.springframework.util.ObjectUtils; |
| 41 |
import org.eclipse.gemini.blueprint.extender.OsgiBeanFactoryPostProcessor; |
41 |
|
| 42 |
import org.eclipse.gemini.blueprint.extender.OsgiServiceDependencyFactory; |
42 |
import java.io.UnsupportedEncodingException; |
| 43 |
import org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.MandatoryImporterDependencyFactory; |
43 |
import java.net.URL; |
| 44 |
import org.eclipse.gemini.blueprint.extender.support.DefaultOsgiApplicationContextCreator; |
44 |
import java.net.URLDecoder; |
| 45 |
import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils; |
45 |
import java.util.*; |
| 46 |
import org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader; |
46 |
|
| 47 |
import org.springframework.scheduling.timer.TimerTaskExecutor; |
47 |
/** |
| 48 |
import org.springframework.util.Assert; |
48 |
* Configuration class for the extender. Takes care of locating the extender specific configurations and merging the |
| 49 |
import org.springframework.util.ObjectUtils; |
49 |
* results with the defaults. |
| 50 |
|
50 |
* |
| 51 |
/** |
51 |
* @author Costin Leau |
| 52 |
* Configuration class for the extender. Takes care of locating the extender specific configurations and merging the |
52 |
*/ |
| 53 |
* results with the defaults. |
53 |
public class ExtenderConfiguration implements BundleActivator { |
| 54 |
* |
54 |
|
| 55 |
* @author Costin Leau |
55 |
/** logger */ |
| 56 |
*/ |
56 |
protected final Log log = LogFactory.getLog(getClass()); |
| 57 |
public class ExtenderConfiguration implements DisposableBean { |
57 |
|
| 58 |
|
58 |
private static final String TASK_EXECUTOR_NAME = "taskExecutor"; |
| 59 |
/** logger */ |
59 |
|
| 60 |
private final Log log; |
60 |
private static final String SHUTDOWN_TASK_EXECUTOR_NAME = "shutdownTaskExecutor"; |
| 61 |
|
61 |
|
| 62 |
private static final String TASK_EXECUTOR_NAME = "taskExecutor"; |
62 |
private static final String CONTEXT_CREATOR_NAME = "applicationContextCreator"; |
| 63 |
|
63 |
|
| 64 |
private static final String SHUTDOWN_TASK_EXECUTOR_NAME = "shutdownTaskExecutor"; |
64 |
private static final String APPLICATION_EVENT_MULTICASTER_BEAN_NAME = "osgiApplicationEventMulticaster"; |
| 65 |
|
65 |
|
| 66 |
private static final String CONTEXT_CREATOR_NAME = "applicationContextCreator"; |
66 |
private static final String CONTEXT_LISTENER_NAME = "osgiApplicationContextListener"; |
| 67 |
|
67 |
|
| 68 |
private static final String APPLICATION_EVENT_MULTICASTER_BEAN_NAME = "osgiApplicationEventMulticaster"; |
68 |
private static final String PROPERTIES_NAME = "extenderProperties"; |
| 69 |
|
69 |
|
| 70 |
private static final String CONTEXT_LISTENER_NAME = "osgiApplicationContextListener"; |
70 |
private static final String SHUTDOWN_WAIT_KEY = "shutdown.wait.time"; |
| 71 |
|
71 |
|
| 72 |
private static final String PROPERTIES_NAME = "extenderProperties"; |
72 |
private static final String PROCESS_ANNOTATIONS_KEY = "process.annotations"; |
| 73 |
|
73 |
|
| 74 |
private static final String SHUTDOWN_WAIT_KEY = "shutdown.wait.time"; |
74 |
private static final String WAIT_FOR_DEPS_TIMEOUT_KEY = "dependencies.wait.time"; |
| 75 |
|
75 |
|
| 76 |
private static final String PROCESS_ANNOTATIONS_KEY = "process.annotations"; |
76 |
private static final String EXTENDER_CFG_LOCATION = "META-INF/spring/extender"; |
| 77 |
|
77 |
|
| 78 |
private static final String WAIT_FOR_DEPS_TIMEOUT_KEY = "dependencies.wait.time"; |
78 |
private static final String XML_PATTERN = "*.xml"; |
| 79 |
|
79 |
|
| 80 |
private static final String EXTENDER_CFG_LOCATION = "META-INF/spring/extender"; |
80 |
private static final String ANNOTATION_DEPENDENCY_FACTORY = |
| 81 |
|
81 |
"org.eclipse.gemini.blueprint.extensions.annotation.ServiceReferenceDependencyBeanFactoryPostProcessor"; |
| 82 |
private static final String XML_PATTERN = "*.xml"; |
82 |
|
| 83 |
|
83 |
/** annotation processing system property (kept for backwards compatibility) */ |
| 84 |
private static final String ANNOTATION_DEPENDENCY_FACTORY = |
84 |
private static final String AUTO_ANNOTATION_PROCESSING = |
| 85 |
"org.eclipse.gemini.blueprint.extensions.annotation.ServiceReferenceDependencyBeanFactoryPostProcessor"; |
85 |
"org.eclipse.gemini.blueprint.extender.annotation.auto.processing"; |
| 86 |
|
86 |
|
| 87 |
/** annotation processing system property (kept for backwards compatibility) */ |
87 |
// |
| 88 |
private static final String AUTO_ANNOTATION_PROCESSING = |
88 |
// defaults |
| 89 |
"org.eclipse.gemini.blueprint.extender.annotation.auto.processing"; |
89 |
// |
| 90 |
|
90 |
|
| 91 |
// |
91 |
// default dependency wait time (in milliseconds) |
| 92 |
// defaults |
92 |
private static final long DEFAULT_DEP_WAIT = ConfigUtils.DIRECTIVE_TIMEOUT_DEFAULT * 1000; |
| 93 |
// |
93 |
private static final boolean DEFAULT_NS_BUNDLE_STATE = true; |
| 94 |
|
94 |
private static final long DEFAULT_SHUTDOWN_WAIT = 10 * 1000; |
| 95 |
// default dependency wait time (in milliseconds) |
95 |
private static final boolean DEFAULT_PROCESS_ANNOTATION = false; |
| 96 |
private static final long DEFAULT_DEP_WAIT = ConfigUtils.DIRECTIVE_TIMEOUT_DEFAULT * 1000; |
96 |
|
| 97 |
private static final boolean DEFAULT_NS_BUNDLE_STATE = true; |
97 |
private ConfigurableOsgiBundleApplicationContext extenderConfiguration; |
| 98 |
private static final long DEFAULT_SHUTDOWN_WAIT = 10 * 1000; |
98 |
|
| 99 |
private static final boolean DEFAULT_PROCESS_ANNOTATION = false; |
99 |
private TaskExecutor taskExecutor, shutdownTaskExecutor; |
| 100 |
|
100 |
|
| 101 |
private ConfigurableOsgiBundleApplicationContext extenderConfiguration; |
101 |
private boolean isTaskExecutorManagedInternally; |
| 102 |
|
102 |
|
| 103 |
private TaskExecutor taskExecutor, shutdownTaskExecutor; |
103 |
private boolean isShutdownTaskExecutorManagedInternally; |
| 104 |
|
104 |
|
| 105 |
private boolean isTaskExecutorManagedInternally; |
105 |
private boolean isMulticasterManagedInternally; |
| 106 |
|
106 |
|
| 107 |
private boolean isShutdownTaskExecutorManagedInternally; |
107 |
private long shutdownWaitTime, dependencyWaitTime; |
| 108 |
|
108 |
|
| 109 |
private boolean isMulticasterManagedInternally; |
109 |
private boolean processAnnotation, nsBundledResolved; |
| 110 |
|
110 |
|
| 111 |
private long shutdownWaitTime, dependencyWaitTime; |
111 |
private OsgiBundleApplicationContextEventMulticaster eventMulticaster; |
| 112 |
|
112 |
|
| 113 |
private boolean processAnnotation, nsBundledResolved; |
113 |
private OsgiBundleApplicationContextListener contextEventListener; |
| 114 |
|
114 |
|
| 115 |
private OsgiBundleApplicationContextEventMulticaster eventMulticaster; |
115 |
private boolean forceThreadShutdown; |
| 116 |
|
116 |
|
| 117 |
private OsgiBundleApplicationContextListener contextEventListener; |
117 |
private OsgiApplicationContextCreator contextCreator = null; |
| 118 |
|
118 |
|
| 119 |
private boolean forceThreadShutdown; |
119 |
/** bundle wrapped class loader */ |
| 120 |
|
120 |
private ClassLoader classLoader; |
| 121 |
private OsgiApplicationContextCreator contextCreator; |
121 |
/** List of context post processors */ |
| 122 |
|
122 |
private final List<OsgiBeanFactoryPostProcessor> postProcessors = |
| 123 |
/** bundle wrapped class loader */ |
123 |
Collections.synchronizedList(new ArrayList<OsgiBeanFactoryPostProcessor>(0)); |
| 124 |
private final ClassLoader classLoader; |
124 |
/** List of service dependency factories */ |
| 125 |
/** List of context post processors */ |
125 |
private final List<OsgiServiceDependencyFactory> dependencyFactories = |
| 126 |
private final List<OsgiBeanFactoryPostProcessor> postProcessors = |
126 |
Collections.synchronizedList(new ArrayList<OsgiServiceDependencyFactory>(0)); |
| 127 |
Collections.synchronizedList(new ArrayList<OsgiBeanFactoryPostProcessor>(0)); |
127 |
|
| 128 |
/** List of service dependency factories */ |
128 |
// fields reading/writing lock |
| 129 |
private final List<OsgiServiceDependencyFactory> dependencyFactories = |
129 |
private final Object lock = new Object(); |
| 130 |
Collections.synchronizedList(new ArrayList<OsgiServiceDependencyFactory>(0)); |
130 |
|
| 131 |
|
131 |
/** |
| 132 |
// fields reading/writing lock |
132 |
* Constructs a new <code>ExtenderConfiguration</code> instance. Locates the extender configuration, creates an |
| 133 |
private final Object lock = new Object(); |
133 |
* application context which will returned the extender items. |
| 134 |
|
134 |
* |
| 135 |
/** |
135 |
* @param extenderBundleContext extender OSGi bundle context |
| 136 |
* Constructs a new <code>ExtenderConfiguration</code> instance. Locates the extender configuration, creates an |
136 |
*/ |
| 137 |
* application context which will returned the extender items. |
137 |
public void start(BundleContext extenderBundleContext) { |
| 138 |
* |
138 |
Bundle bundle = extenderBundleContext.getBundle(); |
| 139 |
* @param bundleContext extender OSGi bundle context |
139 |
Properties properties = new Properties(createDefaultProperties()); |
| 140 |
*/ |
140 |
|
| 141 |
public ExtenderConfiguration(BundleContext bundleContext, Log log) { |
141 |
Enumeration<?> enm = bundle.findEntries(EXTENDER_CFG_LOCATION, XML_PATTERN, false); |
| 142 |
this.log = log; |
142 |
|
| 143 |
Bundle bundle = bundleContext.getBundle(); |
143 |
if (enm == null) { |
| 144 |
Properties properties = new Properties(createDefaultProperties()); |
144 |
log.info("No custom extender configuration detected; using defaults..."); |
| 145 |
|
145 |
synchronized (lock) { |
| 146 |
Enumeration<?> enm = bundle.findEntries(EXTENDER_CFG_LOCATION, XML_PATTERN, false); |
146 |
taskExecutor = createDefaultTaskExecutor(); |
| 147 |
|
147 |
shutdownTaskExecutor = createDefaultShutdownTaskExecutor(); |
| 148 |
if (enm == null) { |
148 |
eventMulticaster = createDefaultEventMulticaster(); |
| 149 |
log.info("No custom extender configuration detected; using defaults..."); |
149 |
contextEventListener = createDefaultApplicationContextListener(); |
| 150 |
|
150 |
} |
| 151 |
synchronized (lock) { |
151 |
classLoader = BundleDelegatingClassLoader.createBundleClassLoaderFor(bundle); |
| 152 |
taskExecutor = createDefaultTaskExecutor(); |
152 |
} else { |
| 153 |
shutdownTaskExecutor = createDefaultShutdownTaskExecutor(); |
153 |
String[] configs = copyEnumerationToList(enm); |
| 154 |
eventMulticaster = createDefaultEventMulticaster(); |
154 |
|
| 155 |
contextCreator = createDefaultApplicationContextCreator(); |
155 |
log.info("Detected extender custom configurations at " + ObjectUtils.nullSafeToString(configs)); |
| 156 |
contextEventListener = createDefaultApplicationContextListener(); |
156 |
// create OSGi specific XML context |
| 157 |
|
157 |
ConfigurableOsgiBundleApplicationContext extenderAppCtx = new OsgiBundleXmlApplicationContext(configs); |
| 158 |
} |
158 |
extenderAppCtx.setBundleContext(extenderBundleContext); |
| 159 |
classLoader = BundleDelegatingClassLoader.createBundleClassLoaderFor(bundle); |
159 |
extenderAppCtx.refresh(); |
| 160 |
} else { |
160 |
|
| 161 |
String[] configs = copyEnumerationToList(enm); |
161 |
synchronized (lock) { |
| 162 |
|
162 |
extenderConfiguration = extenderAppCtx; |
| 163 |
log.info("Detected extender custom configurations at " + ObjectUtils.nullSafeToString(configs)); |
163 |
// initialize beans |
| 164 |
// create OSGi specific XML context |
164 |
taskExecutor = |
| 165 |
ConfigurableOsgiBundleApplicationContext extenderAppCtx = new OsgiBundleXmlApplicationContext(configs); |
165 |
extenderConfiguration.containsBean(TASK_EXECUTOR_NAME) ? (TaskExecutor) extenderConfiguration |
| 166 |
extenderAppCtx.setBundleContext(bundleContext); |
166 |
.getBean(TASK_EXECUTOR_NAME, TaskExecutor.class) : createDefaultTaskExecutor(); |
| 167 |
extenderAppCtx.refresh(); |
167 |
|
| 168 |
|
168 |
shutdownTaskExecutor = |
| 169 |
synchronized (lock) { |
169 |
extenderConfiguration.containsBean(SHUTDOWN_TASK_EXECUTOR_NAME) ? (TaskExecutor) extenderConfiguration |
| 170 |
extenderConfiguration = extenderAppCtx; |
170 |
.getBean(SHUTDOWN_TASK_EXECUTOR_NAME, TaskExecutor.class) |
| 171 |
// initialize beans |
171 |
: createDefaultShutdownTaskExecutor(); |
| 172 |
taskExecutor = |
172 |
|
| 173 |
extenderConfiguration.containsBean(TASK_EXECUTOR_NAME) ? (TaskExecutor) extenderConfiguration |
173 |
eventMulticaster = |
| 174 |
.getBean(TASK_EXECUTOR_NAME, TaskExecutor.class) : createDefaultTaskExecutor(); |
174 |
extenderConfiguration.containsBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME) ? (OsgiBundleApplicationContextEventMulticaster) extenderConfiguration |
| 175 |
|
175 |
.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, |
| 176 |
shutdownTaskExecutor = |
176 |
OsgiBundleApplicationContextEventMulticaster.class) |
| 177 |
extenderConfiguration.containsBean(SHUTDOWN_TASK_EXECUTOR_NAME) ? (TaskExecutor) extenderConfiguration |
177 |
: createDefaultEventMulticaster(); |
| 178 |
.getBean(SHUTDOWN_TASK_EXECUTOR_NAME, TaskExecutor.class) |
178 |
|
| 179 |
: createDefaultShutdownTaskExecutor(); |
179 |
contextCreator = |
| 180 |
|
180 |
extenderConfiguration.containsBean(CONTEXT_CREATOR_NAME) ? (OsgiApplicationContextCreator) extenderConfiguration |
| 181 |
eventMulticaster = |
181 |
.getBean(CONTEXT_CREATOR_NAME, OsgiApplicationContextCreator.class) |
| 182 |
extenderConfiguration.containsBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME) ? (OsgiBundleApplicationContextEventMulticaster) extenderConfiguration |
182 |
: null; |
| 183 |
.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, |
183 |
|
| 184 |
OsgiBundleApplicationContextEventMulticaster.class) |
184 |
contextEventListener = |
| 185 |
: createDefaultEventMulticaster(); |
185 |
extenderConfiguration.containsBean(CONTEXT_LISTENER_NAME) ? (OsgiBundleApplicationContextListener) extenderConfiguration |
| 186 |
|
186 |
.getBean(CONTEXT_LISTENER_NAME, OsgiBundleApplicationContextListener.class) |
| 187 |
contextCreator = |
187 |
: createDefaultApplicationContextListener(); |
| 188 |
extenderConfiguration.containsBean(CONTEXT_CREATOR_NAME) ? (OsgiApplicationContextCreator) extenderConfiguration |
188 |
} |
| 189 |
.getBean(CONTEXT_CREATOR_NAME, OsgiApplicationContextCreator.class) |
189 |
|
| 190 |
: createDefaultApplicationContextCreator(); |
190 |
// get post processors |
| 191 |
|
191 |
postProcessors.addAll(extenderConfiguration.getBeansOfType(OsgiBeanFactoryPostProcessor.class).values()); |
| 192 |
contextEventListener = |
192 |
|
| 193 |
extenderConfiguration.containsBean(CONTEXT_LISTENER_NAME) ? (OsgiBundleApplicationContextListener) extenderConfiguration |
193 |
// get dependency factories |
| 194 |
.getBean(CONTEXT_LISTENER_NAME, OsgiBundleApplicationContextListener.class) |
194 |
dependencyFactories.addAll(extenderConfiguration.getBeansOfType(OsgiServiceDependencyFactory.class) |
| 195 |
: createDefaultApplicationContextListener(); |
195 |
.values()); |
| 196 |
} |
196 |
|
| 197 |
|
197 |
classLoader = extenderConfiguration.getClassLoader(); |
| 198 |
// get post processors |
198 |
// extender properties using the defaults as backup |
| 199 |
postProcessors.addAll(extenderConfiguration.getBeansOfType(OsgiBeanFactoryPostProcessor.class).values()); |
199 |
if (extenderConfiguration.containsBean(PROPERTIES_NAME)) { |
| 200 |
|
200 |
Properties customProperties = |
| 201 |
// get dependency factories |
201 |
(Properties) extenderConfiguration.getBean(PROPERTIES_NAME, Properties.class); |
| 202 |
dependencyFactories.addAll(extenderConfiguration.getBeansOfType(OsgiServiceDependencyFactory.class) |
202 |
Enumeration<?> propertyKey = customProperties.propertyNames(); |
| 203 |
.values()); |
203 |
while (propertyKey.hasMoreElements()) { |
| 204 |
|
204 |
String property = (String) propertyKey.nextElement(); |
| 205 |
classLoader = extenderConfiguration.getClassLoader(); |
205 |
properties.setProperty(property, customProperties.getProperty(property)); |
| 206 |
// extender properties using the defaults as backup |
206 |
} |
| 207 |
if (extenderConfiguration.containsBean(PROPERTIES_NAME)) { |
207 |
} |
| 208 |
Properties customProperties = |
208 |
} |
| 209 |
(Properties) extenderConfiguration.getBean(PROPERTIES_NAME, Properties.class); |
209 |
|
| 210 |
Enumeration<?> propertyKey = customProperties.propertyNames(); |
210 |
synchronized (lock) { |
| 211 |
while (propertyKey.hasMoreElements()) { |
211 |
shutdownWaitTime = getShutdownWaitTime(properties); |
| 212 |
String property = (String) propertyKey.nextElement(); |
212 |
dependencyWaitTime = getDependencyWaitTime(properties); |
| 213 |
properties.setProperty(property, customProperties.getProperty(property)); |
213 |
processAnnotation = getProcessAnnotations(properties); |
| 214 |
} |
214 |
} |
| 215 |
} |
215 |
|
| 216 |
} |
216 |
// load default dependency factories |
| 217 |
|
217 |
addDefaultDependencyFactories(); |
| 218 |
synchronized (lock) { |
218 |
|
| 219 |
shutdownWaitTime = getShutdownWaitTime(properties); |
219 |
// allow post processing |
| 220 |
dependencyWaitTime = getDependencyWaitTime(properties); |
220 |
contextCreator = postProcess(contextCreator); |
| 221 |
processAnnotation = getProcessAnnotations(properties); |
221 |
} |
| 222 |
} |
222 |
|
| 223 |
|
223 |
/** |
| 224 |
// load default dependency factories |
224 |
* Allows post processing of the context creator. |
| 225 |
addDefaultDependencyFactories(); |
225 |
* |
| 226 |
|
226 |
* @param contextCreator |
| 227 |
// allow post processing |
227 |
* @return |
| 228 |
contextCreator = postProcess(contextCreator); |
228 |
*/ |
| 229 |
} |
229 |
protected OsgiApplicationContextCreator postProcess(OsgiApplicationContextCreator contextCreator) { |
| 230 |
|
230 |
return contextCreator; |
| 231 |
/** |
231 |
} |
| 232 |
* Allows post processing of the context creator. |
232 |
|
| 233 |
* |
233 |
/** |
| 234 |
* @param contextCreator |
234 |
* {@inheritDoc} |
| 235 |
* @return |
235 |
* |
| 236 |
*/ |
236 |
* Cleanup the configuration items. |
| 237 |
protected OsgiApplicationContextCreator postProcess(OsgiApplicationContextCreator contextCreator) { |
237 |
*/ |
| 238 |
return contextCreator; |
238 |
public void stop(BundleContext extenderBundleContext) { |
| 239 |
} |
239 |
|
| 240 |
|
240 |
synchronized (lock) { |
| 241 |
/** |
241 |
if (isMulticasterManagedInternally) { |
| 242 |
* {@inheritDoc} |
242 |
eventMulticaster.removeAllListeners(); |
| 243 |
* |
243 |
eventMulticaster = null; |
| 244 |
* Cleanup the configuration items. |
244 |
} |
| 245 |
*/ |
245 |
|
| 246 |
public void destroy() { |
246 |
if (extenderConfiguration != null) { |
| 247 |
|
247 |
extenderConfiguration.close(); |
| 248 |
synchronized (lock) { |
248 |
extenderConfiguration = null; |
| 249 |
if (isMulticasterManagedInternally) { |
249 |
} |
| 250 |
eventMulticaster.removeAllListeners(); |
250 |
|
| 251 |
eventMulticaster = null; |
251 |
// postpone the task executor shutdown |
| 252 |
} |
252 |
if (forceThreadShutdown) { |
| 253 |
|
253 |
|
| 254 |
if (extenderConfiguration != null) { |
254 |
if (isTaskExecutorManagedInternally) { |
| 255 |
extenderConfiguration.close(); |
255 |
log.warn("Forcing the (internally created) taskExecutor to stop..."); |
| 256 |
extenderConfiguration = null; |
256 |
ThreadGroup th = ((SimpleAsyncTaskExecutor) taskExecutor).getThreadGroup(); |
| 257 |
} |
257 |
if (!th.isDestroyed()) { |
| 258 |
|
258 |
// ask the threads nicely to stop |
| 259 |
// postpone the task executor shutdown |
259 |
th.interrupt(); |
| 260 |
if (forceThreadShutdown) { |
260 |
} |
| 261 |
|
261 |
} |
| 262 |
if (isTaskExecutorManagedInternally) { |
262 |
taskExecutor = null; |
| 263 |
log.warn("Forcing the (internally created) taskExecutor to stop..."); |
263 |
} |
| 264 |
ThreadGroup th = ((SimpleAsyncTaskExecutor) taskExecutor).getThreadGroup(); |
264 |
|
| 265 |
if (!th.isDestroyed()) { |
265 |
if (isShutdownTaskExecutorManagedInternally) { |
| 266 |
// ask the threads nicely to stop |
266 |
try { |
| 267 |
th.interrupt(); |
267 |
((DisposableBean) shutdownTaskExecutor).destroy(); |
| 268 |
} |
268 |
} catch (Exception ex) { |
| 269 |
} |
269 |
log.debug("Received exception while shutting down shutdown task executor", ex); |
| 270 |
taskExecutor = null; |
270 |
} |
| 271 |
} |
271 |
shutdownTaskExecutor = null; |
| 272 |
|
272 |
} |
| 273 |
if (isShutdownTaskExecutorManagedInternally) { |
273 |
} |
| 274 |
try { |
274 |
} |
| 275 |
((DisposableBean) shutdownTaskExecutor).destroy(); |
275 |
|
| 276 |
} catch (Exception ex) { |
276 |
/** |
| 277 |
log.debug("Received exception while shutting down shutdown task executor", ex); |
277 |
* Copies the URLs returned by the given enumeration and returns them as an array of Strings for consumption by the |
| 278 |
} |
278 |
* application context. |
| 279 |
shutdownTaskExecutor = null; |
279 |
* |
| 280 |
} |
280 |
* @param enm |
| 281 |
} |
281 |
* @return |
| 282 |
} |
282 |
*/ |
| 283 |
|
283 |
@SuppressWarnings("deprecation") |
| 284 |
/** |
284 |
private String[] copyEnumerationToList(Enumeration<?> enm) { |
| 285 |
* Copies the URLs returned by the given enumeration and returns them as an array of Strings for consumption by the |
285 |
List<String> urls = new ArrayList<String>(4); |
| 286 |
* application context. |
286 |
while (enm != null && enm.hasMoreElements()) { |
| 287 |
* |
287 |
URL configURL = (URL) enm.nextElement(); |
| 288 |
* @param enm |
288 |
if (configURL != null) { |
| 289 |
* @return |
289 |
String configURLAsString = configURL.toExternalForm(); |
| 290 |
*/ |
290 |
try { |
| 291 |
@SuppressWarnings("deprecation") |
291 |
urls.add(URLDecoder.decode(configURLAsString, "UTF8")); |
| 292 |
private String[] copyEnumerationToList(Enumeration<?> enm) { |
292 |
} catch (UnsupportedEncodingException uee) { |
| 293 |
List<String> urls = new ArrayList<String>(4); |
293 |
log.warn("UTF8 encoding not supported, using the platform default"); |
| 294 |
while (enm != null && enm.hasMoreElements()) { |
294 |
urls.add(URLDecoder.decode(configURLAsString)); |
| 295 |
URL configURL = (URL) enm.nextElement(); |
295 |
} |
| 296 |
if (configURL != null) { |
296 |
} |
| 297 |
String configURLAsString = configURL.toExternalForm(); |
297 |
} |
| 298 |
try { |
298 |
|
| 299 |
urls.add(URLDecoder.decode(configURLAsString, "UTF8")); |
299 |
return (String[]) urls.toArray(new String[urls.size()]); |
| 300 |
} catch (UnsupportedEncodingException uee) { |
300 |
} |
| 301 |
log.warn("UTF8 encoding not supported, using the platform default"); |
301 |
|
| 302 |
urls.add(URLDecoder.decode(configURLAsString)); |
302 |
private Properties createDefaultProperties() { |
| 303 |
} |
303 |
Properties properties = new Properties(); |
| 304 |
} |
304 |
properties.setProperty(SHUTDOWN_WAIT_KEY, "" + DEFAULT_SHUTDOWN_WAIT); |
| 305 |
} |
305 |
properties.setProperty(PROCESS_ANNOTATIONS_KEY, "" + DEFAULT_PROCESS_ANNOTATION); |
| 306 |
|
306 |
properties.setProperty(WAIT_FOR_DEPS_TIMEOUT_KEY, "" + DEFAULT_DEP_WAIT); |
| 307 |
return (String[]) urls.toArray(new String[urls.size()]); |
307 |
|
| 308 |
} |
308 |
return properties; |
| 309 |
|
309 |
} |
| 310 |
private Properties createDefaultProperties() { |
310 |
|
| 311 |
Properties properties = new Properties(); |
311 |
protected void addDefaultDependencyFactories() { |
| 312 |
properties.setProperty(SHUTDOWN_WAIT_KEY, "" + DEFAULT_SHUTDOWN_WAIT); |
312 |
boolean debug = log.isDebugEnabled(); |
| 313 |
properties.setProperty(PROCESS_ANNOTATIONS_KEY, "" + DEFAULT_PROCESS_ANNOTATION); |
313 |
|
| 314 |
properties.setProperty(WAIT_FOR_DEPS_TIMEOUT_KEY, "" + DEFAULT_DEP_WAIT); |
314 |
// default JDK 1.4 processor |
| 315 |
|
315 |
dependencyFactories.add(0, new MandatoryImporterDependencyFactory()); |
| 316 |
return properties; |
316 |
|
| 317 |
} |
317 |
// load through reflection the dependency and injection processors if running on JDK 1.5 and annotation |
| 318 |
|
318 |
// processing is enabled |
| 319 |
protected void addDefaultDependencyFactories() { |
319 |
if (processAnnotation) { |
| 320 |
boolean debug = log.isDebugEnabled(); |
320 |
// dependency processor |
| 321 |
|
321 |
Class<?> annotationProcessor = null; |
| 322 |
// default JDK 1.4 processor |
322 |
try { |
| 323 |
dependencyFactories.add(0, new MandatoryImporterDependencyFactory()); |
323 |
annotationProcessor = |
| 324 |
|
324 |
Class.forName(ANNOTATION_DEPENDENCY_FACTORY, false, ExtenderConfiguration.class |
| 325 |
// load through reflection the dependency and injection processors if running on JDK 1.5 and annotation |
325 |
.getClassLoader()); |
| 326 |
// processing is enabled |
326 |
} catch (ClassNotFoundException cnfe) { |
| 327 |
if (processAnnotation) { |
327 |
log.warn("Spring DM annotation package not found, annotation processing disabled."); |
| 328 |
// dependency processor |
328 |
log.debug("Spring DM annotation package not found, annotation processing disabled.", cnfe); |
| 329 |
Class<?> annotationProcessor = null; |
329 |
return; |
| 330 |
try { |
330 |
} |
| 331 |
annotationProcessor = |
331 |
Object processor = BeanUtils.instantiateClass(annotationProcessor); |
| 332 |
Class.forName(ANNOTATION_DEPENDENCY_FACTORY, false, ExtenderConfiguration.class |
332 |
Assert.isInstanceOf(OsgiServiceDependencyFactory.class, processor); |
| 333 |
.getClassLoader()); |
333 |
dependencyFactories.add(1, (OsgiServiceDependencyFactory) processor); |
| 334 |
} catch (ClassNotFoundException cnfe) { |
334 |
|
| 335 |
log.warn("Spring DM annotation package not found, annotation processing disabled."); |
335 |
if (debug) |
| 336 |
log.debug("Spring DM annotation package not found, annotation processing disabled.", cnfe); |
336 |
log.debug("Succesfully loaded annotation dependency processor [" + ANNOTATION_DEPENDENCY_FACTORY + "]"); |
| 337 |
return; |
337 |
|
| 338 |
} |
338 |
// add injection processor (first in line) |
| 339 |
Object processor = BeanUtils.instantiateClass(annotationProcessor); |
339 |
postProcessors.add(0, new OsgiAnnotationPostProcessor()); |
| 340 |
Assert.isInstanceOf(OsgiServiceDependencyFactory.class, processor); |
340 |
log.info("Spring-DM annotation processing enabled"); |
| 341 |
dependencyFactories.add(1, (OsgiServiceDependencyFactory) processor); |
341 |
} else { |
| 342 |
|
342 |
if (debug) { |
| 343 |
if (debug) |
343 |
log.debug("Spring-DM annotation processing disabled; [" + ANNOTATION_DEPENDENCY_FACTORY |
| 344 |
log.debug("Succesfully loaded annotation dependency processor [" + ANNOTATION_DEPENDENCY_FACTORY + "]"); |
344 |
+ "] not loaded"); |
| 345 |
|
345 |
} |
| 346 |
// add injection processor (first in line) |
346 |
} |
| 347 |
postProcessors.add(0, new OsgiAnnotationPostProcessor()); |
347 |
|
| 348 |
log.info("Spring-DM annotation processing enabled"); |
348 |
} |
| 349 |
} else { |
349 |
|
| 350 |
if (debug) { |
350 |
private TaskExecutor createDefaultTaskExecutor() { |
| 351 |
log.debug("Spring-DM annotation processing disabled; [" + ANNOTATION_DEPENDENCY_FACTORY |
351 |
// create thread-pool for starting contexts |
| 352 |
+ "] not loaded"); |
352 |
ThreadGroup threadGroup = |
| 353 |
} |
353 |
new ThreadGroup("eclipse-gemini-blueprint-extender[" + ObjectUtils.getIdentityHexString(this) + "]-threads"); |
| 354 |
} |
354 |
threadGroup.setDaemon(false); |
| 355 |
|
355 |
|
| 356 |
} |
356 |
SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); |
| 357 |
|
357 |
taskExecutor.setThreadGroup(threadGroup); |
| 358 |
private TaskExecutor createDefaultTaskExecutor() { |
358 |
taskExecutor.setThreadNamePrefix("EclipseGeminiBlueprintExtenderThread-"); |
| 359 |
// create thread-pool for starting contexts |
359 |
|
| 360 |
ThreadGroup threadGroup = |
360 |
isTaskExecutorManagedInternally = true; |
| 361 |
new ThreadGroup("eclipse-gemini-blueprint-extender[" + ObjectUtils.getIdentityHexString(this) + "]-threads"); |
361 |
|
| 362 |
threadGroup.setDaemon(false); |
362 |
return taskExecutor; |
| 363 |
|
363 |
} |
| 364 |
SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); |
364 |
|
| 365 |
taskExecutor.setThreadGroup(threadGroup); |
365 |
private TaskExecutor createDefaultShutdownTaskExecutor() { |
| 366 |
taskExecutor.setThreadNamePrefix("EclipseGeminiBlueprintExtenderThread-"); |
366 |
TimerTaskExecutor taskExecutor = new TimerTaskExecutor() { |
| 367 |
|
367 |
@Override |
| 368 |
isTaskExecutorManagedInternally = true; |
368 |
protected Timer createTimer() { |
| 369 |
|
369 |
return new Timer("Gemini Blueprint context shutdown thread", true); |
| 370 |
return taskExecutor; |
370 |
} |
| 371 |
} |
371 |
}; |
| 372 |
|
372 |
|
| 373 |
private TaskExecutor createDefaultShutdownTaskExecutor() { |
373 |
taskExecutor.afterPropertiesSet(); |
| 374 |
TimerTaskExecutor taskExecutor = new TimerTaskExecutor() { |
374 |
isShutdownTaskExecutorManagedInternally = true; |
| 375 |
@Override |
375 |
return taskExecutor; |
| 376 |
protected Timer createTimer() { |
376 |
} |
| 377 |
return new Timer("Gemini Blueprint context shutdown thread", true); |
377 |
|
| 378 |
} |
378 |
private OsgiBundleApplicationContextEventMulticaster createDefaultEventMulticaster() { |
| 379 |
}; |
379 |
isMulticasterManagedInternally = true; |
| 380 |
|
380 |
return new OsgiBundleApplicationContextEventMulticasterAdapter(new SimpleApplicationEventMulticaster()); |
| 381 |
taskExecutor.afterPropertiesSet(); |
381 |
} |
| 382 |
isShutdownTaskExecutorManagedInternally = true; |
382 |
|
| 383 |
return taskExecutor; |
383 |
private OsgiBundleApplicationContextListener createDefaultApplicationContextListener() { |
| 384 |
} |
384 |
return new DefaultOsgiBundleApplicationContextListener(log); |
| 385 |
|
385 |
} |
| 386 |
private OsgiBundleApplicationContextEventMulticaster createDefaultEventMulticaster() { |
386 |
|
| 387 |
isMulticasterManagedInternally = true; |
387 |
private long getShutdownWaitTime(Properties properties) { |
| 388 |
return new OsgiBundleApplicationContextEventMulticasterAdapter(new SimpleApplicationEventMulticaster()); |
388 |
return Long.parseLong(properties.getProperty(SHUTDOWN_WAIT_KEY)); |
| 389 |
} |
389 |
} |
| 390 |
|
390 |
|
| 391 |
private OsgiApplicationContextCreator createDefaultApplicationContextCreator() { |
391 |
private long getDependencyWaitTime(Properties properties) { |
| 392 |
return new DefaultOsgiApplicationContextCreator(); |
392 |
return Long.parseLong(properties.getProperty(WAIT_FOR_DEPS_TIMEOUT_KEY)); |
| 393 |
} |
393 |
} |
| 394 |
|
394 |
|
| 395 |
private OsgiBundleApplicationContextListener createDefaultApplicationContextListener() { |
395 |
private boolean getProcessAnnotations(Properties properties) { |
| 396 |
return new DefaultOsgiBundleApplicationContextListener(log); |
396 |
return Boolean.valueOf(properties.getProperty(PROCESS_ANNOTATIONS_KEY)).booleanValue() |
| 397 |
} |
397 |
|| Boolean.getBoolean(AUTO_ANNOTATION_PROCESSING); |
| 398 |
|
398 |
} |
| 399 |
private long getShutdownWaitTime(Properties properties) { |
399 |
|
| 400 |
return Long.parseLong(properties.getProperty(SHUTDOWN_WAIT_KEY)); |
400 |
/** |
| 401 |
} |
401 |
* Returns the taskExecutor. |
| 402 |
|
402 |
* |
| 403 |
private long getDependencyWaitTime(Properties properties) { |
403 |
* @return Returns the taskExecutor |
| 404 |
return Long.parseLong(properties.getProperty(WAIT_FOR_DEPS_TIMEOUT_KEY)); |
404 |
*/ |
| 405 |
} |
405 |
public TaskExecutor getTaskExecutor() { |
| 406 |
|
406 |
synchronized (lock) { |
| 407 |
private boolean getProcessAnnotations(Properties properties) { |
407 |
return taskExecutor; |
| 408 |
return Boolean.valueOf(properties.getProperty(PROCESS_ANNOTATIONS_KEY)).booleanValue() |
408 |
} |
| 409 |
|| Boolean.getBoolean(AUTO_ANNOTATION_PROCESSING); |
409 |
} |
| 410 |
} |
410 |
|
| 411 |
|
411 |
/** |
| 412 |
/** |
412 |
* Returns the shutdown task executor. |
| 413 |
* Returns the taskExecutor. |
413 |
* |
| 414 |
* |
414 |
* @return Returns the shutdown task executor |
| 415 |
* @return Returns the taskExecutor |
415 |
*/ |
| 416 |
*/ |
416 |
public TaskExecutor getShutdownTaskExecutor() { |
| 417 |
public TaskExecutor getTaskExecutor() { |
417 |
synchronized (lock) { |
| 418 |
synchronized (lock) { |
418 |
return shutdownTaskExecutor; |
| 419 |
return taskExecutor; |
419 |
} |
| 420 |
} |
420 |
} |
| 421 |
} |
421 |
|
| 422 |
|
422 |
/** |
| 423 |
/** |
423 |
* Returns the contextEventListener. |
| 424 |
* Returns the shutdown task executor. |
424 |
* |
| 425 |
* |
425 |
* @return Returns the contextEventListener |
| 426 |
* @return Returns the shutdown task executor |
426 |
*/ |
| 427 |
*/ |
427 |
public OsgiBundleApplicationContextListener getContextEventListener() { |
| 428 |
public TaskExecutor getShutdownTaskExecutor() { |
428 |
synchronized (lock) { |
| 429 |
synchronized (lock) { |
429 |
return contextEventListener; |
| 430 |
return shutdownTaskExecutor; |
430 |
} |
| 431 |
} |
431 |
} |
| 432 |
} |
432 |
|
| 433 |
|
433 |
/** |
| 434 |
/** |
434 |
* Returns the shutdownWaitTime. |
| 435 |
* Returns the contextEventListener. |
435 |
* |
| 436 |
* |
436 |
* @return Returns the shutdownWaitTime |
| 437 |
* @return Returns the contextEventListener |
437 |
*/ |
| 438 |
*/ |
438 |
public long getShutdownWaitTime() { |
| 439 |
public OsgiBundleApplicationContextListener getContextEventListener() { |
439 |
synchronized (lock) { |
| 440 |
synchronized (lock) { |
440 |
return shutdownWaitTime; |
| 441 |
return contextEventListener; |
441 |
} |
| 442 |
} |
442 |
} |
| 443 |
} |
443 |
|
| 444 |
|
444 |
/** |
| 445 |
/** |
445 |
* Indicates if the process annotation is enabled or not. |
| 446 |
* Returns the shutdownWaitTime. |
446 |
* |
| 447 |
* |
447 |
* @return Returns true if the annotation should be processed or not otherwise. |
| 448 |
* @return Returns the shutdownWaitTime |
448 |
*/ |
| 449 |
*/ |
449 |
public boolean shouldProcessAnnotation() { |
| 450 |
public long getShutdownWaitTime() { |
450 |
synchronized (lock) { |
| 451 |
synchronized (lock) { |
451 |
return processAnnotation; |
| 452 |
return shutdownWaitTime; |
452 |
} |
| 453 |
} |
453 |
} |
| 454 |
} |
454 |
|
| 455 |
|
455 |
/** |
| 456 |
/** |
456 |
* Returns the dependencyWaitTime. |
| 457 |
* Indicates if the process annotation is enabled or not. |
457 |
* |
| 458 |
* |
458 |
* @return Returns the dependencyWaitTime |
| 459 |
* @return Returns true if the annotation should be processed or not otherwise. |
459 |
*/ |
| 460 |
*/ |
460 |
public long getDependencyWaitTime() { |
| 461 |
public boolean shouldProcessAnnotation() { |
461 |
synchronized (lock) { |
| 462 |
synchronized (lock) { |
462 |
return dependencyWaitTime; |
| 463 |
return processAnnotation; |
463 |
} |
| 464 |
} |
464 |
} |
| 465 |
} |
465 |
|
| 466 |
|
466 |
/** |
| 467 |
/** |
467 |
* Returns the eventMulticaster. |
| 468 |
* Returns the dependencyWaitTime. |
468 |
* |
| 469 |
* |
469 |
* @return Returns the eventMulticaster |
| 470 |
* @return Returns the dependencyWaitTime |
470 |
*/ |
| 471 |
*/ |
471 |
public OsgiBundleApplicationContextEventMulticaster getEventMulticaster() { |
| 472 |
public long getDependencyWaitTime() { |
472 |
synchronized (lock) { |
| 473 |
synchronized (lock) { |
473 |
return eventMulticaster; |
| 474 |
return dependencyWaitTime; |
474 |
} |
| 475 |
} |
475 |
} |
| 476 |
} |
476 |
|
| 477 |
|
477 |
/** |
| 478 |
/** |
478 |
* Sets the flag to force the taskExtender to close up in case of runaway threads - this applies *only* if the |
| 479 |
* Returns the eventMulticaster. |
479 |
* taskExecutor has been created internally. |
| 480 |
* |
480 |
* |
| 481 |
* @return Returns the eventMulticaster |
481 |
* <p/> The flag will cause a best attempt to shutdown the threads. |
| 482 |
*/ |
482 |
* |
| 483 |
public OsgiBundleApplicationContextEventMulticaster getEventMulticaster() { |
483 |
* @param forceThreadShutdown The forceThreadShutdown to set. |
| 484 |
synchronized (lock) { |
484 |
*/ |
| 485 |
return eventMulticaster; |
485 |
public void setForceThreadShutdown(boolean forceThreadShutdown) { |
| 486 |
} |
486 |
synchronized (lock) { |
| 487 |
} |
487 |
this.forceThreadShutdown = forceThreadShutdown; |
| 488 |
|
488 |
} |
| 489 |
/** |
489 |
} |
| 490 |
* Sets the flag to force the taskExtender to close up in case of runaway threads - this applies *only* if the |
490 |
|
| 491 |
* taskExecutor has been created internally. |
491 |
/** |
| 492 |
* |
492 |
* Returns the contextCreator. |
| 493 |
* <p/> The flag will cause a best attempt to shutdown the threads. |
493 |
* |
| 494 |
* |
494 |
* @return Returns the contextCreator |
| 495 |
* @param forceThreadShutdown The forceThreadShutdown to set. |
495 |
*/ |
| 496 |
*/ |
496 |
public OsgiApplicationContextCreator getContextCreator() { |
| 497 |
public void setForceThreadShutdown(boolean forceThreadShutdown) { |
497 |
synchronized (lock) { |
| 498 |
synchronized (lock) { |
498 |
return contextCreator; |
| 499 |
this.forceThreadShutdown = forceThreadShutdown; |
499 |
} |
| 500 |
} |
500 |
} |
| 501 |
} |
501 |
|
| 502 |
|
502 |
/** |
| 503 |
/** |
503 |
* Returns the postProcessors. |
| 504 |
* Returns the contextCreator. |
504 |
* |
| 505 |
* |
505 |
* @return Returns the postProcessors |
| 506 |
* @return Returns the contextCreator |
506 |
*/ |
| 507 |
*/ |
507 |
public List<OsgiBeanFactoryPostProcessor> getPostProcessors() { |
| 508 |
public OsgiApplicationContextCreator getContextCreator() { |
508 |
return postProcessors; |
| 509 |
synchronized (lock) { |
509 |
} |
| 510 |
return contextCreator; |
510 |
|
| 511 |
} |
511 |
/** |
| 512 |
} |
512 |
* Returns the class loader wrapped around the extender bundle. |
| 513 |
|
513 |
* |
| 514 |
/** |
514 |
* @return extender bundle class loader |
| 515 |
* Returns the postProcessors. |
515 |
*/ |
| 516 |
* |
516 |
public ClassLoader getClassLoader() { |
| 517 |
* @return Returns the postProcessors |
517 |
return classLoader; |
| 518 |
*/ |
518 |
} |
| 519 |
public List<OsgiBeanFactoryPostProcessor> getPostProcessors() { |
519 |
|
| 520 |
return postProcessors; |
520 |
/** |
| 521 |
} |
521 |
* Returns the dependencies factories declared by the extender configuration. The list automatically contains the |
| 522 |
|
522 |
* default listeners (such as the annotation one). |
| 523 |
/** |
523 |
* |
| 524 |
* Returns the class loader wrapped around the extender bundle. |
524 |
* @return list of dependency factories |
| 525 |
* |
525 |
*/ |
| 526 |
* @return extender bundle class loader |
526 |
public List<OsgiServiceDependencyFactory> getDependencyFactories() { |
| 527 |
*/ |
527 |
return dependencyFactories; |
| 528 |
public ClassLoader getClassLoader() { |
528 |
} |
| 529 |
return classLoader; |
|
|
| 530 |
} |
| 531 |
|
| 532 |
/** |
| 533 |
* Returns the dependencies factories declared by the extender configuration. The list automatically contains the |
| 534 |
* default listeners (such as the annotation one). |
| 535 |
* |
| 536 |
* @return list of dependency factories |
| 537 |
*/ |
| 538 |
public List<OsgiServiceDependencyFactory> getDependencyFactories() { |
| 539 |
return dependencyFactories; |
| 540 |
} |
| 541 |
} |
529 |
} |