YOUR FEEDBACK
Adobe Flex 2 - Answering Tough Questions About Enterprise Development
A Correct Person wrote: Denis Roebrt commented on the 21 Aug 2006 "Tough Que...
SOA World Conference
Virtualization Conference
$50 Savings Expire May 23, 2008... – Register Today!

2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts

SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Server Configuration
Tasks may be made easier with WLST

Digg This!

WebLogic Server Scripting Tool (WLST) is a command-line scripting tool that BEA intends to support as part of the WebLogic Server 9.0 release. This tool is available today on BEA Systems' dev2dev Web site and works with BEA WebLogic Server versions 7.0 and 8.1, including all service packs.

Background

There has always been a need for WebLogic Server to support a scripting solution that allows developers and system administrators to perform both simple and complex changes to their WebLogic Server configuration reliably and interactively. Currently, WebLogic Server supports three command-line tools that require a running WebLogic Server instance: weblogic.Admin, weblogic.Deployer, and the WLConfig Ant task tool. Weblogic.Admin and WLConfig are used to make configuration changes and interrogate MBeans, whereas weblogic.Deployer is used strictly for application deployment. There are also other non-supported tools with which users are familiar such as WLShell, Config2Admin, and MBeanExplorer, etc.

There are many use cases where a simple scripting tool would be handy. For example, developers and administrators may need to write scripts to configure a server and want to enhance it with additional configuration elements via loops and other flow-control constructs. A use case like this would propel the need for a scripting language interpreter that can read user scripts and then run them against the WebLogic Server.

WLST makes an attempt to solve some of the challenges that our current WebLogic Server developers and administrators face. These include capturing repeatable configurations primarily aimed at the preparation of an environment (applications and dependencies) as part of a larger, deployment action; sharing complex configuration changes between users at one level of the life cycle or between levels (e.g., between development and staging); and applying the same change, iteratively, across multiple nodes of a topology, or at some other scope. Adding support for user-defined scripting to WebLogic Server greatly enhances the usability, resulting in higher user satisfaction. With WLST, users are able to customize WebLogic Server to suit their needs, ease their routine tasks, and extend added functionality. Repetitive tasks and complex procedures can now be simplified by providing scripts to handle them. With the help of scripts, components can be "glued" together to form applications. The scripting language augments the Java language and supports the accelerated development.

Introduction

The WebLogic Server Scripting Tool is a command-line scripting interface for WebLogic Server. The WLST scripting environment is based on the Java scripting interpreter, Jython. WLST lets you make use of the provided WebLogic Server scripting functions as well as common features of interpreted languages. These include local variables, conditional variables, and flow control statements. WebLogic Server developers and administrators can extend the WebLogic Server scripting language to suit their environmental needs by following the Jython language syntax.

Jython is an implementation of the high-level, dynamic, object-oriented language Python seamlessly integrated with the Java platform. Jython is 100% Pure Java and is easy to learn with a clear and simple syntax. One of the main advantages of Jython is that you can call any Java object from within the Jython interpreter. What this means for a user is that he/she can reuse any Java code or Java tools that he/she had written. I won't delve too much into details about Jython for this article. For more information about Jython, check out www.jython.org.

WLST Flavors

WLST comes in two flavors, offline and online. Offline is used when a user isn't connected to any WebLogic Server instance and is configuring the domain by interacting with the domain file and configuration templates. This functionality is similar to the Configuration Wizard silent mode scripting that is being deprecated in WebLogic Server version 9.0. Online WLST is utilized when a user is connected to a running WebLogic Server instance and makes changes to the configuration artifacts or monitors the runtime data. Today, both online and offline WLST are available as two separate downloadable JARs. For WebLogic Server version 9.0, the functionality of online and offline WLST will be folded into one tool.

Modes of Operation

WLST provides three modes of operation: interactive, script, and embedded modes. In the interactive mode, the users enter commands and view the response on a command-line prompt. This mode is useful for learning the scripting tool and its capabilities. It is also useful for prototyping command syntax to verify the options before building a larger script. An example of an interactive session is shown in Listing 1. Script mode lets the user supply a set of script commands in a file that the tool executes as a program. Listing 2 shows a simple script that can be executed as a program on WLST. Embedded mode is where a user embeds the WLSTInterpreter in a Java application (see Listing 3).

