summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java22
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java10
2 files changed, 25 insertions, 7 deletions
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index c595e34b97..c94879af56 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -61,6 +61,8 @@ public class NodeImpl implements Node, Client {
private NodeConfiguration configuration;
private NodeFactoryImpl manager;
+ private NodeManager mbean;
+
public NodeImpl(NodeFactoryImpl manager, NodeConfiguration configuration) {
super();
this.configuration = configuration;
@@ -97,8 +99,8 @@ public class NodeImpl implements Node, Client {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
try {
- NodeManager mbean = new NodeManager(this);
- mBeanServer.registerMBean(mbean, NodeManager.getName(this));
+ mbean = new NodeManager(this);
+ mBeanServer.registerMBean(mbean, mbean.getName());
/*
LocateRegistry.createRegistry(9999);
JMXServiceURL url =
@@ -107,6 +109,7 @@ public class NodeImpl implements Node, Client {
connectorServer.start();
*/
} catch (Exception e) {
+ mbean = null;
logger.log(Level.SEVERE, e.getMessage(), e);
}
@@ -125,11 +128,16 @@ public class NodeImpl implements Node, Client {
if (compositeActivator == null) {
return;
}
- MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
- try {
- mBeanServer.unregisterMBean(NodeManager.getName(this));
- } catch (Exception e) {
- logger.log(Level.SEVERE, e.getMessage(), e);
+
+ if (mbean != null) {
+ MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+ try {
+ mBeanServer.unregisterMBean(mbean.getName());
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ } finally {
+ mbean = null;
+ }
}
NodeFinder.removeNode(this);
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java
index 9f7bdfce47..1668619b48 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java
@@ -30,9 +30,15 @@ import org.apache.tuscany.sca.node.impl.NodeImpl;
*/
public class NodeManager implements NodeManagerMBean {
private NodeImpl node;
+ private ObjectName name;
public NodeManager(NodeImpl node) {
this.node = node;
+ try {
+ this.name = getName(node);
+ } catch (MalformedObjectNameException e) {
+ // Ignore
+ }
}
public String getURI() {
@@ -43,6 +49,10 @@ public class NodeManager implements NodeManagerMBean {
return node.getConfiguration().getDomainURI();
}
+ public ObjectName getName() {
+ return name;
+ }
+
public static ObjectName getName(Node node) throws MalformedObjectNameException {
String name =
Node.class.getPackage().getName() + ":Type="