Skip to content

Commit

Permalink
Merge pull request hazelcast#3370 from mheemskerk/allow-override-of-h…
Browse files Browse the repository at this point in the history
…ttpsession

Allow WebFilter subclasses to override HazelcastHttpSession creation
  • Loading branch information
Mesut Celik committed Aug 26, 2014
2 parents 36ca1f4 + 8d836c0 commit 18cedf2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion hazelcast-wm/src/main/java/com/hazelcast/web/WebFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ protected HazelcastHttpSession createNewSession(RequestWrapper requestWrapper, S
}

HttpSession originalSession = requestWrapper.getOriginalSession(true);
HazelcastHttpSession hazelcastSession = new HazelcastHttpSession(id, originalSession, deferredWrite);
HazelcastHttpSession hazelcastSession = createHazelcastHttpSession(id, originalSession, deferredWrite);
if (existingSessionId == null) {
hazelcastSession.setClusterWideNew(true);
// If the session is being created for the first time, add its initial reference in the cluster-wide map.
Expand All @@ -318,6 +318,19 @@ protected HazelcastHttpSession createNewSession(RequestWrapper requestWrapper, S
return hazelcastSession;
}

/**
* {@code HazelcastHttpSession instance} creation is split off to a separate method to allow subclasses to return a
* customized / extended version of {@code HazelcastHttpSession}.
*
* @param id the session id
* @param originalSession the original session
* @param deferredWrite whether writes are deferred
* @return a new HazelcastHttpSession instance
*/
protected HazelcastHttpSession createHazelcastHttpSession(String id, HttpSession originalSession, boolean deferredWrite) {
return new HazelcastHttpSession(id, originalSession, deferredWrite);
}

private void prepareReloadingSession(HazelcastHttpSession hazelcastSession) {
if (deferredWrite && hazelcastSession != null) {
Map<String, LocalCacheEntry> cache = hazelcastSession.localCache;
Expand Down

0 comments on commit 18cedf2

Please sign in to comment.