|
|
|
Clsloader
Action : was.clsloader (Category : was, Name : clsloader, By : kikonf)
Complete Name : was.clsloader.by.kikonf Version : 5.0 License : Modified BSD License Purpose of the was category : Easy to customize. This category use in background the wsadmin command in jython mode (through AdminConfig, AdminControl and AdminTask), to drive WebSphere Application Server ® configuration. You can use it to manage the whole WebSphere ® architecture. Purpose of this clsloader plugin : Change a given Classloader Mode and Policy The following shows the main Source Code File for the Action : was.clsloader Toggle lines ## Copyright (c) 2008, Patrick Germain Placidoux ## All rights reserved. ## ## This file is part of Kikonf Public Software. ## ## Kikonf Public Software is released under the modified BSD License, ## which should accompany it or any part of it in the file "COPYING". ## If you do not have this file you can access the license ## through the WWW at http://www.kikonf.org/license/bsd/license.txt. ## ## Home: http://www.kikonf.org ## Contact: kikonf@gmx.com from actions.was.tools import * class Clsloader(wasAction): def extract(self, scope_attrs=None, **keywords): self_funct='extract' self.verbose(scope_attrs) dct={'server': None, 'node': None, 'application': None, 'war': None} dct.update(scope_attrs) scope_attrs=dct scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent()) indent=self.getIndent() + 3*' ' policy=mode=None if scope_attrs.has_key('application') and scope_attrs['application']!=None: verbose('deployedObject retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) dep=AdminConfig.showAttribute(scope_id, 'deployedObject') verbose('DeployedObject listed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) if scope_attrs['war']==None: policy=AdminConfig.showAttribute(dep, 'warClassLoaderPolicy') verbose('DeployedObject listed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) clloader = AdminConfig.showAttribute(dep, 'classloader') verbose('Classloader retreived.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) mode=AdminConfig.showAttribute(clloader, 'mode') else: mods = split(AdminConfig.showAttribute(dep, 'modules')) uris=[] found=False for mod in mods: uri=AdminConfig.showAttribute(mod, 'uri') uris.append(uri) if uri==scope_attrs['war']: found=True break if not found:raise xception.kikonfActionSystemException(self, self_funct, 'Web Module:' + scope_attrs['war'] + ', of Application:' + scope_attrs['application'] + ' not found ! Found uris are:' + str(uris) + '.') # AdminConfig.showAttribute(mod, 'classloaderMode') clloader = AdminConfig.showAttribute(mod, 'classloader') if clloader==None: xception.kikonfActionInformation(self, self_funct, 'Web Module:' + scope_attrs['war'] + ', of Application:' + scope_attrs['application'] + ' has no specific Class Loader definition.').warn(self.getVerbose()) return verbose('Classloader retreived.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) mode=AdminConfig.showAttribute(clloader, 'mode') else: cps=split(AdminConfig.showAttribute(scope_id, 'components')) for cp in cps: if cp.startswith(scope_attrs['server']): verbose('Component retreived.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) classpaths=getShowAsDict(AdminConfig.show(cp)) policy=classpaths['applicationClassLoadingMode'] mode=classpaths['applicationClassLoaderPolicy'] clsloader_node=self.newTop() #-- because in extract mode, each call returns a new blank top node. clsloader_node.setAttrs(mode=mode, policy=policy) mkNodeScope(clsloader_node, scope_attrs, isUnique=True) #-- creates a scope node. def inject(self): self_funct='inject' clsloader_node = self.getTop() clsloader_attrs = clsloader_node.getAttrs() scope_id, scope_attrs, scope=self.getScope(parent_node=clsloader_node, indent=self.getIndent()) #-- Retreives scope self.verbose(scope_attrs) indent=self.getIndent() + 3*' ' if scope_attrs['application']!=None: dep=AdminConfig.showAttribute(scope_id, 'deployedObject') verbose('Components retreived.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) if scope_attrs['war']==None: verbose('warClassLoaderPolicy modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) AdminConfig.modify(dep, 'warClassLoaderPolicy', clsloader_attrs.policy) verbose('WarClassLoaderPolicy modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) clloader = AdminConfig.showAttribute(dep, 'classloader') verbose('classloader modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) AdminConfig.modify(clloader, 'mode', clsloader_attrs.mode) verbose('Classloader modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) else: mods = split(AdminConfig.showAttribute(dep, 'modules')) uris=[] found=False for mod in mods: uri=AdminConfig.showAttribute(mod, 'uri') uris.append(uri) if AdminConfig.showAttribute(mod, 'uri')==scope_attrs['war']: found=True break if not found:raise xception.kikonfActionSystemException(self, self_funct, 'Web Module:' + scope_attrs['war'] + ', of Application:' + scope_attrs['application'] + ' not found ! Found uris are:' + str(uris) + '.') clloader = AdminConfig.showAttribute(mod, 'classloader') if clloader==None:clloader = AdminConfig.create('Classloader', mod, 'libraries', [, ['mode', 'PARENT_LAST']], 'classloader') verbose('classloader modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) AdminConfig.modify(clloader, [['mode', clsloader_attrs.mode]]) verbose('Classloader modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) else: cps=split(AdminConfig.showAttribute(scope_id, 'components')) for cp in cps: if cp.startswith(scope_attrs['server']): verbose('components modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) AdminConfig.modify(cp, [['applicationClassLoadingMode', clsloader_attrs.mode], ['applicationClassLoaderPolicy', clsloader_attrs.policy]]) verbose('Components modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) def verbose(self, scope_attrs): scope=str(scope_attrs).replace("'", '')[1:-1] verbose('JVM ClassLoader at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
Trademarks :
|