@Override public int getTotalSize() { return this.getCacheSize(); }
@Override public Cache<K, V> createCache(IdentifierFactory<K> identifierFactory, StatefulObjectFactory<V> factory, PassivationListener<V> passivationListener) { return new SimpleCache<>(factory, identifierFactory, this.timeout, this.environment.get(), this.executor.get()); } }
@Override public void release(V bean) { K id = bean.getId(); Entry<V> entry = this.entries.get(id); if ((entry != null) && entry.done()) { if (this.timeout != null) { long value = this.timeout.getValue(); if (value > 0) { TimeUnit unit = this.timeout.getTimeUnit(); RemoveTask task = new RemoveTask(id); // Make sure the expiration future map insertion happens before map removal (during task execution). synchronized (task) { this.expirationFutures.put(id, this.executor.schedule(task, value, unit)); } } else if (value == 0) { // The EJB specification allows a 0 timeout, which means the bean is immediately eligible for removal. // However, removing it directly is faster than scheduling it for immediate removal. remove(id); } } } }