Package org.ametys.core.ui
Class RibbonManagerCache
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.ui.RibbonManagerCache
-
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Contextualizable
,Serviceable
public class RibbonManagerCache extends AbstractLogEnabled implements Contextualizable, Serviceable, Component, Initializable
Helper for RibbonManager, that support Thread safe usage of the managers, while implementing a cache for performances.
-
-
Field Summary
Fields Modifier and Type Field Description private AbstractCacheManager
_cacheManager
private ServiceManager
_cocoonManager
private Context
_context
private SourceResolver
_resolver
private Map<RibbonManager,RibbonConfiguration>
_ribbonConfigurationCache
private RibbonControlsManager
_ribbonControlsManager
private Map<RibbonManager,Map<String,Long>>
_ribbonManagerCacheValidity
private Map<RibbonManager,Integer>
_ribbonManagerUsageCache
private Map<RibbonManager,ThreadSafeComponentManager<Object>>
_ribbonServiceManagers
private RibbonTabsManager
_ribbonTabsManager
static String
ROLE
Avalon role
-
Constructor Summary
Constructors Constructor Description RibbonManagerCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private RibbonManager
_createRibbonManager()
private void
_decreaseUsage(RibbonManager ribbonManager, boolean forceRemove)
private Cache<String,RibbonManager>
_getRibbonManagerCache()
private void
_increaseUsage(RibbonManager ribbonManager)
private boolean
_isRibbonEntryStillValid(Long cachedValidity, RibbonConfigurationSource ribbonEntrySource)
private boolean
_isRibbonManagerStillValid(RibbonManager ribbonManager)
void
addCachedConfiguration(RibbonManager ribbonManager, RibbonConfiguration configuration, Map<String,Long> importsValidity)
Add a ribbon configuration to the cachevoid
contextualize(Context context)
void
dispose(RibbonManager ribbonManager)
Dispose of a RibbonManager that was previously retrieve with this helperRibbonConfiguration
getCachedConfiguration(RibbonManager ribbonManager)
Get the ribbon configuration managed by the RibbonManagerRibbonManager
getManager(String uri)
Create the RibbonManager associated with the given ribbon file.void
initialize()
void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_ribbonManagerCacheValidity
private Map<RibbonManager,Map<String,Long>> _ribbonManagerCacheValidity
-
_ribbonManagerUsageCache
private Map<RibbonManager,Integer> _ribbonManagerUsageCache
-
_ribbonConfigurationCache
private Map<RibbonManager,RibbonConfiguration> _ribbonConfigurationCache
-
_ribbonServiceManagers
private Map<RibbonManager,ThreadSafeComponentManager<Object>> _ribbonServiceManagers
-
_cocoonManager
private ServiceManager _cocoonManager
-
_ribbonControlsManager
private RibbonControlsManager _ribbonControlsManager
-
_ribbonTabsManager
private RibbonTabsManager _ribbonTabsManager
-
_resolver
private SourceResolver _resolver
-
_cacheManager
private AbstractCacheManager _cacheManager
-
-
Constructor Detail
-
RibbonManagerCache
public RibbonManagerCache()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getManager
public RibbonManager getManager(String uri) throws Exception
Create the RibbonManager associated with the given ribbon file. If the RibbonManager already exists for the ribbon file and is still valid, it is simply returned.- Parameters:
uri
- The ribbon configuration uri- Returns:
- The RibbonManager
- Throws:
Exception
- If an error occurs
-
_isRibbonManagerStillValid
private boolean _isRibbonManagerStillValid(RibbonManager ribbonManager)
-
_isRibbonEntryStillValid
private boolean _isRibbonEntryStillValid(Long cachedValidity, RibbonConfigurationSource ribbonEntrySource)
-
_createRibbonManager
private RibbonManager _createRibbonManager() throws Exception
- Throws:
Exception
-
dispose
public void dispose(RibbonManager ribbonManager)
Dispose of a RibbonManager that was previously retrieve with this helper- Parameters:
ribbonManager
- The ribbon manager
-
_increaseUsage
private void _increaseUsage(RibbonManager ribbonManager)
-
_decreaseUsage
private void _decreaseUsage(RibbonManager ribbonManager, boolean forceRemove)
-
getCachedConfiguration
public RibbonConfiguration getCachedConfiguration(RibbonManager ribbonManager)
Get the ribbon configuration managed by the RibbonManager- Parameters:
ribbonManager
- The ribbon manager- Returns:
- The configuration, or null if no configuration was cached
-
addCachedConfiguration
public void addCachedConfiguration(RibbonManager ribbonManager, RibbonConfiguration configuration, Map<String,Long> importsValidity)
Add a ribbon configuration to the cache- Parameters:
ribbonManager
- The ribbon managerconfiguration
- The configurationimportsValidity
- The list of imports for this ribbon configuration and their validity
-
_getRibbonManagerCache
private Cache<String,RibbonManager> _getRibbonManagerCache()
-
-