you can run below CMD to add prop for ALL JVMs:
./wsadmin.sh -f add_prop.py all prop_name prop_value
or add on one JVM with JVM name:
./wsadmin.sh -f add_prop.py my_jvm_name prop_name prop_value
Here is the code:
serverName = sys.argv[0]
propName = sys.argv[1]
propValue = sys.argv[2]
def toList(inStr):
outList=[]
if (len(inStr)>0 and inStr[0]=='[' and inStr[-1]==']'):
inStr = inStr[1:-1]
tmpList = inStr.split(" ")
else:
tmpList = inStr.split("\n")
for item in tmpList:
item = item.rstrip();
if (len(item)>0):
outList.append(item)
return outList
def printWebContainerProperty(serverName):
for p in toList(AdminConfig.showAttribute(getWebContainer(serverName), 'properties')):
print '%60s - %s' % (AdminConfig.showAttribute(p, 'name'), AdminConfig.showAttribute(p, 'value'))
def updateWebContainerProperty(serverName, propName, propValue):
wc = getWebContainer(serverName)
updated = 'N'
for p in toList(AdminConfig.showAttribute(wc, 'properties')):
if AdminConfig.showAttribute(p, 'name') == propName:
AdminConfig.modify(p, [['value', propValue]])
updated = 'Y'
if updated == 'N':
setCustomProperties(wc, 'properties', {propName:propValue})
def removeWebContainerProperty(serverName, propName):
wc = getWebContainer(serverName)
for p in toList(AdminConfig.showAttribute(wc, 'properties')):
if AdminConfig.showAttribute(p, 'name') == propName:
AdminConfig.remove(p)
def getWebContainer(serverName):
return AdminConfig.list('WebContainer', AdminConfig.getid('/Server:' + serverName))
def setCustomProperties (objectName, propertyName, propertyMap):
propVals = []
for (key, value) in propertyMap.items():
propVals.append([["name", key], ["value", value]])
setObjectProperty(objectName, propertyName, propVals)
def setObjectProperty (objectName, propertyName, propertyValue):
AdminConfig.modify(objectName, [[propertyName, propertyValue]])
# Locate all Application Servers if server is 'all'
if (serverName == 'all'):
servers = AdminConfig.list('Server')
for aServer in toList(servers):
type = AdminConfig.showAttribute(aServer,'serverType')
if (type == 'APPLICATION_SERVER'):
serverName = AdminConfig.showAttribute(aServer, 'name')
print serverName
updateWebContainerProperty(serverName, propName, propValue)
else:
# Locate specified Server and its JVM
serverName = sys.argv[0]
updateWebContainerProperty(serverName, propName, propValue)
# Save changes
if (AdminConfig.hasChanges()):
AdminConfig.save()