User: jules_gosnell
Date: 02/01/21 13:58:13
Modified: jetty/src/main/org/jboss/jetty/session ClusteredStore.java
Added: jetty/src/main/org/jboss/jetty/session
ClusteredHttpSessionData.java
Log:
split out and publicise data object
move MBean use into an MBeanProxy instance - much easier
Revision Changes Path
1.4 +16 -241
contrib/jetty/src/main/org/jboss/jetty/session/ClusteredStore.java
Index: ClusteredStore.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/session/ClusteredStore.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ClusteredStore.java 2002/01/19 00:49:50 1.3
+++ ClusteredStore.java 2002/01/21 21:58:13 1.4
@@ -5,198 +5,21 @@
* See terms of license at gnu.org.
*/
-// $Id: ClusteredStore.java,v 1.3 2002/01/19 00:49:50 jules_gosnell Exp $
+// $Id: ClusteredStore.java,v 1.4 2002/01/21 21:58:13 jules_gosnell Exp $
//----------------------------------------
package org.jboss.jetty.session;
//----------------------------------------
-
-import org.jboss.logging.Logger;
-import java.util.Map;
-import javax.naming.InitialContext;
-import java.net.InetAddress;
-
+import org.jboss.util.MBeanProxy;
import javax.management.*;
-import java.util.List;
-
-import org.jboss.ha.httpsession.interfaces.SerializableHttpSession;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpSessionContext;
-import java.util.Enumeration;
+import javax.naming.InitialContext;
+import org.jboss.logging.Logger;
+import org.jboss.ha.httpsession.server.ClusteredHTTPSessionServiceMBean;
//----------------------------------------
-
-
-class
- ClusteredHttpSessionData
- implements AbstractHttpSessionData, SerializableHttpSession
-{
- String _id;
- long _creationTime;
- long _lastAccessedTime;
- int _maxInactiveInterval;
- Map _attributes;
- boolean _attributesWerePassivated;
-
- // from javax.servlet.http.HttpSession
- public long
- getCreationTime()
- {
- return _creationTime;
- }
-
- public String
- getId()
- {
- return _id;
- }
-
- public long
- getLastAccessedTime()
- {
- return _lastAccessedTime;
- }
-
- public int
- getMaxInactiveInterval()
- {
- return _maxInactiveInterval;
- }
-
- public void
- setMaxInactiveInterval(int maxInactiveInterval)
- {
- _maxInactiveInterval=_maxInactiveInterval;
- }
-
- // extra accessors
- public Map
- getAttributes()
- {
- return _attributes;
- }
-
- public void
- setAttributes(Map attributes)
- {
- _attributes=attributes;
- }
-
- public void
- setId(String id)
- {
- _id=id;
- }
-
- public void
- setCreationTime(long creationTime)
- {
- _creationTime=creationTime;
- }
-
- public void
- setLastAccessedTime(long lastAccessedTime)
- {
- _lastAccessedTime=lastAccessedTime;
- }
-
- // extra attributes
- public boolean
- getAttributesWerePassivated()
- {
- return _attributesWerePassivated;
- }
-
- public void
- setAttributesWerePassivated(boolean attributesWerePassivated)
- {
- _attributesWerePassivated=attributesWerePassivated;
- }
-
- // extras that I don't want/need...
-
- public ServletContext
- getServletContext()
- {
- return null;
- }
-
- public HttpSessionContext
- getSessionContext()
- {
- return null;
- }
-
- public Object
- getAttribute(String name)
- throws IllegalStateException
- {
- return null;
- }
-
- public Enumeration
- getAttributeNames()
- throws IllegalStateException
- {
- return null;
- }
-
- public void
- setAttribute(String name, Object value)
- throws IllegalStateException
- {}
-
- public void
- removeAttribute(String name)
- throws IllegalStateException
- {}
- public Object
- getValue(String name)
- throws IllegalStateException
- {
- return getAttribute(name);
- }
-
- public String[]
- getValueNames()
- throws IllegalStateException
- {
- return null;
- }
-
- public void
- putValue(String name, Object value)
- throws IllegalStateException
- {}
-
- public void
- removeValue(String name)
- throws IllegalStateException
- {}
-
- public void
- invalidate()
- throws IllegalStateException
- {}
-
- public boolean
- isNew()
- throws IllegalStateException
- {
- return false;
- }
-
- // Sacha's API
- public boolean
- areAttributesModified(SerializableHttpSession s)
- {
- return true;
- }
-}
-
+// it would be nice to do this with a JMXProxy... - TODO
/**
* An abstraction of a manager for the distributed store of HttpSessions
*
@@ -211,6 +34,7 @@
final Logger _log =Logger.getLogger(getClass().getName());
MBeanServer _server=null;
ObjectName _name =null;
+ ClusteredHTTPSessionServiceMBean _proxy;
public
ClusteredStore()
@@ -220,6 +44,8 @@
{
_server=(MBeanServer)MBeanServerFactory.findMBeanServer(null).iterator().next();
_name =new ObjectName("jboss", "service", "ClusteredHttpSession");
+ _proxy=(ClusteredHTTPSessionServiceMBean)
+ MBeanProxy.create(ClusteredHTTPSessionServiceMBean.class, _name);
}
catch (Exception e)
{
@@ -230,23 +56,7 @@
public String
nextId()
{
- String id=null;
- try
- {
- Object tmp=_server.invoke(_name, // name
- "getSessionId", // operation
- new Object[] {}, // params
- new String[] {} // signature
- );
- id=(String)tmp;
- _log.info("next session id "+id);
- }
- catch (Exception e)
- {
- _log.error("could not get next session id ", e);
- }
-
- return id;
+ return _proxy.getSessionId();
}
public AbstractHttpSessionData
@@ -259,21 +69,10 @@
public AbstractHttpSessionData
get(String id, boolean delete)
{
- AbstractHttpSessionData data=null;
- try
- {
- Object tmp=_server.invoke(_name, // name
- "getHttpSession", // operation
- new Object[] { id }, // params
- new String[] { id.getClass().getName() } // signature
- );
- data=(AbstractHttpSessionData)tmp;
- _log.info("retrieve ClusteredHttpSession "+id);
- }
- catch (Exception e)
- {
- _log.error("could not retrieve ClusteredHttpSession "+id, e);
- }
+ AbstractHttpSessionData
data=(AbstractHttpSessionData)_proxy.getHttpSession(id);
+
+ if (delete)
+ _proxy.removeHttpSession(id);
return data;
}
@@ -281,37 +80,13 @@
public void
put(String id, AbstractHttpSessionData data)
{
- try
- {
- Object tmp=_server.invoke(_name, // name
- "setHttpSession", // operation
- new Object[] { id, data }, // params
- new String[] { id.getClass().getName(),
"org.jboss.ha.httpsession.interfaces.SerializableHttpSession" } // signature
- );
- _log.info("saved ClusteredHttpSession "+id);
- }
- catch (Exception e)
- {
- _log.error("could not save ClusteredHttpSession "+id, e);
- }
+ _proxy.setHttpSession(id, (ClusteredHttpSessionData)data);
}
public void
remove(String id)
{
- try
- {
- Object tmp=_server.invoke(_name, // name
- "removeHttpSession", // operation
- new Object[] { id }, // params
- new String[] { id.getClass().getName() } // signature
- );
- _log.info("removed ClusteredHttpSession "+id);
- }
- catch (Exception e)
- {
- _log.error("could not remove ClusteredHttpSession "+id, e);
- }
+ _proxy.removeHttpSession(id);
}
public boolean
1.1
contrib/jetty/src/main/org/jboss/jetty/session/ClusteredHttpSessionData.java
Index: ClusteredHttpSessionData.java
===================================================================
/*
* jBoss, the OpenSource EJB server
*
* Distributable under GPL license.
* See terms of license at gnu.org.
*/
// $Id: ClusteredHttpSessionData.java,v 1.1 2002/01/21 21:58:13 jules_gosnell Exp $
//----------------------------------------
package org.jboss.jetty.session;
//----------------------------------------
import java.util.Enumeration;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionContext;
import org.jboss.ha.httpsession.interfaces.SerializableHttpSession;
//----------------------------------------
public class
ClusteredHttpSessionData
implements AbstractHttpSessionData, SerializableHttpSession
{
String _id;
long _creationTime;
long _lastAccessedTime;
int _maxInactiveInterval;
Map _attributes;
boolean _attributesWerePassivated;
public
ClusteredHttpSessionData()
{}
// from javax.servlet.http.HttpSession
public long
getCreationTime()
{
return _creationTime;
}
public String
getId()
{
return _id;
}
public long
getLastAccessedTime()
{
return _lastAccessedTime;
}
public int
getMaxInactiveInterval()
{
return _maxInactiveInterval;
}
public void
setMaxInactiveInterval(int maxInactiveInterval)
{
_maxInactiveInterval=_maxInactiveInterval;
}
// extra accessors
public Map
getAttributes()
{
return _attributes;
}
public void
setAttributes(Map attributes)
{
_attributes=attributes;
}
public void
setId(String id)
{
_id=id;
}
public void
setCreationTime(long creationTime)
{
_creationTime=creationTime;
}
public void
setLastAccessedTime(long lastAccessedTime)
{
_lastAccessedTime=lastAccessedTime;
}
// extra attributes
public boolean
getAttributesWerePassivated()
{
return _attributesWerePassivated;
}
public void
setAttributesWerePassivated(boolean attributesWerePassivated)
{
_attributesWerePassivated=attributesWerePassivated;
}
// extras that I don't want/need...
public ServletContext
getServletContext()
{
return null;
}
public HttpSessionContext
getSessionContext()
{
return null;
}
public Object
getAttribute(String name)
throws IllegalStateException
{
return null;
}
public Enumeration
getAttributeNames()
throws IllegalStateException
{
return null;
}
public void
setAttribute(String name, Object value)
throws IllegalStateException
{}
public void
removeAttribute(String name)
throws IllegalStateException
{}
public Object
getValue(String name)
throws IllegalStateException
{
return getAttribute(name);
}
public String[]
getValueNames()
throws IllegalStateException
{
return null;
}
public void
putValue(String name, Object value)
throws IllegalStateException
{}
public void
removeValue(String name)
throws IllegalStateException
{}
public void
invalidate()
throws IllegalStateException
{}
public boolean
isNew()
throws IllegalStateException
{
return false;
}
// Sacha's API
public boolean
areAttributesModified(SerializableHttpSession s)
{
return true;
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development