iterative.jpg


Deployment command and tools deal with libraries in the same way as applications. The same set of commands are supported for libraries as for applications. There are, however, additional restrictions on library undeployment and redeployment. Undeployment or redeployment of a library is disallowed in case there are any deployed applications that refer to it in a running server. This does not necessarily interfere with upgrade scenarios. The recommended practice for upgrading shared libraries is to use versions and not to use “exact-match” while referring to libraries. A new version of library may be deployed without touching the older version. The applications that need to be upgraded may then simply be redeployed.

There is, however, a need for developers who create these libraries to test a change in deployed libraries in an iterative development scenario. If the developer does not mind loosing application state, she could use getReferencingRuntimes() methods of LibraryRuntimeMBean to identify referring applications and perform the following steps:



  1. Undeploy referring applications


  2. Redeploy library


  3. Deploy applications from the list gathered in #1


Here is a simple function that implements steps 1 – 3:


def redeployLibraryWithApps(libraryName):

serverRuntime()

cd('LibraryRuntimes/'+libraryName)
apps=cmo.getReferencingRuntimes()

appPaths={}

domainConfig()

cd('AppDeployments')

for app in apps:

appId = app.getApplicationIdentifier()

cd(appId)

appPaths[appId] = cmo.getAbsoluteSourcePath()

cd('..')

undeploy(appId)

redeploy(libraryName)

for appId in appPaths.keys():

deploy(appId, appPaths[appId])

return

Such a function may then be used in WLST scripts:


if (len(sys.argv) < 4):

print "Usage java weblogic.WLST redeployLib.py [username] [password] [library-name]"

exit()

connect(sys.argv[1],sys.argv[2])

redeployLibraryWithApps(sys.argv[3])

disconnect()

(Picture licensed from quapan under Creative Commons)