Sunday, March 21, 2010

Modifying the starting weight of applications using scripting (jython)

1. Update the starting weight of an Enterprise Application:
 
AdminConfig.modify
(AdminConfig.showAttribute
(AdminConfig.getid("/Deployment:myApps/"),
"deployedObject"),[['startingWeight','20']])

Note: Valid range for 'startingWeight': 0 and 2147483647

2. Update the class loader mode of an Enterprise Application:
 
AdminConfig.modify
(AdminConfig.showAttribute(AdminConfig.showAttribute
(AdminConfig.getid('/Deployment:myApps/'),'deployedObject'),
'classloader'),[['mode','PARENT_LAST']])

Note: Valid values for 'mode' : PARENT_FIRST, PARENT_LAST

3. Update the WAR class loader policy of an Enterprise Application:
 
AdminConfig.modify
(AdminConfig.showAttribute
(AdminConfig.getid('/Deployment:myApps/'),
'deployedObject'),[['warClassLoaderPolicy','SINGLE']])

Note: Valid values for 'warClassLoaderPolicy':
SINGLE (Application), MULTIPLE (Module;default)

4. Update the starting weight of individual modules (Web or EJB) within an EAR -->

def modifyModStartingWeight(appName, modStWeight, modName):
    global AdminConfig
    try:
        refParam = "/Deployment:" + appName + "/"
        depRef = AdminConfig.getid(refParam)
        depObjectRef = AdminConfig.showAttribute(depRef, 'deployedObject')
        modules = AdminConfig.showAttribute(depObjectRef, 'modules')
        arrayModules = modules[1:len(modules)-1].split(" ")
        for module in arrayModules:
        tmpStr = AdminConfig.showAttribute(module,'uri')
                if tmpStr == modName:
                        AdminConfig.modify(module, [['startingWeight', modStWeight]])
                        print "New starting weight for " +
AdminConfig.showAttribute(module,'uri') + "is " +
AdminConfig.showAttribute(module,'startingWeight')
        try:
            AdminConfig.save()
        except:print "AdminConfig.save() caught exception. \n"
    except: print "AdminConfig.modify(" + appName + ") caught 

###########################################################################

No comments:

Post a Comment