cle_clock
Home > wikikonf >  wls/actions/by kikonf > jms







Jms

print

Action : wls.jms   (Category : wls, Name : jms, By : kikonf)
Complete Name : wls.jms.by.kikonf
Version : 4.0        License : Modified BSD License

Purpose of the wls category :
Easy to customize. This category use in background the wlst command in jython mode, to drive WebLogic Server configuration.
You can use it to manage the whole WebLogic architecture.

Purpose of this jms plugin : Creates JMS QCFS and Queues

The following shows the main Source Code File for the Action : wls.jms

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.wls.tools import *



class Jms(wlsAction):
        
    def extract(self, scope_attrs=None, prefix=None, **keywords):
        self_funct='extract'
        scope_cp, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent())
        self.verbose(scope_attrs, prefix=prefix)
        indent=self.getIndent() + 3*' '
        
        verbose('JMSSystemResource listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        cmo=cd('/')
        rscs=cmo.getJMSSystemResources()

        for rsc in rscs:
            rname=rsc.getName()
            
            if prefix!=None and rname.startswith(prefix) \
            or prefix==None and name!=None and rname==name \
            or prefix==None and name==None:
                if not checkTarget(rsc, scope):continue

                # - module
                verbose('JMSSystemResource' + rname + ' retreived.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
                cmo=cd('/JMSSystemResources/' + rname)
                
                # - Sub Deployments
                sbs=cmo.getSubDeployments()
                
                if len(sbs)>1:
                    verbose('JMSSystemResource:' + rname + ', more than one Sub Deployment instances found. Skipped !', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
                    continue
                    
                sb=sbs[0]
                
                # - JMSserver
                srv=sb.getTargets()[0]
                if srv==None:
                    verbose('JMSSystemResource/SubDeployment:' + rname + '/' + sb.getName() + ', no target JMS server found. Skipped !', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
                    continue
                srv=srv.getName()
                verbose('JMSserver:' + srv + ' retreived.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
                
                desc=cmo.getNotes()
                if desc==DESIGN_NOTICE:desc=None

                jms_node=self.newTop() #-- because in extract mode, each call returns a new blank top node.
                _name=rname
                if prefix!=None:_name=rname.split(prefix + '_')[1]
                jms_node.setAttrs(name=_name, srv=srv, create_srv='false', prefix=prefix, desc=desc)
                mkNodeScope(jms_node, scope_attrs, isUnique=True) #-- creates a scope node.

                cmo=cd('/JMSSystemResources/'+ rname + '/JMSResource/' + rname)
                
                # - qcfs
                qcfs=cmo.getConnectionFactories()
                if len(qcfs)>0:
                    verbose('ConnectionFactories:', level=self.getVerbose(), ifLevel=4, indent=indent + 3*' ', logFile=self.getLogFile())
                    qcfs_node=jms_node.newNode('qcfs')
                
                for qcf in qcfs:
                    desc=qcf.getNotes()
                    if desc==DESIGN_NOTICE:desc=None
                    attrs={
                        'name':qcf.getName(),
                        'jndi_name':qcf.getJNDIName(),
                        'desc':desc
                    }                    
                    verbose('ConnectionFactory:' + attrs['name'] + ' retreived.', level=self.getVerbose(), ifLevel=4, indent=indent + 3*' ', logFile=self.getLogFile())
                    if prefix!=None and attrs['name'].startswith(prefix):attrs['name']=attrs['name'].split(prefix + '_')[1]
                    qcfs_node.newNode('qcf', **attrs)
                    
                # - queues
                queues=cmo.getQueues()
                if len(queues)>0:
                    verbose('Queues:', level=self.getVerbose(), ifLevel=4, indent=indent + 3*' ', logFile=self.getLogFile())
                    queues_node=jms_node.newNode('queues')
                
                for q in queues:
                    desc=qcf.getNotes()
                    if desc==DESIGN_NOTICE:desc=None
                    attrs={
                        'name':qcf.getName(),
                        'jndi_name':qcf.getJNDIName(),
                        'desc':desc,
                        'expiry':q.getIncompleteWorkExpirationTime()
                    }
                    verbose('Queue:' + attrs['name'] + ' retreived.', level=self.getVerbose(), ifLevel=4, indent=indent + 3*' ', logFile=self.getLogFile())
                    if prefix!=None and attrs['name'].startswith(prefix):attrs['name']=attrs['name'].split(prefix + '_')[1]
                    queues_node.newNode('queue', **attrs) 

    def remove(self, no_name, no_name_no_prefix):
        jms_node=self.getTop()        
        jms_attrs = jms_node.getAttrs()
        scope_cp, scope_attrs, scope=self.getScope(parent_node=jms_node, indent=self.getIndent())
        self.verbose(scope_attrs, prefix=jms_attrs.prefix)
        indent=self.getIndent() + 3*' '
        
        self.rmvJMSmodule(name=jms_attrs.name, prefix=jms_attrs.prefix, indent=indent)
        if jms_attrs.create_srv=='true':self.rmvJMSserver(jms_attrs.srv, indent=indent)

    def inject(self):
        self_funct='inject'
        jms_node = self.getTop()        
        jms_attrs = jms_node.getAttrs()
        scope_cp, scope_attrs, scope=self.getScope(parent_node=jms_node, indent=self.getIndent())
        self.verbose(scope_attrs, prefix=jms_attrs.prefix)
        indent=self.getIndent() + 3*' '

        #-- Removing first
        self.rmvJMSmodule(name=jms_attrs.name, prefix=jms_attrs.prefix, indent=indent)
        if jms_attrs.create_srv=='true':self.rmvJMSserver(jms_attrs.srv, indent=indent)

        cmo=cd('/')
        tg=getMBean(scope_cp)
        
        # - srv
        if jms_attrs.create_srv=='true':jmsrv=cmo.createJMSServer(jms_attrs.srv)
        else:jmsrv=cmo.lookupJMSServer(jms_attrs.srv)
        
        if jmsrv==None:raise xception.kikonfActionSystemException(self, self_funct, 'The JMS server:' + jms_attrs.srv + ', do not exist ! Advice: Use the Attribute "create_srv" to force its creation !' )
        jmsrv.addTarget(tg)

        # - module
        if jms_attrs.prefix!=None:mname=jms_attrs.prefix + '_' + jms_attrs.name
        else:mname=jms_attrs.name

        jmsysrsc = cmo.createJMSSystemResource(mname)
        # -- desc
        if jms_attrs.desc==None:desc=DESIGN_NOTICE
        else:desc=jms_attrs.desc
        jmsysrsc.setNotes(desc)
        # -- target
        jmsysrsc.addTarget(tg)
        
        sbname=mname + '_sb'
        sb = jmsysrsc.createSubDeployment(sbname)
        # -- desc
        sb.setNotes(DESIGN_NOTICE)
        # -- target
        sb.addTarget(jmsrv)
        
        jmsrsc = jmsysrsc.getJMSResource()

        # - qcfs
        verbose('ConnectionFactories:', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        if jms_node.hasNode('qcfs'):
            
            for qcf_node in jms_node.getNode('qcfs')[0].getNodes():
                qcf_attrs = qcf_node.getAttrs()

                if jms_attrs.prefix!=None:qcf_name=jms_attrs.prefix + '_' + qcf_attrs.name
                else:qcf_name=qcf_attrs.name
                
                verbose('ConnectionFactory:' + qcf_name + ' creating.', level=self.getVerbose(), ifLevel=4, indent=indent + 3*' ', logFile=self.getLogFile())
                qcf = jmsrsc.createConnectionFactory(qcf_name)
                # -- desc
                if qcf_attrs.desc==None:desc=DESIGN_NOTICE
                else:desc=qcf_attrs.desc
                sb.setNotes(desc)
                qcf.setJNDIName(qcf_attrs.jndi_name)
                qcf.setSubDeploymentName(sbname)
                verbose('ConnectionFactory:' + qcf_name + ' created.', level=self.getVerbose(), ifLevel=3, indent=indent + 3*' ', logFile=self.getLogFile())

        # - queues
        verbose('Queues:', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        if jms_node.hasNode('queues'):

            for queue_node in jms_node.getNode('queues')[0].getNodes():
                queue_attrs = queue_node.getAttrs()
                
                if jms_attrs.prefix!=None:qname=jms_attrs.prefix + '_' + queue_attrs.name
                else:qname=queue_attrs.name
                
                verbose('ConnectionFactory:' + qname + ' creating.', level=self.getVerbose(), ifLevel=3, indent=indent + 3*' ', logFile=self.getLogFile())        
                q = jmsrsc.createQueue(qname)
                # -- desc
                if queue_attrs.desc==None:desc=DESIGN_NOTICE
                else:desc=queue_attrs.desc
                sb.setNotes(desc)
                q.setJNDIName(queue_attrs.jndi_name)
                q.setSubDeploymentName(sbname)
                verbose('ConnectionFactory:' + qname + ' created.', level=self.getVerbose(), ifLevel=3, indent=indent + 3*' ', logFile=self.getLogFile())        

    def rmvJMSmodule(self, name=None, prefix=None, indent=None):
        scope_cp, scope_attrs, scope=self.getScope()
        verbose('JMSSystemResource listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        cmo=cd('/')
        rscs=cmo.getJMSSystemResources()

        for rsc in rscs:
            rname=rsc.getName()
            
            if prefix!=None and rname.startswith(prefix) \
            or prefix==None and name!=None and rname==name \
            or prefix==None and name==None:
                if not checkTarget(rsc, scope):continue
                
                verbose('JMSSystemResource:' + rname + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
                cmo.destroyJMSSystemResource(rsc) 
                verbose('JMSSystemResource:' + rname + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())

    def rmvJMSserver(self, name, indent=None):
        scope_cp, scope_attrs, scope=self.getScope()
        verbose('JMSserver listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        cmo=cd('/')
        srv=cmo.lookupJMSServer(name)
        srv=cmo.lookupJMSServer('myjmserver')
        if srv!=None:
            verbose('JMSServer:' + name + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            cmo.destroyJMSServer(srv) 
            verbose('JMSServer:' + name + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())

    def verbose(self, scope_attrs, name=None, prefix=None, logFile=None):
        scope=str(scope_attrs).replace("'", '')[1:-1]
        
        if prefix==None:verbose('MQQueueConnectionFactories,MQQueues,WMQActivationSpecs at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
        else:verbose('MQQueueConnectionFactory,MQQueue,WMQActivationSpecs under prefix:' + prefix + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/wls/jms/by/kikonf/jms.py)


  • Line 1 to 3 say something , say something , say something
  • Line 10 to 17 say something , say something , say something , say something , say something
  • Line 20 to 25 say something



Trademarks :
  • "IBM WebSphere MQ" and "WebSphere MQ" are registred trademarks of International Business Machines Corporation.
  • "oracle", "Weblogic", "Weblogic Server", "Java" and "JVM" are a registred trademarks of Oracle and/or its affiliates.
  • Other names may be trademarks of their respective owners.

Copyright © 2011 - Patrick Placidoux, Hélène Malamoud