You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2013/12/23 21:54:17 UTC

[3/4] git commit: [KARAF-2511] Review and update the connect page of the developers guide

[KARAF-2511] Review and update the connect page of the developers guide


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/9a0d8d03
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/9a0d8d03
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/9a0d8d03

Branch: refs/heads/master
Commit: 9a0d8d033d9ff033a7f2e5dc53acfe940f129cb1
Parents: 900c612
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Mon Dec 23 21:27:48 2013 +0100
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Mon Dec 23 21:27:48 2013 +0100

----------------------------------------------------------------------
 .../main/webapp/developers-guide/connect.conf   | 41 +++++++++++++++++---
 1 file changed, 35 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/9a0d8d03/manual/src/main/webapp/developers-guide/connect.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/developers-guide/connect.conf b/manual/src/main/webapp/developers-guide/connect.conf
index 0253960..5afdf7c 100644
--- a/manual/src/main/webapp/developers-guide/connect.conf
+++ b/manual/src/main/webapp/developers-guide/connect.conf
@@ -1,11 +1,20 @@
+h1. Programmatically connect
 
+As described in the users guide, Apache Karaf supports remote access to both the console (by embedding a SSHd server) and
+the management layer.
 
-h1. Programmatically connect to the console
+h2. To the console
 
-A connection to the Karaf console can also be done programmatically.
-The following code is a simplified version of the code from the client library.
+You can write a Apache Karaf remote console client in Java (or other language).
 
-{pygmentize:java}
+Accessing to a remote Apache Karaf console means writing a SSH client. This SSH client can be in pure Java or in
+another language.
+
+For instance, the {{bin/client}} script starts a SSH client written in Java.
+
+The following code is a simple code to create a SSH client:
+
+{code:lang=java}
 import org.apache.sshd.ClientChannel;
 import org.apache.sshd.ClientSession;
 import org.apache.sshd.SshClient;
@@ -45,9 +54,29 @@ public class Main {
     }
 
 }
-{pygmentize}
+{code}
 
-You can find a more complete example at the [following location|http://svn.apache.org/repos/asf/karaf/trunk/client/src/main/java/org/apache/karaf/client/Main.java].
+h2. To the management layer
 
+The Apache Karaf management layer uses JMX. Apache Karaf embeds a JMX MBeanServer that you can use remotely.
 
+In order to use the MBeanServer remotely, you have to write a JMX client.
 
+The following example shows a simple JMX client stopping Apache Karaf remotely via the JMX layer:
+
+{code:lang=java}
+javax.management.*;
+
+public class Main {
+
+    public static void main(String[] args) throws Exception {
+        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root");
+        JMXConnector connector = JMXConnectorFactory.connect(url, null);
+        MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();
+        ObjectName systemMBean = new ObjectName("org.apache.karaf:type=system,name=karaf-root");
+        mbeanServer.invoke(systemMBean, "halt", null, null);
+        connector.close();
+    }
+
+}
+{code}
\ No newline at end of file