[ Team LiB ] |
Using Ant with the Command-Line InterfaceThe version of Ant that ships with WebLogic Sever 8.1 has built-in tasks specific to WebLogic Server. The wlserver Ant task enables you to start, reboot, shut down, and connect to an existing WebLogic Server instance or create a new one. The wlconfig Ant task enables you to change the configuration of a WebLogic Server domain. The sample Ant script build file shows how to create and delete a connection pool in the MedRec domain that is installed when you install WebLogic Server with examples. Listing 38.5 shows a script that calls an Ant task file. Listing 38.5 runAntTask.cmd@echo off @rem set environment variable for WebLogic Home set WL_HOME=f:\bea\weblogic81 @rem set the environment call %WL_HOME%\server\bin\setWLSEnv.cmd @rem Run the Administration Command echo off ant -Dusername=weblogic -Dpassword=weblogic The Ant task in the preceding script calls the build file as shown in Listing 38.6. Listing 38.6 build.xml<project name="jdbcPoolDEMO" default="delete-pool"> <target name="create-pool"> <wlconfig url="t3://localhost:7001" username="${username}" password="${password}"> <query domain="medrec" type="Server" name="MedRecServer" property="medrecserver"/> <create type="JDBCConnectionPool" name="demoPool" property="medrecpool"> <set attribute="CapacityIncrement" value="1"/> <set attribute="DriverName" value="com.pointbase.jdbc.jdbcUniversalDriver"/> <set attribute="InitialCapacity" value="4"/> <set attribute="MaxCapacity" value="15"/> <set attribute="Password" value="MedRec"/> <set attribute="Properties" value="user=MedRec"/> <set attribute="RefreshMinutes" value="0"/> <set attribute="ShrinkPeriodMinutes" value="10"/> <set attribute="ShrinkingEnabled" value="true"/> <set attribute="TestConnectionsOnRelease" value="false"/> <set attribute="TestConnectionsOnReserve" value="false"/> <set attribute="URL" value="jdbc:pointbase:server://localhost:9092/demo"/> <set attribute="Targets" value="${medrecserver}"/> </create> <query domain="medrec" type="JDBCConnectionPool" property="poolName"/> </wlconfig> <echo> Pool created=${poolName}</echo> </target> <target name="delete-pool" depends="create-pool"> <wlconfig url="t3://localhost:7001" username="${username}" password="${password}"> <delete mbean="${poolName}"> </delete> </wlconfig> </target> </project> This Ant project first creates a JDBC connection pool by the name demoPool in the medrec domain and then deletes the pool. You can run this command as
runAntTask.cmd user pwd
where user is the password for your WebLogic Server and pwd is the password. You can also call the Ant task directly. |
[ Team LiB ] |