Cleanup Generics

Fixes #3
This commit is contained in:
Rob Winch
2014-06-30 16:43:02 -05:00
parent 0ab9385eeb
commit f28a6fea1f
3 changed files with 11 additions and 11 deletions

View File

@@ -39,7 +39,7 @@ public interface SessionRepository<S extends Session> {
* @param id the {@link org.springframework.session.Session#getId()} to lookup
* @return the {@link Session} by the {@link Session#getId()} or null if no {@link Session} is found.
*/
Session getSession(String id);
S getSession(String id);
/**
* Deletes the {@link Session} with the given {@link Session#getId()} or does nothing if the {@link Session} is not found.

View File

@@ -61,7 +61,7 @@ public class RedisOperationsSessionRepository implements SessionRepository<Redis
}
@Override
public Session getSession(String id) {
public RedisSession getSession(String id) {
Map<Object, Object> entries = getOperations(id).entries();
if(entries.isEmpty()) {
return null;

View File

@@ -53,12 +53,12 @@ import java.util.Set;
*
* @author Rob Winch
*/
public class SessionRepositoryFilter extends OncePerRequestFilter {
private final SessionRepository<Session> sessionRepository;
public class SessionRepositoryFilter<S extends Session> extends OncePerRequestFilter {
private final SessionRepository<S> sessionRepository;
private HttpSessionStrategy httpSessionStrategy = new CookieHttpSessionStrategy();
public SessionRepositoryFilter(SessionRepository sessionRepository) {
public SessionRepositoryFilter(SessionRepository<S> sessionRepository) {
this.sessionRepository = sessionRepository;
}
@@ -82,7 +82,7 @@ public class SessionRepositoryFilter extends OncePerRequestFilter {
}
}
private static final class SessionRepositoryResponseWrapper extends OnCommittedResponseWrapper {
private final class SessionRepositoryResponseWrapper extends OnCommittedResponseWrapper {
private final SessionRepositoryRequestWrapper request;
@@ -124,7 +124,7 @@ public class SessionRepositoryFilter extends OncePerRequestFilter {
httpSessionStrategy.onInvalidateSession(this, response);
}
} else {
Session session = wrappedSession.session;
S session = wrappedSession.session;
sessionRepository.save(session);
httpSessionStrategy.onNewSession(session, this, response);
}
@@ -141,7 +141,7 @@ public class SessionRepositoryFilter extends OncePerRequestFilter {
}
String requestedSessionId = getRequestedSessionId();
if(requestedSessionId != null) {
Session session = sessionRepository.getSession(requestedSessionId);
S session = sessionRepository.getSession(requestedSessionId);
if(session != null) {
this.requestedValidSession = true;
session.setLastAccessedTime(System.currentTimeMillis());
@@ -153,7 +153,7 @@ public class SessionRepositoryFilter extends OncePerRequestFilter {
if(!create) {
return null;
}
Session session = sessionRepository.createSession();
S session = sessionRepository.createSession();
currentSession = new HttpSessionWrapper(session, getServletContext());
return currentSession;
}
@@ -169,12 +169,12 @@ public class SessionRepositoryFilter extends OncePerRequestFilter {
}
private final class HttpSessionWrapper implements HttpSession {
final Session session;
final S session;
private final ServletContext servletContext;
private boolean invalidated;
private boolean old;
public HttpSessionWrapper(Session session, ServletContext servletContext) {
public HttpSessionWrapper(S session, ServletContext servletContext) {
this.session = session;
this.servletContext = servletContext;
}