summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-06-17 23:40:55 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-06-17 23:40:55 +0000
commit8d0877e9d381eca535abc031fff581913a261ac8 (patch)
tree5960600a3096a7f48d02fb2bd2f28d1b8b2293a7 /java/sca
parentd88b2af71307638c59e819285efaa91b8a1bd495 (diff)
Start to play with JMX management for SCA nodes
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@785857 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java30
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java55
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java30
3 files changed, 115 insertions, 0 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 6737a16d3a..c9935c503e 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
@@ -19,11 +19,14 @@
package org.apache.tuscany.sca.node.impl;
+import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.management.MBeanServer;
+
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
@@ -39,6 +42,7 @@ import org.apache.tuscany.sca.node.Client;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFinder;
import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.management.NodeManager;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -63,6 +67,10 @@ public class NodeImpl implements Node, Client {
this.manager = manager;
}
+ public String getURI() {
+ return getConfiguration().getURI();
+ }
+
public void destroy() {
}
@@ -88,6 +96,21 @@ public class NodeImpl implements Node, Client {
NodeFinder.addNode(NodeUtil.createURI(configuration.getDomainURI()), this);
+ MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+ try {
+ NodeManager mbean = new NodeManager(this);
+ mBeanServer.registerMBean(mbean, NodeManager.getName(this));
+ /*
+ LocateRegistry.createRegistry(9999);
+ JMXServiceURL url =
+ new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/server");
+ JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mBeanServer);
+ connectorServer.start();
+ */
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+
return this;
} catch (Exception e) {
@@ -103,6 +126,13 @@ 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);
+ }
+
NodeFinder.removeNode(this);
if( compositeActivator.getDomainComposite() != null ) {
List<Composite> composites = compositeActivator.getDomainComposite().getIncludes();
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
new file mode 100644
index 0000000000..9f7bdfce47
--- /dev/null
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.management;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+
+/**
+ * MBean implementation for the node
+ */
+public class NodeManager implements NodeManagerMBean {
+ private NodeImpl node;
+
+ public NodeManager(NodeImpl node) {
+ this.node = node;
+ }
+
+ public String getURI() {
+ return node.getURI();
+ }
+
+ public String getDomainURI() {
+ return node.getConfiguration().getDomainURI();
+ }
+
+ public static ObjectName getName(Node node) throws MalformedObjectNameException {
+ String name =
+ Node.class.getPackage().getName() + ":Type="
+ + Node.class.getSimpleName()
+ + ",ID="
+ + System.identityHashCode(node);
+ return ObjectName.getInstance(name);
+
+ }
+}
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java
new file mode 100644
index 0000000000..c25cd0f0ca
--- /dev/null
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.management;
+
+
+
+/**
+ * MBean for NodeImpl
+ */
+public interface NodeManagerMBean {
+ String getURI();
+ String getDomainURI();
+}