Features

WebLogic Server implements the Java Management Extensions (JMX) 1.0 and all subsystems (JMS, JDBC, Security, etc.) are instrumented as MBeans and contain attributes by which they can be configured, monitored, and managed. All of these MBeans are arranged in a hierarchical fashion with the DomainMBean as the parent to all of the Configuration MBeans and the DomainRuntimeMBean as the parent to all of the Runtime MBeans. A user can navigate to all of the MBeans via WLST by invoking different WLST commands. For simplicity, the navigation is loosely based upon the file notation in any operating system.

Navigation
In OS terms, WLST has three drives: config, runtime, and custom. The config drive hosts all of the Configuration MBeans with DomainMBean as the parent. The runtime drive hosts all of the Runtime MBeans with DomainRuntimeMBean as the parent, and the custom drive hosts all of the Custom (non-WebLogic) MBeans that a user registers in the WebLogic Server. The MBean types or instances are like the directories in which a user can "cd" or navigate into these MBeans to interrogate the attribute names and values or operations (i.e., files). Listing 4 shows an example in which a user navigates to different drives and MBeans to list the attributes and values.

Configuration
A user can easily move resources from one domain to another by using the "configToScript" command. This command takes a config.xml and converts it into a WLST script that can be applied on another domain to create a similar configuration. It also creates a properties file that contains name-value pairs that can be changed to create configurations with different domain names, server names, etc. Listing 5 demonstrates a simple example where a config.xml is converted into a WLST script. The user can also create new configuration information, and retrieve and change existing configuration values that are stored in the domain config.xml file or in a domain template JAR created using Template Builder. Listing 6 demonstrates a simple example where a user reads an existing medrec template to create a medrec domain.

Current Managed Object (cmo)
Whenever a user navigates to an MBean instance, he has access to that MBean object via the cmo variable. This variable holds the MBean's proxy object so that a user can invoke all of the methods or operations that the MBean interface exposes. Listing 7 demonstrates an example where this variable can be used.

Java from WLST
If you have written any utility command-line tools in Java and would like to reuse these in WLST, you can certainly do so. For example, I wrote a simple Java program that queries the MBeanServer and retrieves all of the MBeans that are registered in this server and prints their object names. The advantage of this is that I do not need to throw away this piece of useful code or rewrite the same in Jython. All I have to do is call this program from WLST. Listing 8 shows the program in Java and shows how a user can call this existing Java program from WLST.

Invoking WLST from Ant
There are many users out there using Ant to automate their WebLogic domain configuration and if you would like to embed your WLST configuration scripts into your Ant build files, you can certainly do so. Listing 9 shows a snippet of a build file that invokes WLST to run a script.

Extend WLST Commands
WLST defines a limited set of commonly used or popular commands out of the box, but this does not restrict a user to define custom commands or modules that can be imported into WLST to suit their needs. Listing 10 defines two custom commands - "createServer" and "deleteServer" - that will create and delete a server with the specified name. These commands will be active for the WLST session. Users can also write modules that define several useful functions and can be imported into WLST. Listing 11 shows an example in which a user defines a security class that has utility functions to create a user, change a password, etc.

WLST Module
Often times, users want to use WLST in conjunction with their other Jython modules. This can be done as easily as writing the WLST module to a file and importing it in your Jython modules. Listing 12 demonstrates how to write out the WLST module and use in a Jython module. You can also check out http://dev2dev.bea.com/codelibrary/code/posample.jsp.

WLST in Action

Let's work through a simple use case that demonstrates an end-to-end scenario where WLST fits in naturally. Consider an administrator trying to configure a domain for his developers. Essentially, he would like to create a domain (one admin server) from scratch, start the server, configure managed servers, and cluster and deploy applications. He would also like to monitor the health of these servers via a simple script. The steps involved here are:
  • Create a simple domain (one admin server) from a template and start the server (see Listing 13).
  • Configure two managed servers and a cluster. Add these two managed servers to this cluster and start the cluster after connecting to the running admin server. Also, deploy a simple application to the cluster (see Listing 14).
  • With a simple monitoring script Monitor the server's health (see Listing 15).

