-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Groovy WebLogic Scripting Tool is a domain-specific language embedded in the Groovy programming language that seamlessly accesses the management interface of a remote WebLogic Server instance. By connecting to an admin server, GWLST can be used to control domain configuration and runtime operations and statistics for the entire domain.
WebLogic Server already exposes its configuration and runtime management interfaces over JMX, and just about anything that can be done through WebLogic Console and more can also be done programmatically over this interface. GWLST merely makes this less painful than Oracle’s WLST or plain Java.
GWLST can be used as a scripting tool to update domain configuration or perform operations tasks instead of or in conjunction with using the WebLogic Console. It can also be used as a class library to develop standalone tools.
(When connected to an admin server, binding domainRuntimeService is already bound to a proxy to DomainRuntimeServiceMBean.)
// Connected to admin server, resume any instances in admin mode.
for (sr in domainRuntimeService.ServerRuntimes)
if (sr.State == "ADMIN")
sr.resume()WLST offers both an offline mode as well as an online mode. WLST Offline directly manipulates files in a WebLogic domain directory; it therefore remains one of the tools used to create a domain from scratch. GWLST plays the same role as WLST Online in that it connects to a running WebLogic server over JMX. In addition, the GWLST runtime handles connecting and authenticating before the script is called, which reduces boilerplate code.
GWLST can be run as a self-contained and embeddable Java library whereas WLST is part of an entire WebLogic Server installation. Since the GWLST runtime handles connecting and authenticating, GWLST scripts are agnostic as to whether they run in a remote JVM or in WebLogic server JVM.
The coupling between GWLST and WebLogic Server is very small, which makes GWLT itself backwards compatible to WebLogic Server 9.0 or so.
Whereas GWLST is embedded in Groovy, WLST is built on top of Jython. Although a matter of taste and preference, GWLST scripts tend to be about half as long as the corresponding WLST script. Groovy also integrates seamlessly with Java, and you can write classes in GWLST that you can call from Java.
Ironically, the static nature of the Java programming language is not very fit for the dynamic nature of Java Management Extensions (JMX). When a Java caller accesses an MBean, its static interface is not known at compile time, and without that the Java program must use the verbose reflection style rather than the native “dots and parenthesis”. While this may seem cosmetic for small programs, it adds significant noise. The Groovy programming language has dynamic language features that allow us to access the remote MBeans just as if they were ordinary objects.
Groovy is in itself more expressive and better suited for scripting than Java. Unlike Java, Groovy/GWLST scripts can run “on the fly” as if they were interpreted. At the same time, Groovy integrates seamlessly with Java since it compiles into Java bytecode, runs on the same JVM and uses the same libraries. It is therefore possible to write a tool in Groovy with GWLST as a class library, compile and package as a JAR (embedding the Groovy runtime) without anyone knowing it’s not “Java”.
Comparing a GWLST script with the corresponding Java program, you will find the latter is about 10 times longer.