0
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="monitorResources" default="help" basedir=".">
<taskdef name = "wlst" classname="weblogic.ant.taskdefs.management.WLSTTask">
<classpath>
<pathelement location="${oracle.home}/wlserver_10.3/jdeveloper/ant/lib/weblogic.jar"/>
</classpath>
</taskdef>
<property file="Test_Build.properties"/>
<property name="ant-contrib.jar" location="${oracle.home}/ant/lib/ant-contrib-1.0b3.jar"/>
<property name="weblogic.jar" location="${oracle.home}/wlserver_10.3/server/lib/weblogic.jar"/>
<target name="fetchConnections">
<wlst executescriptbeforefile="true" debug="false">
<script>
def monitorJmsAdapter(serverName):
cd("ServerRuntimes/"+str(serverName)+"/ApplicationRuntimes/JmsAdapter/ComponentRuntimes/JmsAdapter/ConnectionPools")
connectionPools = ls(returnMap='true')
excessConnectionsList = [];
print '--------------------------------------------------------------------------------------'
print 'JmsAdapter Runtime details for '+ serverName
print ' '
print ' '
print '--------------------------------------------------------------------------------------'
print '%10s %13s %15s %18s' % ('Connection Pool', 'State', 'Current', 'Max')
print '%10s %10s %24s %21s' % ('', '', 'Capacity', 'Capacity')
print ' '
print '--------------------------------------------------------------------------------------'
for connectionPool in connectionPools:
cd('/')
cd("ServerRuntimes/"+str(serverName)+"/ApplicationRuntimes/JmsAdapter/ComponentRuntimes/JmsAdapter/ConnectionPools/"+str(connectionPool))
connectionName=cmo.getName()
print 'Name is' +connectionPool
currentCapacity=cmo.getCurrentCapacity()
maxCapacity=cmo.getMaxCapacity()
preferedCapacity=maxCapacity-190
if currentCapacity >= preferedCapacity:
excessConnectionsList.append(cmo.getName())
print excessConnectionsList
print '%15s %15s %10s %20s' % (cmo.getName(), cmo.getState(), +currentCapacity, +maxCapacity)
print ' '
print '--------------------------------------------------------------------------------------'
return excessConnectionsList
def main():
connect('weblogic','****','t3://localhost:7001')
servers = cmo.getServers()
domainRuntime()
for server in servers:
if server.getName()=='soa_server1':
monitorJmsAdapter(server.getName())
disconnect()
main()
</script>
</wlst>
</target>
<target name = "checkConnections">
<echo>###</echo>
</target>
</project>
上述腳本用於獲取超出其當前容量的連接的值。 WLST腳本已嵌入到Ant腳本中。將WLST腳本的值返回到Ant腳本
如何在「checkConnections」目標中獲取「excessConnectionsList」WLST變量的值?