]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java
Improve runtime
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.osgi / src / main / java / org / argeo / slc / osgi / OsgiExecutionModulesManager.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.osgi;
17
18 import java.lang.management.ManagementFactory;
19 import java.util.ArrayList;
20 import java.util.Dictionary;
21 import java.util.Enumeration;
22 import java.util.HashMap;
23 import java.util.HashSet;
24 import java.util.Iterator;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Set;
28
29 import javax.management.MBeanServer;
30 import javax.management.ObjectName;
31 import javax.management.StandardMBean;
32
33 import org.apache.commons.logging.Log;
34 import org.apache.commons.logging.LogFactory;
35 import org.argeo.slc.BasicNameVersion;
36 import org.argeo.slc.NameVersion;
37 import org.argeo.slc.SlcException;
38 import org.argeo.slc.core.execution.AbstractExecutionModulesManager;
39 import org.argeo.slc.core.execution.DefaultExecutionFlowDescriptorConverter;
40 import org.argeo.slc.deploy.Module;
41 import org.argeo.slc.deploy.ModuleDescriptor;
42 import org.argeo.slc.execution.ExecutionContext;
43 import org.argeo.slc.execution.ExecutionFlow;
44 import org.argeo.slc.execution.ExecutionFlowDescriptor;
45 import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
46 import org.argeo.slc.execution.ExecutionModuleDescriptor;
47 import org.argeo.slc.execution.ExecutionModulesListener;
48 import org.argeo.slc.process.RealizedFlow;
49 import org.osgi.framework.Bundle;
50 import org.osgi.framework.BundleEvent;
51 import org.osgi.framework.BundleException;
52 import org.osgi.framework.BundleListener;
53 import org.osgi.framework.Constants;
54 import org.osgi.framework.launch.Framework;
55 import org.springframework.context.ApplicationContext;
56 import org.springframework.osgi.service.importer.OsgiServiceLifecycleListener;
57
58 /** Execution modules manager implementation based on an OSGi runtime. */
59 public class OsgiExecutionModulesManager extends
60 AbstractExecutionModulesManager implements
61 OsgiServiceLifecycleListener, BundleListener {
62
63 private final static Log log = LogFactory
64 .getLog(OsgiExecutionModulesManager.class);
65
66 private BundlesManager bundlesManager;
67 private Map<OsgiBundle, ExecutionContext> executionContexts = new HashMap<OsgiBundle, ExecutionContext>();
68 private Map<OsgiBundle, ExecutionFlowDescriptorConverter> executionFlowDescriptorConverters = new HashMap<OsgiBundle, ExecutionFlowDescriptorConverter>();
69 private Map<OsgiBundle, Set<ExecutionFlow>> executionFlows = new HashMap<OsgiBundle, Set<ExecutionFlow>>();
70 private ExecutionFlowDescriptorConverter defaultDescriptorConverter = new DefaultExecutionFlowDescriptorConverter();
71
72 private List<ExecutionModulesListener> executionModulesListeners = new ArrayList<ExecutionModulesListener>();
73
74 private Boolean registerFlowsToJmx = false;
75
76 public void init() throws Exception {
77 bundlesManager.getBundleContext().addBundleListener(this);
78
79 final String module = System.getProperty(UNIQUE_LAUNCH_MODULE_PROPERTY);
80 final String flow = System.getProperty(UNIQUE_LAUNCH_FLOW_PROPERTY);
81 if (module != null) {
82 // launch a flow and stops
83 new Thread("Unique Flow") {
84 @Override
85 public void run() {
86 executeFlowAndExit(module, null, flow);
87 }
88 }.start();
89 }
90 }
91
92 public void destroy() {
93 bundlesManager.getBundleContext().removeBundleListener(this);
94 }
95
96 /** Executes a single flow and <b>stops the JVM</b> */
97 protected void executeFlowAndExit(final String module,
98 final String version, final String flow) {
99 if (log.isDebugEnabled())
100 log.debug("Launch unique flow " + flow + " from module " + module);
101 try {
102 OsgiBundle osgiBundle = bundlesManager.findFromPattern(module);
103 Bundle moduleBundle = bundlesManager.findRelatedBundle(osgiBundle);
104 bundlesManager.startSynchronous(moduleBundle);
105 RealizedFlow lastLaunch = findRealizedFlow(module, flow);
106 if (lastLaunch == null)
107 throw new SlcException("Cannot find launch for " + module + " "
108 + flow);
109 execute(lastLaunch);
110 } catch (Exception e) {
111 log.error(
112 "Error in unique flow " + flow + " from module " + module,
113 e);
114 } finally {
115 if (log.isDebugEnabled())
116 log.debug("Shutdown OSGi runtime...");
117 Framework framework = (Framework) bundlesManager.getBundleContext()
118 .getBundle(0);
119 try {
120 // shutdown framework
121 framework.stop();
122 // wait 1 min for shutdown
123 framework.waitForStop(60 * 1000);
124 // close VM
125 System.exit(0);
126 } catch (Exception e) {
127 e.printStackTrace();
128 System.exit(1);
129 }
130 }
131 }
132
133 public synchronized ExecutionModuleDescriptor getExecutionModuleDescriptor(
134 String moduleName, String version) {
135 ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
136 OsgiBundle osgiBundle = null;
137 BasicNameVersion nameVersion = new BasicNameVersion(moduleName, version);
138 bundles: for (Iterator<OsgiBundle> iterator = executionContexts
139 .keySet().iterator(); iterator.hasNext();) {
140 OsgiBundle ob = iterator.next();
141 if (ob.equals(nameVersion)) {
142 osgiBundle = ob;
143 break bundles;
144 }
145 }
146 if (osgiBundle == null)
147 throw new SlcException("No execution module registered for "
148 + nameVersion);
149 md.setName(osgiBundle.getName());
150 md.setVersion(osgiBundle.getVersion());
151 md.setTitle(osgiBundle.getTitle());
152 md.setDescription(osgiBundle.getDescription());
153
154 ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = getExecutionFlowDescriptorConverter(
155 moduleName, version);
156 if (executionFlowDescriptorConverter == null)
157 throw new SlcException("No flow converter found.");
158 executionFlowDescriptorConverter.addFlowsToDescriptor(md,
159 listFlows(moduleName, version));
160 return md;
161 }
162
163 public synchronized List<ExecutionModuleDescriptor> listExecutionModules() {
164 List<ExecutionModuleDescriptor> descriptors = new ArrayList<ExecutionModuleDescriptor>();
165
166 for (Iterator<OsgiBundle> iterator = executionContexts.keySet()
167 .iterator(); iterator.hasNext();) {
168 OsgiBundle osgiBundle = iterator.next();
169 ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
170 setMetadataFromBundle(md,
171 bundlesManager.findRelatedBundle(osgiBundle));
172 descriptors.add(md);
173 }
174 return descriptors;
175 }
176
177 protected synchronized Map<String, ExecutionFlow> listFlows(
178 String moduleName, String moduleVersion) {
179
180 Map<String, ExecutionFlow> flows = new HashMap<String, ExecutionFlow>();
181 OsgiBundle key = new OsgiBundle(moduleName, moduleVersion);
182 if (!executionFlows.containsKey(key))
183 return flows;
184 Set<ExecutionFlow> flowsT = executionFlows.get(key);
185 for (ExecutionFlow flow : flowsT)
186 flows.put(flow.getName(), flow);
187 return flows;
188 }
189
190 protected ExecutionFlow findExecutionFlow(String moduleName,
191 String moduleVersion, String flowName) {
192 String filter = "(&(Bundle-SymbolicName=" + moduleName
193 + ")(org.springframework.osgi.bean.name=" + flowName + "))";
194 return bundlesManager.getSingleServiceStrict(ExecutionFlow.class,
195 filter, true);
196 }
197
198 protected ExecutionContext findExecutionContext(String moduleName,
199 String moduleVersion) {
200 String filter = "(&(Bundle-SymbolicName=" + moduleName
201 + ")(Bundle-Version=" + moduleVersion + "))";
202 return bundlesManager.getSingleServiceStrict(ExecutionContext.class,
203 filter, true);
204 }
205
206 protected ExecutionFlowDescriptorConverter findExecutionFlowDescriptorConverter(
207 String moduleName, String moduleVersion) {
208 String filter = "(&(Bundle-SymbolicName=" + moduleName
209 + ")(Bundle-Version=" + moduleVersion + "))";
210 return bundlesManager.getSingleService(
211 ExecutionFlowDescriptorConverter.class, filter, false);
212 }
213
214 /**
215 * Builds a minimal realized flow, based on the provided information
216 * (typically from the command line).
217 *
218 * @param module
219 * a bundle id, or a pattern contained in a bundle symbolic name
220 * @param module
221 * the execution flow name
222 * @return a minimal realized flow, to be used in an execution
223 */
224 public RealizedFlow findRealizedFlow(String module, String executionName) {
225 // First check whether we have a bundleId
226 Long bundleId = null;
227 try {
228 bundleId = Long.parseLong(module);
229 } catch (NumberFormatException e) {
230 // silent
231 }
232
233 // Look for bundle names containing pattern
234 OsgiBundle bundle = null;
235 if (bundleId != null) {
236 bundle = bundlesManager.getBundle(bundleId);
237 } else {
238 bundle = bundlesManager.findFromPattern(module);
239 }
240
241 if (bundle != null) {
242 RealizedFlow launch = new RealizedFlow();
243 launch.setModuleName(bundle.getName());
244 launch.setModuleVersion(bundle.getVersion());
245 ExecutionFlowDescriptor descriptor = new ExecutionFlowDescriptor();
246 descriptor.setName(executionName);
247 launch.setFlowDescriptor(descriptor);
248 return launch;
249 } else {
250 log.warn("Could not find any execution module matching these requirements.");
251 return null;
252 }
253 }
254
255 public void upgrade(NameVersion nameVersion) {
256 OsgiBundle osgiBundle = new OsgiBundle(nameVersion);
257 bundlesManager.upgradeSynchronous(osgiBundle);
258 }
259
260 protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
261 String moduleName, String moduleVersion) {
262 OsgiBundle osgiBundle = new OsgiBundle(moduleName, moduleVersion);
263 return getExecutionFlowDescriptorConverter(osgiBundle);
264 }
265
266 protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
267 OsgiBundle osgiBundle) {
268 if (executionFlowDescriptorConverters.containsKey(osgiBundle))
269 return executionFlowDescriptorConverters.get(osgiBundle);
270 else
271 return defaultDescriptorConverter;
272 }
273
274 public ModuleDescriptor getModuleDescriptor(String moduleName,
275 String version) {
276 return getExecutionModuleDescriptor(moduleName, version);
277 }
278
279 public List<ModuleDescriptor> listModules() {
280 Bundle[] bundles = bundlesManager.getBundleContext().getBundles();
281 List<ModuleDescriptor> lst = new ArrayList<ModuleDescriptor>();
282 for (Bundle bundle : bundles) {
283 ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
284 setMetadataFromBundle(moduleDescriptor, bundle);
285 lst.add(moduleDescriptor);
286 }
287 return lst;
288 }
289
290 public void start(NameVersion nameVersion) {
291 try {
292 Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
293 nameVersion));
294 bundlesManager.startSynchronous(bundle);
295 boolean isSpringInstrumented = bundle.getEntryPaths(
296 "/META-INF/spring").hasMoreElements()
297 || bundle.getHeaders().get("Spring-Context") == null;
298 if (isSpringInstrumented) {
299 // Wait for Spring application context to be ready
300 String filter = "(Bundle-SymbolicName="
301 + bundle.getSymbolicName() + ")";
302 try {
303 bundlesManager.getServiceRefSynchronous(
304 ApplicationContext.class.getName(), filter);
305 } catch (Exception e) {
306 // stop if application context not found
307 bundle.stop();
308 throw e;
309 }
310 }
311 } catch (Exception e) {
312 throw new SlcException("Cannot start " + nameVersion, e);
313 }
314 }
315
316 public void stop(NameVersion nameVersion) {
317 try {
318 Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
319 nameVersion));
320 bundlesManager.stopSynchronous(bundle);
321 } catch (BundleException e) {
322 throw new SlcException("Cannot stop " + nameVersion, e);
323 }
324 }
325
326 protected void setMetadataFromBundle(ModuleDescriptor md, Bundle bundle) {
327 Bundle bdl = bundle;
328 if (bdl == null) {
329 if (md.getName() == null || md.getVersion() == null)
330 throw new SlcException("Name and version not available.");
331
332 Bundle[] bundles = bundlesManager.getBundleContext().getBundles();
333 for (Bundle b : bundles) {
334 if (b.getSymbolicName().equals(md.getName())
335 && md.getVersion().equals(
336 getHeaderSafe(b, Constants.BUNDLE_VERSION))) {
337 bdl = b;
338 break;
339 }
340 }
341
342 }
343
344 if (bdl == null)
345 throw new SlcException("Cannot find bundle.");
346
347 md.setName(bdl.getSymbolicName());
348 md.setVersion(getHeaderSafe(bdl, Constants.BUNDLE_VERSION));
349 md.setTitle(getHeaderSafe(bdl, Constants.BUNDLE_NAME));
350 md.setDescription(getHeaderSafe(bdl, Constants.BUNDLE_DESCRIPTION));
351
352 // copy manifets header to meta data
353 Dictionary<?, ?> headers = bundle.getHeaders();
354 Enumeration<?> keys = headers.keys();
355 while (keys.hasMoreElements()) {
356 Object key = keys.nextElement();
357 Object value = headers.get(key);
358 if (value != null)
359 md.getMetadata().put(key.toString(), value.toString());
360 }
361
362 // check if started
363 if (bundle.getState() == Bundle.ACTIVE
364 || bundle.getState() == Bundle.STARTING)
365 md.setStarted(true);
366 else
367 md.setStarted(false);
368 }
369
370 private String getHeaderSafe(Bundle bundle, Object key) {
371 Object obj = bundle.getHeaders().get(key);
372 if (obj == null)
373 return null;
374 else
375 return obj.toString();
376 }
377
378 /*
379 * REGISTRATION
380 */
381
382 /** Registers an execution context. */
383 public synchronized void register(ExecutionContext executionContext,
384 Map<String, String> properties) {
385 OsgiBundle osgiBundle = asOsgiBundle(properties);
386 Bundle bundle = bundlesManager.findRelatedBundle(osgiBundle);
387 osgiBundle.setTitle(getHeaderSafe(bundle, Constants.BUNDLE_NAME));
388 osgiBundle.setDescription(getHeaderSafe(bundle,
389 Constants.BUNDLE_DESCRIPTION));
390 executionContexts.put(osgiBundle, executionContext);
391 if (log.isTraceEnabled())
392 log.trace("Registered execution context from " + osgiBundle);
393 // Notify
394 ModuleDescriptor md = osgiBundle.getModuleDescriptor();
395 md.setStarted(true);
396 for (ExecutionModulesListener listener : executionModulesListeners)
397 listener.executionModuleAdded(md);
398 }
399
400 /** Unregisters an execution context. */
401 public synchronized void unregister(ExecutionContext executionContext,
402 Map<String, String> properties) {
403 OsgiBundle osgiBundle = asOsgiBundle(properties);
404 if (executionContexts.containsKey(osgiBundle)) {
405 executionContexts.remove(osgiBundle);
406 if (log.isTraceEnabled())
407 log.trace("Removed execution context from " + osgiBundle);
408 // Notify
409 ModuleDescriptor md = osgiBundle.getModuleDescriptor();
410 md.setStarted(false);
411 for (ExecutionModulesListener listener : executionModulesListeners)
412 listener.executionModuleRemoved(md);
413 }
414 }
415
416 /** Registers an execution flow. */
417 public synchronized void register(ExecutionFlow executionFlow,
418 Map<String, String> properties) {
419 OsgiBundle osgiBundle = asOsgiBundle(properties);
420 if (!executionFlows.containsKey(osgiBundle)) {
421 executionFlows.put(osgiBundle, new HashSet<ExecutionFlow>());
422 }
423 executionFlows.get(osgiBundle).add(executionFlow);
424 if (log.isTraceEnabled())
425 log.trace("Registered " + executionFlow + " from " + osgiBundle);
426
427 // notifications
428 if (registerFlowsToJmx)
429 registerMBean(osgiBundle, executionFlow);
430 ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
431 for (ExecutionModulesListener listener : executionModulesListeners)
432 listener.executionFlowAdded(osgiBundle.getModuleDescriptor(),
433 efdc.getExecutionFlowDescriptor(executionFlow));
434 }
435
436 /** Unregisters an execution flow. */
437 public synchronized void unregister(ExecutionFlow executionFlow,
438 Map<String, String> properties) {
439 OsgiBundle osgiBundle = asOsgiBundle(properties);
440 if (executionFlows.containsKey(osgiBundle)) {
441 Set<ExecutionFlow> flows = executionFlows.get(osgiBundle);
442 flows.remove(executionFlow);
443 if (log.isTraceEnabled())
444 log.trace("Removed " + executionFlow + " from " + osgiBundle);
445 if (flows.size() == 0) {
446 executionFlows.remove(osgiBundle);
447 if (log.isTraceEnabled())
448 log.trace("Removed flows set from " + osgiBundle);
449 }
450
451 // notifications
452 if (registerFlowsToJmx)
453 unregisterMBean(osgiBundle, executionFlow);
454 ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
455 for (ExecutionModulesListener listener : executionModulesListeners)
456 listener.executionFlowRemoved(osgiBundle.getModuleDescriptor(),
457 efdc.getExecutionFlowDescriptor(executionFlow));
458 }
459 }
460
461 /** Registers an execution module listener. */
462 public synchronized void register(
463 ExecutionModulesListener executionModulesListener,
464 Map<String, String> properties) {
465 // sync with current state
466 for (OsgiBundle osgiBundle : executionContexts.keySet()) {
467 executionModulesListener.executionModuleAdded(osgiBundle
468 .getModuleDescriptor());
469 }
470 for (OsgiBundle osgiBundle : executionFlows.keySet()) {
471 ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
472 for (ExecutionFlow executionFlow : executionFlows.get(osgiBundle))
473 executionModulesListener.executionFlowAdded(
474 osgiBundle.getModuleDescriptor(),
475 efdc.getExecutionFlowDescriptor(executionFlow));
476 }
477 executionModulesListeners.add(executionModulesListener);
478 }
479
480 /** Unregisters an execution module listener. */
481 public synchronized void unregister(
482 ExecutionModulesListener executionModulesListener,
483 Map<String, String> properties) {
484 executionModulesListeners.remove(executionModulesListener);
485 }
486
487 /*
488 * INTERFACE IMPLEMENTATIONS
489 */
490
491 public void bundleChanged(BundleEvent evt) {
492 Bundle bundle = evt.getBundle();
493 if (bundle.getHeaders().get(
494 ExecutionModuleDescriptor.SLC_EXECUTION_MODULE) != null) {
495 OsgiBundle osgiBundle = new OsgiBundle(bundle);
496 if (evt.getType() == BundleEvent.INSTALLED)
497 for (ExecutionModulesListener listener : executionModulesListeners)
498 listener.executionModuleAdded(osgiBundle
499 .getModuleDescriptor());
500 else if (evt.getType() == BundleEvent.UNINSTALLED)
501 for (ExecutionModulesListener listener : executionModulesListeners)
502 listener.executionModuleRemoved(osgiBundle
503 .getModuleDescriptor());
504 }
505
506 }
507
508 @SuppressWarnings({ "rawtypes" })
509 public synchronized void bind(Object service, Map properties)
510 throws Exception {
511 if (service instanceof ExecutionFlowDescriptorConverter) {
512 ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = (ExecutionFlowDescriptorConverter) service;
513 OsgiBundle osgiBundle = asOsgiBundle(properties);
514 executionFlowDescriptorConverters.put(osgiBundle,
515 executionFlowDescriptorConverter);
516 if (log.isTraceEnabled())
517 log.debug("Registered execution flow descriptor converter from "
518 + osgiBundle);
519 } else {
520 // ignore
521 }
522 }
523
524 @SuppressWarnings("rawtypes")
525 public synchronized void unbind(Object service, Map properties)
526 throws Exception {
527 if (service instanceof ExecutionFlowDescriptorConverter) {
528 OsgiBundle osgiBundle = asOsgiBundle(properties);
529 if (executionFlowDescriptorConverters.containsKey(osgiBundle)) {
530 executionFlowDescriptorConverters.remove(osgiBundle);
531 if (log.isTraceEnabled())
532 log.debug("Removed execution flow descriptor converter from "
533 + osgiBundle);
534 }
535 } else {
536 // ignore
537 }
538 }
539
540 /*
541 * JMX
542 */
543 protected MBeanServer getMBeanServer() {
544 return ManagementFactory.getPlatformMBeanServer();
545 }
546
547 public void registerMBean(Module module, ExecutionFlow executionFlow) {
548 try {
549 StandardMBean mbean = new StandardMBean(executionFlow,
550 ExecutionFlow.class);
551 getMBeanServer().registerMBean(mbean,
552 flowMBeanName(module, executionFlow));
553 } catch (Exception e) {
554 String msg = "Cannot register execution flow " + executionFlow
555 + " as mbean";
556 throw new SlcException(msg, e);
557 }
558 }
559
560 public void unregisterMBean(Module module, ExecutionFlow executionFlow) {
561 try {
562 getMBeanServer().unregisterMBean(
563 flowMBeanName(module, executionFlow));
564 } catch (Exception e) {
565 String msg = "Cannot unregister execution flow " + executionFlow
566 + " as mbean";
567 throw new SlcException(msg, e);
568 }
569 }
570
571 @SuppressWarnings("deprecation")
572 protected ObjectName flowMBeanName(Module module,
573 ExecutionFlow executionFlow) {
574 String executionModulesPrefix = "SLCExecutionModules";
575 String path = executionFlow.getPath();
576 String name = executionFlow.getName();
577 if (path == null && name.indexOf('/') >= 0) {
578 path = name.substring(0, name.lastIndexOf('/'));
579 name = name.substring(name.lastIndexOf('/'));
580 }
581
582 StringBuffer buf = new StringBuffer(executionModulesPrefix + ":"
583 + "module=" + module.getName() + " [" + module.getVersion()
584 + "],");
585
586 if (path != null && !path.equals("")) {
587 int depth = 0;
588 for (String token : path.split("/")) {
589 if (!token.equals("")) {
590 buf.append("path").append(depth).append('=');
591 // in order to have directories first
592 buf.append('/');
593 buf.append(token).append(',');
594 depth++;
595 }
596 }
597 }
598 buf.append("name=").append(name);
599 try {
600 return new ObjectName(buf.toString());
601 } catch (Exception e) {
602 throw new SlcException("Cannot generate object name based on "
603 + buf, e);
604 }
605 }
606
607 /*
608 * UTILITIES
609 */
610 @SuppressWarnings("rawtypes")
611 private OsgiBundle asOsgiBundle(Map properties) {
612 String bundleSymbolicName = checkAndGet(Constants.BUNDLE_SYMBOLICNAME,
613 properties);
614 String bundleVersion = checkAndGet(Constants.BUNDLE_VERSION, properties);
615 return new OsgiBundle(bundleSymbolicName, bundleVersion);
616 }
617
618 @SuppressWarnings("rawtypes")
619 private String checkAndGet(Object key, Map properties) {
620 if (!properties.containsKey(key) || properties.get(key) == null)
621 throw new SlcException(key + " not set in " + properties);
622 else
623 return properties.get(key).toString();
624 }
625
626 public void setBundlesManager(BundlesManager bundlesManager) {
627 this.bundlesManager = bundlesManager;
628 }
629
630 public void setDefaultDescriptorConverter(
631 ExecutionFlowDescriptorConverter defaultDescriptorConverter) {
632 this.defaultDescriptorConverter = defaultDescriptorConverter;
633 }
634
635 public void setRegisterFlowsToJmx(Boolean registerFlowsToJmx) {
636 this.registerFlowsToJmx = registerFlowsToJmx;
637 }
638
639 }