Example usage for org.apache.commons.collections.map ReferenceMap ReferenceMap

List of usage examples for org.apache.commons.collections.map ReferenceMap ReferenceMap

Introduction

In this page you can find the example usage for org.apache.commons.collections.map ReferenceMap ReferenceMap.

Prototype

public ReferenceMap() 

Source Link

Document

Constructs a new ReferenceMap that will use hard references to keys and soft references to values.

Usage

From source file:lucee.runtime.db.DataSourceSupport.java

public Map<String, ProcMetaCollection> getProcedureColumnCache() {
    if (procedureColumnCache == null)
        procedureColumnCache = new ReferenceMap();
    return procedureColumnCache;
}

From source file:lucee.commons.io.res.util.ResourceClassLoader.java

public ResourceClassLoader getCustomResourceClassLoader(Resource[] resources) throws IOException {
    if (ArrayUtil.isEmpty(resources))
        return this;
    String key = hash(resources);
    ResourceClassLoader rcl = customCLs == null ? null : customCLs.get(key);
    if (rcl != null)
        return rcl;

    resources = ResourceUtil.merge(this.getResources(), resources);
    rcl = new ResourceClassLoader(resources, getParent());
    if (customCLs == null)
        customCLs = new ReferenceMap();
    customCLs.put(key, rcl);//from  w  w  w  . ja v  a 2  s  .  c  o  m
    return rcl;
}

From source file:lucee.commons.io.res.util.ResourceClassLoader.java

public ResourceClassLoader getCustomResourceClassLoader2(Resource[] resources) throws IOException {
    if (ArrayUtil.isEmpty(resources))
        return this;
    String key = hash(resources);
    ResourceClassLoader rcl = customCLs == null ? null : customCLs.get(key);
    if (rcl != null)
        return rcl;

    rcl = new ResourceClassLoader(resources, this);
    if (customCLs == null)
        customCLs = new ReferenceMap();
    customCLs.put(key, rcl);//from w  w w.  ja  v a 2  s.c  o m
    return rcl;
}

From source file:com.larvalabs.megamap.MegaMap.java

private void init(CacheManager manager, boolean persistent) throws CacheException {
    cacheQueue = new UnboundedFifoBuffer();
    softMap = new ReferenceMap();
    keySet = new HashSet();
    cache = new Cache(storeName, 1, true, true, 0L, 0L, persistent, 2147483647L);
    manager.addCache(cache);//www  . j a v a 2s . c  o m
    running = true;
    Thread thread = new Thread(this, "MegaMap-" + storeName);
    thread.setDaemon(false);
    thread.start();
}

From source file:lucee.commons.lang.PhysicalClassLoader.java

public PhysicalClassLoader getCustomClassLoader(Resource[] resources, boolean reload) throws IOException {
    if (ArrayUtil.isEmpty(resources))
        return this;
    String key = hash(resources);

    if (reload && customCLs != null)
        customCLs.remove(key);/*from ww  w . j a v  a  2s .  c o m*/

    PhysicalClassLoader pcl = customCLs == null ? null : customCLs.get(key);
    if (pcl != null)
        return pcl;
    pcl = new PhysicalClassLoader(this.getDirectory(), new ResourceClassLoader(resources, getParent()));
    if (customCLs == null)
        customCLs = new ReferenceMap();
    customCLs.put(key, pcl);
    return pcl;
}

From source file:org.apache.james.container.spring.bean.factory.mailrepositorystore.MailRepositoryStoreBeanFactory.java

@PostConstruct
@SuppressWarnings("unchecked")
public void init() throws Exception {

    getLogger().info("JamesMailStore init...");

    repositories = new ReferenceMap();
    classes = new HashMap<String, String>();
    defaultConfigs = new HashMap<String, HierarchicalConfiguration>();
    List<HierarchicalConfiguration> registeredClasses = configuration
            .configurationsAt("mailrepositories.mailrepository");
    for (HierarchicalConfiguration registeredClass : registeredClasses) {
        registerRepository(registeredClass);
    }//from  w ww .jav a  2s .  c o  m

}

From source file:org.jaffa.qm.util.PropertyFilter.java

/**
 * Fetches (or creates if it does not exist) the PropertyFilter instance for the given input.
 *///from  w w  w  .  j  a v  a 2  s.c o m
