Search in sources :

Example 1 with LRULinkedHashMap

use of org.apache.myfaces.util.lang.LRULinkedHashMap in project myfaces by apache.

the class ClientWindowScopeContextualStorageHolder method init.

@PostConstruct
@Override
public void init() {
    super.init();
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Integer numberOfClientWindowsInSession = MyfacesConfig.getCurrentInstance(facesContext).getNumberOfClientWindows();
    clientWindowExpirationStack = new LRULinkedHashMap<>(numberOfClientWindowsInSession, (eldest) -> {
        destroyAll(FacesContext.getCurrentInstance(), eldest.getKey());
    });
    pushClientWindow(facesContext, facesContext.getExternalContext().getClientWindow());
}
Also used : SessionScoped(jakarta.enterprise.context.SessionScoped) MyfacesConfig(org.apache.myfaces.config.MyfacesConfig) ClientWindow(jakarta.faces.lifecycle.ClientWindow) PostConstruct(jakarta.annotation.PostConstruct) FacesContext(jakarta.faces.context.FacesContext) Contextual(jakarta.enterprise.context.spi.Contextual) ContextualInstanceInfo(org.apache.myfaces.cdi.util.ContextualInstanceInfo) Typed(jakarta.enterprise.inject.Typed) Serializable(java.io.Serializable) ContextualStorage(org.apache.myfaces.cdi.util.ContextualStorage) AbstractContextualStorageHolder(org.apache.myfaces.cdi.util.AbstractContextualStorageHolder) LRULinkedHashMap(org.apache.myfaces.util.lang.LRULinkedHashMap) Map(java.util.Map) FacesContext(jakarta.faces.context.FacesContext) PostConstruct(jakarta.annotation.PostConstruct)

Example 2 with LRULinkedHashMap

use of org.apache.myfaces.util.lang.LRULinkedHashMap in project myfaces by apache.

the class SerializedViewCollection method putLastWindowKey.

public synchronized void putLastWindowKey(FacesContext context, String id, SerializedViewKey key) {
    if (_lastWindowKeys == null) {
        Integer i = getNumberOfSequentialViewsInSession(context);
        int j = getNumberOfViewsInSession(context);
        if (i != null && i > 0) {
            _lastWindowKeys = new LRULinkedHashMap<>((j / i) + 1);
        } else {
            _lastWindowKeys = new LRULinkedHashMap(j + 1);
        }
    }
    _lastWindowKeys.put(id, key);
}
Also used : LRULinkedHashMap(org.apache.myfaces.util.lang.LRULinkedHashMap)

Example 3 with LRULinkedHashMap

use of org.apache.myfaces.util.lang.LRULinkedHashMap in project myfaces by apache.

the class FlowScopeContextualStorageHolder method init.

@PostConstruct
@Override
public void init() {
    super.init();
    activeFlowMapKeys = new ConcurrentHashMap<>();
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Integer numberOfClientWindowsInSession = MyfacesConfig.getCurrentInstance(facesContext).getNumberOfClientWindows();
    clientWindowExpirationStack = new LRULinkedHashMap<>(numberOfClientWindowsInSession, (eldest) -> {
        clearFlowMap(FacesContext.getCurrentInstance(), eldest.getKey());
    });
    refreshClientWindow(facesContext);
}
Also used : Flow(jakarta.faces.flow.Flow) SessionScoped(jakarta.enterprise.context.SessionScoped) MyfacesConfig(org.apache.myfaces.config.MyfacesConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ClientWindow(jakarta.faces.lifecycle.ClientWindow) PostConstruct(jakarta.annotation.PostConstruct) HashMap(java.util.HashMap) FacesContext(jakarta.faces.context.FacesContext) ContextualInstanceInfo(org.apache.myfaces.cdi.util.ContextualInstanceInfo) Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) Typed(jakarta.enterprise.inject.Typed) ContextualStorage(org.apache.myfaces.cdi.util.ContextualStorage) FlowUtils(org.apache.myfaces.flow.FlowUtils) List(java.util.List) AbstractContextualStorageHolder(org.apache.myfaces.cdi.util.AbstractContextualStorageHolder) LRULinkedHashMap(org.apache.myfaces.util.lang.LRULinkedHashMap) Map(java.util.Map) FlowHandler(jakarta.faces.flow.FlowHandler) Collections(java.util.Collections) BeanManager(jakarta.enterprise.inject.spi.BeanManager) FacesContext(jakarta.faces.context.FacesContext) PostConstruct(jakarta.annotation.PostConstruct)

Aggregations

LRULinkedHashMap (org.apache.myfaces.util.lang.LRULinkedHashMap)3 PostConstruct (jakarta.annotation.PostConstruct)2 SessionScoped (jakarta.enterprise.context.SessionScoped)2 Typed (jakarta.enterprise.inject.Typed)2 FacesContext (jakarta.faces.context.FacesContext)2 ClientWindow (jakarta.faces.lifecycle.ClientWindow)2 Serializable (java.io.Serializable)2 Map (java.util.Map)2 AbstractContextualStorageHolder (org.apache.myfaces.cdi.util.AbstractContextualStorageHolder)2 ContextualInstanceInfo (org.apache.myfaces.cdi.util.ContextualInstanceInfo)2 ContextualStorage (org.apache.myfaces.cdi.util.ContextualStorage)2 MyfacesConfig (org.apache.myfaces.config.MyfacesConfig)2 Contextual (jakarta.enterprise.context.spi.Contextual)1 BeanManager (jakarta.enterprise.inject.spi.BeanManager)1 Flow (jakarta.faces.flow.Flow)1 FlowHandler (jakarta.faces.flow.FlowHandler)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1