List of usage examples for com.google.common.collect MapMaker MapMaker
public MapMaker()
From source file:eu.interedition.text.rdbms.RelationalNameRepository.java
private void initCache() { nameCache = new MapMaker().maximumSize(cacheSize).makeMap(); if (jt.queryForInt("select count(*) from text_qname") <= cacheSize) { // warm-up cache for (RelationalName name : jt.query("select " + selectNameFrom("n") + " from text_qname n", ROW_MAPPER)) {//from w w w .j av a 2s. c om nameCache.put(name, name.getId()); } } }
From source file:org.sakaiproject.tool.impl.RebuildBreakdownServiceImpl.java
public void init() { log.info("INIT: session clustering=" + isSessionClusteringEnabled()); if (isSessionClusteringEnabled()) { sessionCache = memoryService.newCache("org.sakaiproject.tool.impl.RebuildBreakdownService.cache"); stashingCache = memoryService.newCache("org.sakaiproject.tool.impl.RebuildBreakdownService.stash"); sessionClassWhitelist = new HashSet<String>(4); // number should match items count below sessionClassWhitelist.add(Locale.class.getName()); sessionClassWhitelist.add("org.sakaiproject.event.api.SimpleEvent"); sessionClassWhitelist.add("org.sakaiproject.authz.api.SimpleRole"); sessionClassWhitelist.add("org.apache.commons.lang.mutable.MutableLong"); sessionAttributeBlacklist = new HashSet<String>(6); // number should match items count below sessionAttributeBlacklist.add(SESSION_LAST_BREAKDOWN_KEY); sessionAttributeBlacklist.add(SESSION_LAST_REBUILD_KEY); /* from BasePreferencesService.ATTR_PREFERENCE_IS_NULL * This controls whether the session cached version of prefs is reloaded or assumed to be populated, * when it is true the processing assumes it is populated (very weird logic and dual-caching) *//* w ww. ja va 2 s . co m*/ sessionAttributeBlacklist.add("attr_preference_is_null"); /* from BasePreferencesService.ATTR_PREFERENCE * rebuild this manually on demand from the cache instead of storing it */ sessionAttributeBlacklist.add("attr_preference"); /** should be re-detected on rebuild of the session */ sessionAttributeBlacklist.add("is_mobile_device"); /** this is normally only set on login, we handle it specially on breakdown and rebuild */ sessionAttributeBlacklist.add(UsageSessionService.USAGE_SESSION_KEY); } /* Create a map with weak references to the values */ breakdownableHandlers = new MapMaker().weakValues().makeMap(); }
From source file:com.galeoconsulting.leonardinius.servlet.ScriptRunnerSessionServlet.java
private Map<String, Object> makeContext() { return new MapMaker().makeMap(); }
From source file:com.ardor3d.scenegraph.Spatial.java
/** * Sets the render delegate./*ww w. j a v a 2 s . com*/ * * @param delegate * the new delegate, or null for default behavior * @param glContextRef * if null, the delegate is set as the default render delegate for this spatial. Otherwise, the delegate * is used when this Spatial is rendered in a RenderContext tied to the given glContextRef. */ public void setRenderDelegate(final RenderDelegate delegate, final Object glContextRef) { if (_delegateMap == null) { if (delegate == null) { return; } else { _delegateMap = new MapMaker().weakKeys().makeMap(); } } if (delegate != null) { if (glContextRef == null) { _delegateMap.put(defaultDelegateRef, delegate); } else { _delegateMap.put(glContextRef, delegate); } } else { if (glContextRef == null) { _delegateMap.remove(defaultDelegateRef); } else { _delegateMap.remove(glContextRef); } if (_delegateMap.isEmpty()) { _delegateMap = null; } } }
From source file:com.stackframe.symbolfactory.SymbolRepository.java
public Map<String, String> getCodeDescriptions() { return new MapMaker().makeComputingMap(new Function<String, String>() { public String apply(String code) { return SIDCParser.getDescription(code); }// www . j a va 2 s . co m }); }
From source file:org.jclouds.aws.ec2.compute.config.EC2ComputeServiceDependenciesModule.java
@Provides @Singleton/*from ww w. j a va 2 s . c o m*/ protected Map<RegionAndName, Image> provideImageMap(RegionAndIdToImage regionAndIdToImage) { return new MapMaker().makeComputingMap(regionAndIdToImage); }
From source file:org.apache.s4.core.ProcessingElement.java
protected ProcessingElement() { OverloadDispatcherGenerator oldg = new OverloadDispatcherGenerator(this.getClass()); Class<?> overloadDispatcherClass = oldg.generate(); try {/*from www.j a va2 s .com*/ overloadDispatcher = (OverloadDispatcher) overloadDispatcherClass.newInstance(); } catch (Exception e) { throw new RuntimeException(e); } peInstances = CacheBuilder.newBuilder().build(new CacheLoader<String, ProcessingElement>() { @Override public ProcessingElement load(String key) throws Exception { return createPE(key); } }); turnPE = 0; triggers = new MapMaker().makeMap(); // replications = new HashMap<Class<? extends ProcessingElement>, // Integer>(); /* * Only the PE Prototype uses the constructor. The PEPrototype field * will be cloned by the instances and point to the prototype. */ this.pePrototype = this; }
From source file:org.apache.flex.compiler.internal.workspaces.Workspace.java
/** * Constructor/*from www.j ava 2 s . co m*/ * * @param es {@link ExecutorService} to use to do background work in this * workspace. */ public Workspace(ExecutorService es) { executorService = es; profilingDelegate = null; invalidationListeners = new LinkedHashSet<IInvalidationListener>(); swcManager = new SWCManager(this); mxmlDataManager = new MXMLDataManager(); projects = new MapMaker().weakKeys().makeMap(); pathToFileSpecMap = new HashMap<String, IFileSpecification>(); pathToCompilationUnitMapping = new StringToCompilationUnitMap(); includeFilesToIncludingCompilationUnitMapping = new StringToCompilationUnitMap(); packageNamespaceDefinitionCache = new PackageNamespaceDefinitionCache(); embedDataCache = new WeakHashMap<EmbedData, EmbedData>(); embedLock = new ReentrantReadWriteLock(); invisibleCompilationUnitReferenceQueue = new FinalizableReferenceQueue(); asDocDelegate = NilASDocDelegate.get(); buildSync = new BuildSynchronizationState(); }
From source file:org.opencms.jsp.util.CmsJspStandardContextBean.java
/** * Returns a map which allows access to dynamic function beans using the JSP EL.<p> * /*w w w . ja v a2s .c o m*/ * When given a key, the returned map will look up the corresponding dynamic function in the module configuration.<p> * * @return a map which allows access to dynamic function beans */ public Object getFunction() { if (m_function != null) { return m_function; } MapMaker mm = new MapMaker(); m_function = mm.makeComputingMap(new Function<String, Object>() { public Object apply(String key) { try { CmsDynamicFunctionBean dynamicFunction = readDynamicFunctionBean(key); CmsDynamicFunctionBeanWrapper wrapper = new CmsDynamicFunctionBeanWrapper(m_cms, dynamicFunction); return wrapper; } catch (CmsException e) { return new CmsDynamicFunctionBeanWrapper(m_cms, null); } } }); return m_function; }
From source file:ome.services.sessions.state.SessionCache.java
public SessionCache() { final MapMaker mapMaker = new MapMaker(); sessions = mapMaker.makeMap(); sessionCallbackMap = mapMaker.makeMap(); }