public SessionI(boolean reusedSession, Ice.Current current, ServantHolder holder, Glacier2.SessionControlPrx control, OmeroContext context, SessionManager sessionManager, Executor executor, Principal principal, String token) throws ApiUsageException { this.clientId = clientId(current); this.adapter = current.adapter; this.control = control; this.sessionManager = sessionManager; this.context = context; this.executor = executor; this.principal = principal; this.token = token; this.reusedSession = new AtomicBoolean(reusedSession); // Setting up in memory store. Ehcache cache = sessionManager.inMemoryCache(principal.getName()); String key = "servantHolder"; this.holder = holder; if (!cache.isKeyInCache(key)) { cache.put(new Element(key, holder)); } else { // Check that SessionManagerI has given us the same instance. ServantHolder oldHolder = (ServantHolder) cache.get(key).getObjectValue(); assert oldHolder == holder; } }