JMXUtils.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 javax.management.MBeanAttributeInfo;
  22. import javax.management.MBeanOperationInfo;
  23. import javax.management.MBeanParameterInfo;

  24. /**
  25.  * JMXUtils
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class JMXUtils {

  32.     /** Nomi attributi */
  33.     public static final String CACHE_ATTRIBUTE_ABILITATA = "cacheAbilitata";
  34.    
  35.     /** Nomi metodi */
  36.     public static final String CACHE_METHOD_NAME_RESET = "resetCache";
  37.     public static final String CACHE_METHOD_NAME_PREFILL = "prefillCache";
  38.     public static final String CACHE_METHOD_NAME_PRINT_STATS = "printStatsCache";
  39.     public static final String CACHE_METHOD_NAME_ABILITA = "abilitaCache";
  40.     public static final String CACHE_METHOD_NAME_DISABILITA = "disabilitaCache";
  41.     public static final String CACHE_METHOD_NAME_LIST_KEYS = "listKeysCache";
  42.     public static final String CACHE_METHOD_NAME_GET_OBJECT = "getObjectCache";
  43.     public static final String CACHE_METHOD_NAME_REMOVE_OBJECT = "removeObjectCache";
  44.    
  45.     /** Messaggi */
  46.     public static final String MSG_OPERAZIONE_REGISTRATA_SUCCESSO_TEMPLATE_SECONDI = "SECONDI";
  47.     public static final String MSG_OPERAZIONE_REGISTRATA_SUCCESSO = "la richiesta è stata registrata e verrà evasa entro "+MSG_OPERAZIONE_REGISTRATA_SUCCESSO_TEMPLATE_SECONDI+" secondi";
  48.     public static final String MSG_OPERAZIONE_NON_EFFETTUATA = "Operazione non riuscita: ";
  49.     public static final String MSG_OPERAZIONE_EFFETTUATA_SUCCESSO = "Operazione effettuata con successo";
  50.     public static final String MSG_OPERAZIONE_EFFETTUATA_SUCCESSO_PREFIX = "Operazione effettuata con successo; ";
  51.     public static final String MSG_RESET_CACHE_EFFETTUATO_SUCCESSO = "Operazione di reset effettuata con successo";
  52.     public static final String MSG_PREFILL_CACHE_EFFETTUATO_SUCCESSO = "Operazione pre-fill cache effettuata con successo";
  53.     public static final String MSG_ABILITAZIONE_CACHE_EFFETTUATA = "Abilitazione cache effettuata con successo";
  54.     public static final String MSG_DISABILITAZIONE_CACHE_EFFETTUATA = "Disabilitazione cache effettuata con successo";
  55.     public static final String MSG_RIMOZIONE_CACHE_EFFETTUATA = "Rimozione elemento dalla cache effettuata con successo";

  56.     /** Per determinare se l'attributo e' leggibile/scrivibile */
  57.     public static final boolean JMX_ATTRIBUTE_READABLE = true;
  58.     public static final boolean JMX_ATTRIBUTE_WRITABLE = true;
  59.     /** Per determinare se l'attributo e' ricavabile nella forma booleana isAttribute() */
  60.     public static final boolean JMX_ATTRIBUTE_IS_GETTER = true;
  61.    
  62.     /** MBean Attribute */
  63.     public static final MBeanAttributeInfo MBEAN_ATTRIBUTE_INFO_CACHE_ABILITATA =
  64.             new MBeanAttributeInfo(CACHE_ATTRIBUTE_ABILITATA,boolean.class.getName(),
  65.                     "Indicazione se e' abilita una cache",
  66.                     JMX_ATTRIBUTE_READABLE,JMX_ATTRIBUTE_WRITABLE,!JMX_ATTRIBUTE_IS_GETTER);
  67.    
  68.     /** MBean Operation */
  69.     // Reset Cache
  70.     public static final MBeanOperationInfo MBEAN_OPERATION_RESET_CACHE
  71.         = new MBeanOperationInfo(CACHE_METHOD_NAME_RESET,"Svuota la cache",
  72.                 null,
  73.                 String.class.getName(),
  74.                 MBeanOperationInfo.ACTION);
  75.    
  76.     // PreFill Cache
  77.     public static final MBeanOperationInfo MBEAN_OPERATION_PREFILL_CACHE
  78.         = new MBeanOperationInfo(CACHE_METHOD_NAME_PREFILL,"Pre-fill della cache",
  79.                 null,
  80.                 String.class.getName(),
  81.                 MBeanOperationInfo.ACTION);
  82.            
  83.     // Print Stats Cache
  84.     public static final MBeanOperationInfo MBEAN_OPERATION_PRINT_STATS_CACHE
  85.         = new MBeanOperationInfo(CACHE_METHOD_NAME_PRINT_STATS,"Visualizza le informazioni statistiche sugli oggetti presenti in cache",
  86.             null,
  87.             String.class.getName(),
  88.             MBeanOperationInfo.ACTION);
  89.            
  90.     // Disabilita Cache
  91.     public static final MBeanOperationInfo MBEAN_OPERATION_DISABILITA_CACHE
  92.         = new MBeanOperationInfo(CACHE_METHOD_NAME_DISABILITA,"Disabilita la cache",
  93.             null,
  94.             String.class.getName(),
  95.             MBeanOperationInfo.ACTION);
  96.            
  97.     // Abilita Cache con parametri
  98.     public static final MBeanOperationInfo MBEAN_OPERATION_ABILITA_CACHE_CON_PARAMETRI
  99.         = new MBeanOperationInfo(CACHE_METHOD_NAME_ABILITA,"Abilita la cache",
  100.             new MBeanParameterInfo[]{
  101.                 new MBeanParameterInfo("dimensioneCache",long.class.getName(),"Dimensione della cache"),
  102.                 new MBeanParameterInfo("algoritmoCacheLRU",boolean.class.getName(),"Algoritmo utilizzato (lru/mru)"),
  103.                 new MBeanParameterInfo("itemIdleTime",long.class.getName(),"Indica il massimo intervallo di tempo che un item può esistere senza essere acceduto (con -1 verra' assegnato un tempo infinito)"),
  104.                 new MBeanParameterInfo("itemLifeSecond",long.class.getName(),"Vita di un elemento inserito in cache (secondi)")
  105.             },
  106.             String.class.getName(),
  107.             MBeanOperationInfo.ACTION);
  108.    
  109.     // List keys Cache
  110.     public static final MBeanOperationInfo MBEAN_OPERATION_LIST_KEYS_CACHE
  111.         = new MBeanOperationInfo(CACHE_METHOD_NAME_LIST_KEYS,"Visualizza le chiavi attualmente presenti nella cache",
  112.             null,
  113.             String.class.getName(),
  114.             MBeanOperationInfo.ACTION);
  115.    
  116.     // get Object Cache
  117.     public static final MBeanOperationInfo MBEAN_OPERATION_GET_OBJECT_CACHE
  118.         = new MBeanOperationInfo(CACHE_METHOD_NAME_GET_OBJECT,"Recupera l'oggetto registrato nella cache con chiave fornita come parametro",
  119.             new MBeanParameterInfo[]{
  120.                 new MBeanParameterInfo("key",String.class.getName(),"Chiave dell'oggetto in cache"),
  121.             },
  122.             String.class.getName(),
  123.             MBeanOperationInfo.ACTION);
  124.    
  125.     // remove Object Cache
  126.     public static final MBeanOperationInfo MBEAN_OPERATION_REMOVE_OBJECT_CACHE
  127.         = new MBeanOperationInfo(CACHE_METHOD_NAME_REMOVE_OBJECT,"Rimuove l'oggetto registrato nella cache con chiave fornita come parametro",
  128.             new MBeanParameterInfo[]{
  129.                 new MBeanParameterInfo("key",String.class.getName(),"Chiave dell'oggetto in cache"),
  130.             },
  131.             String.class.getName(),
  132.             MBeanOperationInfo.ACTION);
  133.    
  134. }