The <execJava> mechanism enables agent-side, in-process execution of client-provided Java code within a plan or component definition. <execJava> is similar to <execNative>, but is specifically intended to enable execution of Java code.
The <execJava> feature is provided as an XML step and as a Java-based API. For information about the XML schema, attributes, and child elements, see <execJava> Step in Sun N1 Service Provisioning System 5.1 XML Schema Reference Guide. For more information about the execJava API, including examples, see execJava API.
The <execJava> XML step has one required and two optional attributes:
className – A required attribute that provides the Java class to be executed on the target host.
classPath – An optional attribute that provides the path to the class identified by the className attribute; If this attribute is not used, the system class path of the remote agent is used
timeout – An optional attribute that specifies the number of seconds to wait for the Java class to execute before timing out
The <execJava> mechanism can pass arguments to the Java Executor using the <argList> child element.
<varList> <var name="installPath" default="/opt/util"/> </varList> <resourceList defaultInstallPath=":[installPath]"> <resource resourceName="util/propPrint.jar" installName="propPrint.jar"/> </resourceList> ... <controlList> <control name="showProp"/> <paramList> <param name="propName"> </paramList> <execJava className="com.raplix.util.PropertyPrinterFactory" classPath="$[installPath]/propPrint.jar"> <argList> <arg name="propertyName" value=":[propName]"/> </argList> <successCriteria outputMatches="<undefined>" inverse="true"/> </execJava>
<executionPlan xmlns="http://www.sun.com/schema/SPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sun.com/schema/SPSplan.xsd" name="execJavaExample" version="5.1"> <paramList> <param name="name"></param> <param name="value"></param> </paramList> <varList> <var name="classpath" default=":[target:sys.raDataDir]:[/]systemcomps:[/]plugin-com.sun.sample.jar"/> </varList> <simpleSteps> <execJava className="com.sun.n1.sps.pluginimpl.sample.executor.SampleExecutorFactory" classPath=":[classpath]"> <argList nameParam=":[name]" valueParam=":[value]" /> </execJava> </simpleSteps> </executionPlan>