public String getCacheKey (String id) { return _context.getCanonicalContextPath()+"_"+_context.getVhost()+"_"+id; }
public String getCacheKey( String id ) { return _context.getCanonicalContextPath() + "_" + _context.getVhost() + "_" + id; } }
@Override public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) { return new InfinispanSessionData(id, _context.getCanonicalContextPath(), _context.getVhost(), created, accessed, lastAccessed, maxInactiveMs); }
/** * @see org.eclipse.jetty.server.session.AbstractSessionDataStore#newSessionData(java.lang.String, long, long, long, long) */ @Override public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) { return new SessionData(id, _context.getCanonicalContextPath(), _context.getVhost(), created, accessed, lastAccessed, maxInactiveMs); }
private String getCanonicalContextId () { return canonicalizeVHost(_context.getVhost()) + ":" + _context.getCanonicalContextPath(); }
@Override public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) { return new NoSqlSessionData(id, _context.getCanonicalContextPath(), _context.getVhost(), created, accessed, lastAccessed, maxInactiveMs); }
/** * @see org.eclipse.jetty.server.session.SessionDataStore#newSessionData(java.lang.String, long, long, long, long) */ @Override public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) { return new SessionData(id, _context.getCanonicalContextPath(), _context.getVhost(), created, accessed, lastAccessed, maxInactiveMs); }
@Override public void initialize(SessionContext context) throws Exception { super.initialize(context); _contextString = _context.getCanonicalContextPath()+"_"+_context.getVhost(); }
/** * Make a unique key for this session. * As the same session id can be used across multiple contexts, to * make it unique, the key must be composed of: * <ol> * <li>the id</li> * <li>the context path</li> * <li>the virtual hosts</li> * </ol> * * * @param id the id * @param context the session context * @return the key */ protected Key makeKey (String id, SessionContext context) { String key = context.getCanonicalContextPath()+"_"+context.getVhost()+"_"+id; return _keyFactory.newKey(key); }
/** * @param os the output stream to save to * @param id identity of the session * @param data the info of the session * @throws IOException */ protected void save(OutputStream os, String id, SessionData data) throws IOException { DataOutputStream out = new DataOutputStream(os); out.writeUTF(id); out.writeUTF(_context.getCanonicalContextPath()); out.writeUTF(_context.getVhost()); out.writeUTF(data.getLastNode()); out.writeLong(data.getCreated()); out.writeLong(data.getAccessed()); out.writeLong(data.getLastAccessed()); out.writeLong(data.getCookieSet()); out.writeLong(data.getExpiry()); out.writeLong(data.getMaxInactiveMs()); List<String> keys = new ArrayList<String>(data.getKeys()); out.writeInt(keys.size()); ObjectOutputStream oos = new ObjectOutputStream(out); for (String name:keys) { oos.writeUTF(name); oos.writeObject(data.getAttribute(name)); } }
public PreparedStatement getLoadStatement (Connection connection, String id, SessionContext contextId) throws SQLException { if (_dbAdaptor == null) throw new IllegalStateException("No DB adaptor"); String cp = contextId.getCanonicalContextPath(); if (_dbAdaptor.isEmptyStringNull()&& StringUtil.isBlank(cp)) cp = NULL_CONTEXT_PATH; PreparedStatement statement = connection.prepareStatement("select * from "+getSchemaTableName()+ " where "+getIdColumn()+" = ? and "+getContextPathColumn()+ " = ? and "+getVirtualHostColumn()+" = ?"); statement.setString(1, id); statement.setString(2, cp); statement.setString(3, contextId.getVhost()); return statement; }
public PreparedStatement getDeleteStatement (Connection connection, String id, SessionContext contextId) throws Exception { if (_dbAdaptor == null) throw new IllegalStateException("No DB adaptor"); String cp = contextId.getCanonicalContextPath(); if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp)) cp = NULL_CONTEXT_PATH; PreparedStatement statement = connection.prepareStatement("delete from "+getSchemaTableName()+ " where "+getIdColumn()+" = ? and "+getContextPathColumn()+ " = ? and "+getVirtualHostColumn()+" = ?"); statement.setString(1, id); statement.setString(2, cp); statement.setString(3, contextId.getVhost()); return statement; }
String cp = _context.getCanonicalContextPath(); if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp)) cp = NULL_CONTEXT_PATH;
public PreparedStatement getCheckSessionExistsStatement (Connection connection, SessionContext context) throws SQLException { if (_dbAdaptor == null) throw new IllegalStateException("No DB adaptor"); String cp = context.getCanonicalContextPath(); if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp)) cp = NULL_CONTEXT_PATH; PreparedStatement statement = connection.prepareStatement("select "+getIdColumn()+", "+getExpiryTimeColumn()+ " from "+getSchemaTableName()+ " where "+getIdColumn()+" = ? and "+ getContextPathColumn()+" = ? and "+ getVirtualHostColumn()+" = ?"); statement.setString(2, cp); statement.setString(3, context.getVhost()); return statement; }
public PreparedStatement getMyExpiredSessionsStatement (Connection connection, SessionContext sessionContext, long expiry) throws SQLException { // TODO expiry should be a delay rather than an absolute time. if (_dbAdaptor == null) throw new IllegalStateException("No DB adaptor"); String cp = sessionContext.getCanonicalContextPath(); if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp)) cp = NULL_CONTEXT_PATH; PreparedStatement statement = connection.prepareStatement("select "+getIdColumn()+", "+getExpiryTimeColumn()+ " from "+getSchemaTableName()+" where "+ getLastNodeColumn()+" = ? and "+ getContextPathColumn()+" = ? and "+ getVirtualHostColumn()+" = ? and "+ getExpiryTimeColumn()+" >0 and "+getExpiryTimeColumn()+" <= ?"); statement.setString(1, sessionContext.getWorkerName()); statement.setString(2, cp); statement.setString(3, sessionContext.getVhost()); statement.setLong(4, expiry); return statement; }
public PreparedStatement getUpdateStatement (Connection connection, String id, SessionContext contextId) throws SQLException { if (_dbAdaptor == null) throw new IllegalStateException("No DB adaptor"); String cp = contextId.getCanonicalContextPath(); if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp)) cp = NULL_CONTEXT_PATH; String s = "update "+getSchemaTableName()+ " set "+getLastNodeColumn()+" = ?, "+getAccessTimeColumn()+" = ?, "+ getLastAccessTimeColumn()+" = ?, "+getLastSavedTimeColumn()+" = ?, "+getExpiryTimeColumn()+" = ?, "+ getMaxIntervalColumn()+" = ?, "+getMapColumn()+" = ? where "+getIdColumn()+" = ? and "+getContextPathColumn()+ " = ? and "+getVirtualHostColumn()+" = ?"; PreparedStatement statement = connection.prepareStatement(s); statement.setString(8, id); statement.setString(9, cp); statement.setString(10, contextId.getVhost()); return statement; }
public PreparedStatement getUpdateSessionStatement(Connection connection, String id, SessionContext context) throws SQLException { String s = "update "+getSchemaTableName()+ " set "+getLastNodeColumn()+" = ?, "+getAccessTimeColumn()+" = ?, "+ getLastAccessTimeColumn()+" = ?, "+getLastSavedTimeColumn()+" = ?, "+getExpiryTimeColumn()+" = ?, "+ getMaxIntervalColumn()+" = ?, "+getMapColumn()+" = ? where "+getIdColumn()+" = ? and "+getContextPathColumn()+ " = ? and "+getVirtualHostColumn()+" = ?"; String cp = context.getCanonicalContextPath(); if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp)) cp = NULL_CONTEXT_PATH; PreparedStatement statement = connection.prepareStatement(s); statement.setString(8, id); statement.setString(9, cp); statement.setString(10, context.getVhost()); return statement; }
data.setLastSaved(result.getLong(_sessionTableSchema.getLastSavedTimeColumn())); data.setExpiry(result.getLong(_sessionTableSchema.getExpiryTimeColumn())); data.setContextPath(_context.getCanonicalContextPath()); data.setVhost(_context.getVhost());
.setProjection(_model.getExpiry()) .setFilter(CompositeFilter.and(PropertyFilter.eq(_model.getId(), id), PropertyFilter.eq(_model.getContextPath(), _context.getCanonicalContextPath()), PropertyFilter.eq(_model.getVhost(), _context.getVhost()))) .setKind(_model.getKind()) .setFilter(CompositeFilter.and(PropertyFilter.eq(_model.getId(), id), PropertyFilter.eq(_model.getContextPath(), _context.getCanonicalContextPath()), PropertyFilter.eq(_model.getVhost(), _context.getVhost())))
data.setVersion(version); data.setExpiry(expiry); data.setContextPath(_context.getCanonicalContextPath()); data.setVhost(_context.getVhost()); data.setLastSaved(lastSaved);