Ok i'll explain you:
First of all i have a table in postgresql called "tomcat_sessions" like this:
Code:
CREATE TABLE tomcat_sessions (
id character varying(100) NOT NULL,
"valid" character varying(1),
max_inactive integer,
last_access bigint,
session_data bytea,
app_name character varying
);
--
-- Definition for index tomcat_sessions_pkey (OID = 21012) :
--
ALTER TABLE ONLY tomcat_sessions
ADD CONSTRAINT tomcat_sessions_pkey PRIMARY KEY (id);
COMMENT ON SCHEMA public IS 'Standard public schema';
Then, I let tomcat manage http sessions with this code into
context.xmlCode:
.....
<Manager
className="org.apache.catalina.session.PersistentManager"
debug="0"
saveOnRestart="true"
maxActiveSessions="-1"
minIdleSwap="30"
maxIdleSwap="600"
maxIdleBackup="0">
<Store className="org.apache.catalina.session.JDBCStore"
driverName="org.postgresql.Driver"
connectionURL="jdbc:postgresql://newintranet/intranet_fnac?user=sessionMGR"
sessionTable="tomcat_sessions"
sessionAppCol="app_name"
sessionDataCol="session_data"
sessionIdCol="id"
sessionLastAccessedCol="last_access"
sessionMaxInactiveCol="max_inactive"
sessionValidCol="valid"
debug="1" />
</Manager>
.....
With this code tomcat inserts into postgresql table sessions that are created, update sessions that had changed its state and delete sessions when are invalidated.
Field, in which i am interested (session_data), is where tomcat insert session's attribute Objects, which is bytea type. And here is my necessity:
- You know now that session_data field is actually Http Session Attributes, so i want to make inversed process. I want to generate Object Data from field in order to extract data like this form:
session.getAttribute("something");.
This method is implemented in order to make a Cluster, so each web application have their own Hibernate SessionFactory but Http sessions are shared between two, three, four servers. So if one of tomcat servers goes down, another one will get this session and this session user wouldn't be invalidated.
Thanks a lot.