User: jules_gosnell
Date: 02/01/13 13:30:14
Modified: jetty/src/main/org/jboss/jetty/session
CoarseDistributedStore.java
DistributedHttpSession.java
DistributedHttpSessionManager.java
Log:
a fixed watchdog ear will now deploy/undeploy happily and tests can be run:
[java] [gtest] *** 333 TEST(S) PASSED! ***
[java] [gtest] *** 9 TEST(S) FAILED! ***
Revision Changes Path
1.2 +15 -11
contrib/jetty/src/main/org/jboss/jetty/session/CoarseDistributedStore.java
Index: CoarseDistributedStore.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/session/CoarseDistributedStore.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CoarseDistributedStore.java 2002/01/13 13:26:45 1.1
+++ CoarseDistributedStore.java 2002/01/13 21:30:13 1.2
@@ -5,7 +5,7 @@
* See terms of license at gnu.org.
*/
-// $Id: CoarseDistributedStore.java,v 1.1 2002/01/13 13:26:45 jules_gosnell Exp $
+// $Id: CoarseDistributedStore.java,v 1.2 2002/01/13 21:30:13 jules_gosnell Exp $
//----------------------------------------
@@ -94,23 +94,24 @@
public AbstractHttpSessionData
get(String id)
{
+ if (_home==null)
+ return null;
+
AbstractHttpSessionData data=null;
try
{
CoarseHttpSession ejb=_home.findByPrimaryKey(id);
- data= ejb.getData();
- ejb.remove();
- ejb=null;
+
+ if (ejb!=null)
+ {
+ data= ejb.getData();
+ ejb.remove();
+ ejb=null;
+ }
}
- catch (RemoteException e)
- {}
- catch (FinderException e)
+ catch (Throwable e)
{}
- catch (RemoveException e)
- {}
- catch (Exception e)
- {}
return data;
}
@@ -124,6 +125,9 @@
public void
set(String id, AbstractHttpSessionData data)
{
+ if (_home==null)
+ return;
+
try
{
CoarseHttpSession ejb=_home.create((CoarseHttpSessionData)data);
1.2 +9 -2
contrib/jetty/src/main/org/jboss/jetty/session/DistributedHttpSession.java
Index: DistributedHttpSession.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/session/DistributedHttpSession.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DistributedHttpSession.java 2002/01/13 13:26:45 1.1
+++ DistributedHttpSession.java 2002/01/13 21:30:14 1.2
@@ -136,9 +136,16 @@
}
//----------------------------------------
+ // Scavenger thread needs this method...
- // Greg's API - where does he use it ? Should be inheriting it from
- // some interface...
+ public DistributedHttpSessionManager
+ getManager()
+ {
+ return _manager;
+ }
+
+ //----------------------------------------
+ // SessionManager API
public void
access()
1.2 +50 -21
contrib/jetty/src/main/org/jboss/jetty/session/DistributedHttpSessionManager.java
Index: DistributedHttpSessionManager.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/session/DistributedHttpSessionManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DistributedHttpSessionManager.java 2002/01/13 13:26:45 1.1
+++ DistributedHttpSessionManager.java 2002/01/13 21:30:14 1.2
@@ -5,7 +5,7 @@
* See terms of license at gnu.org.
*/
-// $Id: DistributedHttpSessionManager.java,v 1.1 2002/01/13 13:26:45 jules_gosnell
Exp $
+// $Id: DistributedHttpSessionManager.java,v 1.2 2002/01/13 21:30:14 jules_gosnell
Exp $
// TODO
@@ -41,18 +41,45 @@
//------------------------------------------------------------------------------
+class MyTimeOutNotifier
+ implements AbstractTimeOutManager.TimeOutNotifier
+{
+ public void
+ timeOut(Object object)
+ {
+ DistributedHttpSession session=(DistributedHttpSession)object;
+ // _log.info("session ("+session.getId()+") timed out - cleaning up");
+ session.getManager().destroyHttpSession(session);
+ }
+}
+
+class MyTimeOutTester
+ implements AbstractTimeOutManager.TimeOutTester
+{
+ public long
+ timeRemaining(Object object, long now, long maxInactiveInterval)
+ {
+ DistributedHttpSession session=(DistributedHttpSession)object;
+ return session.getLastAccessedTime()+ maxInactiveInterval- now;
+ }
+}
+
+//------------------------------------------------------------------------------
/**
*
- * @version $Id: DistributedHttpSessionManager.java,v 1.1 2002/01/13 13:26:45
jules_gosnell Exp $
+ * @version $Id: DistributedHttpSessionManager.java,v 1.2 2002/01/13 21:30:14
jules_gosnell Exp $
* @author [EMAIL PROTECTED]
*/
+//----------------------------------------
public class DistributedHttpSessionManager
implements org.mortbay.jetty.servlet.SessionManager
{
static AbstractStore _store =new
EJBDistributedStore(); // hardwired for the moment - TODO
+ static AbstractTimeOutManager _scavenger =new
NaiveTimeOutManager(5*1000, new MyTimeOutNotifier(), new MyTimeOutTester());
+
+ static { _scavenger.start(); }
- final AbstractTimeOutManager _scavenger =new
NaiveTimeOutManager(5*1000, new MyTimeOutNotifier());
final Logger _log;
final JBossWebApplicationContext _context;
final ServletHandler _handler;
@@ -61,23 +88,11 @@
final Map _sessions =new HashMap();
final boolean _isDistributed =true;
volatile boolean _isStarted =false; // TODO
- volatile int _dftMaxIdleSecs =-1; // negative
means never timeout...
+ volatile int _dftMaxIdleSecs =30; // negative
means never timeout...
//----------------------------------------
- class MyTimeOutNotifier
- implements AbstractTimeOutManager.TimeOutNotifier
- {
- public void
- timeOut(Object object)
- {
- destroyHttpSession((DistributedHttpSession)object);
- }
- }
-
- //----------------------------------------
-
public
DistributedHttpSessionManager(JBossWebApplicationContext context)
{
@@ -95,6 +110,8 @@
String id=getStore().nextId();
DistributedHttpSession session = new DistributedHttpSession(this, id,
_dftMaxIdleSecs);
+ // _log.info("creating DistributedHttpSession: "+session.getId()+" :
"+_dftMaxIdleSecs);
+
putSession(id,session);
notifySessionCreated(session);
getScavenger().register(session, System.currentTimeMillis(),
_dftMaxIdleSecs*1000);
@@ -116,7 +133,10 @@
{
getScavenger().deregister(session);
removeSession(session);
- session.passivate();
+ if (_store!=null)
+ session.passivate();
+
+ _log.info("passivated DistributedHttpSession: "+session.getId());
}
public HttpSession
@@ -130,10 +150,16 @@
// 2. check distributed store
if (session==null && _store!=null)
{
- session=new DistributedHttpSession(this, id, _store.get(id));
- putSession(id,session);
- notifySessionCreated(session);
- getScavenger().register(session, System.currentTimeMillis(),
session.getMaxInactiveInterval()*1000);
+ AbstractHttpSessionData data=_store.get(id);
+ if (data!=null)
+ {
+ session=new DistributedHttpSession(this, id, data);
+ putSession(id,session);
+ notifySessionCreated(session);
+ getScavenger().register(session, System.currentTimeMillis(),
session.getMaxInactiveInterval()*1000);
+
+ _log.info("activated DistributedHttpSession: "+id);
+ }
}
return session;
@@ -173,12 +199,15 @@
throws Exception
{
_isStarted=true;
+ // _scavenger.start();
+
// sessions are activated lazily...
}
public void
stop() // TODO
{
+ // _scavenger.stop();
_isStarted=false; // TODO
// tidy up all sessions...
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development