Author: bstansberry(a)jboss.com
Date: 2008-11-24 02:17:06 -0500 (Mon, 24 Nov 2008)
New Revision: 7187
Modified:
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
Log:
Rearrange a bit
Modified:
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2008-11-24
07:01:36 UTC (rev 7186)
+++
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2008-11-24
07:17:06 UTC (rev 7187)
@@ -374,63 +374,6 @@
return appMetadata.granularity;
}
- private Fqn<String> getSessionFqn(String id)
- {
- return Fqn.fromRelativeElements(baseFqn, id);
- }
-
- private Session createEmptySession()
- {
- Session session = null;
- switch (appMetadata.granularity)
- {
- case SESSION:
- case ATTRIBUTE:
- session = new Session(this);
- break;
- case FIELD:
- throw new IllegalStateException("implement");
- }
- return session;
- }
-
- /**
- * JBC read of a session.
- */
- private Session loadSession(String id)
- {
- Session session = null;
-
- boolean startTx = !isBatchStarted();
- if (startTx)
- startBatch();
- Map<Object, Object> data = null;
- try
- {
- if (buddyReplication)
- {
-
cache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
- }
- data = cache.getData(getSessionFqn(id));
- }
- finally
- {
- if (startTx)
- endBatch();
- }
-
- if (data != null)
- {
- session = createEmptySession();
- AtomicInteger version = (AtomicInteger) data.get(VERSION);
- AtomicLong timestamp = (AtomicLong) data.get(TIMESTAMP);
- SessionMetadata metadata = (SessionMetadata) data.get(METADATA);
- Map<String, Object> attributes = loadSessionAttributes(id, data);
- session.update(version, timestamp, metadata, attributes);
- }
- return session;
- }
-
@SuppressWarnings("unchecked")
protected Map<String, Object> loadSessionAttributes(String id, Map<Object,
Object> sessionNodeData)
{
@@ -506,6 +449,65 @@
}
}
+ // ----------------------------------------------------------------- Private
+
+ private Fqn<String> getSessionFqn(String id)
+ {
+ return Fqn.fromRelativeElements(baseFqn, id);
+ }
+
+ private Session createEmptySession()
+ {
+ Session session = null;
+ switch (appMetadata.granularity)
+ {
+ case SESSION:
+ case ATTRIBUTE:
+ session = new Session(this);
+ break;
+ case FIELD:
+ throw new IllegalStateException("implement");
+ }
+ return session;
+ }
+
+ /**
+ * JBC read of a session.
+ */
+ private Session loadSession(String id)
+ {
+ Session session = null;
+
+ boolean startTx = !isBatchStarted();
+ if (startTx)
+ startBatch();
+ Map<Object, Object> data = null;
+ try
+ {
+ if (buddyReplication)
+ {
+
cache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
+ }
+ data = cache.getData(getSessionFqn(id));
+ }
+ finally
+ {
+ if (startTx)
+ endBatch();
+ }
+
+ if (data != null)
+ {
+ session = createEmptySession();
+ AtomicInteger version = (AtomicInteger) data.get(VERSION);
+ AtomicLong timestamp = (AtomicLong) data.get(TIMESTAMP);
+ SessionMetadata metadata = (SessionMetadata) data.get(METADATA);
+ Map<String, Object> attributes = loadSessionAttributes(id, data);
+ session.update(version, timestamp, metadata, attributes);
+ }
+ return session;
+ }
+
private boolean sessionChangedInDistributedCache(String realId, String owner, int
version)
{
Session session = sessions.get(realId);
Show replies by date