Skip to content

Commit

Permalink
ATS-6 do not use sessions Map
Browse files Browse the repository at this point in the history
  • Loading branch information
madness-inc committed Dec 21, 2017
1 parent 2d16820 commit d564bb1
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@
*/
package org.appng.tomcat.session.mongo;

import java.io.IOException;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.Manager;
import org.apache.catalina.Session;
import org.apache.catalina.session.PersistentManagerBase;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;

/**
* A {@link Manager} implementation that uses a {@link MongoStore}
*/
public final class MongoPersistentManager extends PersistentManagerBase {

private static final Log log = LogFactory.getLog(MongoPersistentManager.class);

/**
* The descriptive information about this implementation.
*/
Expand Down Expand Up @@ -54,4 +62,32 @@ public MongoStore getStore() {
return (MongoStore) super.getStore();
}

@Override
public void add(Session session) {
// do nothing, we don't want to use Map<String,Session> sessions!
}

@Override
public void remove(Session session, boolean update) {
// avoid super.remove
removeSession(session.getId());
}

@Override
public Session findSession(String id) throws IOException {
// do not call super, instead load the session directly from the store
return getStore().load(id);
}

protected synchronized void startInternal() throws LifecycleException {
log.info("[" + this.getName() + "]: Starting.");
super.startInternal();
}

protected synchronized void stopInternal() throws LifecycleException {
log.info("[" + this.getName() + "]: Stopping.");
super.stopInternal();
}

}

0 comments on commit d564bb1

Please sign in to comment.