# script for WLShell
# EJIE S.A, 2003

print "* Inicializando el Sistema"

connect

if $CONNECTED then
  print ""
  print ""
  print ""
  print ""
  print ""
  print "************************************************************************"
  # Se obtiene informacion de la instancia
  print "****************************** INSTANCIA ******************************"
  dominio_desa:
  cd /Server
  dir
  lista=$LAST
  for $elemento in $lista do
    name=get $elemento/Name
    if $name==$instancia then
      port=get $elemento/ListenPort
      state="SHUTDOWN"
      cd /ServerRuntime
      dir
      listaRuntime = $LAST
      for $elementoRuntime in $listaRuntime do
        if $elementoRuntime == $instancia
          state=get $elementoRuntime/State
        end
      end
      print "* Nombre: " $name ", Puerto:" $port ", Estado:" $state
    end
  end

  print "************************************************************************"
  # Se obtiene informacion de la aplicacion
  print "****************************** APLICACION ******************************"
  cd /Application
  dir
  lista=$LAST
  for $elemento in $lista do
    name=get $elemento/Name
    target=get $elemento/StagedTargets
    if $name==$codigoApp then
      path=get $elemento/Path
      components=get $elemento/Components
      print "* Nombre: " $name ", Path:" $path ", Modules:"
      modules=""
      for $component in $components do
        print "*      --> " $component
      end
    end
  end

  print "************************************************************************"
  # Se obtiene informacion del Pool
  print "************************************ POOL ******************************"
  cd /JDBCConnectionPool
  dir
  lista=$LAST
  for $elemento in $lista do
    name=get $elemento/Name
           
    if $name==$codigoApp"Pool" then
      properties=get $elemento/Properties
      initialCapacity=get $elemento/InitialCapacity
      maxCapacity=get $elemento/MaxCapacity
      cd /JDBCConnectionPoolRuntime
      dir
      listaRuntime = $LAST
      state="ND"
      for $elementoRuntime in $listaRuntime do
        if $elementoRuntime == $codigoApp"Pool"
          state=get $elementoRuntime/State
        end
      end
      currCapacity="ND"
      for $elementoRuntime in $listaRuntime do
        if $elementoRuntime == $codigoApp"Pool"
          currCapacity=get $elementoRuntime/CurrCapacity
        end
      end    
      print "* Nombre: " $name ", Properties:" $properties ", InitialCapacity:" $initialCapacity ", MaxCapacity:" $maxCapacity ", CurrCapacity:" $currCapacity ", State:" $state
    end
  end

  print "************************************************************************"
  # Se obtiene informacion del DataSource
  print "****************************** DATASOURCE ******************************"
  cd /JDBCTxDataSource
  dir
  lista=$LAST
  for $elemento in $lista do
    name=get $elemento/Name
                
    if $name==$codigoApp"DataSource" then
      jndiName=get $elemento/JNDIName
      poolName=get $elemento/PoolName
      print "* Nombre: " $name ", JNDIName:" $jndiName ", PoolName:" $poolName 
    end
  end

  print "************************************************************************"

  disconnect
  user=""
  password=""
else
  print "************************************************************************"
  print "********************** No connected to a server ************************"
  print "************************************************************************"
end

quit
