文件结构组织如下所示:
------ear
| ---Communication.ear
------buildfile
| ---build.xml
| ---install_communication.jacl
------bin
| ---Install_EAR.bat
----ReadMe.txt
结构说明在Install_EAR.bat中调用ant命令,ant的脚本为build.xml,在ant脚本中引用install_communication.jacl,而在jacl脚本中引用ear目录下的Communication.ear,每次做更新的时候,仅需要更新Communication.ear即可。
ant 文件如下所示
<project name="INSTALL_EAR" default="all">
<target name="install_application">
<exec executable="wsadmin" vmlauncher="false">
<arg line="-f"/>
<arg line="install_commnication.jacl"/>
</exec>
</target>
<target name="all" depends="install_application"/>
</project>
install_commnication.jacl 文件如下所示
puts "------------- START --------------------"
puts "------------- INSTALL THE EAR COMMUNICATION --------------------"
puts "[$AdminApp install ../ear/Communication.ear]"
puts "------------- SAVING FOR INSTALLING THE EAR COMMUNICATION --------------------"
puts "[$AdminConfig save]"
puts "------------- SET MBEAN --------------------"
puts "[set appManager [$AdminControl queryNames type=ApplicationManager,process=server1,*]]"
puts "------------- START THE APPLICATION --------------------"
puts "[$AdminControl invoke $appManager startApplication Communication]"
puts "------------- SAVING FOR STARTING THE EAR COMMUNICATION --------------------"
puts "[$AdminConfig save]"
puts "------------- END --------------------"
相关说明【以下内容源于 水木社区 - Blog - 羽之天地】:
1. 启动wsadmin工具。
在$Was_install_dir$/profiles/profile_name/bin 目录下运行命令:
linux下为wsadmin.sh,Windows下为wsadmin.bat。
2. 识别应用程序所在的服务器的应用程序管理器 MBean,并将其指定给 appManager 变量。以下示例返回应用程序管理器 MBean 的名称。
set appManager [$AdminControl queryNames cell=mycell,node=mynode,type=ApplicationManager,process=server1,*]
mycell,mynode,server1是要启动应用程序的真实名称,其他的不要更改。
3. 启动应用程序。以下示例在 MBean 上调用 startApplication 操作,提供要启动的应用程序名称。
$AdminControl invoke $appManager startApplication myApplication
其中:
$ 是使用其值替换变量名的 Jacl 运算符
AdminControl 是一个对象,它启用 WebSphere 服务器进程中运行的 MBean 的操作
invoke 是 AdminControl 命令
appManager 求在步骤 1 中指定的服务器标识的值
startApplication 是修改对象的属性
myApplication 是 startApplication 属性的值
更加详细的说明以及Jython 脚本的使用可以参考下面的网页:
【我和那个牛人的聊天记录】
Dong Ming Wang:
call following cmd in wsadmin env, $AdminApp install $earLocation [subst {-node $nodeName -server $serverName -appname $appName -installdir "$ecAppHome" -nopreCompileJSPs -verbose -distributeApp}]
jianjin:
I can't make it clear... Could you give me an example or a document about how to use this command? Thank you
Dong Ming Wang
usage : wsadmin -f abc.jacl <properties file>
Dong Ming Wang
put above cmd in jacl file, then you can run it in your ant script
Dong Ming Wang
also, you google jacl for detail syntax