Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2015 Async-IO.org
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.atmosphere.cache;
import org.atmosphere.cpr.AtmosphereConfig;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.BroadcasterCache;
import org.atmosphere.cpr.BroadcasterCacheListener;
import org.atmosphere.util.ExecutorsFactory;
import org.atmosphere.util.UUIDProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.atmosphere.cpr.ApplicationConfig.UUIDBROADCASTERCACHE_CLIENT_IDLETIME;
import static org.atmosphere.cpr.ApplicationConfig.UUIDBROADCASTERCACHE_IDLE_CACHE_INTERVAL;
/**
* An improved {@link BroadcasterCache} implementation that is based on the unique identifier (UUID) that all
* {@link AtmosphereResource}s have.
*
* @author Paul Khodchenkov
* @author Jeanfrancois Arcand
*/
public class UUIDBroadcasterCache implements BroadcasterCache {
private final static Logger logger = LoggerFactory.getLogger(UUIDBroadcasterCache.class);
private final Map messages = new ConcurrentHashMap();
private final Map activeClients = new ConcurrentHashMap();
protected final List inspectors = new LinkedList();
private ScheduledFuture scheduledFuture;
protected ScheduledExecutorService taskScheduler;
private long clientIdleTime = TimeUnit.SECONDS.toMillis(60); // 1 minutes
private long invalidateCacheInterval = TimeUnit.SECONDS.toMillis(30); // 30 seconds
private boolean shared = true;
protected final List