public void testPackUnpack() throws Exception { ISerializableSession session1, session2; session1 = factory.create("session1"); session1.setAttribute("foo", "foo value"); session1.setAttribute("bar", 22222); byte[] raw = factory.pack(session1); session2 = factory.unpack(raw); assertNotNull(session2); assertEquals(session1.getId(), session2.getId()); assertEquals(session1.getCreationTime(), session2.getCreationTime()); assertEquals(session1.getAttributeMap(), session2.getAttributeMap()); } }
public boolean equals(ISerializableSession other) { System.out.println("this=" + this + ", other=" + other); boolean result = other != null; result = result && this.getCreationTime() == other.getCreationTime(); result = result && this.getAccessed() == other.getAccessed(); result = result && this.getInvalidated() == other.getInvalidated(); result = result && this.getVersion() == other.getVersion(); if (result) { if (this.getId() == null) { result = result && other.getId() == null; } else { result = result && this.getId().equals(other.getId()); result = result && other.getDomain() == null; } else { result = result && this.getDomain().equals(other.getDomain()); result = result && other.getPath() == null; } else { result = result && this.getPath().equals(other.getPath()); result = result && other.getAttributeMap() == null; } else { result = result && this.getAttributeMap().equals(other.getAttributeMap());
boolean valid = data.isValid(); if (!valid) if (!clusterId.equals(data.getId())) log.warn("loadSession: invalid id (expected:" + clusterId + ", got:" + data.getId() + ")"); return null; if (_cookieDomain != null && !data.getDomain().equals("*") && !_cookieDomain.equals(data.getDomain())) log.warn("loadSession: invalid cookie domain (expected:" + _cookieDomain + ", got:" + data.getDomain() + ")"); return null; if (_cookiePath != null && !data.getPath().equals("*") && !_cookiePath.equals(data.getPath())) log.warn("loadSession: invalid cookie path (expected:" + _cookiePath + ", got:" + data.getPath() + ")"); return null; long version = data.getVersion(); long created = data.getCreationTime(); long accessed = data.getAccessed(); SmarterNoSqlSession session = new SmarterNoSqlSession(this, created, accessed, clusterId, version); Enumeration<String> attrs = data.getAttributeNames(); Object value = data.getAttribute(name);
if (data != null) saved = data.getVersion(); boolean valid = data.isValid(); if (!valid) try for (Enumeration<String> e = data.getAttributeNames(); e.hasMoreElements();) Object value = data.getAttribute(name); if (!data.getAttributeMap().containsKey(name))
public ISerializableSession create(AbstractSession session) { synchronized(session) { ISerializableSession s = create(session.getId(), session.getCreationTime(), session.getAccessed()); if (session.isValid()) { for (String key: session.getNames()) { s.setAttribute(key, session.getAttribute(key)); } } else { // we do not need to retrieve attributes of invalidated sessions since // they have been cleared on AbstractSession.invalidate(). s.setValid(false); } return s; } }
public void testPackUnpack() throws Exception { ISerializableSession session1, session2; session1 = factory.create("session1"); session1.setAttribute("foo", "foo value"); session1.setAttribute("bar", 22222); byte[] raw = factory.pack(session1); session2 = factory.unpack(raw); assertNotNull(session2); assertEquals(session1.getId(), session2.getId()); assertEquals(session1.getCreationTime(), session2.getCreationTime()); assertEquals(session1.getAttributeMap(), session2.getAttributeMap()); } }