###
### get_message_listener.jacl
###
### Get message listener parameters from 
### an existing application. Use to generate
### code for $AdminApp install on another 
### WAS domain
###



proc get_message_listener {snames} {

###
### set up globals
###

global AdminConfig
global AdminControl
global AdminApp


set cells [$AdminConfig list Cell]

foreach cell $cells {

     set cname [$AdminConfig showAttribute $cell name]
     set nodes [$AdminConfig list Node $cell]

     foreach node $nodes {

        set nname [$AdminConfig showAttribute $node name]


        foreach sname $snames {

            set serverid [$AdminConfig getid /Cell:$cname/Node:$nname/Server:$sname/]

            if {[llength $serverid] == 0} {
               #puts "Serverid null - returning "
               continue 
            }


            ### 
            ### Identify the message listener service belonging to the server 
            ### and assign it to the mls variable: 
            ### 

            set mls [$AdminConfig list MessageListenerService $serverid]

            ### 
            ### Display attributes of listener ports for this MLS
            ### 

            set lports [$AdminConfig showall $mls listenerPorts]

            foreach lport $lports {

                puts $lport

            }
            
        }
    }
}

$AdminConfig save

}



###
### Main
###
### Test servers: nap_1_1 nap_2_1 
###


if { !($argc == 1) } {
   puts ""
   puts "Usage: , "
   puts " "
   puts "wsadmin.sh -username system -password password -f get_message_listener.jacl \"server1 server2 ...\""
} else { 
   set xservers      [lindex $argv 0]  
   get_message_listener $xservers 
}