All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.as.clustering.infinispan.cache.LazyCache Maven / Gradle / Ivy

There is a newer version: 34.0.0.Final
Show newest version
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.jboss.as.clustering.infinispan.cache;

import java.lang.annotation.Annotation;
import java.util.Set;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;

import org.infinispan.AdvancedCache;
import org.infinispan.Cache;
import org.infinispan.CacheCollection;
import org.infinispan.CacheSet;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.notifications.cachelistener.filter.CacheEventConverter;
import org.infinispan.notifications.cachelistener.filter.CacheEventFilter;

/**
 * An embedded cache that resolves itself from its cache container lazily.
 * @author Paul Ferraro
 */
public class LazyCache extends LazyBasicCache> implements Cache {

    private final EmbeddedCacheManager container;
    private final String name;

    public LazyCache(EmbeddedCacheManager container, String name) {
        super(name);
        this.container = container;
        this.name = name;
    }

    @Override
    public Cache run() {
        return this.container.getCache(this.name);
    }

    @Override
    public EmbeddedCacheManager getCacheManager() {
        return this.container;
    }

    @Override
    public AdvancedCache getAdvancedCache() {
        return this.get().getAdvancedCache();
    }

    @Override
    public Configuration getCacheConfiguration() {
        return this.get().getCacheConfiguration();
    }

    @Deprecated
    @Override
    public Set getListeners() {
        return this.get().getListeners();
    }

    @Override
    public ComponentStatus getStatus() {
        return this.get().getStatus();
    }

    @Override
    public boolean startBatch() {
        return this.get().startBatch();
    }

    @Override
    public void endBatch(boolean successful) {
        this.get().endBatch(successful);
    }

    @Override
    public CacheSet> entrySet() {
        return this.get().entrySet();
    }

    @Override
    public CacheSet keySet() {
        return this.get().keySet();
    }

    @Override
    public CacheCollection values() {
        return this.get().values();
    }

    @Override
    public void evict(K key) {
        this.get().evict(key);
    }

    @Override
    public void putForExternalRead(K key, V value) {
        this.get().putForExternalRead(key, value);
    }

    @Override
    public void putForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit) {
        this.get().putForExternalRead(key, value, lifespan, lifespanUnit);
    }

    @Override
    public void putForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
        this.get().putForExternalRead(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
    }

    @Override
    public CompletionStage addListenerAsync(Object listener) {
        return this.get().addListenerAsync(listener);
    }

    @Override
    public  CompletionStage addListenerAsync(Object listener, CacheEventFilter filter, CacheEventConverter converter) {
        return this.get().addListenerAsync(listener, filter, converter);
    }

    @Override
    public  CompletionStage addFilteredListenerAsync(Object listener, CacheEventFilter filter, CacheEventConverter converter, Set> filterAnnotations) {
        return this.get().addFilteredListenerAsync(listener, filter, converter, filterAnnotations);
    }

    @Override
    public  CompletionStage addStorageFormatFilteredListenerAsync(Object listener, CacheEventFilter filter, CacheEventConverter converter, Set> filterAnnotations) {
        return this.get().addStorageFormatFilteredListenerAsync(listener, filter, converter, filterAnnotations);
    }

    @Override
    public CompletionStage removeListenerAsync(Object listener) {
        return this.get().removeListenerAsync(listener);
    }
}