1. Executing jeusadmin Commands

This section describes how to edit an Ant build file (usually build.xml) to execute jeusadmin commands. This section also uses examples to describe how to create Ant targets.

Example

The following example shows how to execute the server-info command using Ant.

<project name="check-server-state-example" default="check-server-state">
    <property environment="env"/>
    <property name="jeus.home" value="${env.JEUS_HOME}"/>
    <property name="jeus.home.bin" value="${jeus.home}/bin"/>
    <property name="unix.jeusadmin" value="${jeus.home.bin}/jeusadmin"/>
    <property name="windows.jeusadmin" value="${jeus.home.bin}/jeusadmin.cmd"/>
    <property name="jeusadmin.args" value="-u administrator -p jeus -host host1 -port 9736 -verbose"/>
    <property name="server.name" value="adminServer"/>
    <property name="cmd.target" value="server-info -server ${server.name} -state"/>

    <condition property="isWindows">
        <os family="windows"/>
    </condition>
    <condition property="isUnix">
        <os family="unix"/>
    </condition>

    <target name="check-server-state">
        <antcall target="check-server-state-unix"/>
        <antcall target="check-server-state-windows"/>
    </target>

    <target name="check-server-state-windows" if="isWindows">
        <echo>${windows.jeusadmin} ${jeusadmin.args} ${cmd.target}</echo>
        <exec executable="${windows.jeusadmin}" osfamily="windows" spawn="false"
              failonerror="true">
            <arg line="${jeusadmin.args}"/>
            <arg value="${cmd.target}"/>
        </exec>
    </target>

    <target name="check-server-state-unix" if="isUnix">
        <echo>${unix.jeusadmin} ${jeusadmin.args} ${cmd.target}</echo>
        <exec executable="${unix.jeusadmin}" osfamily="unix" spawn="false"
              failonerror="true">
            <arg line="${jeusadmin.args}"/>
            <arg value="${cmd.target}"/>
        </exec>
    </target>
</project>
  • jeus.home is the JEUS installation location. The previous example assumes that the path to jeus.home is saved in the system environment variable JEUS_HOME.

    When executing Ant using the jant script provided by JEUS, JEUS_HOME does not need to be set separately.

  • unix.jeusadmin and windows.jeusadmin set the location of the scripts used to execute the jeusadmin tool. In general, the jeusadmin script is located under JEUS_HOME/bin. The script names in UNIX and Windows differ, so two properties are used.

  • jeusadmin.args is a list of argument values used to execute the jeusadmin tool. Set required options such as user name, password, host address, port number, and verbose output. For more information about the options, refer to jeusadmin.

  • cmd.target sets the command to be executed. This example checks the server status using the server-info command, so it is set to 'server-info -server ${server.name} -state'. For more information about available commands in jeusadmin, refer to Part II. "Console Commands and Tools".

  • check-server-state-windows and check-server-state-unix target use the exec task to execute jeusadmin. The osfamily property can be used to execute the OS-specific script. In the <exec> tag, the spawn property must be set to "false" to check the result using Ant. To fail an Ant build if a command failed to run, set the failonerror property to "true".

The following is the result on UNIX.

JEUS_HOME/bin$jant check-server-state
Buildfile: JEUS_HOME/bin/build.xml

check-server-state:

check-server-state-unix:
     [echo] JEUS_HOME/bin/jeusadmin -u administrator -p jeus -host host1 -port 9736 -verbose server-info -server adminServer -state
     [exec] Verbose output is enabled.
     [exec] Attempting to connect to localhost:9736.
     [exec] The connection has been established to Domain Administration Server adminServer in the domain domain1.
     [exec] RUNNING
     [exec]

check-server-state-windows:

BUILD SUCCESSFUL
Total time: 1 second
JEUS_HOME/bin$