Java CAPS Management and Monitoring APIs

Setting Up Scripting Engines

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.

Downloading, Installing, and Setting Up A Scripting Environment

For the purposes of this topic, we will focus on four scripting engines:


Note –

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.


Setting Up a Scripting Environment to Invoke Java CAPS Management and Monitoring APIs

There are two files that are necessary before you set up your scripting environment to invoke Java CAPS Management and Monitoring APIs:


Note –

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.

ProcedureTo Modify the Environment Variables in env.bat

  1. 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.

  2. 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.

  3. 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.

  4. 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.


    Note –

    You are now ready to run the scripting samples.


Using a Scripting Language to Exercise the Java CAPS Management and Monitoring APIs

Before running the scripting samples, it is assumed that you installed one of the scripting engines.

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


Tip –

If your environment is different, change the following steps or the scripts according to your environment or installation.


Currently Sun supports these services:

Additional services will be supported in the future.

Exercising the Administration Service

Before you can exercise the Administration Service, you must have the following installed, and/or deployed, in your environment:

Exercising the Administration Service in Groovy

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

Exercising the Configuration Service

Before you can exercise the Configuration Service, you must have the following installed in your environment:

Exercising the Configuration Service in Groovy

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

Exercising the Deployment Service

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.

Exercising the Deployment Service in Groovy

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

Exercising the Installation Service

Before you can exercise the Installation Service, you must have aspectserviceengine.jar installed in your environment.


Caution – Caution –

Read the following carefully.


  1. A service engine named sun-aspect-engine attempts to stop, shutdown, and uninstall itself.

  2. The service engine then attempts to install sun-aspect-engine from the attached aspectserviceengine.jar.

  3. Before you run the Installation Service sample scripts, install aspectserviceengine.jar in your environment and start it.

  4. Change the script as you see fit to run in your environment.

Exercising the Installation Service in Groovy

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

Exercising the Runtime Management Service

Before you can exercise the Runtime Management Service, you must have the following installed and deployed in your environment:

Exercising the Runtime Management Service in Groovy

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

Exercising the JMS Management Service

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:


Note –

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.


Exercising the JMS Management Service in Groovy

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

Exercising the BPEL Management Service

Before you can exercise the BPEL Management Service, you must ensure:

Exercising the BPEL Management Service in Groovy

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

Exercising the HTTP Administration Service

Before you can exercise the HTTP Administration Service, you must have the following installed and deployed in your environment:

Exercising the HTTP Administration Service in Groovy

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

Exercising the Notification Service

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.


Note –

Change the script as you see fit to run in your environment.


Exercising the Notification Service in Groovy

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

JRuby Integrated into NetBeans IDE

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.


Note –

Java CAPS 6 delivered with NetBeans IDE 6.1 ML.


ProcedureTo Create a JRuby Project

  1. Create a new JRuby project.

  2. Copy the JRuby scripting files into the project.

  3. Right-click and open the Project Properties tab and provide the appropriate jar files for the project to use.

  4. Start the Sun Java System Application Server.

  5. Open a script file in NetBeans, right-click on the source, and then click Run File to run the script.