The Java CAPS Management and Monitoring API should be callable from any JSR-223 Scripting Environment. This section documents how to set up these scripting engines like Groovy, JRuby, Jython (Java Python), JACL (Java TCL) or one of the 25 other JSR-223 scripting engines capable of calling the Java CAPS Management and Monitoring APIs that are currently available . You can use these instructions to setup your own environment to invoke these APIs from the JSR-223 Scripting Environment of your choice.
For the purposes of this topic, we will focus on four scripting engines:
Groovy: The Java CAPS Management and Monitoring API has been tested and works with Groovy 1.0, Groovy 1.1 beta 1, and with the latest Groovy 1.1 beta 2. Use the installation instructions that are available to install the engine, and ensure that it runs properly. Download Groovy from http://groovy.codehaus.org/.
JRuby: The Java CAPS Management and Monitoring API has been tested and works with JRuby 1.0 and with the latest JRuby 1.0.1. Use the installation instructions that are available to install the engine, and ensure that it runs properly. Download JRuby from http://jruby.codehaus.org/.
Jython (Java Python): The Java CAPS Management and Monitoring API has been tested and works with Jython 2.2 RC1 and with the latest Jython 2.2. Use the installation instructions that are available to install the engine, and ensure that it runs properly. Download Jython from http://www.jython.org/Project/index.html.
JACL (Java TCL): The Java CAPS Management and Monitoring API has been tested and works with the latest JACL 1.4.0. Use the installation instructions that are available to install the engine, and ensure that it runs properly. You may have to modify jaclsh.bat in the bin folder as described in the readme.txt file that is included with the download. My bin/jaclsh.bat looks like this after modification. Download JACL from http://tcljava.sourceforge.net/docs/website/index.html.
The sample files for the services (for example: AdministrationServiceSample.groovy) and the Target option behavior are zipped, and are included with the Java CAPS 6 delivery.
There are two files that are necessary before you set up your scripting environment to invoke Java CAPS Management and Monitoring APIs:
env.bat
caps.management.client.jar
These files are included with the Java CAPS delivery.
After downloading env.bat and caps.management.client.jar, modify the environment variables in env.bat.
To modify environment variables, click To Modify the Environment Variables in env.bat.
Set the JAVA_HOME variable to the JDK/JRE Home folder where your JDK or JRE is installed.
For example: set JAVA_HOME=C:\java\jdk1.6.0.
Set the SJSAS_HOME variable to the SJSAS Home folder where your Sun Java System Application Server is installed.
For example: set SJSAS_HOME=C:\CAPS6\SJSAS.
Set the CAPS_MANAGEMENT_HOME variable to the folder where you saved the Java CAPS Management and Monitoring API Java archive file locally.
For example: set CAPS_MANAGEMENT_HOME=C:\scripting\engines\common.
Set the ENGINE_HOME variable to your Scripting Engine Home folder where your scripting engine is installed.
For example: set ENGINE_HOME=C:\scripting\engines\groovy\groovy-1.1-beta-2.
You are now ready to run the scripting samples.
Before running the scripting samples, it is assumed that you installed one of the scripting engines.
Groovy (located at C:\scripting\engines\groovy\groovy-1.1-beta-2)
JRuby (located at C:\scripting\engines\jruby\jruby-1.0.1)
Jython (located at C:\scripting\engines\jython\jython2.2)
JACL (located at C:\scripting\engines\jacl\jacl140)
It is also assumed that the Sun Java System Application Server is running with the following settings:
|
Host |
HTTP Administration Port |
Admin UserName |
Admin Password |
|---|---|---|---|
|
localhost |
4848 |
admin |
adminadmin |
If your environment is different, change the following steps or the scripts according to your environment or installation.
Currently Sun supports these services:
Administration Service
Configuration Service
Deployment Service
Installation Service
Runtime Management Service
Additional services will be supported in the future.
Before you can exercise the Administration Service, you must have the following installed, and/or deployed, in your environment:
A binding component named sun-http-binding
A shared library named sun-wsdl-library
A service assembly named SynchronousSampleApplication, which contains a service unit named SynchronousSampleApplication-SynchronousSample
You must create the SynchronousSampleApplication from
NetBeans, deploy it, and start it before you run the Administration
Service scripts.
Change the script as you see fit to run in your environment.
The Groovy script for executing the Administration Service is attached in AdministrationServiceTest.groovy. Modify the script to suit your needs before executing it in your environment/installation.
cd C:\JavaCAPS6\managementapienv.batcd scripting\groovy\scripts\groovy ServiceTest\AdministrationServiceTest.groovy
If you are comfortable with the Swing-based groovyConsole, use it to load and execute the script file.
cd C:\scripting\groovy\scripts\env.batgroovyConsole
Before you can exercise the Configuration Service, you must have the following installed in your environment:
A binding component named sun-http-binding
A service engine named sun-bpel-engine
Change the script as you see fit to run in your environment.
The Groovy script for executing the Configuration Service is attached in AdministrationServiceTest.groovy. Modify the script to suit your needs before executing it in your environment/installation.
cd C:\JavaCAPS6\managementapienv.batcd scripting\groovy\scripts\groovy ServiceTest\ConfigurationServiceTest.groovy
If you are comfortable with the Swing-based groovyConsole, use it to load and execute the script file.
cd C:\scripting\groovy\scripts\env.batgroovyConsole
The deployment service tries to deploy a Service Assembly named SynchronousSampleApplication. Before you run the Deployment Service scripts, from NetBeans you must first create a SynchronousSampleApplication, deploy it, and start it. Change the script as you see fit to run in your environment.
The Groovy script for executing the Deployment Service is attached in DeploymentServiceTest.groovy. Modify the script to suit your needs before executing it in your environment/installation.
cd C:\JavaCAPS6\managementapienv.batcd scripting\groovy\scripts\groovy ServiceTest\DeploymentServiceTest.groovy
If you are comfortable with the Swing-based groovyConsole, use it to load and execute the script file.
cd C:\scripting\groovy\scripts\env.batgroovyConsole
Before you can exercise the Installation Service, you must have aspectserviceengine.jar installed in your environment.
Read the following carefully.
A service engine named sun-aspect-engine attempts
to stop, shutdown, and uninstall itself.
The service engine then attempts to install sun-aspect-engine from the attached aspectserviceengine.jar.
Before you run the Installation Service sample scripts, install aspectserviceengine.jar in your environment and start it.
Change the script as you see fit to run in your environment.
The Groovy script for executing the Installation Service is attached in InstallationServiceTest.groovy. Modify the script to suit your needs before executing it in your environment/installation.
cd C:\JavaCAPS6\managementapienv.batcd scripting\groovy\scripts\groovy ServiceTest\InstallationServiceTest.groovy
If you are comfortable with the Swing-based groovyConsole, use it to load and execute the script file.
cd C:\scripting\groovy\scripts\env.batgroovyConsole
Before you can exercise the Runtime Management Service, you must have the following installed and deployed in your environment:
A service engine named sun-bpel-engine
A service assembly named SynchronousSampleApplication, which you created from NetBeans.
Change the script as you see fit to run in your environment.
The Groovy script for executing the Runtime Management Service is attached in RuntimeManagmentServiceTest.groovy. Modify the script to suit your needs before executing it in your environment/installation.
cd C:\JavaCAPS6\managementapienv.batcd scripting\groovy\scripts\groovy ServiceTest\RuntimeManagementServiceTest.groovy
If you are comfortable with the Swing-based groovyConsole, use it to load and execute the script file.
cd C:\scripting\groovy\scripts\env.batgroovyConsole
Before you can exercise the JMS Management Service, you must have first installed the Sun JMS IQ Manager from the Java CAPS 6 Installer and deployed it in your environment:
The Java CAPS Installer, by default, allows you to install Sun JMS IQ Manager during the installation process. However, you can install Sun JMS IQ Manager at any time after you have installed Java CAPS 6.
The Groovy script for executing the JMS Management Service is attached in JMSManagmentServiceTest.groovy. Modify the script to suit your needs before executing it in your environment/installation.
cd C:\JavaCAPS6\managementapienv.batcd scripting\groovy\scripts\groovy ServiceTest\JMSManagementServiceTest.groovy
If you are comfortable with the Swing-based groovyConsole, use it to load and execute the script file.
cd C:\scripting\groovy\scripts\env.batgroovyConsole
Before you can exercise the BPEL Management Service, you must ensure:
That monitoring is enabled for your BPEL Service Engine
That a service engine named sun-bpel-engine has
been installed and deployed in your environment
Change the script as you see fit to run in your environment.
The Groovy script for executing the BPEL Management Service is attached in BPELManagmentServiceTest.groovy. Modify the script to suit your needs before executing it in your environment/installation.
cd C:\JavaCAPS6\managementapienv.batcd scripting\groovy\scripts\groovy ServiceTest\BPELManagementServiceTest.groovy
If you are comfortable with the Swing-based groovyConsole, use it to load and execute the script file.
cd C:\scripting\groovy\scripts\env.batgroovyConsole
Before you can exercise the HTTP Administration Service, you must have the following installed and deployed in your environment:
A binding component named sun-http-binding
A Service Assembly with some HTTP consuming endpoint(s)
Change the script as you see fit to run in your environment.
The Groovy script for executing the HTTP Administration Service is attached in HTTPAdiministrationServiceTest.groovy. Modify the script to suit your needs before executing it in your environment/installation.
cd C:\JavaCAPS6\managementapienv.batcd scripting\groovy\scripts\groovy ServiceTest\HTTPAdministrationServiceTest.groovy
If you are comfortable with the Swing-based groovyConsole, use it to load and execute the script file.
cd C:\scripting\groovy\scripts\env.batgroovyConsole
For Notification Service test, there are no prerequisites except that the AppServer is up and running. When any lifecycle changes happen in the JBI runtime, the Notification Service sends these notifications to all subscribed clients.
Change the script as you see fit to run in your environment.
The Groovy script for executing the Notification Service is attached in NotificationServiceTest.groovy. Modify the script to suit your needs before executing it in your environment/installation.
cd C:\JavaCAPS6\managementapienv.batcd scripting\groovy\scripts\groovy ServiceTest\NotificationServiceTest.groovy
If you are comfortable with the Swing-based groovyConsole, use it to load and execute the script file.
cd C:\scripting\groovy\scripts\env.batgroovyConsole
If you have the latest version of NetBeans IDE 6.0, you can create your own JRuby Project, and execute the JRuby samples (they have “rb” extensions) from within the NetBeans IDE.
Java CAPS 6 delivered with NetBeans IDE 6.1 ML.
Create a new JRuby project.
Copy the JRuby scripting files into the project.
Right-click and open the Project Properties tab and provide the appropriate jar files for the project to use.
Start the Sun Java System Application Server.
Open a script file in NetBeans, right-click on the source, and then click Run File to run the script.