The File System Metaphor

In wlshell the resources available through a connection (MBeans) are mapped to drives, directories and files, establishing an analogy between these resources and a file system. The commands to work with resources are therefore similar to those found on a typical shell: ls/dir, cd, md/mkdir, rd/rmdir, etc...

Using this file system metaphor makes wlshell very easy to use for administrators and developers, who are already familiar with OS shells.

In this section:

Modelling JMX MBeans as Directories

Every JMX Managed Bean (MBean) has an object name which consists of a domain and a list of key-properties. The key property list must be unique within a domain and can be any arbitrary string, except that it cannnot contain any special character (:",=*?). The order of the key properties is not significant. Here are some examples:

MBean set 1:

java.lang:type=OperatingSystem
java.lang:type=Memory
java.lang:type=GarbageCollector,name=Copy
java.lang:type=GarbageCollector,name=MarkSweepCompact
MBean set 2:
mydomain:Type=Server,Name=myserver
mydomain:Type=WebServer,Name=myserver,Server=myserver
mydomain:Type=Log,Name=myserver,Server=myserver

In wlshell these names are represented as directories in a file system. The domain is the disk drive. The directories are the value of the properties of the keys that are included in the path key list.

For instance, with the [type, name] path key list, the MBeans in set 1 will be represented as directories as follows:

java.lang:/OperatingSystem
java.lang:/Memory
java.lang:/GarbageCollector/Copy
java.lang:/GarbageCollector/MarkSweepCompact

MBeans in set 2 will not be represented as directories using the [type, name] path key list, because their key names are different. To map their names to directories we will use the [Type, Name, Server] path key list, obtaining the following directories:

mydomain:/Server/myserver
mydomain:/WebServer/myserver/myserver
mydomain:/Log/myserver/myserver

This convention allows to uniquely map an MBean name to a directory for a given path key list.

Path Key List

The path key list is the concept used in wlshell to determine how the MBeans are organized in directories based on their names. The wlshell keys command can be used to set the path key list at any time and be able to access any MBean

The order of keys in the path key list is significant to translate a directory name to an MBean object name and viceversa. But the order of the keys in the MBean object name is not relevant.

MBean names must have key names that are in the path key list, but it is not required to contain all keys in the path key list. For instance, using [Type, Name, Server] as the path key list, the following MBean name translation is possible:

mydomain:Type=Server,Name=myserver

mydomain:/Server/myserver
but these MBean names cannot be translated into directories:
mydomain:Type=WebServer,Name=myserver,Server=myserver,Location=myserver
mydomain:Type=Server,Name=myserver,Location=myserver
because the key "Location" is not part of the path key list.

Modelling JMX MBean Attributes and Operations as Files

MBean attributes and operations are loosely modelled as files following the file system analogy. Like files, attributes and operations are located under directories and can't have subdirectories themselves. MBean attributes and operations have permissions like files. Attributes can have read and write permissions, allowing the get and set commands to be applied to them. Operations can have the execution permission, allowing the use of the invoke/run command.

As an example, the JDK 5.0 MBean "java.lang:/Runtime" ("java.lang:type=Runtime") has several read only attributes like "InputArguments", "Uptime" or "VmVersion". These attributes are represented in wlshell as follows:

java.lang:/Runtime/InputArguments
java.lang:/Runtime/Uptime
java.lang:/Runtime/VmVersion

The the JDK 5.0 MBean "java.lang:/Memory" ("java.lang:type=Memory") has a read/write attribute called "Verbose" and an operation called "gc". They are represented in wlshell with these path names:

java.lang:/Memory/Verbose
java.lang:/Memory/gc

Accessing MBeans Using the JMX Notation

wlshell includes a special directory named "all" that provides access to the MBeans using their native JMX object names. "all" is a top level directory present in every domain and contains all the MBeans registered in that domain, regardless of the current path key list.

The following screenshot shows the explorer and the "all" directory:

The "all" directory is a convenient way to browse and access any MBean registered in the MBean Server Domain. To refer to an MBean by its actual object name, just specify the name-value pair enclosed by double quotes. Here is an example:

MBean in the Domain Runtime MBean server, object name:
com.bea:Name=AdminServer,Type=Server

wlshell equivalent:
domain.com.bea:/all/Name=AdminServer,Type=Server
wlsh domain.com.bea:/> cd all
domain.com.bea:/all

wlsh domain.com.bea:/all> cd "Type=Server,Name=AdminServer"
domain.com.bea:/all/Type=Server,Name=AdminServer

wlsh domain.com.bea:/> cd /
domain.com.bea:/

wlsh domain.com.bea:/> cd "/all/Type=Server,Name=AdminServer"
domain.com.bea:/all/Type=Server,Name=AdminServer

wlsh domain.com.bea:/all/Type=Server,Name=AdminServer> cd /
domain.com.bea:/

wlsh domain.com.bea:/> get "/all/Type=Server,Name=AdminServer/Name"
AdminServer

Accessing MBeans Using the JMX ObjectName

Another convenient way to access MBeans is through their object name, using an instance of the "javax.management.ObjectName" class.

Here is an example:

wlsh domain.com.bea:/> on = new javax.management.ObjectName "com.bea:Type=Domain,Name=myWDomain100"
variable on set to com.bea:Type=Domain,Name=myWDomain100 (javax.management.ObjectName)
            
wlsh domain.com.bea:/> cd $on
domain.com.bea:/all/Name=myWDomain100,Type=Domain
            
wlsh domain.com.bea:/all/Name=myWDomain100,Type=Domain> pwd
domain.com.bea:/all/Name=myWDomain100,Type=Domain            

When using "cd" with a variable containing an instance of "ObjecName", wlshell will change the current directory to the MBean identified by the ObjectName, under the "all" directory, in the current domain. The domain in ObjectName will be ignored.

This method is particularly useful in BEA WebLogic Server (v9 & v10), where MBeans keep references to related MBeans by storing the "ObjectName" as a property. Here is an example:

ds = myDataSource

sr = run createJDBCSystemResource $ds
cd $sr     
res = get JDBCResource
#res contains the ObjectName of the JDBCResource MBean related to this JDBCSystemResource
cd $res
set Name $ds