SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
Trabalho de Sistemas Distribuídos
                   Implementação de um Chat utilizando JMS
                               Eduardo Rigamonte e Pietro Christ


INTRODUÇÃO
       Neste roteiro iremos explicar a criação de um chat utilizando a tecnologia Java Message
Service (JMS). A arquitetura JMS disponibiliza dois tipos de troca de mensagens, o Queue (modelo
ponto a ponto ou modelo de filas) e o modelo Topic ou Publish/Subscribe.
       Com o modelo de troca de mensagens por filas, poderíamos ter um ou vários produtores
enviando mensagens para uma mesma fila, mas teríamos apenas um único consumidor. Neste
modelo, cada vez que uma mensagem é consumida, ela deixa de existir na fila, por isso, podemos
ter apenas um único consumidor.
       O modelo Topic, permite uma situação em que teríamos de um a vários consumidores para o
mesmo tópico. Funciona como um sistema de assinaturas, cada cliente assina um tópico e a
mensagem fica armazenada no servidor até todos assinantes a tenham consumido. Este será o
modelo usado neste tutorial.




                          Arquitetura utilizando Queue (filas) e Topic (tópicos)



ROTEIRO

    1 Instalação dos artefatos e ferramentas necessárias:
        1.1 Fazer o download do Apache ActiveMQ 5.4.2
           http://www.4shared.com/zip/ksBEB_FW/apache-activemq-542-bin.html
        1.2 Descompactar o arquivo baixado no diretório C:.
        1.3 Para iniciá-lo basta executar o arquivo activemq.bat no caminho:
           C:apache-activemq-5.4.2binwin32
1.4 O FrontEnd do Apache ActiveMQ estará disponivel em http://localhost:8161/admin




                                FrontEnd Apache ActiveMQ


   1.5 É necessário que o JDK e um IDE estejam instalados para funcionamento da
      construção do chat. Neste tutorial utilizamos o Netbeans 7.1.1
2 Etapas para a construção do CHAT (passos a serem realizados pelo estudante):
   2.1 Abra o Netbeans e crie um projeto Java.
   2.2 A criação da interface será abstraída. Iremos disponibilizar o código completo no fim
      do documento.
   2.3 Adicione a biblioteca activemq-all-5.4.2.jar, que se encontra no diretório raiz do
      activeMQ, ao projeto.
   2.4 Criar uma classe JmsSubscriber.java, esta classe tem a finalidade de preparar a
      conexão para poder assinar um tópico e consequentemente poder receber as mensagens
      que serão publicadas.


          import chat.ctrl.CtrlChat;
          import javax.jms.*;
          import javax.naming.Context;
          import javax.naming.InitialContext;
          import javax.naming.NamingException;


          public class JmsSubscriber implements MessageListener {
            private TopicConnection connect;
            public JmsSubscriber(String factoryName, String topicName) throws
          JMSException, NamingException {
          //Obtém os dados da conexão JNDI através do arquivo jndi.properties
Context jndiContext = new
InitialContext(CtrlChat.getInstance().getProperties());
//O cliente utiliza o TopicConnectionFactory para criar um objeto do tipo
//TopicConnection com o provedor JMS
      TopicConnectionFactory factory = (TopicConnectionFactory)
jndiContext.lookup(factoryName);
//Pesquisa o destino do tópico via JNDI
      Topic topic = (Topic) jndiContext.lookup(topicName);
//Utiliza o TopicConnectionFactory para criar a conexão com o provedor JMS
      this.connect = factory.createTopicConnection();
//Utiliza o TopicConnection para criar a sessão para o consumidor
//Atributo false -> uso ou não de transações(tratar uma série de
//envios/recebimentos como unidade atômica e controlá-la via commit e
//rollback)
//Atributo AUTO_ACKNOWLEDGE -> Exige confirmação automática após
//recebimento correto
      TopicSession session = connect.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
//Cria(Assina) o tópico JMS do consumidor das mensagens através da sessão e o
//nome do tópico
      TopicSubscriber subscriber = session.createSubscriber(topic);
//Escuta o tópico para receber as mensagens através do método onMessage()
      subscriber.setMessageListener(this);
//Inicia a conexão JMS, permite que mensagens sejam entregues
      connect.start();
  }


// Recebe as mensagens do tópico assinado
  public void onMessage(Message message) {
      try {
//As mensagens criadas como TextMessage devem ser recebidas como
//TextMessage
        TextMessage textMsg = (TextMessage) message;
        String text = textMsg.getText();
        CtrlChat.getInstance().printtTela(text);
}
               catch (JMSException ex) {
                   ex.printStackTrace();
               }
           }
       // Fecha a conexão JMS
           public void close() throws JMSException {
               this.connect.close();
           }
       }


2.5 Criar uma classe JmsPublisher.java, esta classe tem a finalidade de preparar a conexão
   para poder publicar mensagens em um tópico.


  import chat.ctrl.CtrlChat;
   import javax.jms.*;
   import javax.naming.Context;
   import javax.naming.InitialContext;
   import javax.naming.NamingException;


   public class JmsPublisher {
     private TopicPublisher publisher;
     private TopicSession session;
     private TopicConnection connect;
     public JmsPublisher(String factoryName, String topicName) throws JMSException,
   NamingException {
   //Obtém os dados da conexão JNDI através do método getProperties
        Context jndiContext = new InitialContext(CtrlChat.getInstance().getProperties());
   // O cliente utiliza o TopicConnectionFactory para criar um objeto do tipo
   //TopicConnection com o provedor JMS
        TopicConnectionFactory factory = (TopicConnectionFactory)
   jndiContext.lookup(factoryName);
   // Pesquisa o destino do tópico via JNDI
        Topic topic = (Topic) jndiContext.lookup(topicName);
   // Utiliza o TopicConnectionFactory para criar a conexão com o provedor JMS
this.connect = factory.createTopicConnection();
   //Utiliza o TopicConnection para criar a sessão para o produtor
   //Atributo false -> uso ou não de transações(tratar uma série de
   //envios/recebimentos como unidade atômica e controlá-la via commit e rollback)
   //Atributo AUTO_ACKNOWLEDGE -> Exige confirmação automática após
   //recebimento correto
           this.session = connect.createTopicSession(false,
   Session.AUTO_ACKNOWLEDGE);
   //Cria o tópico JMS do produtor das mensagens através da sessão e o nome do
   //tópico
           this.publisher = session.createPublisher(topic);
       }
   //Cria a mensagem de texto e a publica no tópico. Evento referente ao produtor
       public void publish(String message) throws JMSException {
   //Recebe um objeto da sessao para criar uma mensagem do tipo TextMessage
           TextMessage textMsg = this.session.createTextMessage();
   //Seta no objeto a mensagem que será enviada
           textMsg.setText(message);
   //Publica a mensagem no tópico
           this.publisher.publish(textMsg, DeliveryMode.PERSISTENT, 1, 0);
       }
   //Fecha a conexão JMS
       public void close() throws JMSException {
           this.connect.close();
       }
   }


2.6 Criar uma classe CtrlChat.java , esta classe contém um métodos getProperties que
   retorno o arquivo java.util.properties no qual possui as configurações do servidor (ip do
   servidor, topic etc). Os métodos referente a configuração do JMS está abaixo, o restante
   não será mostrado aqui, porém estará disponibilizado no fim do documento.


       private JmsPublisher publisher = null;
       private JmsSubscriber subscriber = null;
       private String nome = "Anonimo";
private String ipServ = "";
private Properties prop = null;
private String topicName = "topicChat";
private String factoryName = "TopicCF";


