1 package org
.argeo
.slc
.core
.execution
;
3 import java
.lang
.management
.ManagementFactory
;
5 import javax
.management
.MBeanServer
;
6 import javax
.management
.ObjectName
;
7 import javax
.management
.StandardMBean
;
9 import org
.argeo
.slc
.SlcException
;
10 import org
.argeo
.slc
.deploy
.Module
;
11 import org
.argeo
.slc
.execution
.ExecutionContext
;
12 import org
.argeo
.slc
.execution
.ExecutionFlow
;
13 import org
.argeo
.slc
.execution
.ExecutionModulesListener
;
15 public class JmxExecutionModulesListeners
implements ExecutionModulesListener
{
16 private String executionModulesPrefix
= "SLCExecutionModules";
17 private MBeanServer mBeanServer
= ManagementFactory
18 .getPlatformMBeanServer();
20 public void executionModuleAdded(Module module
,
21 ExecutionContext executionContext
) {
24 public void executionModuleRemoved(Module module
,
25 ExecutionContext executionContext
) {
28 public void executionFlowAdded(Module module
, ExecutionFlow executionFlow
) {
30 StandardMBean mbean
= new StandardMBean(executionFlow
,
32 mBeanServer
.registerMBean(mbean
, flowName(module
, executionFlow
));
33 } catch (Exception e
) {
34 String msg
= "Cannot register execution flow " + executionFlow
36 throw new SlcException(msg
, e
);
40 public void executionFlowRemoved(Module module
, ExecutionFlow executionFlow
) {
42 mBeanServer
.unregisterMBean(flowName(module
, executionFlow
));
43 } catch (Exception e
) {
44 String msg
= "Cannot unregister execution flow " + executionFlow
46 throw new SlcException(msg
, e
);
50 protected ObjectName
flowName(Module module
, ExecutionFlow executionFlow
) {
51 String path
= executionFlow
.getPath();
52 String name
= executionModulesPrefix
+ ":" + "module="
53 + module
.getName() + "[" + module
.getVersion() + "],"
54 + (path
!= null ?
"path=" + path
+ "," : "") + "name="
55 + executionFlow
.getName();
57 return new ObjectName(name
);
58 } catch (Exception e
) {
59 throw new SlcException("Cannot generate object name based on "