Example usage for java.util Collections synchronizedMap

List of usage examples for java.util Collections synchronizedMap

Introduction

In this page you can find the example usage for java.util Collections synchronizedMap.

Prototype

public static <K, V> Map<K, V> synchronizedMap(Map<K, V> m) 

Source Link

Document

Returns a synchronized (thread-safe) map backed by the specified map.

Usage

From source file:com.thinkbiganalytics.metadata.sla.spi.core.DefaultServiceLevelAgreementChecker.java

public DefaultServiceLevelAgreementChecker() {
    this.alertedAssessments = Collections
            .synchronizedMap(new LinkedHashMap<ServiceLevelAgreement.ID, ServiceLevelAssessment.ID>());
}

From source file:org.onexus.website.api.widgets.tags.tagstore.TagStoreManager.java

public void init() {
    LOGGER.debug("Connecting to '{}' as '{}'.", database, username);

    Driver.load();/*w  w  w . j a v  a  2 s. com*/

    // Initialize the DataSource with a connection pool
    ConnectionFactory connectionFactory = new H2ConnectionFactory();
    ObjectPool connectionPool = new GenericObjectPool(null, GenericObjectPool.DEFAULT_MAX_ACTIVE,
            GenericObjectPool.WHEN_EXHAUSTED_GROW, GenericObjectPool.DEFAULT_MAX_WAIT);
    @SuppressWarnings("unused")
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
            connectionPool, null, null, false, true);
    dataSource = new PoolingDataSource(connectionPool);

    this.tagStores = Collections.synchronizedMap(new HashMap<String, TagStore>());

}

From source file:org.opencms.xml.containerpage.CmsADESessionCache.java

/**
 * Initializes the session cache.<p>
 * //from  w  w  w.  j av a  2s  . com
 * @param cms the cms context
 */
public CmsADESessionCache(CmsObject cms) {

    // container element cache
    Map<String, CmsContainerElementBean> lruMapCntElem = new HashMap<String, CmsContainerElementBean>();
    m_containerElements = Collections.synchronizedMap(lruMapCntElem);

    // ADE recent lists
    int maxElems = 10;
    maxElems = OpenCms.getADEManager().getRecentListMaxSize(cms.getRequestContext().getCurrentUser());
    List<CmsContainerElementBean> adeRecentList = CmsCollectionsGenericWrapper
            .list(new NodeCachingLinkedList(maxElems));
    m_recentLists = Collections.synchronizedList(adeRecentList);
}

From source file:fr.fg.server.core.TerritoryManager.java

private TerritoryManager() {
    this.territoriesMaps = Collections.synchronizedMap(new HashMap<Integer, ImageCache>());
    this.territoriesHash = Collections.synchronizedMap(new HashMap<String, Integer>());
}

From source file:org.jimcat.services.imagemanager.ImageManagerImpl.java

/**
 * simple constructor//from w ww  .ja va2  s  .c o m
 */
private ImageManagerImpl() {
    // create cache
    cache = Collections.synchronizedMap(new LinkedHashMap<ImageKey, ImageStore>());

    // create preloadservice
    preloadService = new PreloadService(this);

    // startup preloadservice
    Thread loader = new Thread(preloadService);
    loader.setDaemon(true);
    loader.setPriority(2);
    loader.start();
}

From source file:org.rimudb.Database.java

/**
 * Create a Database./* ww w .j a va 2  s .com*/
 * @throws RimuDBException 
 */
public Database(DatabaseConfiguration databaseConfiguration, boolean validateXML) throws RimuDBException {
    super();
    this.databaseConfiguration = databaseConfiguration;
    this.validateXML = validateXML;

    connectionManager = PoolConnectionFactory.createInstance(databaseConfiguration);

    tableDescriptorMap = Collections.synchronizedMap(new TreeMap<String, TableDescriptor>());

    tableDescriptorLoader = new TableDescriptorLoader();

}

From source file:com.onehippo.gogreen.login.HstConcurrentLoginFilter.java

@SuppressWarnings("unchecked")
public void init(FilterConfig filterConfig) throws ServletException {
    ServletContext servletContext = filterConfig.getServletContext();
    usernameHttpSessionWrapperMap = (Map<String, HttpSessionWrapper>) servletContext
            .getAttribute(USERNAME_SESSIONID_MAP_ATTR);

    if (usernameHttpSessionWrapperMap == null) {
        usernameHttpSessionWrapperMap = Collections.synchronizedMap(new HashMap<String, HttpSessionWrapper>());
        servletContext.setAttribute(USERNAME_SESSIONID_MAP_ATTR, usernameHttpSessionWrapperMap);
    }//w  w  w  . ja va 2 s .c om

    String[] disallowConcurrentLoginUsernamesArray = StringUtils
            .split(filterConfig.getInitParameter("disallowConcurrentLoginUsernames"), " ,\t\r\n");

    if (disallowConcurrentLoginUsernamesArray != null && disallowConcurrentLoginUsernamesArray.length > 0) {
        disallowConcurrentLoginUsernames = new HashSet<String>(
                Arrays.asList(disallowConcurrentLoginUsernamesArray));
    }

    log.info(
            "HstConcurrentLoginFilter's disallowConcurrentLoginUsernames: " + disallowConcurrentLoginUsernames);

    String[] allowConcurrentLoginUsernamesArray = StringUtils
            .split(filterConfig.getInitParameter("allowConcurrentLoginUsernames"), " ,\t\r\n");

    if (allowConcurrentLoginUsernamesArray != null && allowConcurrentLoginUsernamesArray.length > 0) {
        allowConcurrentLoginUsernames = new HashSet<String>(Arrays.asList(allowConcurrentLoginUsernamesArray));
    }

    earlySessionInvalidation = BooleanUtils
            .toBoolean(filterConfig.getInitParameter("earlySessionInvalidation"));

    log.info("HstConcurrentLoginFilter's allowConcurrentLoginUsernames: " + allowConcurrentLoginUsernames);
}

From source file:org.springframework.util.CachingMapDecorator.java

/**
 * Create a CachingMapDecorator with initial size,
 * using an underlying synchronized Map.
 * @param weakKeys whether to use weak references for keys
 * @param size the initial cache size//from ww w. j av  a 2 s .  c  o m
 */
public CachingMapDecorator(boolean weakKeys, int size) {
    Map internalMap = weakKeys ? (Map) new WeakHashMap(size) : new HashMap(size);
    this.targetMap = Collections.synchronizedMap(internalMap);
}

From source file:org.jboss.dashboard.scheduler.Scheduler.java

@PostConstruct
public void init() throws Exception {
    scheduledTasks = Collections.synchronizedMap(new HashMap<Object, SchedulerTask>());
    threadFactory = new SchedulerThreadFactory();
    executor = new PausableThreadPoolExecutor(maxThreadPoolSize, threadFactory);
    executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
    executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
    if (runOnStart)
        log.debug("Scheduler started [pool size=" + maxThreadPoolSize + "].");
    else/*w  ww  .ja  v a2  s.c  o  m*/
        pause();
}

From source file:org.apache.hadoop.yarn.server.timeline.security.TimelineACLsManager.java

@SuppressWarnings("unchecked")
public TimelineACLsManager(Configuration conf) {
    this.adminAclsManager = new AdminACLsManager(conf);
    aclExts = Collections.synchronizedMap(new LRUMap(DOMAIN_ACCESS_ENTRY_CACHE_SIZE));
}