@Test public void testGet() { System.out.println("get"); MongoDBSessionDataStorage instance = new MongoDBSessionDataStorage(mongoClient.getDatabase(DATABASE_NAME)); SessionData sessionData = instance.create(); String sessionId = sessionData.getId(); sessionData.put(KEY, VALUE); instance.save(sessionData); SessionData saved = instance.get(sessionId); assertEquals(sessionData, saved); String value1 = sessionData.get(KEY); String value2 = saved.get(KEY); assertEquals(value1, value2); }
@Override public SessionData get(String sessionId) { Document doc = this.sessions .find(eq(SESSION_ID, sessionId)) .projection(include(SESSION_DATA)) .first(); if (doc == null) { return null; } String sessionStored = doc.getString(SESSION_DATA); SessionData sessionData = transcoder.decode(sessionStored); return sessionData; }
MongoDBSessionDataStorage implements SessionDataStorage { @Override public SessionData get(String sessionId) { Document doc = this.sessions .find(eq(SESSION_ID, sessionId)) .projection(include(SESSION_DATA)) .first(); if (doc == null) { return null; } String sessionStored = doc.getString(SESSION_DATA); SessionData sessionData = transcoder.decode(sessionStored); return sessionData; } }
MongoDBSessionDataStorage implements SessionDataStorage { @Override public SessionData get(String sessionId) { Document doc = this.sessions .find(eq(SESSION_ID, sessionId)) .projection(include(SESSION_DATA)) .first(); if (doc == null) { return null; } String sessionStored = doc.getString(SESSION_DATA); SessionData sessionData = transcoder.decode(sessionStored); return sessionData; } MongoDBSessionDataStorage(MongoDatabase database);  MongoDBSessionDataStorage(MongoDatabase database, int idleTime);  MongoDBSessionDataStorage(MongoDatabase database, String collection);  MongoDBSessionDataStorage(MongoDatabase database, String collection, long idleTime, SessionDataTranscoder transcoder); }
MongoDBSessionDataStorage implements SessionDataStorage { @Override public SessionData get(String sessionId) { Document doc = this.sessions .find(eq(SESSION_ID, sessionId)) .projection(include(SESSION_DATA)) .first(); if (doc == null) { return null; } String sessionStored = doc.getString(SESSION_DATA); SessionData sessionData = transcoder.decode(sessionStored); return sessionData; } MongoDBSessionDataStorage(MongoDatabase database);  MongoDBSessionDataStorage(MongoDatabase database, int idleTime);  MongoDBSessionDataStorage(MongoDatabase database, String collection);  MongoDBSessionDataStorage(MongoDatabase database, String collection, long idleTime, SessionDataTranscoder transcoder); @Override SessionData create(); @Override void save(SessionData sessionData); @Override SessionData get(String sessionId); @Override void delete(String sessionId); }
MongoDBSessionDataStorage implements SessionDataStorage { @Override public SessionData get(String sessionId) { Document doc = this.sessions .find(eq(SESSION_ID, sessionId)) .projection(include(SESSION_DATA)) .first(); if (doc == null) { return null; } String sessionStored = doc.getString(SESSION_DATA); SessionData sessionData = transcoder.decode(sessionStored); return sessionData; } MongoDBSessionDataStorage(MongoDatabase database);  MongoDBSessionDataStorage(MongoDatabase database, int idleTime);  MongoDBSessionDataStorage(MongoDatabase database, String collection);  MongoDBSessionDataStorage(MongoDatabase database, String collection, long idleTime, SessionDataTranscoder transcoder); @Override SessionData create(); @Override void save(SessionData sessionData); @Override SessionData get(String sessionId); @Override void delete(String sessionId);  }