Constants.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.utils.cache;

  21. import javax.management.MBeanAttributeInfo;
  22. import javax.management.MBeanOperationInfo;
  23. import javax.management.MBeanParameterInfo;

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

  34.     /** Nomi attributi */
  35.     public static final String CACHE_ATTRIBUTE_ABILITATA = "cache";
  36.    
  37.     /** Nomi metodi */
  38.     public static final String CACHE_METHOD_NAME_RESET = "resetCache";
  39.     public static final String CACHE_METHOD_NAME_PRINT_STATS = "printStatsCache";
  40.     public static final String CACHE_METHOD_NAME_ABILITA = "enableCache";
  41.     public static final String CACHE_METHOD_NAME_DISABILITA = "disableCache";
  42.     public static final String CACHE_METHOD_NAME_LIST_KEYS = "listKeysCache";
  43.     public static final String CACHE_METHOD_NAME_GET_OBJECT = "getObjectCache";
  44.     public static final String CACHE_METHOD_NAME_REMOVE_OBJECT = "removeObjectCache";
  45.    
  46.     /** Messaggi */
  47.     public static final String MSG_OPERAZIONE_NON_EFFETTUATA = "Operation failed: ";
  48.     public static final String MSG_OPERATION_PREFIX = "Operation '";
  49.     public static final String MSG_OPERATION_DONE = "' done";
  50.     public static final String MSG_RESET_CACHE_EFFETTUATO_SUCCESSO = MSG_OPERATION_PREFIX+CACHE_METHOD_NAME_RESET+MSG_OPERATION_DONE;
  51.     public static final String MSG_ABILITAZIONE_CACHE_EFFETTUATA = MSG_OPERATION_PREFIX+CACHE_METHOD_NAME_ABILITA+MSG_OPERATION_DONE;
  52.     public static final String MSG_DISABILITAZIONE_CACHE_EFFETTUATA = MSG_OPERATION_PREFIX+CACHE_METHOD_NAME_DISABILITA+MSG_OPERATION_DONE;
  53.    
  54.     public static final String MSG_CACHE_NON_ABILITATA = "Cache non abilitata";
  55.     public static final String MSG_CACHE_GIA_ABILITATA = "Cache già abilitata";
  56.     public static final String MSG_CACHE_GIA_DISABILITATA = "Cache già disabilitata";
  57.    
  58.     public static final String MSG_CACHE = "Cache";
  59.     public static final String MSG_CACHE_PREFIX = "Cache-";

  60.     /** Per determinare se l'attributo e' leggibile/scrivibile */
  61.     public static final boolean JMX_ATTRIBUTE_READABLE = true;
  62.     public static final boolean JMX_ATTRIBUTE_WRITABLE = true;
  63.     /** Per determinare se l'attributo e' ricavabile nella forma booleana isAttribute() */
  64.     public static final boolean JMX_ATTRIBUTE_IS_GETTER = true;
  65.    
  66.     /** MBean Attribute */
  67.     public static final MBeanAttributeInfo MBEAN_ATTRIBUTE_INFO_CACHE_ABILITATA =
  68.             new MBeanAttributeInfo(CACHE_ATTRIBUTE_ABILITATA,boolean.class.getName(),
  69.                     "Cache enabled",
  70.                     JMX_ATTRIBUTE_READABLE,!JMX_ATTRIBUTE_WRITABLE,!JMX_ATTRIBUTE_IS_GETTER);
  71.    
  72.     /** MBean Operation */
  73.     // Reset Cache
  74.     public static final MBeanOperationInfo MBEAN_OPERATION_RESET_CACHE
  75.         = new MBeanOperationInfo(CACHE_METHOD_NAME_RESET,"Empty cache",
  76.                 null,
  77.                 String.class.getName(),
  78.                 MBeanOperationInfo.ACTION);
  79.            
  80.     // Print Stats Cache
  81.     public static final MBeanOperationInfo MBEAN_OPERATION_PRINT_STATS_CACHE
  82.         = new MBeanOperationInfo(CACHE_METHOD_NAME_PRINT_STATS,"View cache statistics information",
  83.             null,
  84.             String.class.getName(),
  85.             MBeanOperationInfo.ACTION);
  86.            
  87.     // Disabilita Cache
  88.     public static final MBeanOperationInfo MBEAN_OPERATION_DISABILITA_CACHE
  89.         = new MBeanOperationInfo(CACHE_METHOD_NAME_DISABILITA,"Disable cache",
  90.             null,
  91.             String.class.getName(),
  92.             MBeanOperationInfo.ACTION);
  93.            
  94.     // Abilita Cache con parametri
  95.     public static final MBeanOperationInfo MBEAN_OPERATION_ABILITA_CACHE_CON_PARAMETRI
  96.         = new MBeanOperationInfo(CACHE_METHOD_NAME_ABILITA,"Enable cache",
  97.             new MBeanParameterInfo[]{
  98.                 new MBeanParameterInfo("cacheSize",Integer.class.getName(),"Cache size"),
  99.                 new MBeanParameterInfo("isCacheAlgorithmLRU",Boolean.class.getName(),"Cache algorithm LRU"),
  100.                 new MBeanParameterInfo("itemIdleTimeSeconds",Integer.class.getName(),"Item Idle Time in seconds (with -1 infinite time)"),
  101.                 new MBeanParameterInfo("itemLifeTimeSeconds",Integer.class.getName(),"Item Life Time in seconds")
  102.             },
  103.             String.class.getName(),
  104.             MBeanOperationInfo.ACTION);
  105.    
  106.     // List keys Cache
  107.     public static final MBeanOperationInfo MBEAN_OPERATION_LIST_KEYS_CACHE
  108.         = new MBeanOperationInfo(CACHE_METHOD_NAME_LIST_KEYS,"View cache keys",
  109.             null,
  110.             String.class.getName(),
  111.             MBeanOperationInfo.ACTION);
  112.    
  113.     // get Object Cache
  114.     public static final MBeanOperationInfo MBEAN_OPERATION_GET_OBJECT_CACHE
  115.         = new MBeanOperationInfo(CACHE_METHOD_NAME_GET_OBJECT,"Retrieve the object in cache with key parameter",
  116.             new MBeanParameterInfo[]{
  117.                 new MBeanParameterInfo("key",String.class.getName(),"cache key"),
  118.             },
  119.             String.class.getName(),
  120.             MBeanOperationInfo.ACTION);
  121.    
  122.     // remove Object Cache
  123.     public static final MBeanOperationInfo MBEAN_OPERATION_REMOVE_OBJECT_CACHE
  124.         = new MBeanOperationInfo(CACHE_METHOD_NAME_REMOVE_OBJECT,"Remove the object in cache with key parameter",
  125.             new MBeanParameterInfo[]{
  126.                 new MBeanParameterInfo("key",String.class.getName(),"cache key"),
  127.             },
  128.             String.class.getName(),
  129.             MBeanOperationInfo.ACTION);
  130.    
  131. }