Looking Forward

WLST is available today on BEA Systems' dev2dev site. This version of the tool works with WebLogic Server versions 7.0 and 8.1, including all service packs. Support for this tool is provided via the BEA Systems' Management Newsgroups. It will be officially available and supported in WebLogic Server version 9.0, slated for release sometime next year. BEA Systems is also considering retroactive support for WLST for WebLogic Server versions 7.0 and 8.1.

Some of the new features in WLST that you can expect to see are:

  • Deployment via JSR 88 APIs including the editing of deployment plans via WLST
  • Access to all diagnostic framework (new in WebLogic Server 9.0) artifacts via WLST
  • Merging offline WLST (today available as a separate download) with the existing online WLST tool
  • Access to the new (WebLogic Server 9.0) management APIs
  • Support for all new node manager features that are coming in WebLogic Server 9.0

Summary

In this article, I introduced a new tool, the WebLogic Scripting Tool (WLST), that will empower developers and system administrators to conveniently interact with WebLogic Server (both offline and online) and be able to perform actions that achieve configuration changes to WebLogic Server. WLST can be used in an interactive mode, script mode, or in an embedded mode. It provides a generic and simple access to MBeans in WebLogic Server and also defines convenient commands that can be used to monitor the life cycle of a WebLogic Server instance. WLST is built on Jython, which is a 100% Pure Java implementation of the popular Python language.

References

  • Online WLST Tool: http://dev2dev.bea.com/codelibrary/code/wlst.jsp
  • Offline WLST Tool: http://dev2dev.bea.com/codelibrary/code/wlst_offline.jsp
  • Jython's Main Web Site: www.jython.org
  • PO Sample: http://dev2dev.bea.com/codelibrary/code/posample.jsp
  • About Satya Ghattu
    Satya Ghattu has been with BEA Systems for more than three years as a senior software engineer focusing mainly in the OAM (Operations Administration and Management) area. Prior to BEA he worked as a Java developer/DBA for multiple consulting companies.

    BEA WEBLOGIC LATEST STORIES
    3rd International Virtualization Conference & Expo: Themes & Topics
    From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
    Microsoft To Keynote 4th International Virtualization Conference & Expo
    Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec
    Virtualization Meets DaaS - Desktop-as-a-Service
    After a $1.5 million angel round, Desktone, which was started in 2006 by Eric Pulier, who also started SOA Software, US Interactive and IVT, picked up $17 million in first-round funding about a year ago from Highland Capital Partners, SoftBank Capital, Citrix Systems and the China-base
    Engelbart's Usability Dilemma: Efficiency vs Ease-of-Use
    The mouse was the original idea of Doug Engelbart who was the head of the Augmentation Research Center (ARC) at Stanford Research Institute. Engelbart's philosophy is best embodied, in my opinion, in the design of another device that he invented, the five-finger keyboard - with keys li
    Web 2.0 Is Fundamentally About Empowering People
    'Unlocking content to be remixed into new business value' is the driver of Web 2.0 in the enterprise, says Rod Smith, IBM VP of Emerging Internet Technologies, in this Exclusive Q&A with Jeremy Geelan on the occasion of IBM's release of a new technology created by IBM researchers, code
    Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
    Here is a question that I have been pondering on and off for quite a while: Why do 'cool kids' choose Ruby or PHP to build websites instead of Java? I have to admit that I do not have an answer. Why do I even care? Because I am a Java developer. Like many Java developers, I get along w
    SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
    SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
    Click to Add our RSS Feeds to the Service of Your Choice:
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
    myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
    Publish Your Article! Please send it to editorial(at)sys-con.com!

    Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

    SYS-CON FEATURED WHITEPAPERS

    MOST READ THIS WEEK
    ADS BY GOOGLE
    BREAKING NEWS FROM THE WIRES
    AmberPoint Extends SOA Governance to Apache ServiceMix, BEA AquaLogic Service Bus 3.0, BEA WebLogic Integration, Cisco ACE XML Gateway, JBoss Enterprise Application Platform and Oracle Fusion
    AmberPoint announced today that it has extended the reach of its runtime SOA governance