WebSphere WebSphere Enterprise Service Bus, Version 6.0.1 Operating Systems: AIX, HP-UX, Linux, Solaris, Windows

Exercise: Writing a Jacl script

Why and when to perform this task

The basic concepts in this script can be used to communicate with any MBean in the system. All that is required is the name and type of the MBean and the methods and attributes available on the MBean. The getAttribute and setAttribute commands are used for attributes. The invoke command is used for methods. Follow these steps to create a .Jacl script that manages the JMX Security MBean.
Note: The code in each step is prefaced with a statement explaining what the code does.

Steps for this task

  1. Determine the nodename

    The first part of the script shown below determines the nodename. If the nodeName is not specified correctly, the correct syntax is printed and the script exits.

    # read and validate arguments
    
        if {{$argc == 1 } && { [lindex $argv $i] == "-nodeName" } {
                set nodeName [lindex $argv $i]
        
  2. Identify the MBean
    An MBean is identified by a type and a name.
    Note: The name and type are hard coded in this case since you know the specific MBean you want to use.
    The second part of the script identifies the MBean.
    # these two variables, mbeanName and mbeanType are used 
      to uniquely identify the mbean.
           # for this sample, the mbean that access relationship 
             services will be used.
    
           set mbeanName"RelService"
           set mbeanType"WBIRelServices"
  3. Locate and set the reference to the MBean.
    You use the code shown here to set the reference for the MBean.
    # locate the mbean and set a reference to in in "relSvcsMBean" variable
    
           set relSvcsMBean [$AdminControl queryNames 
               name=$mbeanName,node=$nodeName,type=$mbeanType,*]
  4. Call the relationship using the getAttribute command.

    The documentation of this specific MBean defines an attribute named allRelationshipNames. Ask the MBean for that attribute using the getAttribute command. The attribute value will be a list that you step through in the next step that invokes the command.

    # request the list of relationships from the mbean
    
           set relationships 
            [$AdminControl getAttribute $relSvcsMBean allRelationshipNames]
  5. Invoke the command for each relationship name, you print the name, and then go back to the MBean for additional information.
    For each relationship name, you print the name, and then go back to the MBean for additional information. In this example the MBean defines a method named getAllRoleNames with a single parameter for the specific relationship name. You use the invoke command to call this method, passing the current relationship name. For each role in the relationship, a role name is printed.
    # loop through the list of role names and print name
    
             foreach roleName $roles {
               puts "    Role: $roleName"
             }
          }
        } else {
             # arguments were not correct, print correct syntax
                puts "Usage: wsadmin -f RelServicesAdmin.jacl -nodeName nodeName" 
        }

Result

You have now written a script to call relationships.
Related concepts
Access control

Task topic

Terms of Use | Rate this page

Timestamp iconLast updated: 13 Dec 2005
http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.websphere.wesb.doc\jmxtutorial\tut_task_jmxadmin.html

(C) Copyright IBM Corporation 2005. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)