@Test public void testSave() { System.out.println("save"); 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 void save(SessionData sessionData) { String sessionId = sessionData.getId(); this.sessions.updateOne( eq(SESSION_ID, sessionId), combine( set(SESSION_ID, sessionId), set(SESSION_TTL, new Date()), set(SESSION_DATA, transcoder.encode(sessionData))), new UpdateOptions().upsert(true)); }
MongoDBSessionDataStorage implements SessionDataStorage { @Override public void save(SessionData sessionData) { String sessionId = sessionData.getId(); this.sessions.updateOne( eq(SESSION_ID, sessionId), combine( set(SESSION_ID, sessionId), set(SESSION_TTL, new Date()), set(SESSION_DATA, transcoder.encode(sessionData))), new UpdateOptions().upsert(true)); } }
MongoDBSessionDataStorage implements SessionDataStorage { @Override public void save(SessionData sessionData) { String sessionId = sessionData.getId(); this.sessions.updateOne( eq(SESSION_ID, sessionId), combine( set(SESSION_ID, sessionId), set(SESSION_TTL, new Date()), set(SESSION_DATA, transcoder.encode(sessionData))), new UpdateOptions().upsert(true)); } 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 void save(SessionData sessionData) { String sessionId = sessionData.getId(); this.sessions.updateOne( eq(SESSION_ID, sessionId), combine( set(SESSION_ID, sessionId), set(SESSION_TTL, new Date()), set(SESSION_DATA, transcoder.encode(sessionData))), new UpdateOptions().upsert(true)); } 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 void save(SessionData sessionData) { String sessionId = sessionData.getId(); this.sessions.updateOne( eq(SESSION_ID, sessionId), combine( set(SESSION_ID, sessionId), set(SESSION_TTL, new Date()), set(SESSION_DATA, transcoder.encode(sessionData))), new UpdateOptions().upsert(true)); } 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);  }