328306 JDBC Session Manager uses ContextHandler.handle(Runnable) to load contexts
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2387 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
786f0d2299
commit
e5df5d82ee
|
@ -29,6 +29,8 @@ import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Exchanger;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSessionEvent;
|
import javax.servlet.http.HttpSessionEvent;
|
||||||
|
@ -834,14 +836,21 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
* @return the session data that was loaded
|
* @return the session data that was loaded
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected SessionData loadSession (String id, String canonicalContextPath, String vhost)
|
protected SessionData loadSession (final String id, final String canonicalContextPath, final String vhost)
|
||||||
throws Exception
|
throws Exception
|
||||||
|
{
|
||||||
|
final AtomicReference<SessionData> reference = new AtomicReference<SessionData>();
|
||||||
|
final AtomicReference<Exception> exception = new AtomicReference<Exception>();
|
||||||
|
Runnable load = new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
{
|
{
|
||||||
SessionData data = null;
|
SessionData data = null;
|
||||||
Connection connection = getConnection();
|
Connection connection=null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
connection = getConnection();
|
||||||
statement = connection.prepareStatement(__selectSession);
|
statement = connection.prepareStatement(__selectSession);
|
||||||
statement.setString(1, id);
|
statement.setString(1, id);
|
||||||
statement.setString(2, canonicalContextPath);
|
statement.setString(2, canonicalContextPath);
|
||||||
|
@ -870,14 +879,30 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
if (Log.isDebugEnabled())
|
if (Log.isDebugEnabled())
|
||||||
Log.debug("LOADED session "+data);
|
Log.debug("LOADED session "+data);
|
||||||
}
|
}
|
||||||
return data;
|
reference.set(data);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
exception.set(e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (connection!=null)
|
if (connection!=null)
|
||||||
connection.close();
|
{
|
||||||
|
try { connection.close();}
|
||||||
|
catch(Exception e) { Log.warn(e); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_context==null)
|
||||||
|
load.run();
|
||||||
|
else
|
||||||
|
_context.getContextHandler().handle(load);
|
||||||
|
|
||||||
|
return reference.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a session into the database.
|
* Insert a session into the database.
|
||||||
|
|
Loading…
Reference in New Issue