home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / csrootnode.tcl < prev    next >
Text File  |  1997-06-04  |  4KB  |  161 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1996
  4. #
  5. #      File:           @(#)csrootnode.tcl    /main/hindenburg/11
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)csrootnode.tcl    /main/hindenburg/11   4 Jun 1997 Copyright 1996 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. require "repdbms.tcl"
  13. require "csservices.tcl"
  14. require "csbrokersn.tcl"
  15. # End user added include file section
  16.  
  17. require "csnode.tcl"
  18.  
  19. Class CSRootNode : {CSNode} {
  20.     constructor
  21.     method destructor
  22.     method shutdown
  23.     method doUpdate
  24. }
  25.  
  26. constructor CSRootNode {class this name} {
  27.     set this [CSNode::constructor $class $this $name]
  28.     # Start constructor user section
  29.  
  30.         $this label "ObjectTeam"
  31.         $this icon rep_pepper_16
  32.         $this canShutdown 1
  33.  
  34.     # End constructor user section
  35.     return $this
  36. }
  37.  
  38. method CSRootNode::destructor {this} {
  39.     # Start destructor user section
  40.     # End destructor user section
  41.     $this CSNode::destructor
  42. }
  43.  
  44. method CSRootNode::shutdown {this {confirm 1}} {
  45.     if $confirm {
  46.         $this confirmShutdown "Shutdown ObjectTeam" \
  47.       "Are you sure you want to shutdown\
  48.            the entire ObjectTeam environment?" shutdownObjectTeam
  49.         return
  50.     }
  51.  
  52.     # Shutdown the entire ObjectTeam environment: all servers, brokers
  53.     # and nameserver.
  54.     #
  55.     set shutdownCount 0
  56.     set ns [ORB::nameServer]
  57.     set nsBroker [$ns broker]
  58.     set nsShutdown 0
  59.  
  60.     foreach broker [$ns brokers] {
  61.         # Shutdown all servers of this broker.
  62.         #
  63.         foreach implem [$broker implementations] {
  64.             foreach server [$implem servers] {
  65.                 # Skip nameserver, because that fails if its broker is
  66.                 # still running.
  67.                 #
  68.                 if {$server == $ns} {
  69.                     continue
  70.                 }
  71.  
  72.                 if [catch {$server shutdown} shutdownError] {
  73.             [$this view] error $shutdownError
  74.                 } else {
  75.                     incr shutdownCount
  76.                 }
  77.             }
  78.         }
  79.  
  80.         if [catch {$broker shutdown} shutdownError] {
  81.             [$this view] error $shutdownError
  82.         } else {
  83.         incr shutdownCount
  84.  
  85.         # If name_server broker was shutdown, don't try to update,
  86.         # since that will time-out for sure.
  87.         #
  88.         if {$broker == $nsBroker} {
  89.         set nsShutdown 1
  90.         }
  91.     }
  92.     }
  93.  
  94.     if $nsShutdown {
  95.         $this.services removeChildren
  96.     $this.services hasChildren 0
  97.  
  98.         $this.brokers removeChildren
  99.     $this.brokers hasChildren 0
  100.     } elseif {$shutdownCount > 0} {
  101.         $this update 0
  102.     }
  103. }
  104.  
  105. method CSRootNode::doUpdate {this {rebuild 1}} {
  106.     if [lempty [$this childSet]] {
  107.     CSServicesNode new $this.services
  108.     CSBrokersNode new $this.brokers
  109.     }
  110.     $this.services update $rebuild
  111.     $this.brokers update $rebuild
  112.  
  113.     set info [$this info]
  114.  
  115.     $info addHeader "ObjectTeam"
  116.     $info addItem "Package"         [m4_var get M4_package]
  117.     $info addItem "Version"         [versionInfo versionLabel]
  118.     $info addItem "Date"            [versionInfo dateLabel]
  119.     $info addItem "M4 Home"         [m4_var get M4_home]
  120.     $info addItem "Meta4UserEnv"    [m4_var meta4UserEnv]
  121.  
  122.     $info addHeader "C/S Variables In Environment"
  123.     set orbVar(M4_brokerport)        {}
  124.     set orbVar(M4_dblockmode)        {}
  125.     set orbVar(M4_dbms)            {}
  126.     set orbVar(M4_dbtracesql)        {}
  127.     set orbVar(M4_imphost)        {}
  128.     set orbVar(M4_nameserverhost)    {}
  129.     set orbVar(M4_nameserverport)    {}
  130.     set orbVar(M4_orb_linger)        {}
  131.     set orbVar(M4_orb_maxclients)    {}
  132.     set orbVar(M4_orb_maxinstances)    {}
  133.     set orbVar(M4_orb_report)        {}
  134.     set orbVar(M4_orb_timeout)        {}
  135.     set orbVar(M4_protocol)        {}
  136.     set orbVar(M4_services)        {}
  137.  
  138.     set orbVars {}
  139.     m4_var foreach var {
  140.         set context ""
  141.         set name $var
  142.         regexp {(.*)__(.*)} $var dummy name context
  143.         
  144.         if [info exists orbVar($name)] {
  145.             lappend orbVars $var
  146.         }
  147.     }
  148.  
  149.     foreach var [lsort $orbVars] {
  150.         if {$var == "M4_orb_timeout"} {
  151.             set value [[[$this view] rep] orbTimeOut]
  152.         } else {
  153.         set value [m4_var get $var]
  154.         }
  155.     $info addItem $var $value
  156.     }
  157. }
  158.  
  159. # Do not delete this line -- regeneration end marker
  160.  
  161.