Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project
This commit is contained in:
commit
68fa3c50b4
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
This is a source checkout of the Jetty webserver.
|
This is a source checkout of the Jetty webserver.
|
||||||
|
|
||||||
|
|
||||||
To build, use:
|
To build, use:
|
||||||
|
|
||||||
mvn install
|
mvn install
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
||||||
protected long _lastScavengeTime;
|
protected long _lastScavengeTime;
|
||||||
protected long _scavengeIntervalMs = 1000L * 60 * 10; //10mins
|
protected long _scavengeIntervalMs = 1000L * 60 * 10; //10mins
|
||||||
protected String _blobType; //if not set, is deduced from the type of the database at runtime
|
protected String _blobType; //if not set, is deduced from the type of the database at runtime
|
||||||
|
protected String _longType; //if not set, is deduced from the type of the database at runtime
|
||||||
|
|
||||||
protected String _createSessionIdTable;
|
protected String _createSessionIdTable;
|
||||||
protected String _createSessionTable;
|
protected String _createSessionTable;
|
||||||
|
@ -82,6 +83,13 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
||||||
protected String _deleteId;
|
protected String _deleteId;
|
||||||
protected String _queryId;
|
protected String _queryId;
|
||||||
|
|
||||||
|
protected String _insertSession;
|
||||||
|
protected String _deleteSession;
|
||||||
|
protected String _selectSession;
|
||||||
|
protected String _updateSession;
|
||||||
|
protected String _updateSessionNode;
|
||||||
|
protected String _updateSessionAccessTime;
|
||||||
|
|
||||||
protected DatabaseAdaptor _dbAdaptor;
|
protected DatabaseAdaptor _dbAdaptor;
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,6 +154,17 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
||||||
return "blob";
|
return "blob";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLongType ()
|
||||||
|
{
|
||||||
|
if (_longType != null)
|
||||||
|
return _longType;
|
||||||
|
|
||||||
|
if (_dbName.startsWith("oracle"))
|
||||||
|
return "number(20)";
|
||||||
|
|
||||||
|
return "bigint";
|
||||||
|
}
|
||||||
|
|
||||||
public InputStream getBlobInputStream (ResultSet result, String columnName)
|
public InputStream getBlobInputStream (ResultSet result, String columnName)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
|
@ -158,6 +177,18 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
||||||
Blob blob = result.getBlob(columnName);
|
Blob blob = result.getBlob(columnName);
|
||||||
return blob.getBinaryStream();
|
return blob.getBinaryStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rowId is a reserved word for Oracle, so change the name of this column
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getRowIdColumnName ()
|
||||||
|
{
|
||||||
|
if (_dbName != null && _dbName.startsWith("oracle"))
|
||||||
|
return "srowId";
|
||||||
|
|
||||||
|
return "rowId";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,6 +270,18 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
||||||
return _blobType;
|
return _blobType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getLongType()
|
||||||
|
{
|
||||||
|
return _longType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLongType(String longType)
|
||||||
|
{
|
||||||
|
this._longType = longType;
|
||||||
|
}
|
||||||
|
|
||||||
public void setScavengeInterval (long sec)
|
public void setScavengeInterval (long sec)
|
||||||
{
|
{
|
||||||
if (sec<=0)
|
if (sec<=0)
|
||||||
|
@ -528,7 +571,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
DatabaseMetaData metaData = connection.getMetaData();
|
DatabaseMetaData metaData = connection.getMetaData();
|
||||||
_dbAdaptor = new DatabaseAdaptor(metaData);
|
_dbAdaptor = new DatabaseAdaptor(metaData);
|
||||||
_sessionTableRowId = (_dbAdaptor.getDBName() != null && _dbAdaptor.getDBName().contains("oracle") ? "srowId":_sessionTableRowId);
|
_sessionTableRowId = _dbAdaptor.getRowIdColumnName();
|
||||||
|
|
||||||
//checking for table existence is case-sensitive, but table creation is not
|
//checking for table existence is case-sensitive, but table creation is not
|
||||||
String tableName = _dbAdaptor.convertIdentifier(_sessionIdTable);
|
String tableName = _dbAdaptor.convertIdentifier(_sessionIdTable);
|
||||||
|
@ -546,10 +589,11 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
||||||
{
|
{
|
||||||
//table does not exist, so create it
|
//table does not exist, so create it
|
||||||
String blobType = _dbAdaptor.getBlobType();
|
String blobType = _dbAdaptor.getBlobType();
|
||||||
|
String longType = _dbAdaptor.getLongType();
|
||||||
_createSessionTable = "create table "+_sessionTable+" ("+_sessionTableRowId+" varchar(120), sessionId varchar(120), "+
|
_createSessionTable = "create table "+_sessionTable+" ("+_sessionTableRowId+" varchar(120), sessionId varchar(120), "+
|
||||||
" contextPath varchar(60), virtualHost varchar(60), lastNode varchar(60), accessTime bigint, "+
|
" contextPath varchar(60), virtualHost varchar(60), lastNode varchar(60), accessTime "+longType+", "+
|
||||||
" lastAccessTime bigint, createTime bigint, cookieTime bigint, "+
|
" lastAccessTime "+longType+", createTime "+longType+", cookieTime "+longType+", "+
|
||||||
" lastSavedTime bigint, expiryTime bigint, map "+blobType+", primary key("+_sessionTableRowId+"))";
|
" lastSavedTime "+longType+", expiryTime "+longType+", map "+blobType+", primary key("+_sessionTableRowId+"))";
|
||||||
connection.createStatement().executeUpdate(_createSessionTable);
|
connection.createStatement().executeUpdate(_createSessionTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,6 +620,28 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
||||||
if (!index2Exists)
|
if (!index2Exists)
|
||||||
statement.executeUpdate("create index "+index2+" on "+_sessionTable+" (sessionId, contextPath)");
|
statement.executeUpdate("create index "+index2+" on "+_sessionTable+" (sessionId, contextPath)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//set up some strings representing the statements for session manipulation
|
||||||
|
_insertSession = "insert into "+_sessionTable+
|
||||||
|
" ("+_sessionTableRowId+", sessionId, contextPath, virtualHost, lastNode, accessTime, lastAccessTime, createTime, cookieTime, lastSavedTime, expiryTime, map) "+
|
||||||
|
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
_deleteSession = "delete from "+_sessionTable+
|
||||||
|
" where "+_sessionTableRowId+" = ?";
|
||||||
|
|
||||||
|
_selectSession = "select * from "+_sessionTable+
|
||||||
|
" where sessionId = ? and contextPath = ? and virtualHost = ?";
|
||||||
|
|
||||||
|
_updateSession = "update "+_sessionTable+
|
||||||
|
" set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ?, map = ? where "+_sessionTableRowId+" = ?";
|
||||||
|
|
||||||
|
_updateSessionNode = "update "+_sessionTable+
|
||||||
|
" set lastNode = ? where "+_sessionTableRowId+" = ?";
|
||||||
|
|
||||||
|
_updateSessionAccessTime = "update "+_sessionTable+
|
||||||
|
" set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ? where "+_sessionTableRowId+" = ?";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,15 +68,8 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(JDBCSessionManager.class);
|
private static final Logger LOG = Log.getLogger(JDBCSessionManager.class);
|
||||||
|
|
||||||
protected String __insertSession;
|
|
||||||
protected String __deleteSession;
|
|
||||||
protected String __selectSession;
|
|
||||||
protected String __updateSession;
|
|
||||||
protected String __updateSessionNode;
|
|
||||||
protected String __updateSessionAccessTime;
|
|
||||||
protected String __sessionTableRowId;
|
|
||||||
|
|
||||||
private ConcurrentHashMap<String, AbstractSession> _sessions;
|
private ConcurrentHashMap<String, AbstractSession> _sessions;
|
||||||
|
protected JDBCSessionIdManager _jdbcSessionIdMgr = null;
|
||||||
protected long _saveIntervalSec = 60; //only persist changes to session access times every 60 secs
|
protected long _saveIntervalSec = 60; //only persist changes to session access times every 60 secs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -603,7 +596,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
if (_sessionIdManager==null)
|
if (_sessionIdManager==null)
|
||||||
throw new IllegalStateException("No session id manager defined");
|
throw new IllegalStateException("No session id manager defined");
|
||||||
|
|
||||||
prepareTables();
|
_jdbcSessionIdMgr = (JDBCSessionIdManager)_sessionIdManager;
|
||||||
|
|
||||||
_sessions = new ConcurrentHashMap<String, AbstractSession>();
|
_sessions = new ConcurrentHashMap<String, AbstractSession>();
|
||||||
super.doStart();
|
super.doStart();
|
||||||
|
@ -816,30 +809,6 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void prepareTables ()
|
|
||||||
{
|
|
||||||
__sessionTableRowId = ((JDBCSessionIdManager)_sessionIdManager)._sessionTableRowId;
|
|
||||||
|
|
||||||
__insertSession = "insert into "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
|
||||||
" ("+__sessionTableRowId+", sessionId, contextPath, virtualHost, lastNode, accessTime, lastAccessTime, createTime, cookieTime, lastSavedTime, expiryTime, map) "+
|
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
|
||||||
|
|
||||||
__deleteSession = "delete from "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
|
||||||
" where "+__sessionTableRowId+" = ?";
|
|
||||||
|
|
||||||
__selectSession = "select * from "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
|
||||||
" where sessionId = ? and contextPath = ? and virtualHost = ?";
|
|
||||||
|
|
||||||
__updateSession = "update "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
|
||||||
" set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ?, map = ? where "+__sessionTableRowId+" = ?";
|
|
||||||
|
|
||||||
__updateSessionNode = "update "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
|
||||||
" set lastNode = ? where "+__sessionTableRowId+" = ?";
|
|
||||||
|
|
||||||
__updateSessionAccessTime = "update "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
|
||||||
" set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ? where "+__sessionTableRowId+" = ?";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a session from the database
|
* Load a session from the database
|
||||||
* @param id
|
* @param id
|
||||||
|
@ -862,7 +831,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection = getConnection();
|
connection = getConnection();
|
||||||
statement = connection.prepareStatement(__selectSession);
|
statement = connection.prepareStatement(_jdbcSessionIdMgr._selectSession);
|
||||||
statement.setString(1, id);
|
statement.setString(1, id);
|
||||||
statement.setString(2, canonicalContextPath);
|
statement.setString(2, canonicalContextPath);
|
||||||
statement.setString(3, vhost);
|
statement.setString(3, vhost);
|
||||||
|
@ -870,7 +839,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
if (result.next())
|
if (result.next())
|
||||||
{
|
{
|
||||||
data = new SessionData(id);
|
data = new SessionData(id);
|
||||||
data.setRowId(result.getString(__sessionTableRowId));
|
data.setRowId(result.getString(_jdbcSessionIdMgr._sessionTableRowId));
|
||||||
data.setCookieSet(result.getLong("cookieTime"));
|
data.setCookieSet(result.getLong("cookieTime"));
|
||||||
data.setLastAccessed(result.getLong("lastAccessTime"));
|
data.setLastAccessed(result.getLong("lastAccessTime"));
|
||||||
data.setAccessed (result.getLong("accessTime"));
|
data.setAccessed (result.getLong("accessTime"));
|
||||||
|
@ -939,7 +908,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement(__insertSession);
|
statement = connection.prepareStatement(_jdbcSessionIdMgr._insertSession);
|
||||||
statement.setString(1, rowId); //rowId
|
statement.setString(1, rowId); //rowId
|
||||||
statement.setString(2, data.getId()); //session id
|
statement.setString(2, data.getId()); //session id
|
||||||
statement.setString(3, data.getCanonicalContext()); //context path
|
statement.setString(3, data.getCanonicalContext()); //context path
|
||||||
|
@ -994,7 +963,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
{
|
{
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement(__updateSession);
|
statement = connection.prepareStatement(_jdbcSessionIdMgr._updateSession);
|
||||||
statement.setString(1, getSessionIdManager().getWorkerName());//my node id
|
statement.setString(1, getSessionIdManager().getWorkerName());//my node id
|
||||||
statement.setLong(2, data.getAccessed());//accessTime
|
statement.setLong(2, data.getAccessed());//accessTime
|
||||||
statement.setLong(3, data.getLastAccessed()); //lastAccessTime
|
statement.setLong(3, data.getLastAccessed()); //lastAccessTime
|
||||||
|
@ -1038,7 +1007,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement(__updateSessionNode);
|
statement = connection.prepareStatement(_jdbcSessionIdMgr._updateSessionNode);
|
||||||
statement.setString(1, nodeId);
|
statement.setString(1, nodeId);
|
||||||
statement.setString(2, data.getRowId());
|
statement.setString(2, data.getRowId());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
|
@ -1068,7 +1037,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
{
|
{
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement(__updateSessionAccessTime);
|
statement = connection.prepareStatement(_jdbcSessionIdMgr._updateSessionAccessTime);
|
||||||
statement.setString(1, getSessionIdManager().getWorkerName());
|
statement.setString(1, getSessionIdManager().getWorkerName());
|
||||||
statement.setLong(2, data.getAccessed());
|
statement.setLong(2, data.getAccessed());
|
||||||
statement.setLong(3, data.getLastAccessed());
|
statement.setLong(3, data.getLastAccessed());
|
||||||
|
@ -1106,7 +1075,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement(__deleteSession);
|
statement = connection.prepareStatement(_jdbcSessionIdMgr._deleteSession);
|
||||||
statement.setString(1, data.getRowId());
|
statement.setString(1, data.getRowId());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
|
|
|
@ -131,10 +131,11 @@ public abstract class AbstractClientCrossContextSessionTest
|
||||||
{
|
{
|
||||||
HttpSession session = request.getSession(false);
|
HttpSession session = request.getSession(false);
|
||||||
if (session == null)
|
if (session == null)
|
||||||
{
|
|
||||||
session = request.getSession(true);
|
session = request.getSession(true);
|
||||||
|
|
||||||
sessionId = session.getId();
|
sessionId = session.getId();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Add something to the session
|
// Add something to the session
|
||||||
session.setAttribute("B", "B");
|
session.setAttribute("B", "B");
|
||||||
|
|
Loading…
Reference in New Issue