List of usage examples for com.google.common.collect MapMaker MapMaker
public MapMaker()
From source file:com.isotrol.impe3.web20.impl.TimeMap.java
private TimeMap(TimeMapConfig config, SchedulerComponent scheduler, WithTimeMapManager<M> manager) { this.maps = new MapMaker().makeMap(); this.manager = checkNotNull(manager); ImmutableSortedSet.Builder<Long> ib = ImmutableSortedSet.naturalOrder(); if (config.isGlobal()) { ib.add(Long.MAX_VALUE);// w ww . j ava 2 s .c o m this.maps.put(Long.MAX_VALUE, manager.createEmptyTimeMap()); scheduler.scheduleWithFixedDelay(new Task(null), 0L, config.getDelay(), TimeUnit.SECONDS); } for (Long seconds : config.getIntervals()) { ib.add(seconds); this.maps.put(seconds, manager.createEmptyTimeMap()); scheduler.scheduleWithFixedDelay(new Task(seconds), 0L, config.getDelay(), TimeUnit.SECONDS); } this.intervals = ib.build(); }
From source file:org.eclipse.xtext.ui.editor.DirtyStateManager.java
public DirtyStateManager() { managedResources = new MapMaker().makeMap(); }
From source file:org.waterforpeople.mapping.analytics.SubCountrySummarizer.java
public SubCountrySummarizer() { subCountryDao = new SubCountryDao(); featureDao = new OGRFeatureDao(); // use a soft map so we don't end up running out of memory countryCache = new MapMaker().softValues().softKeys().makeMap(); }
From source file:org.polymap.core.runtime.cache.GuavaCacheManager.java
protected GuavaCacheManager() { this.caches = new MapMaker().initialCapacity(256).weakValues().makeMap(); this.journaler = new Journaler(); this.journaler.start(); }
From source file:com.alibaba.otter.shared.communication.core.impl.dubbo.DubboCommunicationConnectionFactory.java
public DubboCommunicationConnectionFactory() { connections = new MapMaker().makeComputingMap(new Function<String, CommunicationEndpoint>() { public CommunicationEndpoint apply(String serviceUrl) { return proxyFactory.getProxy(protocol.refer(CommunicationEndpoint.class, URL.valueOf(serviceUrl))); }//from w ww .ja v a 2 s . c o m }); }
From source file:de.cosmocode.palava.cache.AbstractComputingCacheService.java
public AbstractComputingCacheService() { // weak value "should" remove empty queues from the map final MapMaker maker = new MapMaker().weakValues(); this.computations = maker.makeComputingMap(new Function<Serializable, Queue<ValueFuture<Object>>>() { @Override/*from w ww . jav a2 s. co m*/ public Queue<ValueFuture<Object>> apply(Serializable from) { return new ConcurrentLinkedQueue<ValueFuture<Object>>(); } }); }
From source file:com.alibaba.otter.node.etl.common.db.dialect.DbDialectFactory.java
public DbDialectFactory() { // map/*from ww w .ja v a2 s .c o m*/ GenericMapMaker mapMaker = null; mapMaker = new MapMaker().softValues() .evictionListener(new MapEvictionListener<Long, Map<DbMediaSource, DbDialect>>() { public void onEviction(Long pipelineId, Map<DbMediaSource, DbDialect> dialect) { if (dialect == null) { return; } for (DbDialect dbDialect : dialect.values()) { dbDialect.destory(); } } }); dialects = mapMaker.makeComputingMap(new Function<Long, Map<DbMediaSource, DbDialect>>() { public Map<DbMediaSource, DbDialect> apply(final Long pipelineId) { // map return new MapMaker().makeComputingMap(new Function<DbMediaSource, DbDialect>() { public DbDialect apply(final DbMediaSource source) { DataSource dataSource = dataSourceService.getDataSource(pipelineId, source); final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); return (DbDialect) jdbcTemplate.execute(new ConnectionCallback() { public Object doInConnection(Connection c) throws SQLException, DataAccessException { DatabaseMetaData meta = c.getMetaData(); String databaseName = meta.getDatabaseProductName(); int databaseMajorVersion = meta.getDatabaseMajorVersion(); int databaseMinorVersion = meta.getDatabaseMinorVersion(); DbDialect dialect = dbDialectGenerator.generate(jdbcTemplate, databaseName, databaseMajorVersion, databaseMinorVersion, source.getType()); if (dialect == null) { throw new UnsupportedOperationException("no dialect for" + databaseName); } if (logger.isInfoEnabled()) { logger.info(String.format("--- DATABASE: %s, SCHEMA: %s ---", databaseName, (dialect.getDefaultSchema() == null) ? dialect.getDefaultCatalog() : dialect.getDefaultSchema())); } return dialect; } }); } }); } }); }
From source file:com.voxelplugineering.voxelsniper.util.init.AnnotationCacheHelper.java
/** * Builds the cache for the given class. * //from w w w. j a va2 s.c om * @param target The target class */ public void build(Class<?> target) { if (this.cache.containsKey(target)) { return; } Map<Class, List<Method>> anno = new MapMaker().weakKeys().makeMap(); for (Method m : target.getMethods()) { for (Annotation a : m.getAnnotations()) { if (!anno.containsKey(a.annotationType())) { anno.put(a.annotationType(), Lists.<Method>newArrayList()); } anno.get(a.annotationType()).add(m); } } this.cache.put(target, anno); }
From source file:com.voxelplugineering.voxelsniper.registry.WeakRegistry.java
/** * Creates a new {@link WeakRegistry}.//from w ww . ja v a 2 s . c o m */ public WeakRegistry() { this.registry = new MapMaker().weakKeys().makeMap(); this.nameRegistry = new MapMaker().weakValues().makeMap(); }
From source file:org.apache.marmotta.platform.core.services.task.TaskManagerServiceImpl.java
@Inject public TaskManagerServiceImpl() { tasks = new MapMaker().makeMap(); watchdog = new ThreadWatchdog(15000); }