Chapter 13 Using jagtool and jagant
The EAServer installation includes a sample XML build file. You can find it in %JAGUAR%\sample\jagtool\sample.xml (UNIX) or $JAGUAR/sample/jagtool/sample.xml (Windows).
This file contains targets for:
For example, to run jagant with the sample build file to refresh a package named SVU, enter this command all on one line:
jagant -buildfile %JAGUAR%\sample\jagtool\sample.xml refresh_svu
In this example, jagant is invoked with the specified build file. The target, refresh_svu, is defined in the build file as:
<!--refresh package svu --> <target name="refresh_svu" depends="connect"> <jag_refresh entity="Package:SVU" /> </target>
The refresh_svu target invokes the jag_refresh command to refresh the package named SVU. The refresh_svu target depends on the connect target. This dependency causes the connect target to run before the refresh_svu target. The connect target is defined as follows:
<!-- connect --> <target name="connect"> <jag_connect host="$(jaguar.host)"port="$(jaguar.port)" user="$(jaguar.user)" password="$(jaguar.password)" /> </target>
The connect target invokes the jag_connect command to open a connection with the server. The host name, port number, user name and password are variables. They are defined earlier in the build file as follows:
<!-- global properties for this build --> <property name="jaguar.host" value="yourMachine" /> <property name="jaguar.port" value="9000" /> <property name="jaguar.user" value="jagadmin" /> <property name="jaguar.password" value="" />
You can override these values at the command line using the Ant -D option. This is typically done to specify the password, so that it is not stored directly in the build file. For example (entered all on one line):
jagant -Djaguar.host=eclipse -Djaguar.port=9005 -Djaguar.password=jagpass -buildfile %JAGUAR%\sample\jagtool\sample.xml refresh_svu
This command connects to the server with a host name of eclipse on port 9005 , with the user name jagadmin and the password jagpass . The default user of jagadmin is still used because it was not overridden at the command line.
Each build file that invokes jagtool commands must include definitions for those commands. This is done by including an Ant taskdef directive for each jagtool command. You can see these directives in the sample build file. For example:
<!-- task definitions --> <taskdef name="jag_connect" classname="com.sybase.jaguar.management.jagtool.ant.ConnectTask" /> <taskdef name="jag_copy" class="com.sybase.jaguar.management.jagtool.ant.CopyTask" />
Each definition includes the name of the command and the location of the class file it invokes.
Use the jag_connect command to connect to a server in build files. You cannot use jag_connect from the command line, where the -u, -n, -p and -h flags serve the same purpose. Because a server connection is required for jagtool commands to execute, jag_connect must be executed before any other jagtool commands in the build file. jag_connect can be included directly in any target, or in a "connect" target that other targets list as a dependency.
Options for the jag_connect command include:
You can use multiple jag_connect commands in a single build file, which allows you to execute jagtool commands for different servers. Each time jag_connect is executed, the current connection is closed and a new one is opened. For example, this code restarts two servers:
<target name="restart_all_servers"> <jag_connect host="host1" password-="jagpass" /> <jag_restart /> <jag_connect host="host2" password="jagpass" /> <jag_restart /></target>
A connection to host1 is opened and the server on host1 is restarted. Then the connection is closed, a connection is opened to host2, and the server on host2 is restarted. The port number for both servers is 9000 and the user name is jagadmin (the defaults). The password for both servers is jagpass, and the log file is System.out.
Copyright © 2002 Sybase, Inc. All rights reserved. |
![]() |