public Properties getProperties() {
      if (prop == null) {
          prop = new Properties();


//classe jndi para o ActiveMQ
          prop.put("java.naming.factory.initial",
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
//url para conexão com o provedor
          prop.put("java.naming.provider.url", "tcp://" + ipServ + ":61616");
//nome da conexão
          prop.put("connectionFactoryNames", factoryName);
//nome do tópico jms
          prop.put("topic.topicChat", topicName);
      }
      return prop;
  }


  public void iniciarJMS() {
      try {
          subscriber = new JmsSubscriber(factoryName, topicName);
          publisher = new JmsPublisher(factoryName, topicName);


          publisher.publish(this.nome + " entrou na sala ..n");


//habilita os componentes da janela como enable true/false
          janChat.setComponentesEnable(true);
      }
      catch (JMSException ex) {
          JOptionPane.showMessageDialog(janChat, "Servidor não Encontrado!",
"ERROR", JOptionPane.OK_OPTION);
ipServ = "";
                       Logger.getLogger(CtrlChat.class.getName()).log(Level.SEVERE, null, ex);
                   }
                   catch (NamingException ex) {
                       Logger.getLogger(CtrlChat.class.getName()).log(Level.SEVERE, null, ex);
                   }
               }


       2.7 Existe uma persistência das mensagens no banco de dados SQLITE, utilizando
          JPA/Hibernate.
          2.7.1 Para a persistência foram utilizados os padrões de projeto fábrica abstrata e
             método fábrica. Classes criadas: DAO (interface), DAOJPA (implementação dos
             métodos utilizando JPA), ObjetoPersistente (pai de todas as classes persistentes),
             DAOFactory (classe que implementa o método fábrica e o classe abstrata).
          2.7.2 Para o funcionamento adequado da persistencia deve adicionar as bibliotecas:
             sqlitejdbc-v056.jar, slf4j-simple-1.6.1.jar, slf4j-api-1.6.1.jar, jta-1.1.jar, javassist-
             3.12.0.GA.jar, hibernate3.jar, hibernate-jpa-2.0-api-1.0.1.Final.jar, dom4j-1.6.1.jar,
             commons-collections-3.1.jar, cglib-2.2.jar, c3p0-0.9.1.jar e antlr-2.7.6.jar. Além do
             dialect do SQLITE.


    3 Resultados Esperados
          O esperado é que seja possível estabelecer uma conexão dos clientes ao servidor JMS
          (ActiveMQ) para poder enviar e receber as mensagens. Além disso as mensagens
          trocadas sejam gravadas em um banco formando um histórico para cada cliente.


    4 Resolução de problemas mais comuns
       4.1 O chat só irá funcionar caso o ActiveMQ estiver ativo.
       4.2 Se o IP não for encontrado não será possível estabelecer a comunicação.
       4.3 Caso a rede cair haverá uma tentativa de reconexão, caso não haja sucesso o chat será
          desativado e as mensagens enviadas neste tempo não serão entregues.


REFERÊNCIAS
http://mballem.wordpress.com/2011/02/09/chat-jms-com-activemq/
http://onjava.com/pub/a/onjava/2001/12/12/jms_not.html
Link do Tutorial em Video - http://www.youtube.com/watch?v=7Q9qe6FQ2TE
Anexo
/*
 * Cas cid pr o2 taah d dsiln d Ssea Dsrbio.
    lse raa aa  º rblo a icpia e itms itiuds
 */
pcaeca.ee
 akg htrd;

ipr ca.tlCrCa;
 mot htcr.tlht
ipr jvxjs*
 mot aa.m.;
ipr jvxnmn.otx;
 mot aa.aigCnet
ipr jvxnmn.ntaCnet
 mot aa.aigIiilotx;
ipr jvxnmn.aigxeto;
 mot aa.aigNmnEcpin

pbi casJsusrbripeet Msaeitnr{
 ulc ls mSbcie mlmns esgLsee

  piaeTpconcincnet
  rvt oiCneto onc;

  pbi JsusrbrSrn fcoyae Srn tpcae trw JSxeto,NmnEcpin{
   ulc mSbcie(tig atrNm, tig oiNm) hos MEcpin aigxeto
    / Otmo ddsd cnxoJD arvsd aqiojd.rpris
     / bé s ao a oeã NI taé o ruv nipoete
    CnetjdCnet=nwIiilotx(tlhtgtntne)gtrpris);
     otx niotx    e ntaCnetCrCa.eIsac(.ePoete()
    / OcineuiiaoTpconcinatr pr ciru ojt d tp Tpconcincmopoeo JS
     /  let tlz    oiCnetoFcoy aa ra m beo o io oiCneto o  rvdr M
    Tpconcinatr fcoy=(oiCnetoFcoy jdCnetlou(atrNm)
     oiCnetoFcoy atr     Tpconcinatr) niotx.okpfcoyae;
    / Psus odsiod tpc vaJD
     / eqia   etn o óio i NI
    Tpctpc=(oi)jdCnetlou(oiNm)
     oi oi    Tpc niotx.okptpcae;
    / UiiaoTpconcinatr pr ciracnxocmopoeo JS
     / tlz   oiCnetoFcoy aa ra   oeã o   rvdr M
    ti.onc =fcoycetTpconcin)
     hscnet   atr.raeoiCneto(;
    / UiiaoTpconcinpr cirassã pr ocnuio
     / tlz   oiCneto aa ra   eso aa  osmdr
    / Arbt fle- uoo nod tasçe(rtruasred evo/eeietscm uiaeaôiae
     / tiuo as > s u ã e rnaõstaa m éi e nisrcbmno oo ndd tmc
    / cnrl-avacmi erlbc)
     / otoál i omt    olak
    / Arbt AT_CNWEG - Eiecnimçoatmtc aó rcbmnocreo
     / tiuo UOAKOLDE > xg ofraã uoáia ps eeiet ort
    Tpceso ssin=cnetcetTpceso(as,SsinAT_CNWEG)
     oiSsin eso    onc.raeoiSsinfle eso.UOAKOLDE;
    / Ci(sia otpc JSd cnuio dsmnaesarvsd ssã eonm d tpc
     / raAsn)   óio M o osmdr a esgn taé a eso    oe o óio
    Tpcusrbrsbcie =ssincetSbcie(oi)
     oiSbcie usrbr    eso.raeusrbrtpc;
    / Ect otpc pr rcbra mnaesarvsd mtd oMsae)
     / sua  óio aa eee s esgn taé o éoo nesg(
    sbcie.eMsaeitnrti)
     usrbrstesgLsee(hs;
    / Iii acnxoJS prieqemnaessjmeteus
     / nca  oeã M, emt u esgn ea nrge
    cnetsat)
     onc.tr(;
  }

  @vrie
   Oerd
  / Rcb a mnaesd tpc asnd
   / eee s esgn o óio siao
  pbi vi oMsaeMsaemsae {
   ulc od nesg(esg esg)
     ty{
     r
/ A mnaescidscm TxMsaedvmsrrcbdscm TxMsae
           / s esgn raa oo etesg ee e eeia oo etesg
          TxMsaetxMg=(etesg)msae
           etesg ets   TxMsae esg;
          Srn tx =txMggtet)
           tig et  ets.eTx(;
          CrCa.eIsac(.rnteatx)
           tlhtgtntne)pitTl(et;
        }
        cth(MEcpine){
         ac JSxeto x
           e.rnSakrc(;
           xpittcTae)
        }
    }

    / FcaacnxoJS
     / eh   oeã M
    pbi vi coe)trw JSxeto {
     ulc od ls( hos MEcpin
       ti.onc.ls(;
        hscnetcoe)
    }
}
/*
 * Cas cid pr o2 taah d dsiln d Ssea Dsrbio.
    lse raa aa  º rblo a icpia e itms itiuds
 */
pcaeca.ee
 akg htrd;

ipr ca.tlCrCa;
 mot htcr.tlht
ipr jvxjs*
 mot aa.m.;
ipr jvxnmn.otx;
 mot aa.aigCnet
ipr jvxnmn.ntaCnet
 mot aa.aigIiilotx;
ipr jvxnmn.aigxeto;
 mot aa.aigNmnEcpin

pbi casJsulse {
ulc ls mPbihr

  piaeTpculse pbihr
  rvt oiPbihr ulse;
  piaeTpceso ssin
   rvt oiSsin eso;
  piaeTpconcincnet
   rvt oiCneto onc;

  pbi Jsulse(tigfcoyae Srn tpcae trw JSxeto,NmnEcpin{
   ulc mPbihrSrn atrNm, tig oiNm) hos MEcpin aigxeto
    / Otmo ddsd cnxoJD arvsd aqiojd.rpris
     / bé s ao a oeã NI taé o ruv nipoete
    CnetjdCnet=nwIiilotx(tlhtgtntne)gtrpris);
     otx niotx    e ntaCnetCrCa.eIsac(.ePoete()
    / OcineuiiaoTpconcinatr pr ciru ojt d tp Tpconcincmopoeo JS
     /  let tlz    oiCnetoFcoy aa ra m beo o io oiCneto o rvdr M
    Tpconcinatr fcoy=(oiCnetoFcoy jdCnetlou(atrNm)
     oiCnetoFcoy atr    Tpconcinatr) niotx.okpfcoyae;
    / Psus odsiod tpc vaJD
     / eqia  etn o óio i NI
    Tpctpc=(oi)jdCnetlou(oiNm)
     oi oi    Tpc niotx.okptpcae;
    / UiiaoTpconcinatr pr ciracnxocmopoeo JS
     / tlz   oiCnetoFcoy aa ra   oeã o   rvdr M
    ti.onc =fcoycetTpconcin)
     hscnet   atr.raeoiCneto(;
    / UiiaoTpconcinpr cirassã pr opouo
     / tlz   oiCneto aa ra   eso aa  rdtr
    / Arbt fle- uoo nod tasçe(rtruasred evo/eeietscm uiaeaôiae
     / tiuo as > s u ã e rnaõstaa m éi e nisrcbmno oo ndd tmc
    / cnrl-avacmi erlbc)
     / otoál i omt   olak
    / Arbt AT_CNWEG - Eiecnimçoatmtc aó rcbmnocreo
     / tiuo UOAKOLDE > xg ofraã uoáia ps eeiet ort
    ti.eso =cnetcetTpceso(as,SsinAT_CNWEG)
     hsssin   onc.raeoiSsinfle eso.UOAKOLDE;
    / Ci otpc JSd pouo dsmnaesarvsd ssã eonm d tpc
     / ra  óio M o rdtr a esgn taé a eso    oe o óio
    ti.ulse =ssincetPbihrtpc;
     hspbihr   eso.raeulse(oi)
  }

  / Ci amnae d txoeapbian tpc.Eet rfrnea pouo
   / ra   esgm e et    ulc o óio vno eeet o rdtr
  pbi vi pbihSrn msae trw JSxeto {
   ulc od uls(tig esg) hos MEcpin
     / Rcb u ojt d ssa pr ciruamnae d tp TxMsae
      / eee m beo a eso aa ra m esgm o io etesg
     TxMsaetxMg=ti.eso.raeetesg(;
      etesg ets     hsssincetTxMsae)
     / St n ojt amnae qesr evaa
      / ea o beo  esgm u eá nid
     txMgstetmsae;
      ets.eTx(esg)
/ Pbiaamnae n tpc
         / ulc esgm o óio
        ti.ulse.uls(ets,DlvrMd.ESSET 1 0;
         hspbihrpbihtxMg eieyoePRITN, , )
    }

    / FcaacnxoJS
     / eh  oeã M
    pbi vi coe)trw JSxeto {
     ulc od ls( hos MEcpin
       ti.onc.ls(;
        hscnetcoe)
    }
}
/*
 * Cas cid pr o2 taah d dsiln d Ssea Dsrbio.
    lse raa aa  º rblo a icpia e itms itiuds
 */
pcaeca.tl
 akg htcr;

ipr ca.d.esgm
 mot htcpMnae;
ipr ca.i.aCa;
 mot htchJnht
ipr ca.i.aCniua;
 mot htchJnofgrr
ipr jv.tlLs;
 mot aaui.it
ipr jv.tlPoete;
 mot aaui.rpris
ipr jv.tllgigLvl
 mot aaui.ogn.ee;
ipr jv.tllgigLge;
 mot aaui.ogn.ogr
ipr jvxjsJSxeto;
 mot aa.m.MEcpin
ipr jvxnmn.aigxeto;
 mot aa.aigNmnEcpin
ipr jvxsigJpinae
 mot aa.wn.OtoPn;
ipr ca.eeJsulse;
 mot htrd.mPbihr
ipr ca.eeJsusrbr
 mot htrd.mSbcie;
ipr ui.g.A;
 mot tlcdDO
ipr ui.g.AFcoy
 mot tlcdDOatr;

/*
 *
 *
 *@uhreiaot
    ato rgmne
 */
pbi casCrCa {
 ulc ls tlht

  piaeJsulse pbihr=nl;
  rvt mPbihr ulse     ul
  piaeJsusrbrsbcie =nl;
   rvt mSbcie usrbr    ul
  piaeSrn nm ="nnm"
   rvt tig oe  Aoio;
  piaeSrn iSr =";
   rvt tig pev  "
  piaeJnhtjnht
   rvt aCa aCa;
  piaePoete po =nl;
   rvt rpris rp   ul
  piaeSrn tpcae="oiCa"
   rvt tig oiNm    tpcht;
  piaeSrn fcoyae="oiC"
   rvt tig atrNm    TpcF;

  piaeCrCa( {
   rvt tlht)
  }

  pbi sai CrCa gtntne){
   ulc ttc tlht eIsac(
    rtr CrCaHle.NTNE
     eun tlhtodrISAC;
  }
piaesai casCrCaHle {
rvt ttc ls tlhtodr

    piaesai fnlCrCa ISAC =nwCrCa(;
    rvt ttc ia tlht NTNE   e tlht)
}

pbi Poete gtrpris){
ulc rpris ePoete(
  i (rp= nl){
   f po = ul
     po =nwPoete(;
      rp e rpris)

        /cas jd pr oAtvM
         /lse ni aa  cieQ
        po.u(jv.aigfcoyiiil,"r.pceatvm.niAtvMIiilotxFcoy)
         rppt"aanmn.atr.nta" ogaah.cieqjd.cieQntaCnetatr";
        /ulpr cnxocmopoeo
         /r aa oeã o   rvdr
        po.u(jv.aigpoie.r" "c:/ +iSr +"666)
         rppt"aanmn.rvdrul, tp/"  pev  :11";
        /nm d cnxo
         /oe a oeã
        po.u(cnetoFcoyae" fcoyae;
         rppt"oncinatrNms, atrNm)
        /nm d tpc js
         /oe o óio m
        po.u(tpctpcht,tpcae;
         rppt"oi.oiCa" oiNm)
    }

    rtr po;
    eun rp
}

pbi vi cagSre(tigi){
ulc od hneevrSrn p
  /iii o pg a poreae
   /nca u ea s rpidds
  Poete p=gtrpris)
   rpris    ePoete(;
  /rmv oedrç atro
   /eoe   neeo neir
  prmv(jv.aigpoie.r";
   .eoe"aanmn.rvdrul)
  /aiin u nv
   /dcoa m oo
  ppt"aanmn.rvdrul,"c:/ +i +"666)
   .u(jv.aigpoie.r" tp/"  p  :11";
  iSr =i;
   pev  p

}

pbi vi iiirM( {
ulc od ncaJS)
  ty{
   r
     sbcie =nwJsusrbrfcoyae tpcae;
      usrbr  e mSbcie(atrNm, oiNm)
     pbihr=nwJsulse(atrNm,tpcae;
      ulse  e mPbihrfcoyae oiNm)

        pbihrpbihti.oe+"eto n sl .";
         ulse.uls(hsnm   nru a aa .n)
/hblt o cmoetsd jnl cm eal tu/as
       /aiia s opnne a aea oo nbe refle
      jnhtstopnneEal(re;
       aCa.eCmoetsnbetu)
    }
    cth(MEcpine){
     ac JSxeto x
       JpinaesoMsaeilgjnht "evdrnoEcnrd!,"RO" JpinaeO_PIN;
        OtoPn.hwesgDao(aCa, Srio ã notao" ERR, OtoPn.KOTO)
       iSr =";
        pev  "
       Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e)
        ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x;
    }
    cth(aigxeto e){
     ac NmnEcpin x
       Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e)
        ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x;
    }
}

pbi vi rcncaPbihr){
 ulc od eoetrulse(
   ty{
    r
      pbihrcoe)
       ulse.ls(;
      sbcie.ls(;
       usrbrcoe)
      sbcie =nwJsusrbrfcoyae tpcae;
       usrbr   e mSbcie(atrNm, oiNm)
      pbihr=nwJsulse(atrNm,tpcae;
       ulse   e mPbihrfcoyae oiNm)
   }
   cth(MEcpine){
    ac JSxeto x
      JpinaesoMsaeilgjnht "evdrnoEcnrd!,"RO" JpinaeO_PIN;
       OtoPn.hwesgDao(aCa, Srio ã notao" ERR, OtoPn.KOTO)
      iSr =";
       pev  "
      jnhtstopnneEal(as)
       aCa.eCmoetsnbefle;
      Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e)
       ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x;
   }
   cth(aigxeto e){
    ac NmnEcpin x
      Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e)
      ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x;
  }
}

pbi Jsulse gtulse( {
 ulc mPbihr ePbihr)
   rtr pbihr
   eun ulse;
}

pbi Jsusrbrgtusrbr){
 ulc mSbcie eSbcie(
   rtr sbcie;
   eun usrbr
}

pbi vi fcaCnxo){
ulc od ehroea(
  ty{
   r
pbihrpbihti.oe+"si d sl .";
       ulse.uls(hsnm   au a aa .n)

      ti.ulse.ls(;
       hspbihrcoe)
      ti.usrbrcoe)
       hssbcie.ls(;
    }
    cth(MEcpine){
     ac JSxeto x
       Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e)
        ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x;
    }
}

pbi boensrioIiid( {
 ulc ola evdrncao)
  i (ulse ! nl & sbcie ! nl){
    f pbihr = ul & usrbr = ul
      rtr tu;
       eun re
   }
   rtr fle
    eun as;
}

pbi vi arraCniua( {
 ulc od biJnofgrr)
   nwJnofgrr)stiil(re;
    e aCniua(.eVsbetu)
}

pbi Srn gtoe){
 ulc tig eNm(
   rtr nm;
    eun oe
}

pbi vi stoeSrn nm){
 ulc od eNm(tig oe
   i (evdrncao) {
    f srioIiid()
      ty{
       r
         /evapr osrio
          /ni aa  evdr
         pbihrpbihti.oe+"mduonm pr "+nm +"n)
          ulse.uls(hsnm   uo  oe aa  oe   ";
      }
      cth(MEcpine){
       ac JSxeto x
         Lge.eLge(aCa.ls.eNm()lgLvlSVR,nl,e)
         ogrgtogrJnhtcasgtae).o(ee.EEE ul x;
      }
  }
  ti.oe=nm;
    hsnm    oe
}

pbi Srn gtpevdr){
 ulc tig eISrio(
   rtr iSr;
   eun pev
}
pbi vi stpevdrSrn iSr){
 ulc od eISrio(tig pev
   ti.pev=iSr;
   hsiSr   pev
}

pbi vi steaJnhtahs {
 ulc od eTl(aCa Ti)
   jnht=ahs
   aCa   Ti;
}

pbi vi pitTl(tigmg {
 ulc od rnteaSrn s)
   jnhtpiteamg;
   aCa.rnTl(s)
}
/dorsosvlprsla a mnaesn bno
 /a epnae o avr s esgn o ac
piaeDOdo=DOatr.eIsac(.beDOMnae.ls)
 rvt A a   AFcoygtntne)otrA(esgmcas;

pbi vi slaHsoioSrn mg {
ulc od avritrc(tig s)
  Mnae m=nwMnae(;
   esgm   e esgm)
  mstet(s)
   .eTxomg;

    ty{
     r
       dosla()
        a.avrm;
    }
    cth(xeto e){
     ac Ecpin x
       Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e)
        ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x;
    }
}

pbi Srn gtitrc( {
ulc tig eHsoio)
  Ls<esgm cnes =nl;
   itMnae> ovra    ul
  Srn mg=";
   tig s   "
  ty{
   r
     cnes =dootrMnae.ls)
      ovra   a.be(esgmcas;
     Sse.u.rnl(a)
      ytmotpitn"";
     fr(n i=0 cnes! nl & i<cnes.ie) i+ {
      o it    ; ovra= ul & ovrasz(; +)
        mg+ cnes.e()gtet(;
        s = ovragti.eTxo)
     }
  }
  cth(xeto e){
   ac Ecpin x
     Sse.u.rnl(b)
      ytmotpitn"";
     Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e)
      ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x;
  }
rtr mg
         eun s;
    }
}
/*
 * Faecid pr o2 taah d dsiln d Ssea Dsrbio.
    rm rao aa  º rblo a icpia e itms itiuds
 */
pcaeca.i;
 akg htch

ipr ca.tlCrCa;
 mot htcr.tlht
ipr jv.w.WEcpin
 mot aaatATxeto;
ipr jv.w.oo;
 mot aaatClr
ipr jv.w.rm;
 mot aaatFae
ipr jv.w.oo;
 mot aaatRbt
ipr jv.w.vn.eEet
 mot aaateetKyvn;
ipr jv.oFl;
 mot aai.ie
ipr jv.oFlWie;
 mot aai.iertr
ipr jv.oIEcpin
 mot aai.Oxeto;
ipr jv.oPitrtr
 mot aai.rnWie;
ipr jv.etSmlDtFra;
 mot aatx.ipeaeomt
ipr jv.tllgigLvl
 mot aaui.ogn.ee;
ipr jv.tllgigLge;
 mot aaui.ogn.ogr
ipr jvxiaeoIaeO
 mot aa.mgi.mgI;
ipr jvxjsJSxeto;
 mot aa.m.MEcpin
ipr jvxsigJiehoe;
 mot aa.wn.FlCosr

pbi casJnhtetnsjvxsigJrm {
 ulc ls aCa xed aa.wn.Fae

  piaeboensitn=fle
   rvt ola hfO  as;

  pbi Jnht){
   ulc aCa(
     iiCmoet(;
      ntopnns)
     iiFae)
      ntrm(;
     CrCa.eIsac(.eTl(hs;
      tlhtgtntne)steati)
  }

  @upesanns"nhce"
   SprsWrig(ucekd)
  / <dtrfl dfuttt=clasd ds=GnrtdCd"/GNBGNiiCmoet
   / eio-od ealsae"olpe" ec"eeae oe>/E-EI:ntopnns
  piaevi iiCmoet( {
   rvt od ntopnns)

    pnlrnia =nwjvxsigJae(;
     aePicpl      e aa.wn.Pnl)
    pnletr=nwjvxsigJae(;
     aeCne     e aa.wn.Pnl)
    fle5=nwjvxsigBxFle(e jv.w.ieso(,1) nwjv.w.ieso(,1) nwjv.w.ieso(26,1);
     ilr   e aa.wn.o.ilrnw aaatDmnin0 0, e aaatDmnin0 0, e aaatDmnin377 0)
    fle7=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377)
     ilr   e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26);
    fle8=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377)
     ilr   e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26);
    pnliuo=nwjvxsigJae(;
     aeTtl     e aa.wn.Pnl)
    ttlLbl=nwjvxsigJae(;
     iuoae     e aa.wn.Lbl)
    cnesSrlPn =nwjvxsigJcolae)
     ovracolae      e aa.wn.SrlPn(;
    cnesTx =nwjvxsigJetae)
     ovraet     e aa.wn.TxPn(;
    pnlot =nwjvxsigJae(;
     aeSuh    e aa.wn.Pnl)
    fle3=nwjvxsigBxFle(e jv.w.ieso(,1) nwjv.w.ieso(,1) nwjv.w.ieso(26,1);
     ilr   e aa.wn.o.ilrnw aaatDmnin0 0, e aaatDmnin0 0, e aaatDmnin377 0)
    fle4=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377)
     ilr   e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26);
    pnlesgm=nwjvxsigJae(;
     aeMnae      e aa.wn.Pnl)
    pnlet =nwjvxsigJae(;
     aeTxo    e aa.wn.Pnl)
    mnaeSrlPn =nwjvxsigJcolae)
     esgmcolae      e aa.wn.SrlPn(;
    mnaeTx =nwjvxsigJetae)
     esgmet     e aa.wn.TxPn(;
    fle1=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377)
     ilr   e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26);
    pnloa =nwjvxsigJae(;
     aeBto    e aa.wn.Pnl)
    evaBto =nwjvxsigJutn)
     nirutn     e aa.wn.Bto(;
    fle2=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377)
     ilr   e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26);
    braeuht=nwjvxsigJeua(;
     arMnCa      e aa.wn.MnBr)
    aqioeu=nwjvxsigJeu)
     ruvMn     e aa.wn.Mn(;
    cniIe =nwjvxsigJeutm)
     ofgtm    e aa.wn.MnIe(;
    sprdr=nwjvxsigJouMn.eaao(;
     eaao    e aa.wn.PppeuSprtr)
    siIe =nwjvxsigJeutm)
     artm   e aa.wn.MnIe(;
    hsoioeu=nwjvxsigJeu)
     itrcMn      e aa.wn.Mn(;
    aiaCeko =nwjvxsigJhcBxeutm)
     tvrhcBx      e aa.wn.CekoMnIe(;
    epraHsoiotm=nwjvxsigJeutm)
     xotritrcIe       e aa.wn.MnIe(;
stealCoeprto(aa.wn.idwosat.XTO_LS)
 eDfutlsOeainjvxsigWnoCntnsEI_NCOE;
adidwitnrnwjv.w.vn.idwdpe( {
 dWnoLsee(e aaateetWnoAatr)
   pbi vi wnoCoigjv.w.vn.idwvn et {
    ulc od idwlsn(aaateetWnoEet v)
      faelsn(v)
       rmCoiget;
   }
};
 )

pnlrnia.eLyu(e jv.w.odraot);
 aePicplstaotnw aaatBreLyu()

pnletrstaotnwjv.w.odraot);
 aeCne.eLyu(e aaatBreLyu()
pnletradfle5 jv.w.odraotPG_N)
 aeCne.d(ilr, aaatBreLyu.AEED;
pnletradfle7 jv.w.odraotLN_N)
 aeCne.d(ilr, aaatBreLyu.IEED;
pnletradfle8 jv.w.odraotLN_TR)
 aeCne.d(ilr, aaatBreLyu.IESAT;

ttlLblstotnwjv.w.ot"aoa,0 1);/ NI8
 iuoae.eFn(e aaatFn(Thm" , 8) / O1N
ttlLblstet"HTJS)
 iuoae.eTx(CA M";
pnliuoadttlLbl;
 aeTtl.d(iuoae)

pnletradpnliuo jv.w.odraotPG_TR)
 aeCne.d(aeTtl, aaatBreLyu.AESAT;

cnesTx.eFn(e jv.w.ot"oopcd,0 1);/ NI8
 ovraetstotnw aaatFn(Mnsae" , 3) / O1N
cnesSrlPn.eVeprVe(ovraet;
 ovracolaestiwotiwcnesTx)

pnletradcnesSrlPn,jv.w.odraotCNE)
 aeCne.d(ovracolae aaatBreLyu.ETR;

pnlrnia.d(aeCne,jv.w.odraotCNE)
 aePicpladpnletr aaatBreLyu.ETR;

pnlot.eLyu(e jv.w.odraot);
 aeSuhstaotnw aaatBreLyu()
pnlot.d(ilr,jv.w.odraotPG_N)
 aeSuhadfle3 aaatBreLyu.AEED;
pnlot.d(ilr,jv.w.odraotLN_TR)
 aeSuhadfle4 aaatBreLyu.IESAT;

pnlesgmstaotnwjvxsigBxaotpnlesgm jvxsigBxaotXAI);
 aeMnae.eLyu(e aa.wn.oLyu(aeMnae, aa.wn.oLyu._XS)

pnlet.eLyu(e jv.w.odraot);
 aeTxostaotnw aaatBreLyu()

mnaeTx.eFn(e jv.w.ot"oopcd,0 1);/ NI8
 esgmetstotnw aaatFn(Mnsae" , 3) / O1N
mnaeTx.ePeerdienwjv.w.ieso(6,9);
 esgmetstrfreSz(e aaatDmnin14 4)
mnaeTx.dKyitnrnwjv.w.vn.eAatr){
 esgmetadeLsee(e aaateetKydpe(
   pbi vi kyrse(aaateetKyvn et {
    ulc od ePesdjv.w.vn.eEet v)
      mnaeTxKyrse(v)
       esgmetePesdet;
   }
   pbi vi kyeesdjv.w.vn.eEetet {
    ulc od eRlae(aaateetKyvn v)
      mnaeTxKyeesdet;
       esgmeteRlae(v)
   }
};
 )
mnaeSrlPn.eVeprVe(esgmet;
 esgmcolaestiwotiwmnaeTx)

pnlet.d(esgmcolae jv.w.odraotCNE)
 aeTxoadmnaeSrlPn, aaatBreLyu.ETR;
pnlet.d(ilr,jv.w.odraotLN_N)
 aeTxoadfle1 aaatBreLyu.IEED;

pnlesgmadpnlet)
 aeMnae.d(aeTxo;

pnloa.eLyu(e jvxsigBxaotpnloa,jvxsigBxaotLN_XS)
 aeBtostaotnw aa.wn.oLyu(aeBto aa.wn.oLyu.IEAI);

evaBto.eTx(Eva";
 nirutnstet"nir)
evaBto.dAtoLsee(e jv.w.vn.cinitnr){
 nirutnadcinitnrnw aaateetAtoLsee(
   pbi vi atoPromdjv.w.vn.cinvn et {
    ulc od cinefre(aaateetAtoEet v)
      evaBtoAtoPromdet;
       nirutncinefre(v)
   }
};
 )
pnloa.d(nirutn;
 aeBtoadevaBto)

pnlesgmadpnloa)
 aeMnae.d(aeBto;
pnlesgmadfle2;
 aeMnae.d(ilr)
pnlot.d(aeMnae,jv.w.odraotCNE)
   aeSuhadpnlesgm aaatBreLyu.ETR;

  pnlrnia.d(aeSuh jv.w.odraotPG_N)
   aePicpladpnlot, aaatBreLyu.AEED;

  gtotnPn(.d(aePicpl jv.w.odraotCNE)
   eCnetae)adpnlrnia, aaatBreLyu.ETR;

  aqioeustet"ruv";
   ruvMn.eTx(Aqio)

  cniIe.eAclrtrjvxsigKytoegteSrk(aaateetKyvn.KT jv.w.vn.nuEetCR_AK)
   ofgtmstceeao(aa.wn.eSrk.eKytoejv.w.vn.eEetV_, aaateetIptvn.TLMS);
  cniIe.eTx(Cniuaõs)
   ofgtmstet"ofgrçe";
  cniIe.dAtoLsee(e jv.w.vn.cinitnr){
   ofgtmadcinitnrnw aaateetAtoLsee(
     pbi vi atoPromdjv.w.vn.cinvn et {
      ulc od cinefre(aaateetAtoEet v)
        cniIeAtoPromdet;
        ofgtmcinefre(v)
     }
  };
   )
  aqioeuadcniIe)
   ruvMn.d(ofgtm;
  aqioeuadsprdr;
   ruvMn.d(eaao)

  siIe.eAclrtrjvxsigKytoegteSrk(aaateetKyvn.KF,jv.w.vn.nuEetATMS);
   artmstceeao(aa.wn.eSrk.eKytoejv.w.vn.eEetV_4 aaateetIptvn.L_AK)
  siIe.eTx(Si";
   artmstet"ar)
  siIe.dAtoLsee(e jv.w.vn.cinitnr){
   artmadcinitnrnw aaateetAtoLsee(
     pbi vi atoPromdjv.w.vn.cinvn et {
      ulc od cinefre(aaateetAtoEet v)
        siIeAtoPromdet;
         artmcinefre(v)
     }
  };
   )
  aqioeuadsiIe)
   ruvMn.d(artm;

  braeuhtadaqioeu;
   arMnCa.d(ruvMn)

  hsoioeustet"itrc";
   itrcMn.eTx(Hsóio)

  aiaCeko.eAclrtrjvxsigKytoegteSrk(aaateetKyvn.KG jv.w.vn.nuEetCR_AK)
   tvrhcBxstceeao(aa.wn.eSrk.eKytoejv.w.vn.eEetV_, aaateetIptvn.TLMS);
  aiaCeko.eSlce(re;
   tvrhcBxsteetdtu)
  aiaCeko.eTx(Aia Gaaã";
   tvrhcBxstet"tvr rvço)
  hsoioeuadaiaCeko)
   itrcMn.d(tvrhcBx;

  epraHsoiotmstceeao(aa.wn.eSrk.eKytoejv.w.vn.eEetV_,jv.w.vn.nuEetCR_AK)
   xotritrcIe.eAclrtrjvxsigKytoegteSrk(aaateetKyvn.KS aaateetIptvn.TLMS);
  epraHsoiotmstet"xotr.";
   xotritrcIe.eTx(Epra .)
  epraHsoiotmadcinitnrnwjv.w.vn.cinitnr){
   xotritrcIe.dAtoLsee(e aaateetAtoLsee(
     pbi vi atoPromdjv.w.vn.cinvn et {
      ulc od cinefre(aaateetAtoEet v)
        epraHsoiotmcinefre(v)
         xotritrcIeAtoPromdet;
     }
  };
   )
  hsoioeuadepraHsoiotm;
   itrcMn.d(xotritrcIe)

  braeuhtadhsoioeu;
   arMnCa.d(itrcMn)

  stMnBrbraeuht;
   eJeua(arMnCa)

   jv.w.ieso sreSz =jv.w.oli.eDfutoli(.eSreSz(;
    aaatDmnin cenie  aaatToktgtealTokt)gtcenie)
   stons(ceniewdh46/,(ceniehih-5)2 46 31;
    eBud(sreSz.it-1)2 sreSz.egt31/, 1, 5)
}/<eio-od/GNEDiiCmoet
 / /dtrfl>/E-N:ntopnns

/*
 *Es mtd écaaopr cniua ofae
    se éoo hmd aa ofgrr rm.
 */
/ <dtrfl dfuttt=clasd ds=Mtd d cniuaã d Fae>
 / eio-od ealsae"olpe" ec"éoo e ofgrço o rm"
piaevi iiFae){
 rvt od ntrm(
    sprstil(CA JS)
     ue.eTte"HT M";
    sprstxeddtt(rm.AIIE_OH;
     ue.eEtneSaeFaeMXMZDBT)

  ty{
   r
     /aiã d ioea porm
      /dço o cn o rgaa
     sprstcnmg(mgI.edgtls(.eRsuc(/htigioepg))
      ue.eIoIaeIaeOra(eCas)gteore"ca/m/cn.n");
  }
cth(Oxeto e){
   ac IEcpin x
     Sse.r.rnl(Ioenoecnrd!)
      ytmerpitn"cn ã notao";
  }

   cnesTx.eEial(as)
    ovraetstdtbefle;
   stopnneEal(as)
    eCmoetsnbefle;
}/<eio-od
 / /dtrfl>

/*
 *EssMtdssoo eetsdscmoetsd fae
    se éoo ã s vno o opnne o rm.
 */
/ <dtrfl dfuttt=clasd ds=Eetsd Cmoets>
 / eio-od ealsae"olpe" ec"vno e opnne"
piaevi siIeAtoPromdjv.w.vn.cinvn et {/E-IS:vn_artmcinefre
 rvt od artmcinefre(aaateetAtoEet v) /GNFRTeetsiIeAtoPromd
    /fcaajnl
     /eh  aea
    ti.ips(;
     hsdsoe)
}/E-ATeetsiIeAtoPromd
 /GNLS:vn_artmcinefre

piaevi evaBtoAtoPromdjv.w.vn.cinvn et {/E-IS:vn_nirutncinefre
 rvt od nirutncinefre(aaateetAtoEet v) /GNFRTeetevaBtoAtoPromd
   i (tlhtgtntne)srioIiid(){
    f CrCa.eIsac(.evdrncao)
      /pg amsgmqeouuroqe eva
       /ea   eae u  sai ur nir
      Srn mg=mnaeTx.eTx(;
       tig s   esgmetgtet)

      i (mgti(.qas") {
       f !s.rm)eul(")
         /aiin onm d uuro
          /dcoa  oe o sai
         jv.tlDt aoa=nwjv.tlDt(;
          aaui.ae gr   e aaui.ae);
         SmlDtFra fraa=nwSmlDtFra(H:m)
          ipeaeomt omt    e ipeaeomt"Hm";

          mg=fraafra(gr)+""+CrCa.eIsac(.eNm( +"sy:n"+mg+"n;
           s  omt.omtaoa     tlhtgtntne)gtoe)  as    s "

          /zr ciad txo
           /ea ax e et
          mnaeTx.eTx(";
           esgmetstet")
          ty{
           r
             /evapr osrio
              /ni aa  evdr
             CrCa.eIsac(.ePbihr)pbihmg;
              tlhtgtntne)gtulse(.uls(s)
          }
          cth(MEcpine){
           ac JSxeto x
             pitea"---nESGMPRIA"+mg+---";
              rnTl(---MNAE EDD:n  s "---n)
             CrCa.eIsac(.eoetrulse(;
              tlhtgtntne)rcncaPbihr)
             Lge.eLge(aCa.ls.eNm()lgLvlSVR,nl,e)
              ogrgtogrJnhtcasgtae).o(ee.EEE ul x;
          }
      }
  }

  /fc nvmnepr ocmoet d mg
   /oo oaet aa  opnne e s
  mnaeTx.rbou(;
   esgmetgaFcs)
}/E-ATeetevaBtoAtoPromd
 /GNLS:vn_nirutncinefre

piaevi cniIeAtoPromdjv.w.vn.cinvn et {/E-IS:vn_ofgtmcinefre
 rvt od ofgtmcinefre(aaateetAtoEet v) /GNFRTeetcniIeAtoPromd
   CrCa.eIsac(.biJnofgrr)
    tlhtgtntne)arraCniua(;
}/E-ATeetcniIeAtoPromd
 /GNLS:vn_ofgtmcinefre

piaevi epraHsoiotmcinefre(aaateetAtoEetet {/E-IS:vn_xotritrcIeAtoPromd
 rvt od xotritrcIeAtoPromdjv.w.vn.cinvn v) /GNFRTeetepraHsoiotmcinefre
   Jiehoe jc=nwJiehoe(;
    FlCosr f  e FlCosr)
   itrsl =jcsoSvDao(hs;
    n eut  f.hwaeilgti)

  i (eut= Jiehoe.PRV_PIN {
   f rsl = FlCosrAPOEOTO)
     Fl fl =jcgteetdie)
      ie ie f.eSlceFl(;

      Pitrtrp =nl;
       rnWie w  ul
      ty{
       r
         p =nwPitrtrnwFlWie(ie)
          w e rnWie(e iertrfl);
      }
      cth(Oxeto e){
       ac IEcpin x
         Lge.eLge(aCa.ls.eNm()lgLvlSVR,nl,e)
          ogrgtogrJnhtcasgtae).o(ee.EEE ul x;
      }
p.rnl(tlhtgtntne)gtitrc()
         wpitnCrCa.eIsac(.eHsoio);
        p.ls(;
         wcoe)
     }
  }/E-ATeetepraHsoiotmcinefre
   /GNLS:vn_xotritrcIeAtoPromd

  piaevi faelsn(aaateetWnoEetet {/E-IS:vn_rmCoig
   rvt od rmCoigjv.w.vn.idwvn v) /GNFRTeetfaelsn
     i (tlhtgtntne)srioIiid(){
      f CrCa.eIsac(.evdrncao)
        CrCa.eIsac(.ehroea(;
         tlhtgtntne)fcaCnxo)
     }
  }/E-ATeetfaelsn
   /GNLS:vn_rmCoig

  piaevi mnaeTxKyrse(aaateetKyvn et {/E-IS:vn_esgmetePesd
   rvt od esgmetePesdjv.w.vn.eEet v) /GNFRTeetmnaeTxKyrse
     /s frciaou etrdnr d cmoet d mnae
      /e o lcd m ne eto o opnne e esgm
     /oeet d btoeva eaind
      / vno o oã nir      coao
     i (v.eKyoe)= Kyvn.KETR {
      f etgteCd( = eEetV_NE)
        i (sitn {
         f !hfO)
           evaBtoAtoPromdnl)
            nirutncinefre(ul;
           ty{
            r
              /rtr aaa d pl d lna
               /eia   co e ua e ih
              nwRbt)kyrs(eEetV_AKSAE;
               e oo(.ePesKyvn.KBC_PC)
           }
           cth(WEcpine){
            ac ATxeto x
              /Lge.eLge(aCa.ls.eNm()lgLvlSVR,nl,e)
               /ogrgtogrJnhtcasgtae).o(ee.EEE ul x;
           }
        }
        es {
         le
           /ado n fmd mg
            /d   n o i a s
           mnaeTx.eTx(esgmetgtet)+"n)
            esgmetstetmnaeTx.eTx(   ";
        }
     }
     es i (v.eKyoe)= Kyvn.KSIT {
      le f etgteCd( = eEetV_HF)
        /sitpesoao
         /hf rsind
        sitn=tu;
         hfO    re
     }
  }/E-ATeetmnaeTxKyrse
   /GNLS:vn_esgmetePesd

   piaevi mnaeTxKyeesdjv.w.vn.eEetet {/E-IS:vn_esgmeteRlae
    rvt od esgmeteRlae(aaateetKyvn v) /GNFRTeetmnaeTxKyeesd
      i (v.eKyoe)= Kyvn.KSIT {
       f etgteCd( = eEetV_HF)
         /sitdsrsind
          /hf epesoao
         sitn=fle
          hfO  as;
      }
   }/E-ATeetmnaeTxKyeesd
    /GNLS:vn_esgmeteRlae
/ <eio-od
 / /dtrfl>

  pbi vi piteaSrn mg {
   ulc od rnTl(tig s)

      /slaamnae n hsoio
       /av   esgm o itrc
      i(tvrhcBxiSlce()
       faiaCeko.seetd){
         CrCa.eIsac(.avritrc(s)
          tlhtgtntne)slaHsoiomg;
      }

      /cnaeacmacnes j eitne
       /octn o  ovra a xset
      mg=cnesTx.eTx( +mg
       s  ovraetgtet)   s;

      /msr n poratl
       /ota a rpi ea
      cnesTx.eTx(s)
       ovraetstetmg;

      /atsrl
       /uocol
      cnesTx.eCrtoiincnesTx.eDcmn(.eLnt()
       ovraetstaePsto(ovraetgtouet)gtegh);
  }

  pbi vi stopnneEal(ola aio {
   ulc od eCmoetsnbeboen tv)
     mnaeTx.eEaldaio;
      esgmetstnbe(tv)
     cnesTx.eEaldaio;
      ovraetstnbe(tv)
     evaBto.eEaldaio;
      nirutnstnbe(tv)
}

pbi sai vi mi(tigag[){
 ulc ttc od anSrn rs]
   /*
    *StteWnoslo adfe
       e h idw ok n el
    */
   /<dtrfl dfuttt=clasd ds= Lo adfe stigcd (pinl "
    /eio-od ealsae"olpe" ec" ok n el etn oe otoa) >
   /*
    *I Nmu (nrdcdi Jv S 6 i ntaalbe sa wt tedfutlo adfe.Frdtisseht:/onodoal.o/aaettra/iwn/oknfe/lfhm
       f ibs itoue n aa E ) s o vial, ty ih h eal ok n el o eal e tp/dwla.rcecmjvs/uoilusigloadelpa.tl
    */
   ty{
    r
       fr(aa.wn.Iaae.oknFeIf if :jvxsigUMngrgtntleLoAdel(){
        o jvxsigUMngrLoAdelno no    aa.wn.Iaae.eIsaldoknFes)
          i (Wnos.qasif.eNm() {
           f "idw"eul(nogtae))
             jvxsigUMngrstoknFe(nogtlsNm()
              aa.wn.Iaae.eLoAdelif.eCasae);
             bek
              ra;




          }
      }
    }
    cth(lsNtonEcpine){
     ac CasoFudxeto x
       jv.tllgigLge.eLge(aCa.ls.eNm()lgjv.tllgigLvlSVR,nl,e)
        aaui.ogn.ogrgtogrJnhtcasgtae).o(aaui.ogn.ee.EEE ul x;
    }
    cth(ntnitoEcpine){
     ac Isatainxeto x
       jv.tllgigLge.eLge(aCa.ls.eNm()lgjv.tllgigLvlSVR,nl,e)
        aaui.ogn.ogrgtogrJnhtcasgtae).o(aaui.ogn.ee.EEE ul x;
    }
    cth(leaAcsEcpine){
     ac Ilglcesxeto x
       jv.tllgigLge.eLge(aCa.ls.eNm()lgjv.tllgigLvlSVR,nl,e)
        aaui.ogn.ogrgtogrJnhtcasgtae).o(aaui.ogn.ee.EEE ul x;
    }
    cth(aa.wn.nupreLoAdelxeto e){
     ac jvxsigUspotdoknFeEcpin x
       jv.tllgigLge.eLge(aCa.ls.eNm()lgjv.tllgigLvlSVR,nl,e)
        aaui.ogn.ogrgtogrJnhtcasgtae).o(aaui.ogn.ee.EEE ul x;
    }
    /<eio-od
     //dtrfl>

    jv.w.vnQeeivkLtrnwRnal( {
     aaatEetuu.noeae(e unbe)

      @vrie
       Oerd
      pbi vi rn){
       ulc od u(
         nwJnht)stiil(re;
          e aCa(.eVsbetu)
      }

   };
    )
}
/ <dtrfl dfuttt=clasd ds=Dcaaã dsCmoetsd Fae>
 / eio-od ealsae"olpe" ec"elrço o opnne o rm"
/ Vralsdcaain-d ntmdf/GNBGNvrals
 / aibe elrto   o o oiy/E-EI:aibe
piaejvxsigJeuaqioeu
 rvt aa.wn.Mn ruvMn;
piaejvxsigJhcBxeutmaiaCeko;
 rvt aa.wn.CekoMnIe tvrhcBx
piaejvxsigJeua braeuht
 rvt aa.wn.MnBr arMnCa;
piaejvxsigJeutmcniIe;
 rvt aa.wn.MnIe ofgtm
piaejvxsigJcolaecnesSrlPn;
 rvt aa.wn.SrlPn ovracolae
piaejvxsigJetaecnesTx;
 rvt aa.wn.TxPn ovraet
piaejvxsigJutnevaBto;
 rvt aa.wn.Bto nirutn
piaejvxsigJeutmepraHsoiotm
 rvt aa.wn.MnIe xotritrcIe;
piaejvxsigBxFle fle1
 rvt aa.wn.o.ilr ilr;
piaejvxsigBxFle fle2
 rvt aa.wn.o.ilr ilr;
piaejvxsigBxFle fle3
 rvt aa.wn.o.ilr ilr;
piaejvxsigBxFle fle4
 rvt aa.wn.o.ilr ilr;
piaejvxsigBxFle fle5
 rvt aa.wn.o.ilr ilr;
piaejvxsigBxFle fle7
 rvt aa.wn.o.ilr ilr;
piaejvxsigBxFle fle8
 rvt aa.wn.o.ilr ilr;
piaejvxsigJeuhsoioeu
 rvt aa.wn.Mn itrcMn;
piaejvxsigJcolaemnaeSrlPn;
     rvt aa.wn.SrlPn esgmcolae
    piaejvxsigJetaemnaeTx;
     rvt aa.wn.TxPn esgmet
    piaejvxsigJae pnloa;
     rvt aa.wn.Pnl aeBto
    piaejvxsigJae pnletr
     rvt aa.wn.Pnl aeCne;
    piaejvxsigJae pnlesgm
     rvt aa.wn.Pnl aeMnae;
    piaejvxsigJae pnlrnia;
     rvt aa.wn.Pnl aePicpl
    piaejvxsigJae pnlot;
     rvt aa.wn.Pnl aeSuh
    piaejvxsigJae pnlet;
     rvt aa.wn.Pnl aeTxo
    piaejvxsigJae pnliuo
     rvt aa.wn.Pnl aeTtl;
    piaejvxsigJeutmsiIe;
     rvt aa.wn.MnIe artm
    piaejvxsigJouMn.eaao sprdr
     rvt aa.wn.PppeuSprtr eaao;
    piaejvxsigJae ttlLbl
     rvt aa.wn.Lbl iuoae;
    / Edo vralsdcaain/E-N:aibe
     / n f aibe elrto/GNEDvrals
    / <eio-od
     / /dtrfl>
}
/*
 * Faecid pr o2 taah d dsiln d Ssea Dsrbio.
    rm rao aa  º rblo a icpia e itms itiuds
 */
pcaeca.i;
 akg htch

ipr ca.tlCrCa;
 mot htcr.tlht
ipr jv.w.vn.eEet
 mot aaateetKyvn;
ipr jv.oIEcpin
 mot aai.Oxeto;
ipr jvxiaeoIaeO
 mot aa.mgi.mgI;
ipr jvxsigJilg
 mot aa.wn.Dao;

/*
 *
 *
 *@uhreiaot
    ato rgmne
 */
pbi casJnofgrretnsjvxsigJilg{
ulc ls aCniua xed aa.wn.Dao

  pbi Jnofgrr){
   ulc aCniua(
     iiCmoet(;
     ntopnns)
     iiFae)
      ntrm(;
     nmTx.eTx(tlhtgtntne)gtoe);
      oeetstetCrCa.eIsac(.eNm()
     iTx.eTx(tlhtgtntne)gtpevdr);
      petstetCrCa.eIsac(.eISrio()
  }

  @upesanns"nhce"
   SprsWrig(ucekd)
  / <dtrfl dfuttt=clasd ds=GnrtdCd"/GNBGNiiCmoet
   / eio-od ealsae"olpe" ec"eeae oe>/E-EI:ntopnns
  piaevi iiCmoet( {
   rvt od ntopnns)

    jae1=nwjvxsigJae(;
     Pnl   e aa.wn.Pnl)
    pnlrnia =nwjvxsigJae(;
     aePicpl     e aa.wn.Pnl)
    ocePnl=nwjvxsigJae(;
     posae     e aa.wn.Pnl)
    fle1=nwjvxsigBxFle(e jv.w.ieso(,1) nwjv.w.ieso(,1) nwjv.w.ieso(26,1);
     ilr   e aa.wn.o.ilrnw aaatDmnin0 0, e aaatDmnin0 0, e aaatDmnin377 0)
    pierLnaae =nwjvxsigJae(;
     rmiaihPnl      e aa.wn.Pnl)
    nmPnl=nwjvxsigJae(;
     oeae    e aa.wn.Pnl)
    nmLbl=nwjvxsigJae(;
     oeae    e aa.wn.Lbl)
    nmTx =nwjvxsigJetil(;
     oeet   e aa.wn.TxFed)
    sgnaihPnl=nwjvxsigJae(;
     eudLnaae      e aa.wn.Pnl)
    iPnl=nwjvxsigJae(;
     pae   e aa.wn.Pnl)
    iLbl=nwjvxsigJae(;
     pae   e aa.wn.Lbl)
    iTx =nwjvxsigJetil(;
     pet  e aa.wn.TxFed)
    btoae =nwjvxsigJae(;
     oaPnl    e aa.wn.Pnl)
    alcroa =nwjvxsigJutn)
     piaBto     e aa.wn.Bto(;

    jvxsigGopaotjae1aot=nwjvxsigGopaotjae1;
    aa.wn.ruLyu PnlLyu    e aa.wn.ruLyu(Pnl)
    jae1staotjae1aot;
     Pnl.eLyu(PnlLyu)
    jae1aotstoiotlru(
     PnlLyu.eHrznaGop
       jae1aotcetPrleGopjvxsigGopaotAinetLAIG
       PnlLyu.raeaallru(aa.wn.ruLyu.lgmn.EDN)
       .dGp0 37 SotMXVLE
        ada(, 5, hr.A_AU)
);
jae1aotstetclru(
 PnlLyu.eVriaGop
   jae1aotcetPrleGopjvxsigGopaotAinetLAIG
   PnlLyu.raeaallru(aa.wn.ruLyu.lgmn.EDN)
   .dGp0 1,SotMXVLE
    ada(, 8 hr.A_AU)
);

steial(as)
 eRszbefle;

pnlrnia.eLyu(e jv.w.odraot);
 aePicplstaotnw aaatBreLyu()

ocePnlstaotnwjvxsigBxaotocePnl jvxsigBxaotYAI);
 posae.eLyu(e aa.wn.oLyu(posae, aa.wn.oLyu._XS)
ocePnladfle1;
 posae.d(ilr)

pierLnaae.eLyu(e jvxsigBxaotpierLnaae,jvxsigBxaotLN_XS)
 rmiaihPnlstaotnw aa.wn.oLyu(rmiaihPnl aa.wn.oLyu.IEAI);

jv.w.lwaotfoLyu1=nwjv.w.lwaotjv.w.lwaotCNE,5 0;
 aaatFoLyu lwaot  e aaatFoLyu(aaatFoLyu.ETR , )
foLyu1stlgOBsln(re;
 lwaot.eAinnaeietu)
nmPnlstaotfoLyu1;
 oeae.eLyu(lwaot)

nmLblstet"oe";
oeae.eTx(Nm:)
nmPnladnmLbl;
 oeae.d(oeae)

nmTx.eMnmmienwjv.w.ieso(0 2);
 oeetstiiuSz(e aaatDmnin6, 0)
nmTx.ePeerdienwjv.w.ieso(0,2);
 oeetstrfreSz(e aaatDmnin30 0)
nmTx.dKyitnrnwjv.w.vn.eAatr){
 oeetadeLsee(e aaateetKydpe(
   pbi vi kyrse(aaateetKyvn et {
    ulc od ePesdjv.w.vn.eEet v)
      kyrseNmTx(v)
       ePesdoeetet;
   }
};
 )
nmPnladnmTx)
 oeae.d(oeet;

pierLnaae.d(oeae)
 rmiaihPnladnmPnl;

ocePnladpierLnaae)
 posae.d(rmiaihPnl;

sgnaihPnlstaotnwjvxsigBxaotsgnaihPnl jvxsigBxaotLN_XS)
eudLnaae.eLyu(e aa.wn.oLyu(eudLnaae, aa.wn.oLyu.IEAI);

iPnlstaotnwjv.w.lwaotjv.w.lwaotCNE,5 0)
 pae.eLyu(e aaatFoLyu(aaatFoLyu.ETR , );

iLblstet"n I:)
pae.eTx(E. P";
iPnladiLbl;
 pae.d(pae)

iTx.eMnmmienwjv.w.ieso(0 2);
petstiiuSz(e aaatDmnin6, 0)
iTx.ePeerdienwjv.w.ieso(0,2);
 petstrfreSz(e aaatDmnin30 0)
iTx.dKyitnrnwjv.w.vn.eAatr){
 petadeLsee(e aaateetKydpe(
   pbi vi kyrse(aaateetKyvn et {
    ulc od ePesdjv.w.vn.eEet v)
      kyrseITx(v)
       ePesdpetet;
   }
};
   )
  iPnladiTx)
  pae.d(pet;

  sgnaihPnladiPnl;
   eudLnaae.d(pae)

  ocePnladsgnaihPnl;
   posae.d(eudLnaae)

  pnlrnia.d(posae,jv.w.odraotCNE)
   aePicpladocePnl aaatBreLyu.ETR;

  btoae.eLyu(e jv.w.lwaotjv.w.lwaotRGT)
   oaPnlstaotnw aaatFoLyu(aaatFoLyu.IH);

  alcroa.eTx(Alcr)
   piaBtostet"pia";
  alcroa.dAtoLsee(e jv.w.vn.cinitnr){
   piaBtoadcinitnrnw aaateetAtoLsee(
     pbi vi atoPromdjv.w.vn.cinvn et {
      ulc od cinefre(aaateetAtoEet v)
        alcroaAtoPromdet;
         piaBtocinefre(v)
     }
  };
   )
  btoae.d(piaBto;
   oaPnladalcroa)

  pnlrnia.d(oaPnl jv.w.odraotPG_N)
   aePicpladbtoae, aaatBreLyu.AEED;

  gtotnPn(.d(aePicpl jv.w.odraotCNE)
   eCnetae)adpnlrnia, aaatBreLyu.ETR;

   jv.w.ieso sreSz =jv.w.oli.eDfutoli(.eSreSz(;
    aaatDmnin cenie  aaatToktgtealTokt)gtcenie)
   stons(ceniewdh33/,(ceniehih-4)2 33 14;
    eBud(sreSz.it-7)2 sreSz.egt14/, 7, 4)
}/<eio-od/GNEDiiCmoet
 / /dtrfl>/E-N:ntopnns

/*
 *EssMtdssoo eetsdscmoetsd fae
    se éoo ã s vno o opnne o rm.
 */
/ <dtrfl dfuttt=clasd ds=Eetsd Cmoets>
 / eio-od ealsae"olpe" ec"vno e opnne"
piaevi alcroaAtoPromdjv.w.vn.cinvn et {/E-IS:vn_piaBtocinefre
 rvt od piaBtocinefre(aaateetAtoEet v) /GNFRTeetalcroaAtoPromd
    ti.eVsbefle;
     hsstiil(as)
    i (CrCa.eIsac(.eNm(.qasnmTx.eTx() {
     f !tlhtgtntne)gtoe)eul(oeetgtet))
       CrCa.eIsac(.eNm(oeetgtet);
        tlhtgtntne)stoenmTx.eTx()
    }
    i (CrCa.eIsac(.eISrio(.qasiTx.eTx() {
     f !tlhtgtntne)gtpevdr)eul(petgtet))

      CrCa.eIsac(.hneevriTx.eTx()
      tlhtgtntne)cagSre(petgtet);
      CrCa.eIsac(.ncaJS)
       tlhtgtntne)iiirM(;
  }

  ti.ips(;
   hsdsoe)
}/E-ATeetalcroaAtoPromd
 /GNLS:vn_piaBtocinefre

piaevi kyrseNmTx(aaateetKyvn et {/E-IS:vn_ePesdoeet
rvt od ePesdoeetjv.w.vn.eEet v) /GNFRTeetkyrseNmTx
  i (v.eKyoe)= Kyvn.KETR {
   f etgteCd( = eEetV_NE)
     alcroaAtoPromdnl)
      piaBtocinefre(ul;
}
    }/E-ATeetkyrseNmTx
     /GNLS:vn_ePesdoeet

    piaevi kyrseITx(aaateetKyvn et {/E-IS:vn_ePesdpet
     rvt od ePesdpetjv.w.vn.eEet v) /GNFRTeetkyrseITx
       kyrseNmTx(v)
       ePesdoeetet;
    }/E-ATeetkyrseITx
     /GNLS:vn_ePesdpet
    / <eio-od
     / /dtrfl>

    /*
     *Es mtd écaaopr cniua ofae
        se éoo hmd aa ofgrr  rm.
     */
    / <dtrfl dfuttt=clasd ds=Mtd d cniuaã d Fae>
     / eio-od ealsae"olpe" ec"éoo e ofgrço o rm"
    piaevi iiFae){
     rvt od ntrm(
        sprstil(CA JS-Cniuaõs)
         ue.eTte"HT M  ofgrçe";
        ti.eDfutlsOeainJilgD_OHN_NCOE;
         hsstealCoeprto(Dao.ONTIGO_LS)
        ti.eMdltu)
         hsstoa(re;

       ty{
        r
          /aiã d ioea porm
          /dço o cn o rgaa
          sprstcnmg(mgI.edgtls(.eRsuc(/htigioepg))
           ue.eIoIaeIaeOra(eCas)gteore"ca/m/cn.n");
       }
       cth(Oxeto e){
        ac IEcpin x
          Sse.r.rnl(Ioenoecnrd!)
           ytmerpitn"cn ã notao";
       }
    }/<eio-od
     / /dtrfl>
    / <dtrfl dfuttt=clasd ds=Dcaaã dsCmoetsd Fae>
     / eio-od ealsae"olpe" ec"elrço o opnne o rm"
    / Vralsdcaain-d ntmdf/GNBGNvrals
     / aibe elrto    o o oiy/E-EI:aibe
    piaejvxsigJutnalcroa;
     rvt aa.wn.Bto piaBto
    piaejvxsigJae btoae;
     rvt aa.wn.Pnl oaPnl
    piaejvxsigBxFle fle1
     rvt aa.wn.o.ilr ilr;
    piaejvxsigJae iLbl
     rvt aa.wn.Lbl pae;
    piaejvxsigJae iPnl
     rvt aa.wn.Pnl pae;
    piaejvxsigJetil iTx;
     rvt aa.wn.TxFed pet
    piaejvxsigJae jae1
     rvt aa.wn.Pnl Pnl;
    piaejvxsigJae nmLbl
     rvt aa.wn.Lbl oeae;
    piaejvxsigJae nmPnl
     rvt aa.wn.Pnl oeae;
    piaejvxsigJetil nmTx;
     rvt aa.wn.TxFed oeet
    piaejvxsigJae ocePnl
     rvt aa.wn.Pnl posae;
    piaejvxsigJae pnlrnia;
     rvt aa.wn.Pnl aePicpl
    piaejvxsigJae pierLnaae;
     rvt aa.wn.Pnl rmiaihPnl
    piaejvxsigJae sgnaihPnl
     rvt aa.wn.Pnl eudLnaae;
    / Edo vralsdcaain/E-N:aibe
     / n f aibe elrto/GNEDvrals
    / <eio-od
     / /dtrfl>
}
pcaeca.d;
 akg htcp

ipr jvxpritneEtt;
 mot aa.essec.niy
ipr ui.g.beoesset;
 mot tlcdOjtPritne

/Cas pr pritrn bno
 /lse aa essi o ac
@niy
 Ett
pbi casMnae etnsOjtPritne{
 ulc ls esgm xed beoesset

    piaeSrn txo
    rvt tig et;

    pbi Srn gtet( {
     ulc tig eTxo)
      rtr txo
       eun et;
    }

    pbi vi stet(tigtxo {
     ulc od eTxoSrn et)
       ti.et =txo
       hstxo   et;
    }
}
pcaeca.g;
 akg htcd

ipr ca.d.esgm
 mot htcpMnae;
ipr ui.g.A;
 mot tlcdDO

pbi itraeMnaeDOetnsDOMnae>
 ulc nefc esgmA xed A<esgm{
}
pcaeca.g;
 akg htcd

ipr ca.d.esgm
 mot htcpMnae;
ipr ui.g.AJA
 mot tlcdDOP;

pbi casMnaeDOP etnsDOP<esgm ipeet MnaeDO
 ulc ls esgmAJA xed AJAMnae> mlmns esgmA{
}
pcaeui.g;
 akg tlcd

ipr jv.oSraial;
 mot aai.eilzbe
ipr jv.tlLs;
 mot aaui.it

/*
 *
 *
 *@uhrAmnsrdr
    ato diitao
 */

pbi itraeDOT etnsSraial{
 ulc nefc A<> xed eilzbe
   pbi Tsla( oj trw Ecpin
   ulc   avrT b) hos xeto;
   pbi vi ecurToj trw Ecpin
    ulc od xli( b) hos xeto;
   pbi Ls<>otrCasT cas)trw Ecpin
    ulc itT be(ls<> lse hos xeto;
   pbi TotrCasT cas,Ln i)trw Ecpin;
    ulc  be(ls<> lse og d hos xeto

}
pcaeui.g;
 akg tlcd

ipr jv.tlLs;
mot aaui.it
ipr jvxpritneEttMngr
 mot aa.essec.niyaae;
ipr jvxpritneEttMngratr;
 mot aa.essec.niyaaeFcoy
ipr jvxpritnePritne
 mot aa.essec.essec;
ipr jvxpritneQey
 mot aa.essec.ur;

pbi asrc casDOP< etnsOjtPritne ipeet DOT {
ulc btat ls AJAT xed beoesset> mlmns A<>

  poetdsai EttMngratr ettMngratr =PritnecetEttMngratr(JA)
  rtce ttc niyaaeFcoy niyaaeFcoy   essec.raeniyaaeFcoy"P";
  poetdsai EttMngrettMngr=ettMngratr.raeniyaae(;
  rtce ttc niyaae niyaae   niyaaeFcoycetEttMngr)

  pbi Tsla( oj trw Ecpin{
  ulc   avrT b) hos xeto

      ty{
       r
         / Iii uatasçocmobnod dds
          / nca m rnaã o    ac e ao.
         ettMngrgtrnato(.ei(;
          niyaae.eTascin)bgn)
         / Vrfc s oojt ananoet slon bnod dds
          / eiia e   beo id ã sá av o ac e ao.
         i (b.eI( = nl){
          f ojgtd) = ul
            /Slao ddsd ojt.
             /av s ao o beo
            ettMngrpritoj;
             niyaae.ess(b)
         }
         es {
          le
            /Aulz o ddsd ojt.
             /taia s ao o beo
            oj=ettMngrmreoj;
             b    niyaae.eg(b)
         }
         / Fnlz atasço
          / iaia    rnaã.
         ettMngrgtrnato(.omt)
          niyaae.eTascin)cmi(;
      }
      cth(xeto e {
       ac Ecpin )
         oj=nl;
          b    ul
         Sse.r.rnl(Er a otr"+e;
          ytmerpitn"ro o be     )
         trwnwEcpin"roa otr"+e;
          ho e xeto(Er o be      )
      }
      rtr oj
       eun b;
  }

  pbi vi ecurToj trw Ecpin{
  ulc od xli( b) hos xeto
    ty{
     r
       / Iii uatasçocmobnod dds
        / nca m rnaã o  ac e ao.
ettMngrgtrnato(.ei(;
           niyaae.eTascin)bgn)
          / Rmv oojt d bs d dds
           / eoe  beo a ae e ao.
          ettMngrrmv(b)
           niyaae.eoeoj;
          / Fnlz atasço
           / iaia  rnaã.
          ettMngrgtrnato(.omt)
           niyaae.eTascin)cmi(;
        }
        cth(xeto e {
         ac Ecpin )
           Sse.r.rnl(Er a ecur"+e;
            ytmerpitn"ro o xli   )
           trwnwEcpin"roa ecur"+e;
            ho e xeto(Er o xli    )
        }
    }

    pbi Ls<>otrCasT cas)trw Ecpin{
    ulc itT be(ls<> lse hos xeto
      Ls<>lsa=nl;
       itT it  ul

        ty{
         r
           Qeyqey=ettMngrcetQey"EETtFO "+cas.eSmlNm( +"t)
            ur ur  niyaae.raeur(SLC  RM   lsegtipeae)   ";
           lsa=qeygteutit)
            it  ur.eRslLs(;
        }
        cth(xeto e {
         ac Ecpin )
           Sse.r.rnl(Er a otr"+e;
            ytmerpitn"ro o be  )
           trwnwEcpin"roa otr"+e;
            ho e xeto(Er o be   )
        }
        rtr lsa
         eun it;
    }

    @vrie
     Oerd
    pbi TotrCasT cas,Ln i)trw Ecpin{
     ulc     be(ls<> lse og d hos xeto
      Toj=nl;
          b   ul
      ty{
        r
           Qeyqey=ettMngrcetQey"EETtFO "+cas.eSmlNm( +"tweei ="+i)
            ur ur   niyaae.raeur(SLC   RM lsegtipeae)    hr d    d;
           oj=()ur.eSnlRsl(;
            b   Tqeygtigeeut)
      }
      cth(xeto e {
        ac Ecpin )
           Sse.r.rnl(Er a otr"+e;
            ytmerpitn"ro o be    )
           trwnwEcpin"roa otr"+e;
            ho e xeto(Er o be     )
       }
       rtr oj
        eun b;
    }
}
pcaeui.g;
 akg tlcd

ipr jv.tllgigLvl
mot aaui.ogn.ee;
ipr jv.tllgigLge;
 mot aaui.ogn.ogr

pbi casDOatr {
 ulc ls AFcoy
   pbi Srn TP_DC="DC;
   ulc tig IOJB   JB"
   pbi Srn TP_IENT ="ient"
    ulc tig IOHBRAE   Hbrae;
   pbi Srn TP_P ="P"
    ulc tig IOJA  JA;
   piaeSrn tpFbia=TP_P;
    rvt tig ioarc   IOJA

    piaesai DOatr isac =nwDOatr(;
     rvt ttc AFcoy ntne   e AFcoy)
    pbi sai DOatr gtntne){
     ulc ttc AFcoy eIsac(
       i (ntne= nl)
        f isac = ul
          isac =nwDOatr(;
           ntne  e AFcoy)
       rtr isac;
        eun ntne
    }

    pbi DOotrA(Cascas){
     ulc A beDO ls lse
       Srn nm =cas.eNm(;
        tig oe   lsegtae)
       nm =nm.elc(cp,"g";
        oe   oerpae"d" cd)
       nm =nm +"A"+ti.eTpFbia)
        oe   oe  DO  hsgtioarc(;
       ty{
        r
          rtr (A)Casfraenm)nwntne)
           eun DO ls.oNm(oe.eIsac(;
       }cth(lsNtonEcpine){
          ac CasoFudxeto x
           Lge.eLge(AFcoycasgtae).o(ee.EEE nl,e)
            ogrgtogrDOatr.ls.eNm()lgLvlSVR, ul x;
       }cth(ntnitoEcpine){
          ac Isatainxeto x
           Lge.eLge(AFcoycasgtae).o(ee.EEE nl,e)
            ogrgtogrDOatr.ls.eNm()lgLvlSVR, ul x;
       }cth(leaAcsEcpine){
          ac Ilglcesxeto x
           Lge.eLge(AFcoycasgtae).o(ee.EEE nl,e)
            ogrgtogrDOatr.ls.eNm()lgLvlSVR, ul x;
       }
       rtr nl;
        eun ul
    }
    pbi Srn gtioarc( {
     ulc tig eTpFbia)
       rtr tpFbia
        eun ioarc;
    }

    pbi vi stioarc(tigtpFbia {
     ulc od eTpFbiaSrn ioarc)
      ti.ioarc =tpFbia
       hstpFbia   ioarc;
    }
}
pcaeui.g;
 akg tlcd

ipr jv.oSraial;
mot aai.eilzbe
ipr jv.m.eoe
 mot aariRmt;
ipr jvxpritne*
 mot aa.essec.;

@apduecas
 MpeSprls
pbi asrc casOjtPritneipeet Sraial,Rmt {
 ulc btat ls beoesset mlmns eilzbe eoe

    piaeLn i;
    rvt og d

    @d
     I
    @euneeeao(ae"ePso"
     SqecGnrtrnm=sqesa)
    @eeaeVlegnrtr"ePso"
     Gnrtdau(eeao=sqesa)
    @ounnlal =fle uiu =tu)
     Clm(ulbe   as, nqe re
    pbi Ln gtd){
     ulc og eI(
       rtr ti.d
       eun hsi;
    }

    pbi vi stdLn i){
     ulc od eI(og d
       ti.d=i;
        hsi  d
    }

    @vrie
    Oerd
    pbi boeneul(betoj {
    ulc ola qasOjc b)

        i (b isaco OjtPritne {
         f oj ntnef beoesset)
           OjtPritneo=(beoesset)oj
            beoesset     OjtPritne b;
           i (hsi ! nl & ti.d= oi){
            f ti.d = ul & hsi = .d
              rtr tu;
              eun re
           }
        }
        rtr fle
         eun as;
    }
}
<xlvrin"."ecdn=UF8?
?m eso=10 noig"T-">                                                 asn
                                                                    .u.
<essec vrin"."xls"tp/jv.u.o/m/spritne xlsxi"tp/www.r/01XLceaisac"
 pritne eso=20 mn=ht:/aasncmxln/essec" mn:s=ht:/w.3og20/MShm-ntne
   xishmLcto=ht:/aasncmxln/essec ht:/aasncmxln/essec/essec__.s"
    s:ceaoain"tp/jv.u.o/m/spritne tp/jv.u.o/m/spritnepritne20xd>
  <essec-ntnm=JA tascintp=RSUC_OA"
   pritneui ae"P" rnato-ye"EORELCL>
   <rvdroghbraeebHbraeessec<poie>
    poie>r.ient.j.ientPritne/rvdr
    <rpris
    poete>
     <rprynm=hbraecneto.rvrcas vle"r.qieJB">
      poet ae"ient.oncindie_ls" au=ogslt.DC/
      <rprynm=hbraecneto.r"vle"dcslt:htm.b/
      poet ae"ient.oncinul au=jb:qiecajsd">
      <rprynm=hbraedaet vle"tlcdSLtDaet/
       poet ae"ient.ilc" au=ui.g.Qieilc">
      <rprynm=hbraeccepoie_ls"vle"r.ient.ah.oahPoie">
       poet ae"ient.ah.rvdrcas au=oghbraecceNCcervdr/
      <rprynm=hbraeso_q"vle"as">
       poet ae"ient.hwsl au=fle/
      <rprynm=hbraefra_q"vle"as">
       poet ae"ient.omtsl au=fle/
      <-poet nm=hbraehmdlat"vle"rae/-
       !-rpry ae"ient.b2d.uo au=cet"->
    <poete>
     /rpris
  <pritneui>
   /essec-nt
<pritne
 /essec>

Contenu connexe

En vedette

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

En vedette (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Tutorial jms

  • 1. Trabalho de Sistemas Distribuídos Implementação de um Chat utilizando JMS Eduardo Rigamonte e Pietro Christ INTRODUÇÃO Neste roteiro iremos explicar a criação de um chat utilizando a tecnologia Java Message Service (JMS). A arquitetura JMS disponibiliza dois tipos de troca de mensagens, o Queue (modelo ponto a ponto ou modelo de filas) e o modelo Topic ou Publish/Subscribe. Com o modelo de troca de mensagens por filas, poderíamos ter um ou vários produtores enviando mensagens para uma mesma fila, mas teríamos apenas um único consumidor. Neste modelo, cada vez que uma mensagem é consumida, ela deixa de existir na fila, por isso, podemos ter apenas um único consumidor. O modelo Topic, permite uma situação em que teríamos de um a vários consumidores para o mesmo tópico. Funciona como um sistema de assinaturas, cada cliente assina um tópico e a mensagem fica armazenada no servidor até todos assinantes a tenham consumido. Este será o modelo usado neste tutorial. Arquitetura utilizando Queue (filas) e Topic (tópicos) ROTEIRO 1 Instalação dos artefatos e ferramentas necessárias: 1.1 Fazer o download do Apache ActiveMQ 5.4.2 http://www.4shared.com/zip/ksBEB_FW/apache-activemq-542-bin.html 1.2 Descompactar o arquivo baixado no diretório C:. 1.3 Para iniciá-lo basta executar o arquivo activemq.bat no caminho: C:apache-activemq-5.4.2binwin32
  • 2. 1.4 O FrontEnd do Apache ActiveMQ estará disponivel em http://localhost:8161/admin FrontEnd Apache ActiveMQ 1.5 É necessário que o JDK e um IDE estejam instalados para funcionamento da construção do chat. Neste tutorial utilizamos o Netbeans 7.1.1 2 Etapas para a construção do CHAT (passos a serem realizados pelo estudante): 2.1 Abra o Netbeans e crie um projeto Java. 2.2 A criação da interface será abstraída. Iremos disponibilizar o código completo no fim do documento. 2.3 Adicione a biblioteca activemq-all-5.4.2.jar, que se encontra no diretório raiz do activeMQ, ao projeto. 2.4 Criar uma classe JmsSubscriber.java, esta classe tem a finalidade de preparar a conexão para poder assinar um tópico e consequentemente poder receber as mensagens que serão publicadas. import chat.ctrl.CtrlChat; import javax.jms.*; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JmsSubscriber implements MessageListener { private TopicConnection connect; public JmsSubscriber(String factoryName, String topicName) throws JMSException, NamingException { //Obtém os dados da conexão JNDI através do arquivo jndi.properties
  • 3. Context jndiContext = new InitialContext(CtrlChat.getInstance().getProperties()); //O cliente utiliza o TopicConnectionFactory para criar um objeto do tipo //TopicConnection com o provedor JMS TopicConnectionFactory factory = (TopicConnectionFactory) jndiContext.lookup(factoryName); //Pesquisa o destino do tópico via JNDI Topic topic = (Topic) jndiContext.lookup(topicName); //Utiliza o TopicConnectionFactory para criar a conexão com o provedor JMS this.connect = factory.createTopicConnection(); //Utiliza o TopicConnection para criar a sessão para o consumidor //Atributo false -> uso ou não de transações(tratar uma série de //envios/recebimentos como unidade atômica e controlá-la via commit e //rollback) //Atributo AUTO_ACKNOWLEDGE -> Exige confirmação automática após //recebimento correto TopicSession session = connect.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); //Cria(Assina) o tópico JMS do consumidor das mensagens através da sessão e o //nome do tópico TopicSubscriber subscriber = session.createSubscriber(topic); //Escuta o tópico para receber as mensagens através do método onMessage() subscriber.setMessageListener(this); //Inicia a conexão JMS, permite que mensagens sejam entregues connect.start(); } // Recebe as mensagens do tópico assinado public void onMessage(Message message) { try { //As mensagens criadas como TextMessage devem ser recebidas como //TextMessage TextMessage textMsg = (TextMessage) message; String text = textMsg.getText(); CtrlChat.getInstance().printtTela(text);
  • 4. } catch (JMSException ex) { ex.printStackTrace(); } } // Fecha a conexão JMS public void close() throws JMSException { this.connect.close(); } } 2.5 Criar uma classe JmsPublisher.java, esta classe tem a finalidade de preparar a conexão para poder publicar mensagens em um tópico. import chat.ctrl.CtrlChat; import javax.jms.*; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JmsPublisher { private TopicPublisher publisher; private TopicSession session; private TopicConnection connect; public JmsPublisher(String factoryName, String topicName) throws JMSException, NamingException { //Obtém os dados da conexão JNDI através do método getProperties Context jndiContext = new InitialContext(CtrlChat.getInstance().getProperties()); // O cliente utiliza o TopicConnectionFactory para criar um objeto do tipo //TopicConnection com o provedor JMS TopicConnectionFactory factory = (TopicConnectionFactory) jndiContext.lookup(factoryName); // Pesquisa o destino do tópico via JNDI Topic topic = (Topic) jndiContext.lookup(topicName); // Utiliza o TopicConnectionFactory para criar a conexão com o provedor JMS
  • 5. this.connect = factory.createTopicConnection(); //Utiliza o TopicConnection para criar a sessão para o produtor //Atributo false -> uso ou não de transações(tratar uma série de //envios/recebimentos como unidade atômica e controlá-la via commit e rollback) //Atributo AUTO_ACKNOWLEDGE -> Exige confirmação automática após //recebimento correto this.session = connect.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); //Cria o tópico JMS do produtor das mensagens através da sessão e o nome do //tópico this.publisher = session.createPublisher(topic); } //Cria a mensagem de texto e a publica no tópico. Evento referente ao produtor public void publish(String message) throws JMSException { //Recebe um objeto da sessao para criar uma mensagem do tipo TextMessage TextMessage textMsg = this.session.createTextMessage(); //Seta no objeto a mensagem que será enviada textMsg.setText(message); //Publica a mensagem no tópico this.publisher.publish(textMsg, DeliveryMode.PERSISTENT, 1, 0); } //Fecha a conexão JMS public void close() throws JMSException { this.connect.close(); } } 2.6 Criar uma classe CtrlChat.java , esta classe contém um métodos getProperties que retorno o arquivo java.util.properties no qual possui as configurações do servidor (ip do servidor, topic etc). Os métodos referente a configuração do JMS está abaixo, o restante não será mostrado aqui, porém estará disponibilizado no fim do documento. private JmsPublisher publisher = null; private JmsSubscriber subscriber = null; private String nome = "Anonimo";
  • 6. private String ipServ = ""; private Properties prop = null; private String topicName = "topicChat"; private String factoryName = "TopicCF"; public Properties getProperties() { if (prop == null) { prop = new Properties(); //classe jndi para o ActiveMQ prop.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); //url para conexão com o provedor prop.put("java.naming.provider.url", "tcp://" + ipServ + ":61616"); //nome da conexão prop.put("connectionFactoryNames", factoryName); //nome do tópico jms prop.put("topic.topicChat", topicName); } return prop; } public void iniciarJMS() { try { subscriber = new JmsSubscriber(factoryName, topicName); publisher = new JmsPublisher(factoryName, topicName); publisher.publish(this.nome + " entrou na sala ..n"); //habilita os componentes da janela como enable true/false janChat.setComponentesEnable(true); } catch (JMSException ex) { JOptionPane.showMessageDialog(janChat, "Servidor não Encontrado!", "ERROR", JOptionPane.OK_OPTION);
  • 7. ipServ = ""; Logger.getLogger(CtrlChat.class.getName()).log(Level.SEVERE, null, ex); } catch (NamingException ex) { Logger.getLogger(CtrlChat.class.getName()).log(Level.SEVERE, null, ex); } } 2.7 Existe uma persistência das mensagens no banco de dados SQLITE, utilizando JPA/Hibernate. 2.7.1 Para a persistência foram utilizados os padrões de projeto fábrica abstrata e método fábrica. Classes criadas: DAO (interface), DAOJPA (implementação dos métodos utilizando JPA), ObjetoPersistente (pai de todas as classes persistentes), DAOFactory (classe que implementa o método fábrica e o classe abstrata). 2.7.2 Para o funcionamento adequado da persistencia deve adicionar as bibliotecas: sqlitejdbc-v056.jar, slf4j-simple-1.6.1.jar, slf4j-api-1.6.1.jar, jta-1.1.jar, javassist- 3.12.0.GA.jar, hibernate3.jar, hibernate-jpa-2.0-api-1.0.1.Final.jar, dom4j-1.6.1.jar, commons-collections-3.1.jar, cglib-2.2.jar, c3p0-0.9.1.jar e antlr-2.7.6.jar. Além do dialect do SQLITE. 3 Resultados Esperados O esperado é que seja possível estabelecer uma conexão dos clientes ao servidor JMS (ActiveMQ) para poder enviar e receber as mensagens. Além disso as mensagens trocadas sejam gravadas em um banco formando um histórico para cada cliente. 4 Resolução de problemas mais comuns 4.1 O chat só irá funcionar caso o ActiveMQ estiver ativo. 4.2 Se o IP não for encontrado não será possível estabelecer a comunicação. 4.3 Caso a rede cair haverá uma tentativa de reconexão, caso não haja sucesso o chat será desativado e as mensagens enviadas neste tempo não serão entregues. REFERÊNCIAS http://mballem.wordpress.com/2011/02/09/chat-jms-com-activemq/ http://onjava.com/pub/a/onjava/2001/12/12/jms_not.html Link do Tutorial em Video - http://www.youtube.com/watch?v=7Q9qe6FQ2TE
  • 8. Anexo /* * Cas cid pr o2 taah d dsiln d Ssea Dsrbio. lse raa aa º rblo a icpia e itms itiuds */ pcaeca.ee akg htrd; ipr ca.tlCrCa; mot htcr.tlht ipr jvxjs* mot aa.m.; ipr jvxnmn.otx; mot aa.aigCnet ipr jvxnmn.ntaCnet mot aa.aigIiilotx; ipr jvxnmn.aigxeto; mot aa.aigNmnEcpin pbi casJsusrbripeet Msaeitnr{ ulc ls mSbcie mlmns esgLsee piaeTpconcincnet rvt oiCneto onc; pbi JsusrbrSrn fcoyae Srn tpcae trw JSxeto,NmnEcpin{ ulc mSbcie(tig atrNm, tig oiNm) hos MEcpin aigxeto / Otmo ddsd cnxoJD arvsd aqiojd.rpris / bé s ao a oeã NI taé o ruv nipoete CnetjdCnet=nwIiilotx(tlhtgtntne)gtrpris); otx niotx e ntaCnetCrCa.eIsac(.ePoete() / OcineuiiaoTpconcinatr pr ciru ojt d tp Tpconcincmopoeo JS / let tlz oiCnetoFcoy aa ra m beo o io oiCneto o rvdr M Tpconcinatr fcoy=(oiCnetoFcoy jdCnetlou(atrNm) oiCnetoFcoy atr Tpconcinatr) niotx.okpfcoyae; / Psus odsiod tpc vaJD / eqia etn o óio i NI Tpctpc=(oi)jdCnetlou(oiNm) oi oi Tpc niotx.okptpcae; / UiiaoTpconcinatr pr ciracnxocmopoeo JS / tlz oiCnetoFcoy aa ra oeã o rvdr M ti.onc =fcoycetTpconcin) hscnet atr.raeoiCneto(; / UiiaoTpconcinpr cirassã pr ocnuio / tlz oiCneto aa ra eso aa osmdr / Arbt fle- uoo nod tasçe(rtruasred evo/eeietscm uiaeaôiae / tiuo as > s u ã e rnaõstaa m éi e nisrcbmno oo ndd tmc / cnrl-avacmi erlbc) / otoál i omt olak / Arbt AT_CNWEG - Eiecnimçoatmtc aó rcbmnocreo / tiuo UOAKOLDE > xg ofraã uoáia ps eeiet ort Tpceso ssin=cnetcetTpceso(as,SsinAT_CNWEG) oiSsin eso onc.raeoiSsinfle eso.UOAKOLDE; / Ci(sia otpc JSd cnuio dsmnaesarvsd ssã eonm d tpc / raAsn) óio M o osmdr a esgn taé a eso oe o óio Tpcusrbrsbcie =ssincetSbcie(oi) oiSbcie usrbr eso.raeusrbrtpc; / Ect otpc pr rcbra mnaesarvsd mtd oMsae) / sua óio aa eee s esgn taé o éoo nesg( sbcie.eMsaeitnrti) usrbrstesgLsee(hs; / Iii acnxoJS prieqemnaessjmeteus / nca oeã M, emt u esgn ea nrge cnetsat) onc.tr(; } @vrie Oerd / Rcb a mnaesd tpc asnd / eee s esgn o óio siao pbi vi oMsaeMsaemsae { ulc od nesg(esg esg) ty{ r
  • 9. / A mnaescidscm TxMsaedvmsrrcbdscm TxMsae / s esgn raa oo etesg ee e eeia oo etesg TxMsaetxMg=(etesg)msae etesg ets TxMsae esg; Srn tx =txMggtet) tig et ets.eTx(; CrCa.eIsac(.rnteatx) tlhtgtntne)pitTl(et; } cth(MEcpine){ ac JSxeto x e.rnSakrc(; xpittcTae) } } / FcaacnxoJS / eh oeã M pbi vi coe)trw JSxeto { ulc od ls( hos MEcpin ti.onc.ls(; hscnetcoe) } }
  • 10. /* * Cas cid pr o2 taah d dsiln d Ssea Dsrbio. lse raa aa º rblo a icpia e itms itiuds */ pcaeca.ee akg htrd; ipr ca.tlCrCa; mot htcr.tlht ipr jvxjs* mot aa.m.; ipr jvxnmn.otx; mot aa.aigCnet ipr jvxnmn.ntaCnet mot aa.aigIiilotx; ipr jvxnmn.aigxeto; mot aa.aigNmnEcpin pbi casJsulse { ulc ls mPbihr piaeTpculse pbihr rvt oiPbihr ulse; piaeTpceso ssin rvt oiSsin eso; piaeTpconcincnet rvt oiCneto onc; pbi Jsulse(tigfcoyae Srn tpcae trw JSxeto,NmnEcpin{ ulc mPbihrSrn atrNm, tig oiNm) hos MEcpin aigxeto / Otmo ddsd cnxoJD arvsd aqiojd.rpris / bé s ao a oeã NI taé o ruv nipoete CnetjdCnet=nwIiilotx(tlhtgtntne)gtrpris); otx niotx e ntaCnetCrCa.eIsac(.ePoete() / OcineuiiaoTpconcinatr pr ciru ojt d tp Tpconcincmopoeo JS / let tlz oiCnetoFcoy aa ra m beo o io oiCneto o rvdr M Tpconcinatr fcoy=(oiCnetoFcoy jdCnetlou(atrNm) oiCnetoFcoy atr Tpconcinatr) niotx.okpfcoyae; / Psus odsiod tpc vaJD / eqia etn o óio i NI Tpctpc=(oi)jdCnetlou(oiNm) oi oi Tpc niotx.okptpcae; / UiiaoTpconcinatr pr ciracnxocmopoeo JS / tlz oiCnetoFcoy aa ra oeã o rvdr M ti.onc =fcoycetTpconcin) hscnet atr.raeoiCneto(; / UiiaoTpconcinpr cirassã pr opouo / tlz oiCneto aa ra eso aa rdtr / Arbt fle- uoo nod tasçe(rtruasred evo/eeietscm uiaeaôiae / tiuo as > s u ã e rnaõstaa m éi e nisrcbmno oo ndd tmc / cnrl-avacmi erlbc) / otoál i omt olak / Arbt AT_CNWEG - Eiecnimçoatmtc aó rcbmnocreo / tiuo UOAKOLDE > xg ofraã uoáia ps eeiet ort ti.eso =cnetcetTpceso(as,SsinAT_CNWEG) hsssin onc.raeoiSsinfle eso.UOAKOLDE; / Ci otpc JSd pouo dsmnaesarvsd ssã eonm d tpc / ra óio M o rdtr a esgn taé a eso oe o óio ti.ulse =ssincetPbihrtpc; hspbihr eso.raeulse(oi) } / Ci amnae d txoeapbian tpc.Eet rfrnea pouo / ra esgm e et ulc o óio vno eeet o rdtr pbi vi pbihSrn msae trw JSxeto { ulc od uls(tig esg) hos MEcpin / Rcb u ojt d ssa pr ciruamnae d tp TxMsae / eee m beo a eso aa ra m esgm o io etesg TxMsaetxMg=ti.eso.raeetesg(; etesg ets hsssincetTxMsae) / St n ojt amnae qesr evaa / ea o beo esgm u eá nid txMgstetmsae; ets.eTx(esg)
  • 11. / Pbiaamnae n tpc / ulc esgm o óio ti.ulse.uls(ets,DlvrMd.ESSET 1 0; hspbihrpbihtxMg eieyoePRITN, , ) } / FcaacnxoJS / eh oeã M pbi vi coe)trw JSxeto { ulc od ls( hos MEcpin ti.onc.ls(; hscnetcoe) } }
  • 12. /* * Cas cid pr o2 taah d dsiln d Ssea Dsrbio. lse raa aa º rblo a icpia e itms itiuds */ pcaeca.tl akg htcr; ipr ca.d.esgm mot htcpMnae; ipr ca.i.aCa; mot htchJnht ipr ca.i.aCniua; mot htchJnofgrr ipr jv.tlLs; mot aaui.it ipr jv.tlPoete; mot aaui.rpris ipr jv.tllgigLvl mot aaui.ogn.ee; ipr jv.tllgigLge; mot aaui.ogn.ogr ipr jvxjsJSxeto; mot aa.m.MEcpin ipr jvxnmn.aigxeto; mot aa.aigNmnEcpin ipr jvxsigJpinae mot aa.wn.OtoPn; ipr ca.eeJsulse; mot htrd.mPbihr ipr ca.eeJsusrbr mot htrd.mSbcie; ipr ui.g.A; mot tlcdDO ipr ui.g.AFcoy mot tlcdDOatr; /* * * *@uhreiaot ato rgmne */ pbi casCrCa { ulc ls tlht piaeJsulse pbihr=nl; rvt mPbihr ulse ul piaeJsusrbrsbcie =nl; rvt mSbcie usrbr ul piaeSrn nm ="nnm" rvt tig oe Aoio; piaeSrn iSr ="; rvt tig pev " piaeJnhtjnht rvt aCa aCa; piaePoete po =nl; rvt rpris rp ul piaeSrn tpcae="oiCa" rvt tig oiNm tpcht; piaeSrn fcoyae="oiC" rvt tig atrNm TpcF; piaeCrCa( { rvt tlht) } pbi sai CrCa gtntne){ ulc ttc tlht eIsac( rtr CrCaHle.NTNE eun tlhtodrISAC; }
  • 13. piaesai casCrCaHle { rvt ttc ls tlhtodr piaesai fnlCrCa ISAC =nwCrCa(; rvt ttc ia tlht NTNE e tlht) } pbi Poete gtrpris){ ulc rpris ePoete( i (rp= nl){ f po = ul po =nwPoete(; rp e rpris) /cas jd pr oAtvM /lse ni aa cieQ po.u(jv.aigfcoyiiil,"r.pceatvm.niAtvMIiilotxFcoy) rppt"aanmn.atr.nta" ogaah.cieqjd.cieQntaCnetatr"; /ulpr cnxocmopoeo /r aa oeã o rvdr po.u(jv.aigpoie.r" "c:/ +iSr +"666) rppt"aanmn.rvdrul, tp/" pev :11"; /nm d cnxo /oe a oeã po.u(cnetoFcoyae" fcoyae; rppt"oncinatrNms, atrNm) /nm d tpc js /oe o óio m po.u(tpctpcht,tpcae; rppt"oi.oiCa" oiNm) } rtr po; eun rp } pbi vi cagSre(tigi){ ulc od hneevrSrn p /iii o pg a poreae /nca u ea s rpidds Poete p=gtrpris) rpris ePoete(; /rmv oedrç atro /eoe neeo neir prmv(jv.aigpoie.r"; .eoe"aanmn.rvdrul) /aiin u nv /dcoa m oo ppt"aanmn.rvdrul,"c:/ +i +"666) .u(jv.aigpoie.r" tp/" p :11"; iSr =i; pev p } pbi vi iiirM( { ulc od ncaJS) ty{ r sbcie =nwJsusrbrfcoyae tpcae; usrbr e mSbcie(atrNm, oiNm) pbihr=nwJsulse(atrNm,tpcae; ulse e mPbihrfcoyae oiNm) pbihrpbihti.oe+"eto n sl ."; ulse.uls(hsnm nru a aa .n)
  • 14. /hblt o cmoetsd jnl cm eal tu/as /aiia s opnne a aea oo nbe refle jnhtstopnneEal(re; aCa.eCmoetsnbetu) } cth(MEcpine){ ac JSxeto x JpinaesoMsaeilgjnht "evdrnoEcnrd!,"RO" JpinaeO_PIN; OtoPn.hwesgDao(aCa, Srio ã notao" ERR, OtoPn.KOTO) iSr ="; pev " Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e) ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x; } cth(aigxeto e){ ac NmnEcpin x Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e) ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x; } } pbi vi rcncaPbihr){ ulc od eoetrulse( ty{ r pbihrcoe) ulse.ls(; sbcie.ls(; usrbrcoe) sbcie =nwJsusrbrfcoyae tpcae; usrbr e mSbcie(atrNm, oiNm) pbihr=nwJsulse(atrNm,tpcae; ulse e mPbihrfcoyae oiNm) } cth(MEcpine){ ac JSxeto x JpinaesoMsaeilgjnht "evdrnoEcnrd!,"RO" JpinaeO_PIN; OtoPn.hwesgDao(aCa, Srio ã notao" ERR, OtoPn.KOTO) iSr ="; pev " jnhtstopnneEal(as) aCa.eCmoetsnbefle; Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e) ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x; } cth(aigxeto e){ ac NmnEcpin x Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e) ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x; } } pbi Jsulse gtulse( { ulc mPbihr ePbihr) rtr pbihr eun ulse; } pbi Jsusrbrgtusrbr){ ulc mSbcie eSbcie( rtr sbcie; eun usrbr } pbi vi fcaCnxo){ ulc od ehroea( ty{ r
  • 15. pbihrpbihti.oe+"si d sl ."; ulse.uls(hsnm au a aa .n) ti.ulse.ls(; hspbihrcoe) ti.usrbrcoe) hssbcie.ls(; } cth(MEcpine){ ac JSxeto x Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e) ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x; } } pbi boensrioIiid( { ulc ola evdrncao) i (ulse ! nl & sbcie ! nl){ f pbihr = ul & usrbr = ul rtr tu; eun re } rtr fle eun as; } pbi vi arraCniua( { ulc od biJnofgrr) nwJnofgrr)stiil(re; e aCniua(.eVsbetu) } pbi Srn gtoe){ ulc tig eNm( rtr nm; eun oe } pbi vi stoeSrn nm){ ulc od eNm(tig oe i (evdrncao) { f srioIiid() ty{ r /evapr osrio /ni aa evdr pbihrpbihti.oe+"mduonm pr "+nm +"n) ulse.uls(hsnm uo oe aa oe "; } cth(MEcpine){ ac JSxeto x Lge.eLge(aCa.ls.eNm()lgLvlSVR,nl,e) ogrgtogrJnhtcasgtae).o(ee.EEE ul x; } } ti.oe=nm; hsnm oe } pbi Srn gtpevdr){ ulc tig eISrio( rtr iSr; eun pev }
  • 16. pbi vi stpevdrSrn iSr){ ulc od eISrio(tig pev ti.pev=iSr; hsiSr pev } pbi vi steaJnhtahs { ulc od eTl(aCa Ti) jnht=ahs aCa Ti; } pbi vi pitTl(tigmg { ulc od rnteaSrn s) jnhtpiteamg; aCa.rnTl(s) } /dorsosvlprsla a mnaesn bno /a epnae o avr s esgn o ac piaeDOdo=DOatr.eIsac(.beDOMnae.ls) rvt A a AFcoygtntne)otrA(esgmcas; pbi vi slaHsoioSrn mg { ulc od avritrc(tig s) Mnae m=nwMnae(; esgm e esgm) mstet(s) .eTxomg; ty{ r dosla() a.avrm; } cth(xeto e){ ac Ecpin x Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e) ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x; } } pbi Srn gtitrc( { ulc tig eHsoio) Ls<esgm cnes =nl; itMnae> ovra ul Srn mg="; tig s " ty{ r cnes =dootrMnae.ls) ovra a.be(esgmcas; Sse.u.rnl(a) ytmotpitn""; fr(n i=0 cnes! nl & i<cnes.ie) i+ { o it ; ovra= ul & ovrasz(; +) mg+ cnes.e()gtet(; s = ovragti.eTxo) } } cth(xeto e){ ac Ecpin x Sse.u.rnl(b) ytmotpitn""; Lge.eLge(tlhtcasgtae).o(ee.EEE nl,e) ogrgtogrCrCa.ls.eNm()lgLvlSVR, ul x; }
  • 17. rtr mg eun s; } }
  • 18. /* * Faecid pr o2 taah d dsiln d Ssea Dsrbio. rm rao aa º rblo a icpia e itms itiuds */ pcaeca.i; akg htch ipr ca.tlCrCa; mot htcr.tlht ipr jv.w.WEcpin mot aaatATxeto; ipr jv.w.oo; mot aaatClr ipr jv.w.rm; mot aaatFae ipr jv.w.oo; mot aaatRbt ipr jv.w.vn.eEet mot aaateetKyvn; ipr jv.oFl; mot aai.ie ipr jv.oFlWie; mot aai.iertr ipr jv.oIEcpin mot aai.Oxeto; ipr jv.oPitrtr mot aai.rnWie; ipr jv.etSmlDtFra; mot aatx.ipeaeomt ipr jv.tllgigLvl mot aaui.ogn.ee; ipr jv.tllgigLge; mot aaui.ogn.ogr ipr jvxiaeoIaeO mot aa.mgi.mgI; ipr jvxjsJSxeto; mot aa.m.MEcpin ipr jvxsigJiehoe; mot aa.wn.FlCosr pbi casJnhtetnsjvxsigJrm { ulc ls aCa xed aa.wn.Fae piaeboensitn=fle rvt ola hfO as; pbi Jnht){ ulc aCa( iiCmoet(; ntopnns) iiFae) ntrm(; CrCa.eIsac(.eTl(hs; tlhtgtntne)steati) } @upesanns"nhce" SprsWrig(ucekd) / <dtrfl dfuttt=clasd ds=GnrtdCd"/GNBGNiiCmoet / eio-od ealsae"olpe" ec"eeae oe>/E-EI:ntopnns piaevi iiCmoet( { rvt od ntopnns) pnlrnia =nwjvxsigJae(; aePicpl e aa.wn.Pnl) pnletr=nwjvxsigJae(; aeCne e aa.wn.Pnl) fle5=nwjvxsigBxFle(e jv.w.ieso(,1) nwjv.w.ieso(,1) nwjv.w.ieso(26,1); ilr e aa.wn.o.ilrnw aaatDmnin0 0, e aaatDmnin0 0, e aaatDmnin377 0) fle7=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377) ilr e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26); fle8=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377) ilr e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26); pnliuo=nwjvxsigJae(; aeTtl e aa.wn.Pnl) ttlLbl=nwjvxsigJae(; iuoae e aa.wn.Lbl) cnesSrlPn =nwjvxsigJcolae) ovracolae e aa.wn.SrlPn(; cnesTx =nwjvxsigJetae) ovraet e aa.wn.TxPn(; pnlot =nwjvxsigJae(; aeSuh e aa.wn.Pnl) fle3=nwjvxsigBxFle(e jv.w.ieso(,1) nwjv.w.ieso(,1) nwjv.w.ieso(26,1); ilr e aa.wn.o.ilrnw aaatDmnin0 0, e aaatDmnin0 0, e aaatDmnin377 0) fle4=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377) ilr e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26); pnlesgm=nwjvxsigJae(; aeMnae e aa.wn.Pnl) pnlet =nwjvxsigJae(; aeTxo e aa.wn.Pnl) mnaeSrlPn =nwjvxsigJcolae) esgmcolae e aa.wn.SrlPn(; mnaeTx =nwjvxsigJetae) esgmet e aa.wn.TxPn(; fle1=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377) ilr e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26); pnloa =nwjvxsigJae(; aeBto e aa.wn.Pnl) evaBto =nwjvxsigJutn) nirutn e aa.wn.Bto(; fle2=nwjvxsigBxFle(e jv.w.ieso(0 0,nwjv.w.ieso(0 0,nwjv.w.ieso(0 377) ilr e aa.wn.o.ilrnw aaatDmnin1, ) e aaatDmnin1, ) e aaatDmnin1, 26); braeuht=nwjvxsigJeua(; arMnCa e aa.wn.MnBr) aqioeu=nwjvxsigJeu) ruvMn e aa.wn.Mn(; cniIe =nwjvxsigJeutm) ofgtm e aa.wn.MnIe(; sprdr=nwjvxsigJouMn.eaao(; eaao e aa.wn.PppeuSprtr) siIe =nwjvxsigJeutm) artm e aa.wn.MnIe(; hsoioeu=nwjvxsigJeu) itrcMn e aa.wn.Mn(; aiaCeko =nwjvxsigJhcBxeutm) tvrhcBx e aa.wn.CekoMnIe(; epraHsoiotm=nwjvxsigJeutm) xotritrcIe e aa.wn.MnIe(;
  • 19. stealCoeprto(aa.wn.idwosat.XTO_LS) eDfutlsOeainjvxsigWnoCntnsEI_NCOE; adidwitnrnwjv.w.vn.idwdpe( { dWnoLsee(e aaateetWnoAatr) pbi vi wnoCoigjv.w.vn.idwvn et { ulc od idwlsn(aaateetWnoEet v) faelsn(v) rmCoiget; } }; ) pnlrnia.eLyu(e jv.w.odraot); aePicplstaotnw aaatBreLyu() pnletrstaotnwjv.w.odraot); aeCne.eLyu(e aaatBreLyu() pnletradfle5 jv.w.odraotPG_N) aeCne.d(ilr, aaatBreLyu.AEED; pnletradfle7 jv.w.odraotLN_N) aeCne.d(ilr, aaatBreLyu.IEED; pnletradfle8 jv.w.odraotLN_TR) aeCne.d(ilr, aaatBreLyu.IESAT; ttlLblstotnwjv.w.ot"aoa,0 1);/ NI8 iuoae.eFn(e aaatFn(Thm" , 8) / O1N ttlLblstet"HTJS) iuoae.eTx(CA M"; pnliuoadttlLbl; aeTtl.d(iuoae) pnletradpnliuo jv.w.odraotPG_TR) aeCne.d(aeTtl, aaatBreLyu.AESAT; cnesTx.eFn(e jv.w.ot"oopcd,0 1);/ NI8 ovraetstotnw aaatFn(Mnsae" , 3) / O1N cnesSrlPn.eVeprVe(ovraet; ovracolaestiwotiwcnesTx) pnletradcnesSrlPn,jv.w.odraotCNE) aeCne.d(ovracolae aaatBreLyu.ETR; pnlrnia.d(aeCne,jv.w.odraotCNE) aePicpladpnletr aaatBreLyu.ETR; pnlot.eLyu(e jv.w.odraot); aeSuhstaotnw aaatBreLyu() pnlot.d(ilr,jv.w.odraotPG_N) aeSuhadfle3 aaatBreLyu.AEED; pnlot.d(ilr,jv.w.odraotLN_TR) aeSuhadfle4 aaatBreLyu.IESAT; pnlesgmstaotnwjvxsigBxaotpnlesgm jvxsigBxaotXAI); aeMnae.eLyu(e aa.wn.oLyu(aeMnae, aa.wn.oLyu._XS) pnlet.eLyu(e jv.w.odraot); aeTxostaotnw aaatBreLyu() mnaeTx.eFn(e jv.w.ot"oopcd,0 1);/ NI8 esgmetstotnw aaatFn(Mnsae" , 3) / O1N mnaeTx.ePeerdienwjv.w.ieso(6,9); esgmetstrfreSz(e aaatDmnin14 4) mnaeTx.dKyitnrnwjv.w.vn.eAatr){ esgmetadeLsee(e aaateetKydpe( pbi vi kyrse(aaateetKyvn et { ulc od ePesdjv.w.vn.eEet v) mnaeTxKyrse(v) esgmetePesdet; } pbi vi kyeesdjv.w.vn.eEetet { ulc od eRlae(aaateetKyvn v) mnaeTxKyeesdet; esgmeteRlae(v) } }; ) mnaeSrlPn.eVeprVe(esgmet; esgmcolaestiwotiwmnaeTx) pnlet.d(esgmcolae jv.w.odraotCNE) aeTxoadmnaeSrlPn, aaatBreLyu.ETR; pnlet.d(ilr,jv.w.odraotLN_N) aeTxoadfle1 aaatBreLyu.IEED; pnlesgmadpnlet) aeMnae.d(aeTxo; pnloa.eLyu(e jvxsigBxaotpnloa,jvxsigBxaotLN_XS) aeBtostaotnw aa.wn.oLyu(aeBto aa.wn.oLyu.IEAI); evaBto.eTx(Eva"; nirutnstet"nir) evaBto.dAtoLsee(e jv.w.vn.cinitnr){ nirutnadcinitnrnw aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) evaBtoAtoPromdet; nirutncinefre(v) } }; ) pnloa.d(nirutn; aeBtoadevaBto) pnlesgmadpnloa) aeMnae.d(aeBto; pnlesgmadfle2; aeMnae.d(ilr)
  • 20. pnlot.d(aeMnae,jv.w.odraotCNE) aeSuhadpnlesgm aaatBreLyu.ETR; pnlrnia.d(aeSuh jv.w.odraotPG_N) aePicpladpnlot, aaatBreLyu.AEED; gtotnPn(.d(aePicpl jv.w.odraotCNE) eCnetae)adpnlrnia, aaatBreLyu.ETR; aqioeustet"ruv"; ruvMn.eTx(Aqio) cniIe.eAclrtrjvxsigKytoegteSrk(aaateetKyvn.KT jv.w.vn.nuEetCR_AK) ofgtmstceeao(aa.wn.eSrk.eKytoejv.w.vn.eEetV_, aaateetIptvn.TLMS); cniIe.eTx(Cniuaõs) ofgtmstet"ofgrçe"; cniIe.dAtoLsee(e jv.w.vn.cinitnr){ ofgtmadcinitnrnw aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) cniIeAtoPromdet; ofgtmcinefre(v) } }; ) aqioeuadcniIe) ruvMn.d(ofgtm; aqioeuadsprdr; ruvMn.d(eaao) siIe.eAclrtrjvxsigKytoegteSrk(aaateetKyvn.KF,jv.w.vn.nuEetATMS); artmstceeao(aa.wn.eSrk.eKytoejv.w.vn.eEetV_4 aaateetIptvn.L_AK) siIe.eTx(Si"; artmstet"ar) siIe.dAtoLsee(e jv.w.vn.cinitnr){ artmadcinitnrnw aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) siIeAtoPromdet; artmcinefre(v) } }; ) aqioeuadsiIe) ruvMn.d(artm; braeuhtadaqioeu; arMnCa.d(ruvMn) hsoioeustet"itrc"; itrcMn.eTx(Hsóio) aiaCeko.eAclrtrjvxsigKytoegteSrk(aaateetKyvn.KG jv.w.vn.nuEetCR_AK) tvrhcBxstceeao(aa.wn.eSrk.eKytoejv.w.vn.eEetV_, aaateetIptvn.TLMS); aiaCeko.eSlce(re; tvrhcBxsteetdtu) aiaCeko.eTx(Aia Gaaã"; tvrhcBxstet"tvr rvço) hsoioeuadaiaCeko) itrcMn.d(tvrhcBx; epraHsoiotmstceeao(aa.wn.eSrk.eKytoejv.w.vn.eEetV_,jv.w.vn.nuEetCR_AK) xotritrcIe.eAclrtrjvxsigKytoegteSrk(aaateetKyvn.KS aaateetIptvn.TLMS); epraHsoiotmstet"xotr."; xotritrcIe.eTx(Epra .) epraHsoiotmadcinitnrnwjv.w.vn.cinitnr){ xotritrcIe.dAtoLsee(e aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) epraHsoiotmcinefre(v) xotritrcIeAtoPromdet; } }; ) hsoioeuadepraHsoiotm; itrcMn.d(xotritrcIe) braeuhtadhsoioeu; arMnCa.d(itrcMn) stMnBrbraeuht; eJeua(arMnCa) jv.w.ieso sreSz =jv.w.oli.eDfutoli(.eSreSz(; aaatDmnin cenie aaatToktgtealTokt)gtcenie) stons(ceniewdh46/,(ceniehih-5)2 46 31; eBud(sreSz.it-1)2 sreSz.egt31/, 1, 5) }/<eio-od/GNEDiiCmoet / /dtrfl>/E-N:ntopnns /* *Es mtd écaaopr cniua ofae se éoo hmd aa ofgrr rm. */ / <dtrfl dfuttt=clasd ds=Mtd d cniuaã d Fae> / eio-od ealsae"olpe" ec"éoo e ofgrço o rm" piaevi iiFae){ rvt od ntrm( sprstil(CA JS) ue.eTte"HT M"; sprstxeddtt(rm.AIIE_OH; ue.eEtneSaeFaeMXMZDBT) ty{ r /aiã d ioea porm /dço o cn o rgaa sprstcnmg(mgI.edgtls(.eRsuc(/htigioepg)) ue.eIoIaeIaeOra(eCas)gteore"ca/m/cn.n"); }
  • 21. cth(Oxeto e){ ac IEcpin x Sse.r.rnl(Ioenoecnrd!) ytmerpitn"cn ã notao"; } cnesTx.eEial(as) ovraetstdtbefle; stopnneEal(as) eCmoetsnbefle; }/<eio-od / /dtrfl> /* *EssMtdssoo eetsdscmoetsd fae se éoo ã s vno o opnne o rm. */ / <dtrfl dfuttt=clasd ds=Eetsd Cmoets> / eio-od ealsae"olpe" ec"vno e opnne" piaevi siIeAtoPromdjv.w.vn.cinvn et {/E-IS:vn_artmcinefre rvt od artmcinefre(aaateetAtoEet v) /GNFRTeetsiIeAtoPromd /fcaajnl /eh aea ti.ips(; hsdsoe) }/E-ATeetsiIeAtoPromd /GNLS:vn_artmcinefre piaevi evaBtoAtoPromdjv.w.vn.cinvn et {/E-IS:vn_nirutncinefre rvt od nirutncinefre(aaateetAtoEet v) /GNFRTeetevaBtoAtoPromd i (tlhtgtntne)srioIiid(){ f CrCa.eIsac(.evdrncao) /pg amsgmqeouuroqe eva /ea eae u sai ur nir Srn mg=mnaeTx.eTx(; tig s esgmetgtet) i (mgti(.qas") { f !s.rm)eul(") /aiin onm d uuro /dcoa oe o sai jv.tlDt aoa=nwjv.tlDt(; aaui.ae gr e aaui.ae); SmlDtFra fraa=nwSmlDtFra(H:m) ipeaeomt omt e ipeaeomt"Hm"; mg=fraafra(gr)+""+CrCa.eIsac(.eNm( +"sy:n"+mg+"n; s omt.omtaoa tlhtgtntne)gtoe) as s " /zr ciad txo /ea ax e et mnaeTx.eTx("; esgmetstet") ty{ r /evapr osrio /ni aa evdr CrCa.eIsac(.ePbihr)pbihmg; tlhtgtntne)gtulse(.uls(s) } cth(MEcpine){ ac JSxeto x pitea"---nESGMPRIA"+mg+---"; rnTl(---MNAE EDD:n s "---n) CrCa.eIsac(.eoetrulse(; tlhtgtntne)rcncaPbihr) Lge.eLge(aCa.ls.eNm()lgLvlSVR,nl,e) ogrgtogrJnhtcasgtae).o(ee.EEE ul x; } } } /fc nvmnepr ocmoet d mg /oo oaet aa opnne e s mnaeTx.rbou(; esgmetgaFcs) }/E-ATeetevaBtoAtoPromd /GNLS:vn_nirutncinefre piaevi cniIeAtoPromdjv.w.vn.cinvn et {/E-IS:vn_ofgtmcinefre rvt od ofgtmcinefre(aaateetAtoEet v) /GNFRTeetcniIeAtoPromd CrCa.eIsac(.biJnofgrr) tlhtgtntne)arraCniua(; }/E-ATeetcniIeAtoPromd /GNLS:vn_ofgtmcinefre piaevi epraHsoiotmcinefre(aaateetAtoEetet {/E-IS:vn_xotritrcIeAtoPromd rvt od xotritrcIeAtoPromdjv.w.vn.cinvn v) /GNFRTeetepraHsoiotmcinefre Jiehoe jc=nwJiehoe(; FlCosr f e FlCosr) itrsl =jcsoSvDao(hs; n eut f.hwaeilgti) i (eut= Jiehoe.PRV_PIN { f rsl = FlCosrAPOEOTO) Fl fl =jcgteetdie) ie ie f.eSlceFl(; Pitrtrp =nl; rnWie w ul ty{ r p =nwPitrtrnwFlWie(ie) w e rnWie(e iertrfl); } cth(Oxeto e){ ac IEcpin x Lge.eLge(aCa.ls.eNm()lgLvlSVR,nl,e) ogrgtogrJnhtcasgtae).o(ee.EEE ul x; }
  • 22. p.rnl(tlhtgtntne)gtitrc() wpitnCrCa.eIsac(.eHsoio); p.ls(; wcoe) } }/E-ATeetepraHsoiotmcinefre /GNLS:vn_xotritrcIeAtoPromd piaevi faelsn(aaateetWnoEetet {/E-IS:vn_rmCoig rvt od rmCoigjv.w.vn.idwvn v) /GNFRTeetfaelsn i (tlhtgtntne)srioIiid(){ f CrCa.eIsac(.evdrncao) CrCa.eIsac(.ehroea(; tlhtgtntne)fcaCnxo) } }/E-ATeetfaelsn /GNLS:vn_rmCoig piaevi mnaeTxKyrse(aaateetKyvn et {/E-IS:vn_esgmetePesd rvt od esgmetePesdjv.w.vn.eEet v) /GNFRTeetmnaeTxKyrse /s frciaou etrdnr d cmoet d mnae /e o lcd m ne eto o opnne e esgm /oeet d btoeva eaind / vno o oã nir coao i (v.eKyoe)= Kyvn.KETR { f etgteCd( = eEetV_NE) i (sitn { f !hfO) evaBtoAtoPromdnl) nirutncinefre(ul; ty{ r /rtr aaa d pl d lna /eia co e ua e ih nwRbt)kyrs(eEetV_AKSAE; e oo(.ePesKyvn.KBC_PC) } cth(WEcpine){ ac ATxeto x /Lge.eLge(aCa.ls.eNm()lgLvlSVR,nl,e) /ogrgtogrJnhtcasgtae).o(ee.EEE ul x; } } es { le /ado n fmd mg /d n o i a s mnaeTx.eTx(esgmetgtet)+"n) esgmetstetmnaeTx.eTx( "; } } es i (v.eKyoe)= Kyvn.KSIT { le f etgteCd( = eEetV_HF) /sitpesoao /hf rsind sitn=tu; hfO re } }/E-ATeetmnaeTxKyrse /GNLS:vn_esgmetePesd piaevi mnaeTxKyeesdjv.w.vn.eEetet {/E-IS:vn_esgmeteRlae rvt od esgmeteRlae(aaateetKyvn v) /GNFRTeetmnaeTxKyeesd i (v.eKyoe)= Kyvn.KSIT { f etgteCd( = eEetV_HF) /sitdsrsind /hf epesoao sitn=fle hfO as; } }/E-ATeetmnaeTxKyeesd /GNLS:vn_esgmeteRlae / <eio-od / /dtrfl> pbi vi piteaSrn mg { ulc od rnTl(tig s) /slaamnae n hsoio /av esgm o itrc i(tvrhcBxiSlce() faiaCeko.seetd){ CrCa.eIsac(.avritrc(s) tlhtgtntne)slaHsoiomg; } /cnaeacmacnes j eitne /octn o ovra a xset mg=cnesTx.eTx( +mg s ovraetgtet) s; /msr n poratl /ota a rpi ea cnesTx.eTx(s) ovraetstetmg; /atsrl /uocol cnesTx.eCrtoiincnesTx.eDcmn(.eLnt() ovraetstaePsto(ovraetgtouet)gtegh); } pbi vi stopnneEal(ola aio { ulc od eCmoetsnbeboen tv) mnaeTx.eEaldaio; esgmetstnbe(tv) cnesTx.eEaldaio; ovraetstnbe(tv) evaBto.eEaldaio; nirutnstnbe(tv)
  • 23. } pbi sai vi mi(tigag[){ ulc ttc od anSrn rs] /* *StteWnoslo adfe e h idw ok n el */ /<dtrfl dfuttt=clasd ds= Lo adfe stigcd (pinl " /eio-od ealsae"olpe" ec" ok n el etn oe otoa) > /* *I Nmu (nrdcdi Jv S 6 i ntaalbe sa wt tedfutlo adfe.Frdtisseht:/onodoal.o/aaettra/iwn/oknfe/lfhm f ibs itoue n aa E ) s o vial, ty ih h eal ok n el o eal e tp/dwla.rcecmjvs/uoilusigloadelpa.tl */ ty{ r fr(aa.wn.Iaae.oknFeIf if :jvxsigUMngrgtntleLoAdel(){ o jvxsigUMngrLoAdelno no aa.wn.Iaae.eIsaldoknFes) i (Wnos.qasif.eNm() { f "idw"eul(nogtae)) jvxsigUMngrstoknFe(nogtlsNm() aa.wn.Iaae.eLoAdelif.eCasae); bek ra; } } } cth(lsNtonEcpine){ ac CasoFudxeto x jv.tllgigLge.eLge(aCa.ls.eNm()lgjv.tllgigLvlSVR,nl,e) aaui.ogn.ogrgtogrJnhtcasgtae).o(aaui.ogn.ee.EEE ul x; } cth(ntnitoEcpine){ ac Isatainxeto x jv.tllgigLge.eLge(aCa.ls.eNm()lgjv.tllgigLvlSVR,nl,e) aaui.ogn.ogrgtogrJnhtcasgtae).o(aaui.ogn.ee.EEE ul x; } cth(leaAcsEcpine){ ac Ilglcesxeto x jv.tllgigLge.eLge(aCa.ls.eNm()lgjv.tllgigLvlSVR,nl,e) aaui.ogn.ogrgtogrJnhtcasgtae).o(aaui.ogn.ee.EEE ul x; } cth(aa.wn.nupreLoAdelxeto e){ ac jvxsigUspotdoknFeEcpin x jv.tllgigLge.eLge(aCa.ls.eNm()lgjv.tllgigLvlSVR,nl,e) aaui.ogn.ogrgtogrJnhtcasgtae).o(aaui.ogn.ee.EEE ul x; } /<eio-od //dtrfl> jv.w.vnQeeivkLtrnwRnal( { aaatEetuu.noeae(e unbe) @vrie Oerd pbi vi rn){ ulc od u( nwJnht)stiil(re; e aCa(.eVsbetu) } }; ) } / <dtrfl dfuttt=clasd ds=Dcaaã dsCmoetsd Fae> / eio-od ealsae"olpe" ec"elrço o opnne o rm" / Vralsdcaain-d ntmdf/GNBGNvrals / aibe elrto o o oiy/E-EI:aibe piaejvxsigJeuaqioeu rvt aa.wn.Mn ruvMn; piaejvxsigJhcBxeutmaiaCeko; rvt aa.wn.CekoMnIe tvrhcBx piaejvxsigJeua braeuht rvt aa.wn.MnBr arMnCa; piaejvxsigJeutmcniIe; rvt aa.wn.MnIe ofgtm piaejvxsigJcolaecnesSrlPn; rvt aa.wn.SrlPn ovracolae piaejvxsigJetaecnesTx; rvt aa.wn.TxPn ovraet piaejvxsigJutnevaBto; rvt aa.wn.Bto nirutn piaejvxsigJeutmepraHsoiotm rvt aa.wn.MnIe xotritrcIe; piaejvxsigBxFle fle1 rvt aa.wn.o.ilr ilr; piaejvxsigBxFle fle2 rvt aa.wn.o.ilr ilr; piaejvxsigBxFle fle3 rvt aa.wn.o.ilr ilr; piaejvxsigBxFle fle4 rvt aa.wn.o.ilr ilr; piaejvxsigBxFle fle5 rvt aa.wn.o.ilr ilr; piaejvxsigBxFle fle7 rvt aa.wn.o.ilr ilr; piaejvxsigBxFle fle8 rvt aa.wn.o.ilr ilr; piaejvxsigJeuhsoioeu rvt aa.wn.Mn itrcMn;
  • 24. piaejvxsigJcolaemnaeSrlPn; rvt aa.wn.SrlPn esgmcolae piaejvxsigJetaemnaeTx; rvt aa.wn.TxPn esgmet piaejvxsigJae pnloa; rvt aa.wn.Pnl aeBto piaejvxsigJae pnletr rvt aa.wn.Pnl aeCne; piaejvxsigJae pnlesgm rvt aa.wn.Pnl aeMnae; piaejvxsigJae pnlrnia; rvt aa.wn.Pnl aePicpl piaejvxsigJae pnlot; rvt aa.wn.Pnl aeSuh piaejvxsigJae pnlet; rvt aa.wn.Pnl aeTxo piaejvxsigJae pnliuo rvt aa.wn.Pnl aeTtl; piaejvxsigJeutmsiIe; rvt aa.wn.MnIe artm piaejvxsigJouMn.eaao sprdr rvt aa.wn.PppeuSprtr eaao; piaejvxsigJae ttlLbl rvt aa.wn.Lbl iuoae; / Edo vralsdcaain/E-N:aibe / n f aibe elrto/GNEDvrals / <eio-od / /dtrfl> }
  • 25. /* * Faecid pr o2 taah d dsiln d Ssea Dsrbio. rm rao aa º rblo a icpia e itms itiuds */ pcaeca.i; akg htch ipr ca.tlCrCa; mot htcr.tlht ipr jv.w.vn.eEet mot aaateetKyvn; ipr jv.oIEcpin mot aai.Oxeto; ipr jvxiaeoIaeO mot aa.mgi.mgI; ipr jvxsigJilg mot aa.wn.Dao; /* * * *@uhreiaot ato rgmne */ pbi casJnofgrretnsjvxsigJilg{ ulc ls aCniua xed aa.wn.Dao pbi Jnofgrr){ ulc aCniua( iiCmoet(; ntopnns) iiFae) ntrm(; nmTx.eTx(tlhtgtntne)gtoe); oeetstetCrCa.eIsac(.eNm() iTx.eTx(tlhtgtntne)gtpevdr); petstetCrCa.eIsac(.eISrio() } @upesanns"nhce" SprsWrig(ucekd) / <dtrfl dfuttt=clasd ds=GnrtdCd"/GNBGNiiCmoet / eio-od ealsae"olpe" ec"eeae oe>/E-EI:ntopnns piaevi iiCmoet( { rvt od ntopnns) jae1=nwjvxsigJae(; Pnl e aa.wn.Pnl) pnlrnia =nwjvxsigJae(; aePicpl e aa.wn.Pnl) ocePnl=nwjvxsigJae(; posae e aa.wn.Pnl) fle1=nwjvxsigBxFle(e jv.w.ieso(,1) nwjv.w.ieso(,1) nwjv.w.ieso(26,1); ilr e aa.wn.o.ilrnw aaatDmnin0 0, e aaatDmnin0 0, e aaatDmnin377 0) pierLnaae =nwjvxsigJae(; rmiaihPnl e aa.wn.Pnl) nmPnl=nwjvxsigJae(; oeae e aa.wn.Pnl) nmLbl=nwjvxsigJae(; oeae e aa.wn.Lbl) nmTx =nwjvxsigJetil(; oeet e aa.wn.TxFed) sgnaihPnl=nwjvxsigJae(; eudLnaae e aa.wn.Pnl) iPnl=nwjvxsigJae(; pae e aa.wn.Pnl) iLbl=nwjvxsigJae(; pae e aa.wn.Lbl) iTx =nwjvxsigJetil(; pet e aa.wn.TxFed) btoae =nwjvxsigJae(; oaPnl e aa.wn.Pnl) alcroa =nwjvxsigJutn) piaBto e aa.wn.Bto(; jvxsigGopaotjae1aot=nwjvxsigGopaotjae1; aa.wn.ruLyu PnlLyu e aa.wn.ruLyu(Pnl) jae1staotjae1aot; Pnl.eLyu(PnlLyu) jae1aotstoiotlru( PnlLyu.eHrznaGop jae1aotcetPrleGopjvxsigGopaotAinetLAIG PnlLyu.raeaallru(aa.wn.ruLyu.lgmn.EDN) .dGp0 37 SotMXVLE ada(, 5, hr.A_AU)
  • 26. ); jae1aotstetclru( PnlLyu.eVriaGop jae1aotcetPrleGopjvxsigGopaotAinetLAIG PnlLyu.raeaallru(aa.wn.ruLyu.lgmn.EDN) .dGp0 1,SotMXVLE ada(, 8 hr.A_AU) ); steial(as) eRszbefle; pnlrnia.eLyu(e jv.w.odraot); aePicplstaotnw aaatBreLyu() ocePnlstaotnwjvxsigBxaotocePnl jvxsigBxaotYAI); posae.eLyu(e aa.wn.oLyu(posae, aa.wn.oLyu._XS) ocePnladfle1; posae.d(ilr) pierLnaae.eLyu(e jvxsigBxaotpierLnaae,jvxsigBxaotLN_XS) rmiaihPnlstaotnw aa.wn.oLyu(rmiaihPnl aa.wn.oLyu.IEAI); jv.w.lwaotfoLyu1=nwjv.w.lwaotjv.w.lwaotCNE,5 0; aaatFoLyu lwaot e aaatFoLyu(aaatFoLyu.ETR , ) foLyu1stlgOBsln(re; lwaot.eAinnaeietu) nmPnlstaotfoLyu1; oeae.eLyu(lwaot) nmLblstet"oe"; oeae.eTx(Nm:) nmPnladnmLbl; oeae.d(oeae) nmTx.eMnmmienwjv.w.ieso(0 2); oeetstiiuSz(e aaatDmnin6, 0) nmTx.ePeerdienwjv.w.ieso(0,2); oeetstrfreSz(e aaatDmnin30 0) nmTx.dKyitnrnwjv.w.vn.eAatr){ oeetadeLsee(e aaateetKydpe( pbi vi kyrse(aaateetKyvn et { ulc od ePesdjv.w.vn.eEet v) kyrseNmTx(v) ePesdoeetet; } }; ) nmPnladnmTx) oeae.d(oeet; pierLnaae.d(oeae) rmiaihPnladnmPnl; ocePnladpierLnaae) posae.d(rmiaihPnl; sgnaihPnlstaotnwjvxsigBxaotsgnaihPnl jvxsigBxaotLN_XS) eudLnaae.eLyu(e aa.wn.oLyu(eudLnaae, aa.wn.oLyu.IEAI); iPnlstaotnwjv.w.lwaotjv.w.lwaotCNE,5 0) pae.eLyu(e aaatFoLyu(aaatFoLyu.ETR , ); iLblstet"n I:) pae.eTx(E. P"; iPnladiLbl; pae.d(pae) iTx.eMnmmienwjv.w.ieso(0 2); petstiiuSz(e aaatDmnin6, 0) iTx.ePeerdienwjv.w.ieso(0,2); petstrfreSz(e aaatDmnin30 0) iTx.dKyitnrnwjv.w.vn.eAatr){ petadeLsee(e aaateetKydpe( pbi vi kyrse(aaateetKyvn et { ulc od ePesdjv.w.vn.eEet v) kyrseITx(v) ePesdpetet; }
  • 27. }; ) iPnladiTx) pae.d(pet; sgnaihPnladiPnl; eudLnaae.d(pae) ocePnladsgnaihPnl; posae.d(eudLnaae) pnlrnia.d(posae,jv.w.odraotCNE) aePicpladocePnl aaatBreLyu.ETR; btoae.eLyu(e jv.w.lwaotjv.w.lwaotRGT) oaPnlstaotnw aaatFoLyu(aaatFoLyu.IH); alcroa.eTx(Alcr) piaBtostet"pia"; alcroa.dAtoLsee(e jv.w.vn.cinitnr){ piaBtoadcinitnrnw aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) alcroaAtoPromdet; piaBtocinefre(v) } }; ) btoae.d(piaBto; oaPnladalcroa) pnlrnia.d(oaPnl jv.w.odraotPG_N) aePicpladbtoae, aaatBreLyu.AEED; gtotnPn(.d(aePicpl jv.w.odraotCNE) eCnetae)adpnlrnia, aaatBreLyu.ETR; jv.w.ieso sreSz =jv.w.oli.eDfutoli(.eSreSz(; aaatDmnin cenie aaatToktgtealTokt)gtcenie) stons(ceniewdh33/,(ceniehih-4)2 33 14; eBud(sreSz.it-7)2 sreSz.egt14/, 7, 4) }/<eio-od/GNEDiiCmoet / /dtrfl>/E-N:ntopnns /* *EssMtdssoo eetsdscmoetsd fae se éoo ã s vno o opnne o rm. */ / <dtrfl dfuttt=clasd ds=Eetsd Cmoets> / eio-od ealsae"olpe" ec"vno e opnne" piaevi alcroaAtoPromdjv.w.vn.cinvn et {/E-IS:vn_piaBtocinefre rvt od piaBtocinefre(aaateetAtoEet v) /GNFRTeetalcroaAtoPromd ti.eVsbefle; hsstiil(as) i (CrCa.eIsac(.eNm(.qasnmTx.eTx() { f !tlhtgtntne)gtoe)eul(oeetgtet)) CrCa.eIsac(.eNm(oeetgtet); tlhtgtntne)stoenmTx.eTx() } i (CrCa.eIsac(.eISrio(.qasiTx.eTx() { f !tlhtgtntne)gtpevdr)eul(petgtet)) CrCa.eIsac(.hneevriTx.eTx() tlhtgtntne)cagSre(petgtet); CrCa.eIsac(.ncaJS) tlhtgtntne)iiirM(; } ti.ips(; hsdsoe) }/E-ATeetalcroaAtoPromd /GNLS:vn_piaBtocinefre piaevi kyrseNmTx(aaateetKyvn et {/E-IS:vn_ePesdoeet rvt od ePesdoeetjv.w.vn.eEet v) /GNFRTeetkyrseNmTx i (v.eKyoe)= Kyvn.KETR { f etgteCd( = eEetV_NE) alcroaAtoPromdnl) piaBtocinefre(ul;
  • 28. } }/E-ATeetkyrseNmTx /GNLS:vn_ePesdoeet piaevi kyrseITx(aaateetKyvn et {/E-IS:vn_ePesdpet rvt od ePesdpetjv.w.vn.eEet v) /GNFRTeetkyrseITx kyrseNmTx(v) ePesdoeetet; }/E-ATeetkyrseITx /GNLS:vn_ePesdpet / <eio-od / /dtrfl> /* *Es mtd écaaopr cniua ofae se éoo hmd aa ofgrr rm. */ / <dtrfl dfuttt=clasd ds=Mtd d cniuaã d Fae> / eio-od ealsae"olpe" ec"éoo e ofgrço o rm" piaevi iiFae){ rvt od ntrm( sprstil(CA JS-Cniuaõs) ue.eTte"HT M ofgrçe"; ti.eDfutlsOeainJilgD_OHN_NCOE; hsstealCoeprto(Dao.ONTIGO_LS) ti.eMdltu) hsstoa(re; ty{ r /aiã d ioea porm /dço o cn o rgaa sprstcnmg(mgI.edgtls(.eRsuc(/htigioepg)) ue.eIoIaeIaeOra(eCas)gteore"ca/m/cn.n"); } cth(Oxeto e){ ac IEcpin x Sse.r.rnl(Ioenoecnrd!) ytmerpitn"cn ã notao"; } }/<eio-od / /dtrfl> / <dtrfl dfuttt=clasd ds=Dcaaã dsCmoetsd Fae> / eio-od ealsae"olpe" ec"elrço o opnne o rm" / Vralsdcaain-d ntmdf/GNBGNvrals / aibe elrto o o oiy/E-EI:aibe piaejvxsigJutnalcroa; rvt aa.wn.Bto piaBto piaejvxsigJae btoae; rvt aa.wn.Pnl oaPnl piaejvxsigBxFle fle1 rvt aa.wn.o.ilr ilr; piaejvxsigJae iLbl rvt aa.wn.Lbl pae; piaejvxsigJae iPnl rvt aa.wn.Pnl pae; piaejvxsigJetil iTx; rvt aa.wn.TxFed pet piaejvxsigJae jae1 rvt aa.wn.Pnl Pnl; piaejvxsigJae nmLbl rvt aa.wn.Lbl oeae; piaejvxsigJae nmPnl rvt aa.wn.Pnl oeae; piaejvxsigJetil nmTx; rvt aa.wn.TxFed oeet piaejvxsigJae ocePnl rvt aa.wn.Pnl posae; piaejvxsigJae pnlrnia; rvt aa.wn.Pnl aePicpl piaejvxsigJae pierLnaae; rvt aa.wn.Pnl rmiaihPnl piaejvxsigJae sgnaihPnl rvt aa.wn.Pnl eudLnaae; / Edo vralsdcaain/E-N:aibe / n f aibe elrto/GNEDvrals / <eio-od / /dtrfl> }
  • 29. pcaeca.d; akg htcp ipr jvxpritneEtt; mot aa.essec.niy ipr ui.g.beoesset; mot tlcdOjtPritne /Cas pr pritrn bno /lse aa essi o ac @niy Ett pbi casMnae etnsOjtPritne{ ulc ls esgm xed beoesset piaeSrn txo rvt tig et; pbi Srn gtet( { ulc tig eTxo) rtr txo eun et; } pbi vi stet(tigtxo { ulc od eTxoSrn et) ti.et =txo hstxo et; } }
  • 30. pcaeca.g; akg htcd ipr ca.d.esgm mot htcpMnae; ipr ui.g.A; mot tlcdDO pbi itraeMnaeDOetnsDOMnae> ulc nefc esgmA xed A<esgm{ }
  • 31. pcaeca.g; akg htcd ipr ca.d.esgm mot htcpMnae; ipr ui.g.AJA mot tlcdDOP; pbi casMnaeDOP etnsDOP<esgm ipeet MnaeDO ulc ls esgmAJA xed AJAMnae> mlmns esgmA{ }
  • 32. pcaeui.g; akg tlcd ipr jv.oSraial; mot aai.eilzbe ipr jv.tlLs; mot aaui.it /* * * *@uhrAmnsrdr ato diitao */ pbi itraeDOT etnsSraial{ ulc nefc A<> xed eilzbe pbi Tsla( oj trw Ecpin ulc avrT b) hos xeto; pbi vi ecurToj trw Ecpin ulc od xli( b) hos xeto; pbi Ls<>otrCasT cas)trw Ecpin ulc itT be(ls<> lse hos xeto; pbi TotrCasT cas,Ln i)trw Ecpin; ulc be(ls<> lse og d hos xeto }
  • 33. pcaeui.g; akg tlcd ipr jv.tlLs; mot aaui.it ipr jvxpritneEttMngr mot aa.essec.niyaae; ipr jvxpritneEttMngratr; mot aa.essec.niyaaeFcoy ipr jvxpritnePritne mot aa.essec.essec; ipr jvxpritneQey mot aa.essec.ur; pbi asrc casDOP< etnsOjtPritne ipeet DOT { ulc btat ls AJAT xed beoesset> mlmns A<> poetdsai EttMngratr ettMngratr =PritnecetEttMngratr(JA) rtce ttc niyaaeFcoy niyaaeFcoy essec.raeniyaaeFcoy"P"; poetdsai EttMngrettMngr=ettMngratr.raeniyaae(; rtce ttc niyaae niyaae niyaaeFcoycetEttMngr) pbi Tsla( oj trw Ecpin{ ulc avrT b) hos xeto ty{ r / Iii uatasçocmobnod dds / nca m rnaã o ac e ao. ettMngrgtrnato(.ei(; niyaae.eTascin)bgn) / Vrfc s oojt ananoet slon bnod dds / eiia e beo id ã sá av o ac e ao. i (b.eI( = nl){ f ojgtd) = ul /Slao ddsd ojt. /av s ao o beo ettMngrpritoj; niyaae.ess(b) } es { le /Aulz o ddsd ojt. /taia s ao o beo oj=ettMngrmreoj; b niyaae.eg(b) } / Fnlz atasço / iaia rnaã. ettMngrgtrnato(.omt) niyaae.eTascin)cmi(; } cth(xeto e { ac Ecpin ) oj=nl; b ul Sse.r.rnl(Er a otr"+e; ytmerpitn"ro o be ) trwnwEcpin"roa otr"+e; ho e xeto(Er o be ) } rtr oj eun b; } pbi vi ecurToj trw Ecpin{ ulc od xli( b) hos xeto ty{ r / Iii uatasçocmobnod dds / nca m rnaã o ac e ao.
  • 34. ettMngrgtrnato(.ei(; niyaae.eTascin)bgn) / Rmv oojt d bs d dds / eoe beo a ae e ao. ettMngrrmv(b) niyaae.eoeoj; / Fnlz atasço / iaia rnaã. ettMngrgtrnato(.omt) niyaae.eTascin)cmi(; } cth(xeto e { ac Ecpin ) Sse.r.rnl(Er a ecur"+e; ytmerpitn"ro o xli ) trwnwEcpin"roa ecur"+e; ho e xeto(Er o xli ) } } pbi Ls<>otrCasT cas)trw Ecpin{ ulc itT be(ls<> lse hos xeto Ls<>lsa=nl; itT it ul ty{ r Qeyqey=ettMngrcetQey"EETtFO "+cas.eSmlNm( +"t) ur ur niyaae.raeur(SLC RM lsegtipeae) "; lsa=qeygteutit) it ur.eRslLs(; } cth(xeto e { ac Ecpin ) Sse.r.rnl(Er a otr"+e; ytmerpitn"ro o be ) trwnwEcpin"roa otr"+e; ho e xeto(Er o be ) } rtr lsa eun it; } @vrie Oerd pbi TotrCasT cas,Ln i)trw Ecpin{ ulc be(ls<> lse og d hos xeto Toj=nl; b ul ty{ r Qeyqey=ettMngrcetQey"EETtFO "+cas.eSmlNm( +"tweei ="+i) ur ur niyaae.raeur(SLC RM lsegtipeae) hr d d; oj=()ur.eSnlRsl(; b Tqeygtigeeut) } cth(xeto e { ac Ecpin ) Sse.r.rnl(Er a otr"+e; ytmerpitn"ro o be ) trwnwEcpin"roa otr"+e; ho e xeto(Er o be ) } rtr oj eun b; } }
  • 35. pcaeui.g; akg tlcd ipr jv.tllgigLvl mot aaui.ogn.ee; ipr jv.tllgigLge; mot aaui.ogn.ogr pbi casDOatr { ulc ls AFcoy pbi Srn TP_DC="DC; ulc tig IOJB JB" pbi Srn TP_IENT ="ient" ulc tig IOHBRAE Hbrae; pbi Srn TP_P ="P" ulc tig IOJA JA; piaeSrn tpFbia=TP_P; rvt tig ioarc IOJA piaesai DOatr isac =nwDOatr(; rvt ttc AFcoy ntne e AFcoy) pbi sai DOatr gtntne){ ulc ttc AFcoy eIsac( i (ntne= nl) f isac = ul isac =nwDOatr(; ntne e AFcoy) rtr isac; eun ntne } pbi DOotrA(Cascas){ ulc A beDO ls lse Srn nm =cas.eNm(; tig oe lsegtae) nm =nm.elc(cp,"g"; oe oerpae"d" cd) nm =nm +"A"+ti.eTpFbia) oe oe DO hsgtioarc(; ty{ r rtr (A)Casfraenm)nwntne) eun DO ls.oNm(oe.eIsac(; }cth(lsNtonEcpine){ ac CasoFudxeto x Lge.eLge(AFcoycasgtae).o(ee.EEE nl,e) ogrgtogrDOatr.ls.eNm()lgLvlSVR, ul x; }cth(ntnitoEcpine){ ac Isatainxeto x Lge.eLge(AFcoycasgtae).o(ee.EEE nl,e) ogrgtogrDOatr.ls.eNm()lgLvlSVR, ul x; }cth(leaAcsEcpine){ ac Ilglcesxeto x Lge.eLge(AFcoycasgtae).o(ee.EEE nl,e) ogrgtogrDOatr.ls.eNm()lgLvlSVR, ul x; } rtr nl; eun ul } pbi Srn gtioarc( { ulc tig eTpFbia) rtr tpFbia eun ioarc; } pbi vi stioarc(tigtpFbia { ulc od eTpFbiaSrn ioarc) ti.ioarc =tpFbia hstpFbia ioarc; } }
  • 36. pcaeui.g; akg tlcd ipr jv.oSraial; mot aai.eilzbe ipr jv.m.eoe mot aariRmt; ipr jvxpritne* mot aa.essec.; @apduecas MpeSprls pbi asrc casOjtPritneipeet Sraial,Rmt { ulc btat ls beoesset mlmns eilzbe eoe piaeLn i; rvt og d @d I @euneeeao(ae"ePso" SqecGnrtrnm=sqesa) @eeaeVlegnrtr"ePso" Gnrtdau(eeao=sqesa) @ounnlal =fle uiu =tu) Clm(ulbe as, nqe re pbi Ln gtd){ ulc og eI( rtr ti.d eun hsi; } pbi vi stdLn i){ ulc od eI(og d ti.d=i; hsi d } @vrie Oerd pbi boeneul(betoj { ulc ola qasOjc b) i (b isaco OjtPritne { f oj ntnef beoesset) OjtPritneo=(beoesset)oj beoesset OjtPritne b; i (hsi ! nl & ti.d= oi){ f ti.d = ul & hsi = .d rtr tu; eun re } } rtr fle eun as; } }
  • 37. <xlvrin"."ecdn=UF8? ?m eso=10 noig"T-"> asn .u. <essec vrin"."xls"tp/jv.u.o/m/spritne xlsxi"tp/www.r/01XLceaisac" pritne eso=20 mn=ht:/aasncmxln/essec" mn:s=ht:/w.3og20/MShm-ntne xishmLcto=ht:/aasncmxln/essec ht:/aasncmxln/essec/essec__.s" s:ceaoain"tp/jv.u.o/m/spritne tp/jv.u.o/m/spritnepritne20xd> <essec-ntnm=JA tascintp=RSUC_OA" pritneui ae"P" rnato-ye"EORELCL> <rvdroghbraeebHbraeessec<poie> poie>r.ient.j.ientPritne/rvdr <rpris poete> <rprynm=hbraecneto.rvrcas vle"r.qieJB"> poet ae"ient.oncindie_ls" au=ogslt.DC/ <rprynm=hbraecneto.r"vle"dcslt:htm.b/ poet ae"ient.oncinul au=jb:qiecajsd"> <rprynm=hbraedaet vle"tlcdSLtDaet/ poet ae"ient.ilc" au=ui.g.Qieilc"> <rprynm=hbraeccepoie_ls"vle"r.ient.ah.oahPoie"> poet ae"ient.ah.rvdrcas au=oghbraecceNCcervdr/ <rprynm=hbraeso_q"vle"as"> poet ae"ient.hwsl au=fle/ <rprynm=hbraefra_q"vle"as"> poet ae"ient.omtsl au=fle/ <-poet nm=hbraehmdlat"vle"rae/- !-rpry ae"ient.b2d.uo au=cet"-> <poete> /rpris <pritneui> /essec-nt <pritne /essec>