2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.slc
.osgi
;
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
;
29 import javax
.management
.MBeanServer
;
30 import javax
.management
.ObjectName
;
31 import javax
.management
.StandardMBean
;
33 import org
.apache
.commons
.logging
.Log
;
34 import org
.apache
.commons
.logging
.LogFactory
;
35 import org
.argeo
.slc
.DefaultNameVersion
;
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
.execution
.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
.eclipse
.gemini
.blueprint
.service
.importer
.OsgiServiceLifecycleListener
;
58 /** Execution modules manager implementation based on an OSGi runtime. */
59 public class OsgiExecutionModulesManager
extends
60 AbstractExecutionModulesManager
implements
61 OsgiServiceLifecycleListener
, BundleListener
{
63 private final static Log log
= LogFactory
64 .getLog(OsgiExecutionModulesManager
.class);
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();
72 private List
<ExecutionModulesListener
> executionModulesListeners
= new ArrayList
<ExecutionModulesListener
>();
74 private Boolean registerFlowsToJmx
= false;
76 public void init() throws Exception
{
77 bundlesManager
.getBundleContext().addBundleListener(this);
79 final String module
= System
.getProperty(UNIQUE_LAUNCH_MODULE_PROPERTY
);
80 final String flow
= System
.getProperty(UNIQUE_LAUNCH_FLOW_PROPERTY
);
82 // launch a flow and stops
83 new Thread("Unique Flow") {
86 executeFlowAndExit(module
, null, flow
);
92 public void destroy() {
93 bundlesManager
.getBundleContext().removeBundleListener(this);
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
);
102 OsgiBundle osgiBundle
= bundlesManager
.findFromPattern(module
);
103 if (osgiBundle
== null)
104 throw new SlcException("No OSGi bundle found for " + module
);
105 // Bundle moduleBundle =
106 // bundlesManager.findRelatedBundle(osgiBundle);
109 RealizedFlow lastLaunch
= findRealizedFlow(module
, flow
);
110 if (lastLaunch
== null)
111 throw new SlcException("Cannot find launch for " + module
+ " "
114 } catch (Exception e
) {
116 "Error in unique flow " + flow
+ " from module " + module
,
119 if (log
.isDebugEnabled())
120 log
.debug("Shutdown OSGi runtime...");
121 Framework framework
= (Framework
) bundlesManager
.getBundleContext()
124 // shutdown framework
126 // wait 1 min for shutdown
127 framework
.waitForStop(60 * 1000);
130 } catch (Exception e
) {
137 // public void startExectionModule(String moduleName, String moduleVersion)
140 // ServiceReference[] sr = bundlesManager.getServiceRefSynchronous(
141 // ApplicationContext.class.getName(),
142 // "org.springframework.context.service.name=" + moduleName);
143 // // bundlesManager.startSynchronous(moduleBundle);
144 // if (sr == null || sr.length == 0)
145 // throw new SlcException(
146 // "Cannot find execution module application context "
148 // } catch (InvalidSyntaxException e) {
149 // throw new SlcException("Cannot start exeuction module "
154 public synchronized ExecutionModuleDescriptor
getExecutionModuleDescriptor(
155 String moduleName
, String version
) {
156 ExecutionModuleDescriptor md
= new ExecutionModuleDescriptor();
157 OsgiBundle osgiBundle
= null;
158 DefaultNameVersion nameVersion
= new DefaultNameVersion(moduleName
,
160 bundles
: for (Iterator
<OsgiBundle
> iterator
= executionContexts
161 .keySet().iterator(); iterator
.hasNext();) {
162 OsgiBundle ob
= iterator
.next();
163 if (nameVersion
.getVersion() != null) {
164 if (ob
.equals(nameVersion
)) {
169 if (ob
.getName().equals(nameVersion
.getName())) {
175 if (osgiBundle
== null)
176 throw new SlcException("No execution module registered for "
178 md
.setName(osgiBundle
.getName());
179 md
.setVersion(osgiBundle
.getVersion());
180 md
.setTitle(osgiBundle
.getTitle());
181 md
.setDescription(osgiBundle
.getDescription());
183 ExecutionFlowDescriptorConverter executionFlowDescriptorConverter
= getExecutionFlowDescriptorConverter(
184 moduleName
, version
);
185 if (executionFlowDescriptorConverter
== null)
186 throw new SlcException("No flow converter found.");
187 executionFlowDescriptorConverter
.addFlowsToDescriptor(md
,
188 listFlows(moduleName
, version
));
192 public synchronized List
<ExecutionModuleDescriptor
> listExecutionModules() {
193 List
<ExecutionModuleDescriptor
> descriptors
= new ArrayList
<ExecutionModuleDescriptor
>();
195 for (Iterator
<OsgiBundle
> iterator
= executionContexts
.keySet()
196 .iterator(); iterator
.hasNext();) {
197 OsgiBundle osgiBundle
= iterator
.next();
198 ExecutionModuleDescriptor md
= new ExecutionModuleDescriptor();
199 setMetadataFromBundle(md
,
200 bundlesManager
.findRelatedBundle(osgiBundle
));
206 protected synchronized Map
<String
, ExecutionFlow
> listFlows(
207 String moduleName
, String moduleVersion
) {
209 Map
<String
, ExecutionFlow
> flows
= new HashMap
<String
, ExecutionFlow
>();
210 OsgiBundle key
= bundlesManager
.findRelatedBundle(moduleName
,
212 if (!executionFlows
.containsKey(key
))
214 Set
<ExecutionFlow
> flowsT
= executionFlows
.get(key
);
215 for (ExecutionFlow flow
: flowsT
)
216 flows
.put(flow
.getName(), flow
);
220 protected ExecutionFlow
findExecutionFlow(String moduleName
,
221 String moduleVersion
, String flowName
) {
222 String filter
= moduleVersion
== null || moduleVersion
.equals("0.0.0") ?
"(&(Bundle-SymbolicName="
224 + ")(org.eclipse.gemini.blueprint.bean.name="
226 : "(&(Bundle-SymbolicName=" + moduleName
+ ")(Bundle-Version="
228 + ")(org.eclipse.gemini.blueprint.bean.name=" + flowName
230 return bundlesManager
.getSingleServiceStrict(ExecutionFlow
.class,
234 protected ExecutionContext
findExecutionContext(String moduleName
,
235 String moduleVersion
) {
236 String filter
= moduleFilter(moduleName
, moduleVersion
);
237 return bundlesManager
.getSingleServiceStrict(ExecutionContext
.class,
241 protected ExecutionFlowDescriptorConverter
findExecutionFlowDescriptorConverter(
242 String moduleName
, String moduleVersion
) {
243 String filter
= moduleFilter(moduleName
, moduleVersion
);
244 return bundlesManager
.getSingleService(
245 ExecutionFlowDescriptorConverter
.class, filter
, false);
248 /** Only based on symbolic name if version is null or "0.0.0" */
249 protected String
moduleFilter(String moduleName
, String moduleVersion
) {
250 return moduleVersion
== null || moduleVersion
.equals("0.0.0") ?
"(Bundle-SymbolicName="
252 : "(&(Bundle-SymbolicName=" + moduleName
+ ")(Bundle-Version="
253 + moduleVersion
+ "))";
258 * Builds a minimal realized flow, based on the provided information
259 * (typically from the command line).
262 * a bundle id, or a pattern contained in a bundle symbolic name
264 * the execution flow name
265 * @return a minimal realized flow, to be used in an execution
267 public RealizedFlow
findRealizedFlow(String module
, String executionName
) {
268 // First check whether we have a bundleId
269 Long bundleId
= null;
271 bundleId
= Long
.parseLong(module
);
272 } catch (NumberFormatException e
) {
276 // Look for bundle names containing pattern
277 OsgiBundle bundle
= null;
278 if (bundleId
!= null) {
279 bundle
= bundlesManager
.getBundle(bundleId
);
281 bundle
= bundlesManager
.findFromPattern(module
);
284 if (bundle
!= null) {
285 RealizedFlow launch
= new RealizedFlow();
286 launch
.setModuleName(bundle
.getName());
287 launch
.setModuleVersion(bundle
.getVersion());
288 ExecutionFlowDescriptor descriptor
= new ExecutionFlowDescriptor();
289 descriptor
.setName(executionName
);
290 launch
.setFlowDescriptor(descriptor
);
293 log
.warn("Could not find any execution module matching these requirements.");
298 public void upgrade(NameVersion nameVersion
) {
299 OsgiBundle osgiBundle
= new OsgiBundle(nameVersion
);
300 bundlesManager
.upgradeSynchronous(osgiBundle
);
303 protected synchronized ExecutionFlowDescriptorConverter
getExecutionFlowDescriptorConverter(
304 String moduleName
, String moduleVersion
) {
305 return findExecutionFlowDescriptorConverter(moduleName
, moduleVersion
);
306 // OsgiBundle osgiBundle = new OsgiBundle(moduleName, moduleVersion);
307 // return getExecutionFlowDescriptorConverter(osgiBundle);
310 protected synchronized ExecutionFlowDescriptorConverter
getExecutionFlowDescriptorConverter(
311 OsgiBundle osgiBundle
) {
312 if (executionFlowDescriptorConverters
.containsKey(osgiBundle
))
313 return executionFlowDescriptorConverters
.get(osgiBundle
);
315 return defaultDescriptorConverter
;
318 public ModuleDescriptor
getModuleDescriptor(String moduleName
,
320 return getExecutionModuleDescriptor(moduleName
, version
);
323 public List
<ModuleDescriptor
> listModules() {
324 Bundle
[] bundles
= bundlesManager
.getBundleContext().getBundles();
325 List
<ModuleDescriptor
> lst
= new ArrayList
<ModuleDescriptor
>();
326 for (Bundle bundle
: bundles
) {
327 ModuleDescriptor moduleDescriptor
= new ModuleDescriptor();
328 setMetadataFromBundle(moduleDescriptor
, bundle
);
329 lst
.add(moduleDescriptor
);
334 public void start(NameVersion nameVersion
) {
336 Bundle bundle
= bundlesManager
.findRelatedBundle(new OsgiBundle(
339 throw new SlcException("Could not find bundle for "
342 bundlesManager
.startSynchronous(bundle
);
343 if (isSpringInstrumented(bundle
)) {
344 // Wait for Spring application context to be ready
345 String filter
= "(Bundle-SymbolicName="
346 + bundle
.getSymbolicName() + ")";
348 bundlesManager
.getServiceRefSynchronous(
349 ApplicationContext
.class.getName(), filter
);
350 } catch (Exception e
) {
351 // stop if application context not found
356 } catch (Exception e
) {
357 throw new SlcException("Cannot start " + nameVersion
, e
);
361 /** Do it calmly in order to avoid NPE */
362 private Boolean
isSpringInstrumented(Bundle bundle
) {
363 Dictionary
<?
, ?
> headers
= bundle
.getHeaders();
364 if (headers
!= null && headers
.get("Spring-Context") != null)
366 Enumeration
<?
> springEntryPaths
= bundle
367 .getEntryPaths("/META-INF/spring");
368 if (springEntryPaths
!= null && springEntryPaths
.hasMoreElements())
373 public void stop(NameVersion nameVersion
) {
375 Bundle bundle
= bundlesManager
.findRelatedBundle(new OsgiBundle(
377 bundlesManager
.stopSynchronous(bundle
);
378 } catch (BundleException e
) {
379 throw new SlcException("Cannot stop " + nameVersion
, e
);
383 protected void setMetadataFromBundle(ModuleDescriptor md
, Bundle bundle
) {
386 if (md
.getName() == null || md
.getVersion() == null)
387 throw new SlcException("Name and version not available.");
389 Bundle
[] bundles
= bundlesManager
.getBundleContext().getBundles();
390 for (Bundle b
: bundles
) {
391 if (b
.getSymbolicName().equals(md
.getName())
392 && md
.getVersion().equals(
393 getHeaderSafe(b
, Constants
.BUNDLE_VERSION
))) {
402 throw new SlcException("Cannot find bundle.");
404 md
.setName(bdl
.getSymbolicName());
405 md
.setVersion(getHeaderSafe(bdl
, Constants
.BUNDLE_VERSION
));
406 md
.setTitle(getHeaderSafe(bdl
, Constants
.BUNDLE_NAME
));
407 md
.setDescription(getHeaderSafe(bdl
, Constants
.BUNDLE_DESCRIPTION
));
409 // copy manifets header to meta data
410 Dictionary
<?
, ?
> headers
= bundle
.getHeaders();
411 Enumeration
<?
> keys
= headers
.keys();
412 while (keys
.hasMoreElements()) {
413 Object key
= keys
.nextElement();
414 Object value
= headers
.get(key
);
416 md
.getMetadata().put(key
.toString(), value
.toString());
420 if (bundle
.getState() == Bundle
.ACTIVE
421 || bundle
.getState() == Bundle
.STARTING
)
424 md
.setStarted(false);
427 private String
getHeaderSafe(Bundle bundle
, Object key
) {
428 Object obj
= bundle
.getHeaders().get(key
);
432 return obj
.toString();
439 /** Registers an execution context. */
440 public synchronized void register(ExecutionContext executionContext
,
441 Map
<String
, String
> properties
) {
442 OsgiBundle osgiBundle
= asOsgiBundle(properties
);
443 Bundle bundle
= bundlesManager
.findRelatedBundle(osgiBundle
);
444 osgiBundle
.setTitle(getHeaderSafe(bundle
, Constants
.BUNDLE_NAME
));
445 osgiBundle
.setDescription(getHeaderSafe(bundle
,
446 Constants
.BUNDLE_DESCRIPTION
));
447 executionContexts
.put(osgiBundle
, executionContext
);
448 if (log
.isTraceEnabled())
449 log
.trace("Registered execution context from " + osgiBundle
);
451 ModuleDescriptor md
= osgiBundle
.getModuleDescriptor();
453 for (ExecutionModulesListener listener
: executionModulesListeners
)
454 listener
.executionModuleAdded(md
);
457 /** Unregisters an execution context. */
458 public synchronized void unregister(ExecutionContext executionContext
,
459 Map
<String
, String
> properties
) {
460 OsgiBundle osgiBundle
= asOsgiBundle(properties
);
461 if (executionContexts
.containsKey(osgiBundle
)) {
462 executionContexts
.remove(osgiBundle
);
463 if (log
.isTraceEnabled())
464 log
.trace("Removed execution context from " + osgiBundle
);
466 ModuleDescriptor md
= osgiBundle
.getModuleDescriptor();
467 md
.setStarted(false);
468 for (ExecutionModulesListener listener
: executionModulesListeners
)
469 listener
.executionModuleRemoved(md
);
473 /** Registers an execution flow. */
474 public synchronized void register(ExecutionFlow executionFlow
,
475 Map
<String
, String
> properties
) {
476 OsgiBundle osgiBundle
= asOsgiBundle(properties
);
477 if (!executionFlows
.containsKey(osgiBundle
)) {
478 executionFlows
.put(osgiBundle
, new HashSet
<ExecutionFlow
>());
480 executionFlows
.get(osgiBundle
).add(executionFlow
);
481 if (log
.isTraceEnabled())
482 log
.trace("Registered " + executionFlow
+ " from " + osgiBundle
);
485 if (registerFlowsToJmx
)
486 registerMBean(osgiBundle
, executionFlow
);
487 ExecutionFlowDescriptorConverter efdc
= getExecutionFlowDescriptorConverter(osgiBundle
);
488 for (ExecutionModulesListener listener
: executionModulesListeners
)
489 listener
.executionFlowAdded(osgiBundle
.getModuleDescriptor(),
490 efdc
.getExecutionFlowDescriptor(executionFlow
));
493 /** Unregisters an execution flow. */
494 public synchronized void unregister(ExecutionFlow executionFlow
,
495 Map
<String
, String
> properties
) {
496 OsgiBundle osgiBundle
= asOsgiBundle(properties
);
497 if (executionFlows
.containsKey(osgiBundle
)) {
498 Set
<ExecutionFlow
> flows
= executionFlows
.get(osgiBundle
);
499 flows
.remove(executionFlow
);
500 if (log
.isTraceEnabled())
501 log
.trace("Removed " + executionFlow
+ " from " + osgiBundle
);
502 if (flows
.size() == 0) {
503 executionFlows
.remove(osgiBundle
);
504 if (log
.isTraceEnabled())
505 log
.trace("Removed flows set from " + osgiBundle
);
509 if (registerFlowsToJmx
)
510 unregisterMBean(osgiBundle
, executionFlow
);
511 ExecutionFlowDescriptorConverter efdc
= getExecutionFlowDescriptorConverter(osgiBundle
);
512 for (ExecutionModulesListener listener
: executionModulesListeners
)
513 listener
.executionFlowRemoved(osgiBundle
.getModuleDescriptor(),
514 efdc
.getExecutionFlowDescriptor(executionFlow
));
518 /** Registers an execution module listener. */
519 public synchronized void register(
520 ExecutionModulesListener executionModulesListener
,
521 Map
<String
, String
> properties
) {
522 // sync with current state
523 for (OsgiBundle osgiBundle
: executionContexts
.keySet()) {
524 executionModulesListener
.executionModuleAdded(osgiBundle
525 .getModuleDescriptor());
527 for (OsgiBundle osgiBundle
: executionFlows
.keySet()) {
528 ExecutionFlowDescriptorConverter efdc
= getExecutionFlowDescriptorConverter(osgiBundle
);
529 for (ExecutionFlow executionFlow
: executionFlows
.get(osgiBundle
))
530 executionModulesListener
.executionFlowAdded(
531 osgiBundle
.getModuleDescriptor(),
532 efdc
.getExecutionFlowDescriptor(executionFlow
));
534 executionModulesListeners
.add(executionModulesListener
);
537 /** Unregisters an execution module listener. */
538 public synchronized void unregister(
539 ExecutionModulesListener executionModulesListener
,
540 Map
<String
, String
> properties
) {
541 executionModulesListeners
.remove(executionModulesListener
);
545 * INTERFACE IMPLEMENTATIONS
548 public void bundleChanged(BundleEvent evt
) {
549 Bundle bundle
= evt
.getBundle();
550 if (bundle
.getHeaders().get(
551 ExecutionModuleDescriptor
.SLC_EXECUTION_MODULE
) != null) {
552 OsgiBundle osgiBundle
= new OsgiBundle(bundle
);
553 if (evt
.getType() == BundleEvent
.INSTALLED
)
554 for (ExecutionModulesListener listener
: executionModulesListeners
)
555 listener
.executionModuleAdded(osgiBundle
556 .getModuleDescriptor());
557 else if (evt
.getType() == BundleEvent
.UNINSTALLED
)
558 for (ExecutionModulesListener listener
: executionModulesListeners
)
559 listener
.executionModuleRemoved(osgiBundle
560 .getModuleDescriptor());
565 @SuppressWarnings({ "rawtypes" })
566 public synchronized void bind(Object service
, Map properties
)
568 if (service
instanceof ExecutionFlowDescriptorConverter
) {
569 ExecutionFlowDescriptorConverter executionFlowDescriptorConverter
= (ExecutionFlowDescriptorConverter
) service
;
570 OsgiBundle osgiBundle
= asOsgiBundle(properties
);
571 executionFlowDescriptorConverters
.put(osgiBundle
,
572 executionFlowDescriptorConverter
);
573 if (log
.isTraceEnabled())
574 log
.debug("Registered execution flow descriptor converter from "
581 @SuppressWarnings("rawtypes")
582 public synchronized void unbind(Object service
, Map properties
)
584 if (service
instanceof ExecutionFlowDescriptorConverter
) {
585 OsgiBundle osgiBundle
= asOsgiBundle(properties
);
586 if (executionFlowDescriptorConverters
.containsKey(osgiBundle
)) {
587 executionFlowDescriptorConverters
.remove(osgiBundle
);
588 if (log
.isTraceEnabled())
589 log
.debug("Removed execution flow descriptor converter from "
600 protected MBeanServer
getMBeanServer() {
601 return ManagementFactory
.getPlatformMBeanServer();
604 public void registerMBean(Module module
, ExecutionFlow executionFlow
) {
606 StandardMBean mbean
= new StandardMBean(executionFlow
,
607 ExecutionFlow
.class);
608 getMBeanServer().registerMBean(mbean
,
609 flowMBeanName(module
, executionFlow
));
610 } catch (Exception e
) {
611 String msg
= "Cannot register execution flow " + executionFlow
613 throw new SlcException(msg
, e
);
617 public void unregisterMBean(Module module
, ExecutionFlow executionFlow
) {
619 getMBeanServer().unregisterMBean(
620 flowMBeanName(module
, executionFlow
));
621 } catch (Exception e
) {
622 String msg
= "Cannot unregister execution flow " + executionFlow
624 throw new SlcException(msg
, e
);
628 @SuppressWarnings("deprecation")
629 protected ObjectName
flowMBeanName(Module module
,
630 ExecutionFlow executionFlow
) {
631 String executionModulesPrefix
= "SLCExecutionModules";
632 String path
= executionFlow
.getPath();
633 String name
= executionFlow
.getName();
634 if (path
== null && name
.indexOf('/') >= 0) {
635 path
= name
.substring(0, name
.lastIndexOf('/'));
636 name
= name
.substring(name
.lastIndexOf('/'));
639 StringBuffer buf
= new StringBuffer(executionModulesPrefix
+ ":"
640 + "module=" + module
.getName() + " [" + module
.getVersion()
643 if (path
!= null && !path
.equals("")) {
645 for (String token
: path
.split("/")) {
646 if (!token
.equals("")) {
647 buf
.append("path").append(depth
).append('=');
648 // in order to have directories first
650 buf
.append(token
).append(',');
655 buf
.append("name=").append(name
);
657 return new ObjectName(buf
.toString());
658 } catch (Exception e
) {
659 throw new SlcException("Cannot generate object name based on "
667 @SuppressWarnings("rawtypes")
668 private OsgiBundle
asOsgiBundle(Map properties
) {
669 String bundleSymbolicName
= checkAndGet(Constants
.BUNDLE_SYMBOLICNAME
,
671 String bundleVersion
= checkAndGet(Constants
.BUNDLE_VERSION
, properties
);
672 return new OsgiBundle(bundleSymbolicName
, bundleVersion
);
675 @SuppressWarnings("rawtypes")
676 private String
checkAndGet(Object key
, Map properties
) {
677 if (!properties
.containsKey(key
) || properties
.get(key
) == null)
678 throw new SlcException(key
+ " not set in " + properties
);
680 return properties
.get(key
).toString();
683 public void setBundlesManager(BundlesManager bundlesManager
) {
684 this.bundlesManager
= bundlesManager
;
687 public void setDefaultDescriptorConverter(
688 ExecutionFlowDescriptorConverter defaultDescriptorConverter
) {
689 this.defaultDescriptorConverter
= defaultDescriptorConverter
;
692 public void setRegisterFlowsToJmx(Boolean registerFlowsToJmx
) {
693 this.registerFlowsToJmx
= registerFlowsToJmx
;