MonitoraggioRisorse.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */


  20. package org.openspcoop2.pdd.core.jmx;

  21. import java.util.ArrayList;
  22. import java.util.Iterator;
  23. import java.util.List;
  24. import java.util.Map;

  25. import javax.management.Attribute;
  26. import javax.management.AttributeList;
  27. import javax.management.AttributeNotFoundException;
  28. import javax.management.DynamicMBean;
  29. import javax.management.InvalidAttributeValueException;
  30. import javax.management.JMException;
  31. import javax.management.MBeanAttributeInfo;
  32. import javax.management.MBeanConstructorInfo;
  33. import javax.management.MBeanException;
  34. import javax.management.MBeanInfo;
  35. import javax.management.MBeanOperationInfo;
  36. import javax.management.MBeanParameterInfo;
  37. import javax.management.NotificationBroadcasterSupport;
  38. import javax.management.ReflectionException;

  39. import org.openspcoop2.pdd.config.DBConsegneMessageBoxManager;
  40. import org.openspcoop2.pdd.config.DBConsegnePreseInCaricoManager;
  41. import org.openspcoop2.pdd.config.DBManager;
  42. import org.openspcoop2.pdd.config.DBStatisticheManager;
  43. import org.openspcoop2.pdd.config.DBTransazioniManager;
  44. import org.openspcoop2.pdd.config.OpenSPCoop2Properties;
  45. import org.openspcoop2.pdd.config.QueueManager;
  46. import org.openspcoop2.pdd.core.connettori.IConnettore;
  47. import org.openspcoop2.pdd.core.connettori.RepositoryConnettori;
  48. import org.openspcoop2.pdd.core.transazioni.Transaction;
  49. import org.openspcoop2.pdd.core.transazioni.TransactionContext;
  50. import org.openspcoop2.pdd.core.transazioni.TransactionNotExistsException;
  51. import org.openspcoop2.pdd.logger.Dump;
  52. import org.openspcoop2.pdd.logger.MsgDiagnostico;
  53. import org.openspcoop2.pdd.logger.OpenSPCoop2Logger;
  54. import org.openspcoop2.pdd.logger.Tracciamento;
  55. import org.openspcoop2.pdd.monitor.StatoPdd;
  56. import org.openspcoop2.pdd.monitor.driver.DriverMonitoraggio;
  57. import org.openspcoop2.pdd.monitor.driver.FilterSearch;
  58. import org.openspcoop2.pdd.timers.TimerMonitoraggioRisorseThread;
  59. import org.openspcoop2.pdd.timers.TimerThresholdThread;
  60. import org.openspcoop2.utils.Utilities;
  61. import org.openspcoop2.utils.cache.Cache;
  62. import org.openspcoop2.utils.date.DateManager;
  63. import org.slf4j.Logger;




  64. /**
  65.  * Implementazione JMX per la gestione delle risorse
  66.  *  
  67.  * @author Poli Andrea (apoli@link.it)
  68.  * @author $Author$
  69.  * @version $Rev$, $Date$
  70.  */
  71. public class MonitoraggioRisorse extends NotificationBroadcasterSupport implements DynamicMBean {

  72.     /** Nomi attributi */
  73.     public static final String NUMERO_MSG_IN_CONSEGNA = "numMsgInConsegna";
  74.     public static final String TEMPO_MEDIO_ATTESA_IN_CONSEGNA = "tempoMedioAttesaInConsegna";
  75.     public static final String TEMPO_MAX_ATTESA_IN_CONSEGNA = "tempoMaxAttesaInConsegna";
  76.     public static final String NUMERO_MSG_IN_SPEDIZIONE = "numMsgInSpedizione";
  77.     public static final String TEMPO_MEDIO_ATTESA_IN_SPEDIZIONE = "tempoMedioAttesaInSpedizione";
  78.     public static final String TEMPO_MAX_ATTESA_IN_SPEDIZIONE = "tempoMaxAttesaInSpedizione";
  79.     public static final String NUMERO_MSG_IN_PROCESSAMENTO = "numMsgInProcessamento";
  80.     public static final String TEMPO_MEDIO_ATTESA_IN_PROCESSAMENTO = "tempoMedioAttesaInProcessamento";
  81.     public static final String TEMPO_MAX_ATTESA_IN_PROCESSAMENTO = "tempoMaxAttesaInProcessamento";
  82.     public static final String NUMERO_MSG_TOTALI = "totMessaggi";
  83.     public static final String TEMPO_MEDIO_ATTESA_MSG_TOTALI = "tempoMedioAttesa";
  84.     public static final String TEMPO_MAX_ATTESA_MSG_TOTALI = "tempoMaxAttesa";
  85.     public static final String TOT_MSG_DUPLICATI = "totMessaggiDuplicati";
  86.     public static final String STATO_DATI_MONITORAGGIO = "statoDatiMonitoraggioPdD";
  87.     public static final String RISORSE_DI_SISTEMA = "risorseDiSistema";
  88.    
  89.     /** Nomi metodi */
  90.     public static final String GET_STATO_RISORSE_DI_SISTEMA = "getStatoRisorseSistema";
  91.     public static final String GET_STATO_RISORSE_DI_SISTEMA_METHOD2 = "listStatoRisorseSistema"; // per farlo comparire in jmx-console
  92.     public static final String GET_STATO_CACHES = "getStatoCache";
  93.     public static final String GET_STATO_CACHES_METHOD2 = "listStatoCache"; // per farlo comparire in jmx-console
  94.     public static final String CONNESSIONI_ALLOCATE_DB_MANAGER = "getUsedDBConnections";
  95.     public static final String CONNESSIONI_ALLOCATE_DB_MANAGER_METHOD2 = "listUsedDBConnections"; // per farlo comparire in jmx-console
  96.     public static final String CONNESSIONI_ALLOCATE_QUEUE_MANAGER = "getUsedQueueConnections";
  97.     public static final String CONNESSIONI_ALLOCATE_QUEUE_MANAGER_METHOD2 = "listUsedQueueConnections"; // per farlo comparire in jmx-console
  98.     public static final String TRANSAZIONI_ATTIVE_ID = "getActiveTransactions";
  99.     public static final String TRANSAZIONI_ATTIVE_ID_METHOD2 = "listActiveTransactions"; // per farlo comparire in jmx-console
  100.     public static final String TRANSAZIONI_ATTIVE_ID_PROTOCOLLO = "getActiveProtocolIds";
  101.     public static final String TRANSAZIONI_ATTIVE_ID_PROTOCOLLO_METHOD2 = "listActiveProtocolIds"; // per farlo comparire in jmx-console
  102.     public static final String GET_DETTAGLIO_TRANSAZIONE_ATTIVA = "getActiveTransactionDetails";
  103.     public static final String CONNESSIONI_ALLOCATE_CONNETTORI_PD = "getActivePDConnections";
  104.     public static final String CONNESSIONI_ALLOCATE_CONNETTORI_PD_METHOD2 = "listActivePDConnections"; // per farlo comparire in jmx-console
  105.     public static final String CONNESSIONI_ALLOCATE_CONNETTORI_PA = "getActivePAConnections";
  106.     public static final String CONNESSIONI_ALLOCATE_CONNETTORI_PA_METHOD2 = "listActivePAConnections"; // per farlo comparire in jmx-console
  107.    
  108.    
  109.    
  110.     /** Attributi */
  111.     // Messaggi in consegna
  112.     private long numMsgInConsegna = 0;
  113.     // Secondi
  114.     private String tempoMedioAttesaInConsegna = "";
  115.     private String tempoMaxAttesaInConsegna = "";  
  116.     //  Messaggi in spedizione
  117.     private long numMsgInSpedizione = 0;
  118.     //  Secondi
  119.     private String tempoMedioAttesaInSpedizione = "";
  120.     private String tempoMaxAttesaInSpedizione = "";
  121.     //  Messaggi in processamento
  122.     private long numMsgInProcessamento=0;
  123.     //  Secondi
  124.     private String tempoMedioAttesaInProcessamento = "";
  125.     private String tempoMaxAttesaInProcessamento = "";
  126.     // Messaggi totali
  127.     private long totMessaggi=0;
  128.     // Secondi
  129.     private String tempoMedioAttesa = "";
  130.     private String tempoMaxAttesa = "";
  131.     // Messaggi duplicati
  132.     private long totMessaggiDuplicati=0;
  133.    
  134.     //  Risorse di sistema non disponibili o disponibili ad un livello critico
  135.     private String risorseDiSistema ="Lettura dati non effettuata         ";
  136.    
  137.     // Stato dati MonitoraggioPdD
  138.     private String datiMonitoraggioPdD = "Non disponibili";
  139.    
  140.     /** getAttribute */
  141.     @Override
  142.     public Object getAttribute(String attributeName) throws AttributeNotFoundException,MBeanException,ReflectionException{
  143.        
  144.         if( (attributeName==null) || (attributeName.equals("")) )
  145.             throw new IllegalArgumentException("Il nome dell'attributo e' nullo o vuoto");
  146.        
  147.         if(attributeName.equals(MonitoraggioRisorse.NUMERO_MSG_IN_CONSEGNA))
  148.             return this.numMsgInConsegna;
  149.        
  150.         if(attributeName.equals(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_IN_CONSEGNA))
  151.             return this.tempoMedioAttesaInConsegna;
  152.        
  153.         if(attributeName.equals(MonitoraggioRisorse.TEMPO_MAX_ATTESA_IN_CONSEGNA))
  154.             return this.tempoMaxAttesaInConsegna;
  155.        
  156.         if(attributeName.equals(MonitoraggioRisorse.NUMERO_MSG_IN_SPEDIZIONE))
  157.             return this.numMsgInSpedizione;
  158.        
  159.         if(attributeName.equals(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_IN_SPEDIZIONE))
  160.             return this.tempoMedioAttesaInSpedizione;
  161.        
  162.         if(attributeName.equals(MonitoraggioRisorse.TEMPO_MAX_ATTESA_IN_SPEDIZIONE))
  163.             return this.tempoMaxAttesaInSpedizione;
  164.        
  165.         if(attributeName.equals(MonitoraggioRisorse.NUMERO_MSG_IN_PROCESSAMENTO))
  166.             return this.numMsgInProcessamento;
  167.        
  168.         if(attributeName.equals(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_IN_PROCESSAMENTO))
  169.             return this.tempoMedioAttesaInProcessamento;
  170.        
  171.         if(attributeName.equals(MonitoraggioRisorse.TEMPO_MAX_ATTESA_IN_PROCESSAMENTO))
  172.             return this.tempoMaxAttesaInProcessamento;
  173.        
  174.         if(attributeName.equals(MonitoraggioRisorse.NUMERO_MSG_TOTALI))
  175.             return this.totMessaggi;
  176.        
  177.         if(attributeName.equals(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_MSG_TOTALI))
  178.             return this.tempoMedioAttesa;
  179.        
  180.         if(attributeName.equals(MonitoraggioRisorse.TEMPO_MAX_ATTESA_MSG_TOTALI))
  181.             return this.tempoMaxAttesa;
  182.        
  183.         if(attributeName.equals(MonitoraggioRisorse.TOT_MSG_DUPLICATI))
  184.             return this.totMessaggiDuplicati;
  185.        
  186.         if(attributeName.equals(MonitoraggioRisorse.RISORSE_DI_SISTEMA))
  187.             return this.risorseDiSistema;
  188.        
  189.         if(attributeName.equals(MonitoraggioRisorse.STATO_DATI_MONITORAGGIO))
  190.             return this.datiMonitoraggioPdD;
  191.        
  192.         throw new AttributeNotFoundException("Attributo "+attributeName+" non trovato");
  193.     }
  194.    
  195.     /** getAttributes */
  196.     @Override
  197.     public AttributeList getAttributes(String [] attributesNames){
  198.        
  199.         if(attributesNames==null)
  200.             throw new IllegalArgumentException("Array nullo");
  201.        
  202.         AttributeList list = new AttributeList();
  203.         for (int i=0; i<attributesNames.length; i++){
  204.             try{
  205.                 list.add(new Attribute(attributesNames[i],getAttribute(attributesNames[i])));
  206.             }catch(JMException ex){}
  207.         }
  208.         return list;
  209.     }
  210.    
  211.     /** setAttribute */
  212.     @Override
  213.     public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException{
  214.        
  215.         if( attribute==null )
  216.             throw new IllegalArgumentException("Il nome dell'attributo e' nullo");
  217.        
  218.         try{
  219.            
  220.             if(attribute.getName().equals(MonitoraggioRisorse.NUMERO_MSG_IN_CONSEGNA))
  221.                 this.numMsgInConsegna = (Long) attribute.getValue();
  222.            
  223.             else if(attribute.getName().equals(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_IN_CONSEGNA))
  224.                 this.tempoMedioAttesaInConsegna = (String) attribute.getValue();
  225.            
  226.             else if(attribute.getName().equals(MonitoraggioRisorse.TEMPO_MAX_ATTESA_IN_CONSEGNA))
  227.                 this.tempoMaxAttesaInConsegna = (String) attribute.getValue();
  228.            
  229.             else if(attribute.getName().equals(MonitoraggioRisorse.NUMERO_MSG_IN_SPEDIZIONE))
  230.                 this.numMsgInSpedizione = (Long) attribute.getValue();
  231.            
  232.             else if(attribute.getName().equals(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_IN_SPEDIZIONE))
  233.                 this.tempoMedioAttesaInSpedizione = (String) attribute.getValue();
  234.            
  235.             else if(attribute.getName().equals(MonitoraggioRisorse.TEMPO_MAX_ATTESA_IN_SPEDIZIONE))
  236.                 this.tempoMaxAttesaInSpedizione = (String) attribute.getValue();
  237.            
  238.             else if(attribute.getName().equals(MonitoraggioRisorse.NUMERO_MSG_IN_PROCESSAMENTO))
  239.                 this.numMsgInProcessamento = (Long) attribute.getValue();
  240.            
  241.             else if(attribute.getName().equals(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_IN_PROCESSAMENTO))
  242.                 this.tempoMedioAttesaInProcessamento = (String) attribute.getValue();
  243.            
  244.             else if(attribute.getName().equals(MonitoraggioRisorse.TEMPO_MAX_ATTESA_IN_PROCESSAMENTO))
  245.                 this.tempoMaxAttesaInProcessamento = (String) attribute.getValue();
  246.            
  247.             else if(attribute.getName().equals(MonitoraggioRisorse.NUMERO_MSG_TOTALI))
  248.                 this.totMessaggi = (Long) attribute.getValue();
  249.            
  250.             else if(attribute.getName().equals(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_MSG_TOTALI))
  251.                 this.tempoMedioAttesa = (String) attribute.getValue();
  252.            
  253.             else if(attribute.getName().equals(MonitoraggioRisorse.TEMPO_MAX_ATTESA_MSG_TOTALI))
  254.                 this.tempoMaxAttesa = (String) attribute.getValue();
  255.            
  256.             else if(attribute.getName().equals(MonitoraggioRisorse.TOT_MSG_DUPLICATI))
  257.                 this.totMessaggiDuplicati = (Long) attribute.getValue();
  258.            
  259.             else if(attribute.getName().equals(MonitoraggioRisorse.RISORSE_DI_SISTEMA))
  260.                 this.risorseDiSistema = (String) attribute.getValue();
  261.            
  262.             else if(attribute.getName().equals(MonitoraggioRisorse.STATO_DATI_MONITORAGGIO))
  263.                 this.refreshDatiMonitoraggioPdD();
  264.            
  265.             else
  266.                 throw new AttributeNotFoundException("Attributo "+attribute.getName()+" non trovato");
  267.            
  268.         }catch(ClassCastException ce){
  269.             throw new InvalidAttributeValueException("il tipo "+attribute.getValue().getClass()+" dell'attributo "+attribute.getName()+" non e' valido");
  270.         }catch(JMException j){
  271.             throw new MBeanException(j);
  272.         }
  273.        
  274.     }
  275.    
  276.     /** setAttributes */
  277.     @Override
  278.     public AttributeList setAttributes(AttributeList list){
  279.        
  280.         if(list==null)
  281.             throw new IllegalArgumentException("Lista degli attributi e' nulla");
  282.        
  283.         AttributeList ret = new AttributeList();
  284.         Iterator<?> it = ret.iterator();
  285.        
  286.         while(it.hasNext()){
  287.             try{
  288.                 Attribute attribute = (Attribute) it.next();
  289.                 setAttribute(attribute);
  290.                 ret.add(attribute);
  291.             }catch(JMException ex){}
  292.         }
  293.        
  294.         return ret;
  295.        
  296.     }
  297.    
  298.     /** invoke */
  299.     @Override
  300.     public Object invoke(String actionName, Object[]params, String[]signature) throws MBeanException,ReflectionException{
  301.        
  302.         if( (actionName==null) || (actionName.equals("")) )
  303.             throw new IllegalArgumentException("Nessuna operazione definita");
  304.        
  305.         if(actionName.equals(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_DB_MANAGER) || actionName.equals(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_DB_MANAGER_METHOD2)){
  306.             return this.getUsedDBConnections();
  307.         }
  308.        
  309.         else if(actionName.equals(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_QUEUE_MANAGER) || actionName.equals(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_QUEUE_MANAGER_METHOD2)){
  310.             return this.getUsedQueueConnections();
  311.         }
  312.        
  313.         else if(actionName.equals(MonitoraggioRisorse.TRANSAZIONI_ATTIVE_ID) || actionName.equals(MonitoraggioRisorse.TRANSAZIONI_ATTIVE_ID_METHOD2)){
  314.             return this.getTransazioniAttiveId();
  315.         }
  316.        
  317.         else if(actionName.equals(MonitoraggioRisorse.GET_DETTAGLIO_TRANSAZIONE_ATTIVA)){
  318.            
  319.             if(params.length != 1)
  320.                 throw new MBeanException(new Exception("["+MonitoraggioRisorse.GET_DETTAGLIO_TRANSAZIONE_ATTIVA+"] Lunghezza parametri non corretta: "+params.length));
  321.            
  322.             String param1 = null;
  323.             if(params[0]!=null && !"".equals(params[0])){
  324.                 param1 = (String)params[0];
  325.             }
  326.            
  327.             return this.getDettaglioTransazioneAttivaId(param1);
  328.         }
  329.        
  330.         else if(actionName.equals(MonitoraggioRisorse.TRANSAZIONI_ATTIVE_ID_PROTOCOLLO) || actionName.equals(MonitoraggioRisorse.TRANSAZIONI_ATTIVE_ID_PROTOCOLLO_METHOD2)){
  331.             return this.getTransazioniAttiveIdProtocollo();
  332.         }
  333.        
  334.         else if(actionName.equals(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_CONNETTORI_PD) || actionName.equals(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_CONNETTORI_PD_METHOD2)){
  335.             return this.getActivePDConnections();
  336.         }
  337.        
  338.         else if(actionName.equals(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_CONNETTORI_PA) || actionName.equals(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_CONNETTORI_PA_METHOD2)){
  339.             return this.getActivePAConnections();
  340.         }
  341.        
  342.         else if(actionName.equals(MonitoraggioRisorse.GET_STATO_RISORSE_DI_SISTEMA) || actionName.equals(MonitoraggioRisorse.GET_STATO_RISORSE_DI_SISTEMA_METHOD2)){
  343.             this.refreshDatiMonitoraggioPdD();
  344.             return this.risorseDiSistema;
  345.         }
  346.        
  347.         else if(actionName.equals(MonitoraggioRisorse.GET_STATO_CACHES) || actionName.equals(MonitoraggioRisorse.GET_STATO_CACHES_METHOD2)){
  348.             return this.getStatoCaches();
  349.         }
  350.        
  351.         throw new UnsupportedOperationException("Operazione "+actionName+" sconosciuta");
  352.     }
  353.    
  354.     /* MBean info */
  355.     @Override
  356.     public MBeanInfo getMBeanInfo(){
  357.        
  358.         /*
  359.         if(OpenSPCoopStartup.initialize){
  360.             this.refresh();
  361.         }
  362.         */
  363.        
  364.         // Per determinare se l'attributo e' leggibile/scrivibile
  365.         final boolean READABLE = true;
  366.         final boolean WRITABLE = true;
  367.        
  368.         // Per determinare se l'attributo e' ricavabile nella forma booleana isAttribute()
  369.         final boolean IS_GETTER = true;
  370.        
  371.         // Descrizione della classe nel MBean
  372.         String className = this.getClass().getName();
  373.         String description = "Monitoraggio delle risorse utilizzate ("+OpenSPCoop2Properties.getInstance().getVersione()+"), premi pulsante (apply changes) per aggiornare i dati";

  374.         // MetaData per l'attributo numMsgInConsegna
  375.         MBeanAttributeInfo numMsgInConsegnaVAR
  376.             = new MBeanAttributeInfo(MonitoraggioRisorse.NUMERO_MSG_IN_CONSEGNA,long.class.getName(),
  377.                         "Numero di Messaggi in gestione nel modulo 'ConsegnaContenutiApplicativi'",
  378.                             READABLE,!WRITABLE,!IS_GETTER);
  379.        
  380.         // MetaData per l'attributo tempoMedioAttesaInConsegna
  381.         MBeanAttributeInfo tempoMedioAttesaInConsegnaVAR
  382.             = new MBeanAttributeInfo(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_IN_CONSEGNA,String.class.getName(),
  383.                         "Tempo medio di attesa dei Messaggi prima di essere stati consegnati ai servizi applicativi dal modulo 'ConsegnaContenutiApplicativi'",
  384.                             READABLE,!WRITABLE,!IS_GETTER);
  385.        
  386.         // MetaData per l'attributo tempoMaxAttesaInConsegna
  387.         MBeanAttributeInfo tempoMaxAttesaInConsegnaVAR
  388.             = new MBeanAttributeInfo(MonitoraggioRisorse.TEMPO_MAX_ATTESA_IN_CONSEGNA,String.class.getName(),
  389.                         "Tempo massimo di attesa dei Messaggi prima di essere stati consegnati ai servizi applicativi dal modulo 'ConsegnaContenutiApplicativi'",
  390.                             READABLE,!WRITABLE,!IS_GETTER);
  391.        
  392.         // MetaData per l'attributo numMsgInSpedizione
  393.         MBeanAttributeInfo numMsgInSpedizioneVAR
  394.             = new MBeanAttributeInfo(MonitoraggioRisorse.NUMERO_MSG_IN_SPEDIZIONE,long.class.getName(),
  395.                         "Numero di Messaggi in gestione nei moduli 'InoltroBuste'",
  396.                             READABLE,!WRITABLE,!IS_GETTER);
  397.        
  398.         // MetaData per l'attributo tempoMedioAttesaInSpedizione
  399.         MBeanAttributeInfo tempoMedioAttesaInSpedizioneVAR
  400.             = new MBeanAttributeInfo(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_IN_SPEDIZIONE,String.class.getName(),
  401.                         "Tempo medio di attesa dei Messaggi prima di essere stati inoltrate alle porte di dominio destinatarie dai moduli 'InoltroBuste'",
  402.                             READABLE,!WRITABLE,!IS_GETTER);
  403.        
  404.         // MetaData per l'attributo tempoMaxAttesaInSpedizione
  405.         MBeanAttributeInfo tempoMaxAttesaInSpedizioneVAR
  406.             = new MBeanAttributeInfo(MonitoraggioRisorse.TEMPO_MAX_ATTESA_IN_SPEDIZIONE,String.class.getName(),
  407.                         "Tempo massimo di attesa dei Messaggi prima di essere stati inoltrate alle porte di dominio destinatarie dai moduli 'InoltroBuste'",
  408.                             READABLE,!WRITABLE,!IS_GETTER);
  409.        
  410.         // MetaData per l'attributo numMsgInProcessamento
  411.         MBeanAttributeInfo numMsgInProcessamentoVAR
  412.             = new MBeanAttributeInfo(MonitoraggioRisorse.NUMERO_MSG_IN_PROCESSAMENTO,long.class.getName(),
  413.                         "Numero di Messaggi in gestione nei moduli interni all'infrastruttura della porta di dominio",
  414.                             READABLE,!WRITABLE,!IS_GETTER);
  415.        
  416.         // MetaData per l'attributo tempoMedioAttesaInProcessamento
  417.         MBeanAttributeInfo tempoMedioAttesaInProcessamentoVAR
  418.             = new MBeanAttributeInfo(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_IN_PROCESSAMENTO,String.class.getName(),
  419.                         "Tempo medio di attesa in gestione nei moduli interni all'infrastruttura della porta di dominio",
  420.                             READABLE,!WRITABLE,!IS_GETTER);
  421.        
  422.         // MetaData per l'attributo tempoMaxAttesaInProcessamento
  423.         MBeanAttributeInfo tempoMaxAttesaInProcessamentoVAR
  424.             = new MBeanAttributeInfo(MonitoraggioRisorse.TEMPO_MAX_ATTESA_IN_PROCESSAMENTO,String.class.getName(),
  425.                         "Tempo massimo di attesa in gestione nei moduli interni all'infrastruttura della porta di dominio",
  426.                             READABLE,!WRITABLE,!IS_GETTER);
  427.        
  428.         // MetaData per l'attributo totMessaggi
  429.         MBeanAttributeInfo totMessaggiVAR
  430.             = new MBeanAttributeInfo(MonitoraggioRisorse.NUMERO_MSG_TOTALI,long.class.getName(),
  431.                         "Numero di Messaggi totali in gestione nella porta di dominio",
  432.                             READABLE,!WRITABLE,!IS_GETTER);
  433.        
  434.         // MetaData per l'attributo tempoMedioAttesa
  435.         MBeanAttributeInfo tempoMedioAttesaVAR
  436.             = new MBeanAttributeInfo(MonitoraggioRisorse.TEMPO_MEDIO_ATTESA_MSG_TOTALI,String.class.getName(),
  437.                         "Tempo medio di attesa dei Messaggi gestiti nella porta di dominio",
  438.                             READABLE,!WRITABLE,!IS_GETTER);
  439.        
  440.         // MetaData per l'attributo tempoMaxAttesa
  441.         MBeanAttributeInfo tempoMaxAttesaVAR
  442.             = new MBeanAttributeInfo(MonitoraggioRisorse.TEMPO_MAX_ATTESA_MSG_TOTALI,String.class.getName(),
  443.                         "Tempo massimo di attesa dei Messaggi gestiti nella porta di dominio",
  444.                             READABLE,!WRITABLE,!IS_GETTER);
  445.        
  446.         // MetaData per l'attributo totMessaggiDuplicati
  447.         MBeanAttributeInfo totMessaggiDuplicatiVAR
  448.             = new MBeanAttributeInfo(MonitoraggioRisorse.TOT_MSG_DUPLICATI,long.class.getName(),
  449.                         "Numero di Messaggi duplicati gestiti nella porta di dominio",
  450.                             READABLE,!WRITABLE,!IS_GETTER);
  451.        
  452.         // MetaData per l'attributo risorseDisponibili
  453.         MBeanAttributeInfo risorseDisponibiliVAR
  454.             = new MBeanAttributeInfo(MonitoraggioRisorse.RISORSE_DI_SISTEMA,String.class.getName(),
  455.                         "Indicazione sullo stato delle risorse disponibili per la porta di dominio",
  456.                             READABLE,!WRITABLE,!IS_GETTER);
  457.        
  458.         // MetaData per l'attributo risorseDisponibili
  459.         MBeanAttributeInfo monitoraggioPdDVAR
  460.             = new MBeanAttributeInfo(MonitoraggioRisorse.STATO_DATI_MONITORAGGIO,String.class.getName(),
  461.                         "Monitoraggio della porta di dominio, premi pulsante (apply changes) per aggiornare i dati",
  462.                             READABLE,WRITABLE,!IS_GETTER);
  463.        
  464.         // MetaData per l'operazione
  465.         MBeanOperationInfo getConnessioneAllocateDBManagerOP
  466.             = new MBeanOperationInfo(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_DB_MANAGER,"Moduli funzionali che dispongono di una connessione verso il database dei messaggi",
  467.                     null,
  468.                     String.class.getName(),
  469.                     MBeanOperationInfo.ACTION);
  470.        
  471.         // MetaData per l'operazione
  472.         MBeanOperationInfo getConnessioneAllocateDBManagerOP_method2
  473.             = new MBeanOperationInfo(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_DB_MANAGER_METHOD2,"Moduli funzionali che dispongono di una connessione verso il database dei messaggi",
  474.                     null,
  475.                     String.class.getName(),
  476.                     MBeanOperationInfo.ACTION);
  477.        
  478.         // MetaData per l'operazione
  479.         MBeanOperationInfo getConnessioneAllocateQueueManagerOP
  480.             = new MBeanOperationInfo(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_QUEUE_MANAGER,"Moduli funzionali che dispongono di una connessione verso il Broker JMS",
  481.                     null,
  482.                     String.class.getName(),
  483.                     MBeanOperationInfo.ACTION);
  484.        
  485.         // MetaData per l'operazione
  486.         MBeanOperationInfo getConnessioneAllocateQueueManagerOP_method2
  487.             = new MBeanOperationInfo(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_QUEUE_MANAGER_METHOD2,"Moduli funzionali che dispongono di una connessione verso il Broker JMS",
  488.                     null,
  489.                     String.class.getName(),
  490.                     MBeanOperationInfo.ACTION);
  491.        
  492.         // MetaData per l'operazione
  493.         MBeanOperationInfo getTransazioniAttiveOP
  494.         = new MBeanOperationInfo(TRANSAZIONI_ATTIVE_ID,"Transazioni attive",
  495.             null,
  496.             String.class.getName(),
  497.             MBeanOperationInfo.ACTION);
  498.        
  499.         // MetaData per l'operazione
  500.         MBeanOperationInfo getTransazioniAttiveOP_method2
  501.         = new MBeanOperationInfo(TRANSAZIONI_ATTIVE_ID_METHOD2,"Transazioni attive",
  502.             null,
  503.             String.class.getName(),
  504.             MBeanOperationInfo.ACTION);
  505.        
  506.         // MetaData per l'operazione
  507.         MBeanOperationInfo getDettaglioTransazioneAttiva
  508.         = new MBeanOperationInfo(GET_DETTAGLIO_TRANSAZIONE_ATTIVA,"Recupera i dettagli della transazione con id fornito come parametro",
  509.             new MBeanParameterInfo[]{
  510.                 new MBeanParameterInfo("idTransazione",String.class.getName(),"Identificativo della transazione"),
  511.             },
  512.             String.class.getName(),
  513.             MBeanOperationInfo.ACTION);
  514.        
  515.         // MetaData per l'operazione
  516.         MBeanOperationInfo getTransazioniIdProtocolloAttiviOP
  517.             = new MBeanOperationInfo(MonitoraggioRisorse.TRANSAZIONI_ATTIVE_ID_PROTOCOLLO,"Identificativi di Protocollo attivi sulla Porta",
  518.                     null,
  519.                     String.class.getName(),
  520.                     MBeanOperationInfo.ACTION);
  521.        
  522.         // MetaData per l'operazione
  523.         MBeanOperationInfo getTransazioniIdProtocolloAttiviOP_method2  
  524.             = new MBeanOperationInfo(MonitoraggioRisorse.TRANSAZIONI_ATTIVE_ID_PROTOCOLLO_METHOD2,"Identificativi di Protocollo attivi sulla Porta",
  525.                     null,
  526.                     String.class.getName(),
  527.                     MBeanOperationInfo.ACTION);
  528.                
  529.         // MetaData per l'operazione
  530.         MBeanOperationInfo getActiveConnectionsPD_OP
  531.             = new MBeanOperationInfo(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_CONNETTORI_PD,"Connessioni attive su cui e' in corso un inoltro di busta (PortaDelegata)",
  532.                     null,
  533.                     String.class.getName(),
  534.                     MBeanOperationInfo.ACTION);
  535.        
  536.         // MetaData per l'operazione
  537.         MBeanOperationInfo getActiveConnectionsPD_OP_method2  
  538.             = new MBeanOperationInfo(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_CONNETTORI_PD_METHOD2,"Connessioni attive su cui e' in corso un inoltro di busta (PortaDelegata)",
  539.                     null,
  540.                     String.class.getName(),
  541.                     MBeanOperationInfo.ACTION);
  542.        
  543.         // MetaData per l'operazione
  544.         MBeanOperationInfo getActiveConnectionsPA_OP
  545.             = new MBeanOperationInfo(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_CONNETTORI_PA,"Connessioni attive su cui e' in corso una consegna di contenuti applicativi (PortaApplicativa)",
  546.                     null,
  547.                     String.class.getName(),
  548.                     MBeanOperationInfo.ACTION);
  549.        
  550.         // MetaData per l'operazione
  551.         MBeanOperationInfo getActiveConnectionsPA_OP_method2    
  552.             = new MBeanOperationInfo(MonitoraggioRisorse.CONNESSIONI_ALLOCATE_CONNETTORI_PA_METHOD2,"Connessioni attive su cui e' in corso una consegna di contenuti applicativi (PortaApplicativa)",
  553.                     null,
  554.                     String.class.getName(),
  555.                     MBeanOperationInfo.ACTION);
  556.        
  557.         // MetaData per l'operazione
  558.         MBeanOperationInfo getRisorseSistema_OP
  559.             = new MBeanOperationInfo(MonitoraggioRisorse.GET_STATO_RISORSE_DI_SISTEMA,"Ritorna lo stato delle risorse di sistema",
  560.                     null,
  561.                     String.class.getName(),
  562.                     MBeanOperationInfo.ACTION);
  563.        
  564.         // MetaData per l'operazione
  565.         MBeanOperationInfo getRisorseSistema_OP_method2  
  566.             = new MBeanOperationInfo(MonitoraggioRisorse.GET_STATO_RISORSE_DI_SISTEMA_METHOD2,"Ritorna lo stato delle risorse di sistema",
  567.                     null,
  568.                     String.class.getName(),
  569.                     MBeanOperationInfo.ACTION);
  570.        
  571.         // MetaData per l'operazione
  572.         MBeanOperationInfo getRisorseCache_OP
  573.             = new MBeanOperationInfo(MonitoraggioRisorse.GET_STATO_CACHES,"Ritorna lo stato delle cache utilizzate dalla Porta",
  574.                     null,
  575.                     String.class.getName(),
  576.                     MBeanOperationInfo.ACTION);
  577.        
  578.         // MetaData per l'operazione
  579.         MBeanOperationInfo getRisorseCache_OP_method2  
  580.             = new MBeanOperationInfo(MonitoraggioRisorse.GET_STATO_CACHES_METHOD2,"Ritorna lo stato delle cache utilizzate dalla Porta",
  581.                     null,
  582.                     String.class.getName(),
  583.                     MBeanOperationInfo.ACTION);
  584.        
  585.         // Mbean costruttore
  586.         MBeanConstructorInfo defaultConstructor = new MBeanConstructorInfo("Default Constructor","Crea e inizializza una nuova istanza del MBean",null);

  587.         // Lista attributi
  588.         MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[]{monitoraggioPdDVAR,risorseDisponibiliVAR,
  589.                 numMsgInConsegnaVAR,tempoMedioAttesaInConsegnaVAR,tempoMaxAttesaInConsegnaVAR,
  590.                 numMsgInSpedizioneVAR,tempoMedioAttesaInSpedizioneVAR,tempoMaxAttesaInSpedizioneVAR,
  591.                 numMsgInProcessamentoVAR,tempoMedioAttesaInProcessamentoVAR,tempoMaxAttesaInProcessamentoVAR,
  592.                 totMessaggiVAR,tempoMedioAttesaVAR,tempoMaxAttesaVAR,totMessaggiDuplicatiVAR};
  593.        
  594.         // Lista Costruttori
  595.         MBeanConstructorInfo[] constructors = new MBeanConstructorInfo[]{defaultConstructor};
  596.        
  597.         // Lista operazioni
  598.         MBeanOperationInfo[] operations = new MBeanOperationInfo[]{getRisorseSistema_OP,getRisorseSistema_OP_method2,getRisorseCache_OP,getRisorseCache_OP_method2,
  599.                 getConnessioneAllocateDBManagerOP,getConnessioneAllocateDBManagerOP_method2,getConnessioneAllocateQueueManagerOP,getConnessioneAllocateQueueManagerOP_method2,
  600.                 getTransazioniAttiveOP,getTransazioniAttiveOP_method2, getDettaglioTransazioneAttiva, getTransazioniIdProtocolloAttiviOP,getTransazioniIdProtocolloAttiviOP_method2,
  601.                 getActiveConnectionsPD_OP,getActiveConnectionsPD_OP_method2,getActiveConnectionsPA_OP,getActiveConnectionsPA_OP_method2};
  602.        
  603.         return new MBeanInfo(className,description,attributes,constructors,operations,null);
  604.     }
  605.    
  606.    
  607.     /* Variabili per la gestione JMX */
  608.     private Logger log;

  609.     /* Costruttore */
  610.     public MonitoraggioRisorse(){
  611.         this.log = OpenSPCoop2Logger.getLoggerOpenSPCoopCore();
  612.     }
  613.    
  614.     public static final String MESSAGGIO_RISORSE_ADEGUATE = "GovWay possiede le adeguate risorse di sistema";
  615.    
  616.     public void refreshDatiMonitoraggioPdD(){

  617.         StringBuilder bf = new StringBuilder();
  618.         if( !TimerMonitoraggioRisorseThread.isRisorseDisponibili()){
  619.             bf.append("Risorse di sistema non disponibili: "+TimerMonitoraggioRisorseThread.getRisorsaNonDisponibile().getMessage());
  620.         }
  621.         if( !TimerThresholdThread.freeSpace){
  622.             if(bf.length()>0){
  623.                 bf.append("\n");
  624.             }
  625.             bf.append("[ThresholdCheck] Non sono disponibili abbastanza risorse per la gestione delle richieste");
  626.         }
  627.         if( !Tracciamento.tracciamentoDisponibile){
  628.             if(bf.length()>0){
  629.                 bf.append("\n");
  630.             }
  631.             bf.append("Tracciamento non disponibile: "+Tracciamento.motivoMalfunzionamentoTracciamento.getMessage());
  632.         }
  633.         if( !MsgDiagnostico.gestoreDiagnosticaDisponibile){
  634.             if(bf.length()>0){
  635.                 bf.append("\n");
  636.             }
  637.             bf.append("Sistema di diagnostica non disponibile: "+MsgDiagnostico.motivoMalfunzionamentoDiagnostici.getMessage());
  638.         }
  639.         if( !Dump.isSistemaDumpDisponibile()){
  640.             if(bf.length()>0){
  641.                 bf.append("\n");
  642.             }
  643.             bf.append("Sistema di dump dei contenuti applicativi non disponibile: "+Dump.getMotivoMalfunzionamentoDump().getMessage());
  644.         }
  645.         if(bf.length()==0){
  646.             bf.append(MonitoraggioRisorse.MESSAGGIO_RISORSE_ADEGUATE);
  647.         }
  648.         this.risorseDiSistema = bf.toString();
  649.        
  650.         try{
  651.             OpenSPCoop2Properties properties = OpenSPCoop2Properties.getInstance();
  652.             if(properties.getDatabaseType()!=null){
  653.                 DriverMonitoraggio driver = new DriverMonitoraggio(properties.getJNDIName_DataSource(),
  654.                         properties.getDatabaseType(),properties.getJNDIContext_DataSource(),this.log);
  655.                 StatoPdd stato = driver.getStatoRichiestePendenti(new FilterSearch());
  656.                 this.numMsgInConsegna = stato.getNumMsgInConsegna();
  657.                 this.numMsgInSpedizione = stato.getNumMsgInSpedizione();
  658.                 this.numMsgInProcessamento = stato.getNumMsgInProcessamento();
  659.                 this.totMessaggi = stato.getTotMessaggi();
  660.                 this.totMessaggiDuplicati = stato.getTotMessaggiDuplicati();
  661.                 if(stato.getTempoMaxAttesa()>0)
  662.                     this.tempoMaxAttesa = Utilities.convertSystemTimeIntoStringMillisecondi(stato.getTempoMaxAttesa()*1000, false);
  663.                 if(stato.getTempoMaxAttesaInConsegna()>0)
  664.                     this.tempoMaxAttesaInConsegna = Utilities.convertSystemTimeIntoStringMillisecondi(stato.getTempoMaxAttesaInConsegna()*1000, false);
  665.                 if(stato.getTempoMaxAttesaInSpedizione()>0)
  666.                     this.tempoMaxAttesaInSpedizione = Utilities.convertSystemTimeIntoStringMillisecondi(stato.getTempoMaxAttesaInSpedizione()*1000, false);
  667.                 if(stato.getTempoMaxAttesaInProcessamento()>0)
  668.                     this.tempoMaxAttesaInProcessamento = Utilities.convertSystemTimeIntoStringMillisecondi(stato.getTempoMaxAttesaInProcessamento()*1000, false);
  669.                 if(stato.getTempoMedioAttesa()>0)
  670.                     this.tempoMedioAttesa = Utilities.convertSystemTimeIntoStringMillisecondi(stato.getTempoMedioAttesa()*1000, false);
  671.                 if(stato.getTempoMedioAttesaInConsegna()>0)
  672.                     this.tempoMedioAttesaInConsegna = Utilities.convertSystemTimeIntoStringMillisecondi(stato.getTempoMedioAttesaInConsegna()*1000, false);
  673.                 if(stato.getTempoMedioAttesaInSpedizione()>0)
  674.                     this.tempoMedioAttesaInSpedizione = Utilities.convertSystemTimeIntoStringMillisecondi(stato.getTempoMedioAttesaInSpedizione()*1000, false);
  675.                 if(stato.getTempoMedioAttesaInProcessamento()>0)
  676.                     this.tempoMedioAttesaInProcessamento = Utilities.convertSystemTimeIntoStringMillisecondi(stato.getTempoMedioAttesaInProcessamento()*1000, false);
  677.            
  678.                 this.datiMonitoraggioPdD = "Aggiornati al "+DateManager.getDate().toString();
  679.             }else{
  680.                 this.datiMonitoraggioPdD = "Non disponibili: e' necessario indicare il tipo di database in govway.properties";
  681.                 throw new Exception("Per il monitoraggio della porta di dominio e' necessario indicare il tipo di database in govway.properties");
  682.             }
  683.         }catch(Throwable e){
  684.             this.log.error("DriverMonitoraggio non inizializzato",e);
  685.             this.datiMonitoraggioPdD = "Non disponibili: "+e.getMessage();
  686.         }
  687.            
  688.    
  689.     }
  690.    
  691.     /* Metodi di management JMX */
  692.    
  693.     public String getStatoCaches(){
  694.         try{
  695.             return Cache.printStatistics("\n","\n-----------------------------------------------------\n");
  696.         }catch(Throwable e){
  697.             this.log.error(e.getMessage(),e);
  698.             return JMXUtils.MSG_OPERAZIONE_NON_EFFETTUATA+e.getMessage();
  699.         }
  700.     }
  701.    
  702.     public static final String MSG_NESSUNA_CONNESSIONE_ALLOCATA = "Nessuna connessione allocata";
  703.     public static final String MSG_CONNESSIONI_ALLOCATE = " risorse allocate: ";
  704.     public static final String MSG_CONNESSIONI_ALLOCATE_TRANSAZIONI = " risorse allocate per la gestione delle transazioni: ";
  705.     public static final String MSG_CONNESSIONI_ALLOCATE_STATISTICHE = " risorse allocate per la generazione delle statistiche: ";
  706.     public static final String MSG_CONNESSIONI_ALLOCATE_CONSEGNE_PRESE_IN_CARICO_SMISTATORE = " risorse allocate per lo smistatore dei messaggi presi in carico: ";
  707.     public static final String MSG_CONNESSIONI_ALLOCATE_CONSEGNE_PRESE_IN_CARICO_RUNTIME = " risorse allocate per il gestore runtime dei messaggi presi in carico: ";
  708.     public static final String MSG_CONNESSIONI_ALLOCATE_CONSEGNE_PRESE_IN_CARICO_TRANSAZIONI = " risorse allocate per il gestore delle tracce relative ai messaggi presi in carico: ";
  709.     public static final String MSG_CONNESSIONI_ALLOCATE_CONSEGNE_MESSAGE_BOX_RUNTIME = " risorse allocate per il gestore runtime del servizio MessageBox: ";
  710.     public static final String MSG_CONNESSIONI_ALLOCATE_CONSEGNE_MESSAGE_BOX_TRANSAZIONI = " risorse allocate per il gestore delle tracce del servizio MessageBox: ";
  711.     public static final String MSG_CONNESSIONI_HTTP_ALLOCATE = " connessioni allocate: ";
  712.    
  713.     public static final String MSG_NESSUNA_TRANSAZIONE_ATTIVA = "Nessuna transazione attiva";
  714.     public static final String MSG_TRANSAZIONI_ATTIVE = " transazioni attive: ";
  715.     public static final String MSG_TRANSAZIONI_ATTIVE_ID_PROTOCOLLO = " id di protocollo attivi: ";
  716.    
  717.     public String getUsedDBConnections(){
  718.         String[] risorse = null;
  719.         String[] risorseTransaction = null;
  720.         String[] risorseStatistiche = null;
  721.         String[] risorseConsegnePreseInCaricoSmistatore = null;
  722.         String[] risorseConsegnePreseInCaricoRuntime = null;
  723.         String[] risorseConsegnePreseInCaricoTransazioni = null;
  724.         String[] risorseConsegneMessageBoxRuntime = null;
  725.         String[] risorseConsegneMessageBoxTransazioni = null;
  726.         try{
  727.             risorse = DBManager.getStatoRisorse();
  728.            
  729.             OpenSPCoop2Properties prop = OpenSPCoop2Properties.getInstance();
  730.            
  731.             boolean useRuntimePdDTransazioni = DBTransazioniManager.getInstance().useRuntimePdD();
  732.             if(!useRuntimePdDTransazioni) {
  733.                 if(!prop.isTransazioniDatasourceUseDBUtils()) {
  734.                     // le aggiungo altrimenti non c'è altro modo per vederle
  735.                     risorseTransaction = DBTransazioniManager.getStatoRisorse();
  736.                 }
  737.             }
  738.            
  739.             if(prop.isStatisticheGenerazioneEnabled()) {
  740.                 boolean useRuntimePdDStatistiche = DBStatisticheManager.getInstance().useRuntimePdD();
  741.                 boolean useTransazioniStatistiche = DBStatisticheManager.getInstance().useTransazioni();
  742.                 if(!useRuntimePdDStatistiche && !useTransazioniStatistiche) {
  743.                     if(!prop.isStatisticheDatasourceUseDBUtils()) {
  744.                         // le aggiungo altrimenti non c'è altro modo per vederle
  745.                         risorseStatistiche = DBStatisticheManager.getStatoRisorse();
  746.                     }
  747.                 }
  748.             }
  749.            
  750.             if(prop.isServerJ2EE()!=null && !prop.isServerJ2EE()){
  751.                 if(prop.isTimerConsegnaContenutiApplicativiAbilitato()){
  752.                     boolean useDefaultManager = DBConsegnePreseInCaricoManager.getInstanceSmistatore().useDefaultManager();
  753.                     if(!useDefaultManager) {
  754.                         if(!prop.isTimerConsegnaContenutiApplicativi_smistatore_runtime_dataSource_useDBUtils()) {
  755.                             // le aggiungo altrimenti non c'è altro modo per vederle
  756.                             risorseConsegnePreseInCaricoSmistatore = DBConsegnePreseInCaricoManager.getStatoRisorseSmistatore();
  757.                         }
  758.                     }
  759.                    
  760.                     useDefaultManager = DBConsegnePreseInCaricoManager.getInstanceRuntime().useDefaultManager();
  761.                     if(!useDefaultManager) {
  762.                         if(!prop.isTimerConsegnaContenutiApplicativi_runtime_dataSource_useDBUtils()) {
  763.                             // le aggiungo altrimenti non c'è altro modo per vederle
  764.                             risorseConsegnePreseInCaricoRuntime = DBConsegnePreseInCaricoManager.getStatoRisorseRuntime();
  765.                         }
  766.                     }
  767.                    
  768.                     useDefaultManager = DBConsegnePreseInCaricoManager.getInstanceTransazioni().useDefaultManager();
  769.                     if(!useDefaultManager) {
  770.                         if(!prop.isTimerConsegnaContenutiApplicativi_transazioni_dataSource_useDBUtils()) {
  771.                             // le aggiungo altrimenti non c'è altro modo per vederle
  772.                             risorseConsegnePreseInCaricoTransazioni = DBConsegnePreseInCaricoManager.getStatoRisorseTransazioni();
  773.                         }
  774.                     }
  775.                 }
  776.             }
  777.            
  778.             if(prop.isIntegrationManagerEnabled()) {
  779.                 boolean useDefaultManager = DBConsegneMessageBoxManager.getInstanceRuntime().useDefaultManager() ||  DBConsegneMessageBoxManager.getInstanceRuntime().useConsegnePreseInCaricoManager();
  780.                 if(!useDefaultManager) {
  781.                     if(!prop.isIntegrationManager_runtime_dataSource_useDBUtils()) {
  782.                         // le aggiungo altrimenti non c'è altro modo per vederle
  783.                         risorseConsegneMessageBoxRuntime = DBConsegneMessageBoxManager.getStatoRisorse_runtime();
  784.                     }
  785.                 }
  786.                
  787.                 useDefaultManager = DBConsegneMessageBoxManager.getInstanceTransazioni().useDefaultManager() ||  DBConsegneMessageBoxManager.getInstanceTransazioni().useConsegnePreseInCaricoManager();
  788.                 if(!useDefaultManager) {
  789.                     if(!prop.isIntegrationManager_transazioni_dataSource_useDBUtils()) {
  790.                         // le aggiungo altrimenti non c'è altro modo per vederle
  791.                         risorseConsegneMessageBoxTransazioni = DBConsegneMessageBoxManager.getStatoRisorse_transazioni();
  792.                     }
  793.                 }
  794.             }
  795.            
  796.         }catch(Throwable e){
  797.             this.log.error(e.getMessage(),e);
  798.             return JMXUtils.MSG_OPERAZIONE_NON_EFFETTUATA+e.getMessage();
  799.         }      
  800.         return getResultUsedDBConnections(risorse, risorseTransaction, risorseStatistiche,
  801.                 risorseConsegnePreseInCaricoSmistatore, risorseConsegnePreseInCaricoRuntime, risorseConsegnePreseInCaricoTransazioni,
  802.                 risorseConsegneMessageBoxRuntime, risorseConsegneMessageBoxTransazioni);
  803.     }
  804.     public static String getResultUsedDBConnections(String[] risorse, String[] risorseTransaction, String[] risorseStatistiche,
  805.             String[] risorseConsegnePreseInCaricoSmistatore, String[] risorseConsegnePreseInCaricoRuntime, String[] risorseConsegnePreseInCaricoTransazioni,
  806.             String[] risorseConsegneMessageBoxRuntime, String[] risorseConsegneMessageBoxTransazioni) {
  807.        
  808.         if((risorse==null || risorse.length<=0) &&
  809.                 (risorseTransaction==null || risorseTransaction.length<=0) &&
  810.                 (risorseStatistiche==null || risorseStatistiche.length<=0)
  811.                 ) {
  812.             return MSG_NESSUNA_CONNESSIONE_ALLOCATA;
  813.         }
  814.            
  815.         StringBuilder bf = new StringBuilder();
  816.         if(risorse!=null && risorse.length>0) {
  817.             bf.append(risorse.length+MSG_CONNESSIONI_ALLOCATE+"\n");
  818.             for(int i=0; i<risorse.length; i++){
  819.                 bf.append(risorse[i]+"\n");
  820.             }
  821.         }
  822.         if(risorseTransaction!=null && risorseTransaction.length>0) {
  823.             bf.append(risorseTransaction.length+MSG_CONNESSIONI_ALLOCATE_TRANSAZIONI+"\n");
  824.             for(int i=0; i<risorseTransaction.length; i++){
  825.                 bf.append(risorseTransaction[i]+"\n");
  826.             }
  827.         }
  828.         if(risorseStatistiche!=null && risorseStatistiche.length>0) {
  829.             bf.append(risorseStatistiche.length+MSG_CONNESSIONI_ALLOCATE_STATISTICHE+"\n");
  830.             for(int i=0; i<risorseStatistiche.length; i++){
  831.                 bf.append(risorseStatistiche[i]+"\n");
  832.             }
  833.         }
  834.         if(risorseConsegnePreseInCaricoSmistatore!=null && risorseConsegnePreseInCaricoSmistatore.length>0) {
  835.             bf.append(risorseConsegnePreseInCaricoSmistatore.length+MSG_CONNESSIONI_ALLOCATE_CONSEGNE_PRESE_IN_CARICO_SMISTATORE+"\n");
  836.             for(int i=0; i<risorseConsegnePreseInCaricoSmistatore.length; i++){
  837.                 bf.append(risorseConsegnePreseInCaricoSmistatore[i]+"\n");
  838.             }
  839.         }
  840.         if(risorseConsegnePreseInCaricoRuntime!=null && risorseConsegnePreseInCaricoRuntime.length>0) {
  841.             bf.append(risorseConsegnePreseInCaricoRuntime.length+MSG_CONNESSIONI_ALLOCATE_CONSEGNE_PRESE_IN_CARICO_RUNTIME+"\n");
  842.             for(int i=0; i<risorseConsegnePreseInCaricoRuntime.length; i++){
  843.                 bf.append(risorseConsegnePreseInCaricoRuntime[i]+"\n");
  844.             }
  845.         }
  846.         if(risorseConsegnePreseInCaricoTransazioni!=null && risorseConsegnePreseInCaricoTransazioni.length>0) {
  847.             bf.append(risorseConsegnePreseInCaricoTransazioni.length+MSG_CONNESSIONI_ALLOCATE_CONSEGNE_PRESE_IN_CARICO_TRANSAZIONI+"\n");
  848.             for(int i=0; i<risorseConsegnePreseInCaricoTransazioni.length; i++){
  849.                 bf.append(risorseConsegnePreseInCaricoTransazioni[i]+"\n");
  850.             }
  851.         }
  852.         if(risorseConsegneMessageBoxRuntime!=null && risorseConsegneMessageBoxRuntime.length>0) {
  853.             bf.append(risorseConsegneMessageBoxRuntime.length+MSG_CONNESSIONI_ALLOCATE_CONSEGNE_MESSAGE_BOX_RUNTIME+"\n");
  854.             for(int i=0; i<risorseConsegneMessageBoxRuntime.length; i++){
  855.                 bf.append(risorseConsegneMessageBoxRuntime[i]+"\n");
  856.             }
  857.         }
  858.         if(risorseConsegneMessageBoxTransazioni!=null && risorseConsegneMessageBoxTransazioni.length>0) {
  859.             bf.append(risorseConsegneMessageBoxTransazioni.length+MSG_CONNESSIONI_ALLOCATE_CONSEGNE_MESSAGE_BOX_TRANSAZIONI+"\n");
  860.             for(int i=0; i<risorseConsegneMessageBoxTransazioni.length; i++){
  861.                 bf.append(risorseConsegneMessageBoxTransazioni[i]+"\n");
  862.             }
  863.         }
  864.        
  865.         return bf.toString();
  866.     }
  867.    
  868.     public String getUsedQueueConnections(){
  869.         String[] risorse = null;
  870.         try{
  871.             risorse = QueueManager.getStatoRisorse();
  872.         }catch(Throwable e){
  873.             this.log.error(e.getMessage(),e);
  874.             return JMXUtils.MSG_OPERAZIONE_NON_EFFETTUATA+e.getMessage();
  875.         }
  876.         return getResultUsedQueueConnections(risorse);
  877.     }
  878.     public static String getResultUsedQueueConnections(String[] risorse) {
  879.         if(risorse==null || risorse.length<=0)
  880.             return MSG_NESSUNA_CONNESSIONE_ALLOCATA;
  881.        
  882.         StringBuilder bf = new StringBuilder();
  883.         bf.append(risorse.length+MSG_CONNESSIONI_ALLOCATE+"\n");
  884.         for(int i=0; i<risorse.length; i++){
  885.             bf.append(risorse[i]+"\n");
  886.         }
  887.         return bf.toString();
  888.     }
  889.    
  890.     public String getTransazioniAttiveId() {
  891.         List<String> risorse = null;
  892.         try{
  893.             risorse = TransactionContext.getTransactionKeys();
  894.         }catch(Throwable e){
  895.             this.log.error(e.getMessage(),e);
  896.             return JMXUtils.MSG_OPERAZIONE_NON_EFFETTUATA+e.getMessage();
  897.         }
  898.         return getResultTransazioniAttiveId(risorse);
  899.     }
  900.     public static String getResultTransazioniAttiveId(List<String> risorse) {
  901.         if(risorse==null || risorse.size()<=0)
  902.             return MSG_NESSUNA_TRANSAZIONE_ATTIVA;
  903.        
  904.         StringBuilder bf = new StringBuilder();
  905.         bf.append(risorse.size()+MSG_TRANSAZIONI_ATTIVE+"\n");
  906.         for(int i=0; i<risorse.size(); i++){
  907.             bf.append(risorse.get(i)+"\n");
  908.         }
  909.         return bf.toString();
  910.     }
  911.    
  912.     public String getDettaglioTransazioneAttivaId(String idTransazione) {
  913.        
  914.         try{
  915.             Transaction tr = TransactionContext.getTransaction(idTransazione);
  916.             if(tr!=null) {
  917.                 return tr.toString();
  918.             }
  919.             throw new TransactionNotExistsException();
  920.         }
  921.         catch(TransactionNotExistsException notFound) {
  922.             return "Transazione non esistente";
  923.         }
  924.         catch(Throwable e){
  925.             this.log.error(e.getMessage(),e);
  926.             return JMXUtils.MSG_OPERAZIONE_NON_EFFETTUATA+e.getMessage();
  927.         }
  928.        
  929.     }
  930.    
  931.     public String getTransazioniAttiveIdProtocollo() {
  932.         List<String> risorse = null;
  933.         try{
  934.             risorse = TransactionContext.getIdBustaKeys();
  935.         }catch(Throwable e){
  936.             this.log.error(e.getMessage(),e);
  937.             return JMXUtils.MSG_OPERAZIONE_NON_EFFETTUATA+e.getMessage();
  938.         }
  939.         return getResultTransazioniAttiveIdProtocollo(risorse);
  940.     }
  941.     public static String getResultTransazioniAttiveIdProtocollo(List<String> risorse) {
  942.         if(risorse==null || risorse.size()<=0)
  943.             return MSG_NESSUNA_TRANSAZIONE_ATTIVA;
  944.        
  945.         StringBuilder bf = new StringBuilder();
  946.         bf.append(risorse.size()+MSG_TRANSAZIONI_ATTIVE_ID_PROTOCOLLO+"\n");
  947.         for(int i=0; i<risorse.size(); i++){
  948.             bf.append(risorse.get(i)+"\n");
  949.         }
  950.         return bf.toString();
  951.     }
  952.    
  953.     public String getActivePDConnections(){
  954.         Map<String, IConnettore> connettori_pd = RepositoryConnettori.getConnettori_pd();      
  955.         return getActiveConnections(connettori_pd);
  956.     }
  957.     public String getActivePAConnections(){
  958.         Map<String, IConnettore> connettori_pa = RepositoryConnettori.getConnettori_pa();      
  959.         return getActiveConnections(connettori_pa);
  960.     }
  961.     private String getActiveConnections(Map<String, IConnettore> connettoriParam){
  962.        
  963.         List<String> cConnettori = new ArrayList<>();
  964.         for (String id : connettoriParam.keySet()) {
  965.             IConnettore c = connettoriParam.get(id);
  966.             String location = null;
  967.             try{
  968.                 location = c.getLocation();
  969.             }catch(Exception e){
  970.                 location = "ERRORE: "+e.getMessage();
  971.             }
  972.             cConnettori.add((id+" -> ["+location+"]"));
  973.         }
  974.         return getResultActiveConnections(cConnettori);
  975.        
  976.     }
  977.     public static String getResultActiveConnections(List<String> cConnettori) {
  978.         if(cConnettori==null || cConnettori.size()==0)
  979.             return MSG_NESSUNA_CONNESSIONE_ALLOCATA;
  980.        
  981.         StringBuilder bf = new StringBuilder();
  982.         bf.append(cConnettori.size()+MSG_CONNESSIONI_HTTP_ALLOCATE+"\n");
  983.         for(int i=0; i<cConnettori.size(); i++){
  984.             bf.append(cConnettori.get(i)+"\n");
  985.         }
  986.         return bf.toString();
  987.     }
  988.    
  989. }