|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectr01f.xmlproperties.XMLPropertiesCacheImpl
class XMLPropertiesCacheImpl
Caché de propiedades para un código de aplicación.
Hay DOS cachés:
Se va completando a medida que se accede a las propiedades,
es decir, cuando se recupera una propiedad del XML se almacena
su valor en esta caché y NO se vuelve a obtener del XML.
Esta caché está gestionada en la clase XMLPropertiesCache.
Esta caché se utiliza en la clase XMLPropertiesManager.
Cuando se accede por primera vez a una propiedad cualquiera de un appCode/contentType
se carga el XML de propiedades desde su almacenamiento, en este momento el Document XML
se cachea en la clase XMLPropertiesForComponentContainer, de forma que NO es necesario
volver a leer el XML.
A medida que se van leyendo propiedades del XML, sus valores se almacenan en la
clase XMLPropertiesCache.
Esta caché está en la clase XMLPropertiesForComponentContainer y se
instancia en ESTA clase utilizando la factoría.
| Nested Class Summary | |
|---|---|
private class |
XMLPropertiesCacheImpl.CacheKey
|
(package private) class |
XMLPropertiesCacheImpl.CacheStatistics
|
private class |
XMLPropertiesCacheImpl.CacheValue
Información que se guarda en la caché cuando una entrada NO se encuentra en el properties, de esta forma se evita tener que consultar de nuevo el árbol DOM. |
| Field Summary | |
|---|---|
private java.lang.String |
_appCode
|
private java.util.Map<XMLPropertiesCacheImpl.CacheKey,XMLPropertiesCacheImpl.CacheValue> |
_cache
|
private XMLPropertiesForComponentContainer |
_componentXMLManager
|
private boolean |
_useCache
|
(package private) static int |
DEFAULT_COMPONENTS_NUMBER
|
(package private) static int |
DEFAULT_PROPERTIES_PER_COMPONENT
|
| Constructor Summary | |
|---|---|
XMLPropertiesCacheImpl(ResourcesLoaderFactory resourcesLoaderFactory,
java.lang.String appCode,
int componentsNumberEstimation,
boolean useCache)
Constructor en base al tamaño del cache y el modo de depuración. |
|
| Method Summary | ||
|---|---|---|
private void |
_ensureCapacity(int propertiesPerComponentEstimation)
Se asegura cierta capacidad del caché. |
|
private
|
_retrieve(java.lang.String component,
java.lang.String xPath,
java.lang.Class<T> type,
Marshaller marshaller)
Recupera la referencia a un objeto extraido de las propiedades. |
|
private
|
_retrieveBeanPropertyUsingMarshaller(java.lang.String component,
java.lang.String propXPath,
java.lang.Class<?> type,
Marshaller marshaller)
|
|
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
_retrieveMapOfStringsProperty(java.lang.String component,
java.lang.String propXPath)
|
|
private java.lang.String |
_retrieveStringProperty(java.lang.String component,
java.lang.String propXPath)
|
|
private XMLPropertiesCacheImpl.CacheValue |
_store(java.lang.String component,
java.lang.String xPath,
java.lang.Object obj,
boolean isDefaultVal)
Almacena en la caché un objeto extraido de las propiedades. |
|
int |
clear()
Inicializa la caché de todos los componentes de todas las aplicaciones. |
|
int |
clear(java.lang.String component)
Recarga las propiedades de un componente o de todos. |
|
boolean |
existProperty(java.lang.String component,
java.lang.String propXPath)
Comprueba si existe una propiedad. |
|
|
getProperty(java.lang.String component,
java.lang.String propXPath,
T defaultValue,
java.lang.Class<T> type)
Devuelve una propiedad. |
|
|
getProperty(java.lang.String component,
java.lang.String propXPath,
T defaultValue,
java.lang.Class<T> type,
Marshaller marshaller)
Devuelve una propiedad. |
|
void |
newComponentLoaded(XMLPropertiesComponentDef def)
Se ha cargado un nuevo componente. |
|
XMLPropertiesCacheImpl.CacheStatistics |
usageStats()
Obtiene las estadísticas de la cache a partir de los datos de uso almacenados en cada entrada de la cache. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static int DEFAULT_COMPONENTS_NUMBER
static int DEFAULT_PROPERTIES_PER_COMPONENT
private XMLPropertiesForComponentContainer _componentXMLManager
private java.util.Map<XMLPropertiesCacheImpl.CacheKey,XMLPropertiesCacheImpl.CacheValue> _cache
private java.lang.String _appCode
private boolean _useCache
| Constructor Detail |
|---|
@Inject
public XMLPropertiesCacheImpl(ResourcesLoaderFactory resourcesLoaderFactory,
java.lang.String appCode,
int componentsNumberEstimation,
boolean useCache)
AssistedInject ya que los parametros appCode, componentsNumberEstimation y
useCache NO se conocen hasta el momento de la ejecución por lo que NO se puede crear un binding estatico para XMLPropertiesCache
Para utilizar AssistedInject:
XMLPropertiesCache, por ejemplo XMLPropertiesCacheFactory
public XMLPropertiesCache createFor(String appCode,int componentsNumberEstimation,
boolean useCache);
(esta interfaz NO se implementa... lo hace Guice automáticamente).
@Inject
public XMLPropertiesCacheImpl(final ResourcesLoaderFactory resourcesLoaderFactory,
@Assisted final String appCode,@Assisted final int componentsNumberEstimation,
@Assisted final boolean useCache)
XMLPropertiesCacheFactory y que Guice construye automáticamente por detrás:
Module assistedModuleForPropertiesCacheFactory = new FactoryModuleBuilder().implement(XMLPropertiesCache.class,XMLPropertiesCacheImpl.class).build(XMLPropertiesCacheFactory.class);
binder.install(assistedModuleForPropertiesCacheFactory);
resourcesLoaderFactory - Factoría de los ResourcesLoaders responsables de cargar los xmls de propiedades.ResourcesLoader concreto a utilizar se indica en el fichero de configuración del
componente que SIEMPRE se carga desde el classPath (ver XMLPropertiesForComponentContainer).appCode - Código de aplicación.componentsNumberEstimation - Tamaño de la cache de apps/components.useCache - true indica si se utiliza la cache de objetos recuperados del properties.| Method Detail |
|---|
public void newComponentLoaded(XMLPropertiesComponentDef def)
XMLPropertiesComponentLoadedListener
newComponentLoaded in interface XMLPropertiesComponentLoadedListenerdef - La definición del componenteprivate void _ensureCapacity(int propertiesPerComponentEstimation)
XMLPropertiesForComponentContainer cuando se carga
un nuevo XML de propiedades para un componente:
propertiesPerComponentEstimation - Estimación de número de propiedades para el componente.public int clear()
XMLPropertiesCache
clear in interface XMLPropertiesCachepublic int clear(java.lang.String component)
XMLPropertiesCache
clear in interface XMLPropertiesCachecomponent - El componente puede ser:
public XMLPropertiesCacheImpl.CacheStatistics usageStats()
XMLPropertiesCache
usageStats in interface XMLPropertiesCache
public boolean existProperty(java.lang.String component,
java.lang.String propXPath)
XMLPropertiesCache
existProperty in interface XMLPropertiesCachecomponent - componente de la aplicación.propXPath - ruta xpath para obtener la propiedad.
null).
public <T> T getProperty(java.lang.String component,
java.lang.String propXPath,
T defaultValue,
java.lang.Class<T> type)
XMLPropertiesCache
getProperty in interface XMLPropertiesCachecomponent - el componente de la aplicación.propXPath - la ruta XPath de la propiedad.defaultValue - el valor por defecto de la propiedad.type - el tipo de dato en el que se quiere la propiedad.
null si la propiedad no existe.
public <T> T getProperty(java.lang.String component,
java.lang.String propXPath,
T defaultValue,
java.lang.Class<T> type,
Marshaller marshaller)
XMLPropertiesCache
getProperty in interface XMLPropertiesCachecomponent - el componente de la aplicación.propXPath - la ruta XPath de la propiedad.defaultValue - el valor por defecto de la propiedad.type - el tipo de dato en el que se quiere la propiedad.marshaller - el marshaller para pasar de XML a objetos el xml de las propiedades.
null si la propiedad no existe.
private java.lang.String _retrieveStringProperty(java.lang.String component,
java.lang.String propXPath)
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> _retrieveMapOfStringsProperty(java.lang.String component,
java.lang.String propXPath)
private <T> T _retrieveBeanPropertyUsingMarshaller(java.lang.String component,
java.lang.String propXPath,
java.lang.Class<?> type,
Marshaller marshaller)
private <T> XMLPropertiesCacheImpl.CacheValue _retrieve(java.lang.String component,
java.lang.String xPath,
java.lang.Class<T> type,
Marshaller marshaller)
Si el parámetro type==null, SOLO se mira la caché, NO hace la carga desde el XML
en caso de NO estar la propiedad en la caché.
component - Componente.xPath - El xPath a la propiedad.type - El tipo del objeto devuelto.marshaller - El marshaller utilizado para pasar el xml a objetos.
private XMLPropertiesCacheImpl.CacheValue _store(java.lang.String component,
java.lang.String xPath,
java.lang.Object obj,
boolean isDefaultVal)
component - Componente.xPath - El xpath de la propiedad.obj - El objeto a almacenar.isDefaultVal - true si se está almacenando el valor por defecto para la propiedad.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||