public static PropertyFilter getInstance(Class clazz, String[] rules) throws IntrospectionException {
    if (rules == null || rules.length == 0)
        rules = new String[] { "*" };
    Map<String[], PropertyFilter> m = c_propertyFilterCache.get(clazz.getName());
    if (m == null) {
        synchronized (c_propertyFilterCache) {
            m = c_propertyFilterCache.get(clazz.getName());
            if (m == null) {
                m = new ReferenceMap();
                c_propertyFilterCache.put(clazz.getName(), m);
                if (log.isInfoEnabled())
                    log.info("Created cache for " + clazz.getName());
            } else {
                if (log.isDebugEnabled())
                    log.debug("Cache found for " + clazz.getName());
            }
        }
    } else {
        if (log.isDebugEnabled())
            log.debug("Cache found for " + clazz.getName());
    }

    PropertyFilter propertyFilter = get(m, rules);
    if (propertyFilter == null) {
        synchronized (m) {
            propertyFilter = get(m, rules);
            if (propertyFilter == null) {
                propertyFilter = new PropertyFilter(clazz, rules);
                m.put(rules, propertyFilter);
                if (log.isInfoEnabled())
                    log.info("Created cache entry for " + clazz.getName() + " / " + Arrays.toString(rules));
            } else {
                if (log.isDebugEnabled())
                    log.debug("Cached entry found for " + clazz.getName() + " / " + Arrays.toString(rules));
            }
        }
    } else {
        if (log.isDebugEnabled())
            log.debug("Cached entry found for " + clazz.getName() + " / " + Arrays.toString(rules));
    }
    return propertyFilter;
}

From source file:org.jaffa.soa.dataaccess.MappingFilter.java

/**
 * Fetches (or creates if it does not exist) the MappingFilter instance for the given input.
 *//*from  w  w  w .ja  va  2 s .  co  m*/
public static MappingFilter getInstance(GraphMapping graph, String[] rules) {
    if (rules == null || rules.length == 0)
        rules = new String[] { "*" };
    Map<String[], MappingFilter> m = c_mappingFilterCache.get(graph.getDataClassName());
    if (m == null) {
        synchronized (c_mappingFilterCache) {
            m = c_mappingFilterCache.get(graph.getDataClassName());
            if (m == null) {
                m = new ReferenceMap();
                c_mappingFilterCache.put(graph.getDataClassName(), m);
                if (log.isDebugEnabled())
                    log.debug("Created cache for " + graph.getDataClassName());
            } else {
                if (log.isDebugEnabled())
                    log.debug("Cache found for " + graph.getDataClassName());
            }
        }
    } else {
        if (log.isDebugEnabled())
            log.debug("Cache found for " + graph.getDataClassName());
    }

    MappingFilter mappingFilter = get(m, rules);
    if (mappingFilter == null) {
        synchronized (m) {
            mappingFilter = get(m, rules);
            if (mappingFilter == null) {
                mappingFilter = new MappingFilter(graph, rules, false);
                m.put(rules, mappingFilter);
                if (log.isDebugEnabled())
                    log.debug("Created cache entry for " + graph.getDataClassName() + " / "
                            + Arrays.toString(rules));
            } else {
                if (log.isDebugEnabled())
                    log.debug("Cached entry found for " + graph.getDataClassName() + " / "
                            + Arrays.toString(rules));
            }
        }
    } else {
        if (log.isDebugEnabled())
            log.debug("Cached entry found for " + graph.getDataClassName() + " / " + Arrays.toString(rules));
    }
    return mappingFilter;
}

From source file:org.mule.util.queue.CachingPersistenceStrategy.java

public CachingPersistenceStrategy(QueuePersistenceStrategy ps) {
    this.ps = ps;
    this.objects = Collections.synchronizedMap(new ReferenceMap());
}

From source file:org.nuxeo.ecm.core.repository.jcr.JCRRepository.java

public JCRRepository(RepositoryDescriptor descriptor, RepositoryConfig config)
        throws IllegalAccessException, InstantiationException, RepositoryException {
    super(config);
    if (descriptor.getSecurityManagerClass() == null) {
        securityManager = new JCRSecurityManager();
    } else {/*from   www  . j  a  v  a2 s.c o m*/
        securityManager = descriptor.getSecurityManager();
    }
    sessions = new ReferenceMap();
    name = descriptor.getName();
}