我试图在 wlst 中获取数据源的第一个集群的字符串值名称
cd("/JDBCSystemResources/<datasource name>")
targets = get('Targets')
mytarget = targets[0]
这工作正常。如果我使用 viewMBean 命令“viewMBean(mytarget)”,我可以将名称视为属性“名称”
如果我打印 mytarget 的值,我会得到类似:“com.bea:Name=Cluster-1,Type=Cluster”
但我无法弄清楚如何获取名称(上例中的“Cluster-1”)
目前,除了将集群名称作为对象字符串表示的子字符串之外,我想不出任何办法,这听起来不像是要做的事情
任何帮助表示赞赏。
更新:
到目前为止没有答案,我正在使用这个解决方案,但仍然希望有一个更好的解决方案
# get the target cluster from the string "com.bea:Name=<clustername>,Type=Cluster"
if len(targets) == 1 :
tstring = str(targets[0])
targetCluster = tstring[13:tstring.find(",Type=Cluster")]
print "targetCluster = "+targetCluster;
else :
raise Exception("Expected single target cluster for datasource. Targets length was "+str(len(targets)))