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:
Refreshing a package
Restarting a server
Exporting a package to a JAR file
Deploying a J2EE EAR file
Creating a package
Setting package properties
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.
In build files, use the jag_connect command to connect to a server or to specify the server name for local mode. You cannot use jag_connect from the command line; instead use the connection or local-mode arguments described in “Local versus connected mode”.
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.
As with jagtool, you can run jagant in local or connected mode. “Local versus connected mode” explains the difference.
To run jagant in connected mode, specify these options for the jag_connect command:
user The user name used to connect. The default is jagadmin.
password The password used to connect. The default is no password.
logfile The log file for the connection attempt. The default is System.out.
For example, this sample project defines a connect task to connect to the machine “myhost” at port 9000, logging in as “jagadmin,” and runs the jag_list command over the connection:
<?xml version="1.0"?> <!DOCTYPE project [ <!ENTITY jagtasks SYSTEM "file:./jagtasks.xml"> ]> <project name="local_sample" default="list_packages" basedir="."> <!-- include Jaguar task definitions --> &jagtasks; <!-- connect --> <target name="connect"> <jag_connect host="myhost" port="9000" user="jagadmin" password="" /> </target> <!-- list packages in the server --> <target name="list_packages" depends="connect"> <jag_list type="Package" /> </target> <!-- list the properties of package CtsSecurity --> <target name="CtsSecurity_props" depends="connect"> <jag_props entity="Package:CtsSecurity" /> </target> </project>
To define a jag_connect task to run in local mode, set the localServer option to the name of the server to use when running in local mode. Specify the name of the server that you would connect to if running in connected mode. If you specify this option, the connected-mode arguments are ignored and jagant runs in local mode. For example, this sample project defines a connect task to run in local mode, then runs the jag_list command in the scope of the local-mode connection:
<?xml version="1.0"?> <!DOCTYPE project [ <!ENTITY jagtasks SYSTEM "file:./jagtasks.xml"> ]> <project name="local_sample" default="list_packages" basedir="."> <!-- include Jaguar task definitions --> &jagtasks; <!-- connect --> <target name="connect"> <jag_connect localServer="Jaguar" /> </target> <!-- list packages in the server --> <target name="list_packages" depends="connect"> <jag_list type="Package" /> </target> </project>
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 or local-mode session 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 © 2005. Sybase Inc. All rights reserved. |
![]() |