wlshell includes a TELNET Protocol Adaptor for JMX. This adaptor provides a text-only interface to access MBeans using a standard TELNET client.
The TELNET adaptor is configured through configuration properties described below. These properties can be specified in different ways: properties file, API and "web.xml" file.
The TELNET adaptor can be deployed on the same JVM as the MBeanServer or on a different JVM, as shown in the Architecture section.
Once the TELNET client is connected to the TELNET protocol adaptor, the user can connect to the MBeanServer where the adaptor is deployed using the JMX local connector or to other MBeanServers using other connectors.
The next subsections describe three possible configurations:
The last subsections describe topics common to all configurations:
The TELNET Protocol Adaptor has a public API documented in the wlshell daemon API section.
In this configuration, the TELNET adaptor runs in the same JVM as the MBeanServer(s) and the application(s) to be managed. The following steps are required to run this configuration:
1. Several jar files need to be added to the classpath to include the TELNET adaptor in your applications. These jar are located on the "lib" directory under the wlshell installation directory. The files "env4jmx.cmd" and "env4wls.cmd" under the "bin" directory can be used as a reference.
2. Select the listen port for the TELNET adaptor. The default port for TELNET is 23, but it can be changed to any other port number. The configuration properties section describes this and other TELNET adaptor properties.
3. The API to instantiate and use the adaptor is easy to use. Here is an example:
import wlshell.daemon.mbeans.Daemon;
...
Daemon wlshelld = new Daemon();
wlshelld.configure("wlshelld.properties");
wlshelld.startup();
wlshelld.shutdown();
4. The TELNET adaptor can be registered as an MBean on the MBeanServer. For example:
name = new ObjectName("wlshell:type=Daemon,name=wlshelld");
mBeanServer.registerMBean(wlshelld, name);
A sample application is provided to illustrate the usage of the TELNET protocol adaptor. The application does the following:
create MBeanServer create and register MBean create and start daemon wait until finished shutdown daemon and exit
To run the example follow these steps:
domains wlshell: dir cd /Samples/Utils dir get Properties invoke toUpper "hello, world!" explore
This is the source code for the sample application:
/*
* wlshell, a multipurpose shell.
* Copyright (C) 2002-2005 Paco Gomez, paco AT wlshell DOT com
*
*/
package wlshell.samples.daemon;
import java.io.*;
import javax.management.*;
import wlshell.serverside.jmx.*;
import wlshell.daemon.mbeans.Daemon;
public class Main {
public static void main(String[] args) throws Exception {
System.out.println("wlshell daemon sample");
//Create an MBeanServer and register an MBean
MBeanServer mBeanServer = MBeanServerFactory.createMBeanServer();
ObjectName name = new ObjectName("wlshell:type=Samples,name=Utils");
mBeanServer.registerMBean(new Utils(), name);
System.out.println("MBean created = " + name.getCanonicalName());
//start wlshell daemon
Daemon wlshelld = new Daemon();
wlshelld.configure("wlshelld.properties");
wlshelld.startup();
//optionally, register wlshell daemon as an MBean
name = new ObjectName("wlshell:type=Daemon,name=wlshelld");
mBeanServer.registerMBean(wlshelld, name);
System.out.println("MBean created = " + name.getCanonicalName());
//receive input
System.out.println(
"\nTo connect to the daemon, open a TELNET connection to port " +
wlshelld.getListenPort());
System.out.print("press <enter> to finish");
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
stdin.readLine();
//shutdown wlshell daemon
wlshelld.shutdown();
//exit JVM
System.out.println("wlshell daemon finished. Bye!");
System.exit(0);
}
}
The wlshell TELNET Protocol Adaptor is also distributed as a Web Application. The Web Application is intended to make easy to deploy the adaptor on Servlet/JSP Containers like WebLogic, Tomcat, etc. This case is similar to the previous one as the Adaptor is in the same JVM as the MBeanServer, but no coding is required.
To deploy the TELNET Adaptor, simply deploy the Web Application to the servlet container. The Web Application is located under the "lib" directory of the wlshell installation directory. The name of the Web Application file is "wlshell-version.war". The configuration properties for the adaptor are in the "web.xml" file as context parameters, and can be changed by editing the "web.xml" file.
The wlshell TELNET Protocol Adaptor can be deployed as a standalone process or daemon. See configuration #2 in the Architecture section. In this configuration, the user client program is a standard Telnet client that connects to the wlshell daemon. Once connected, the user can connect to MBeanServers running on other JVMs using the JMX Remote Connector or the WebLogic Connector.
To use the Adaptor as a standalone process, start wlshell with the "-daemon" option. Here is an example:
cd /opt/wlshell/bin ./wlsh.sh -daemon
The configuration properties for the standalone daemon are provided through a properties file with name "wlshelld.properties", located in the directory where the daemon is started.
The TELNET Protocol Adaptor is configured through configuration properties. These properties can be specified in three different ways:
The configuration properties are described as follows:
| wlshelld.port | Listening port, default TELNET port is 23. |
| wlshelld.maxcon | Maximum concurrent connections, default is 10. |
| wlshelld.debug | wlshell debug: on, off. |
| wlshelld.time_to_warning | Warning setting for connections, in milliseconds. Default is one hour (3600000). |
| wlshelld.time_to_timedout | Timeout setting for connections, in milliseconds. Default is eight hours (28800000). |
| syslog | Syslog settings: on, off. |
| debuglog | Debuglog settings: on, off. |
Here is an example of the "wlshelld.properties" properties file:
# # wlshell TELNET protocol adaptor # configuration properties # #listening port, default TELNET port is 23 wlshelld.port=7777 #maximum concurrent connections wlshelld.maxcon=10 #wlshell debug: on, off wlshelld.debug=off #timeout settings for connections #half hour= 1800000 #one hour= 3600000 #eight hours= 28800000 #maxint= 2147483647 #warning: one hour wlshelld.time_to_warning=3600000 #timeout: eight hours wlshelld.time_to_timedout=28800000 #syslog settings: on, off syslog=on #debuglog settings: on, off debuglog=on
The TELNET Protocol Adaptor implements the TELNET specification, supporting standard TELNET clients. The default TELNET protocol is 23, but it can be changed by modifying the "wlshelld.port" configuration property. Please refer to the TELNET client documentation of your choice on how to specify the server listen port. For example, on Unix and Windows, if the server port is different from 23, then it can be specified after the host:
telnet [<host> [<port>]]
telnet myserver 7777
The following screenshot shows PuTTY TELNET client connecting to wlshell daemon: