1 24 package org.objectweb.jalisto.se.impl.server.page.info; 25 26 import org.objectweb.jalisto.se.impl.server.page.info.InMemoryPageInfo; 27 28 import java.util.ArrayList ; 29 import java.util.HashMap ; 30 import java.util.Map ; 31 32 public class InMemoryPageInfoMulti extends InMemoryPageInfo { 33 34 protected InMemoryPageInfoMulti(ArrayList sessionIds, PageInfo pageInfo) { 35 super(pageInfo); 36 transactionnalImage = new HashMap (); 37 if (sessionIds != null) { 38 for (int i = 0; i < sessionIds.size(); i++) { 39 begin(sessionIds.get(i)); 40 } 41 } 42 } 43 44 public void getAFreeSpace(Object sessionId) { 45 freeSpaceSize--; 46 Integer i = (Integer ) transactionnalImage.get(sessionId); 47 transactionnalImage.put(sessionId, new Integer (i.intValue() + 1)); 48 } 49 50 public void freeASpace(Object sessionId) { 51 freeSpaceSize++; 52 Integer i = (Integer ) transactionnalImage.get(sessionId); 53 transactionnalImage.put(sessionId, new Integer (i.intValue() - 1)); 54 } 55 56 public void begin(Object sessionId) { 57 transactionnalImage.put(sessionId, new Integer (0)); 58 } 59 60 public boolean rollback(Object sessionId) { 61 int i = ((Integer ) transactionnalImage.get(sessionId)).intValue(); 62 if (i < 0) { 63 return false; 64 } 65 if (i != 0) { 67 transactionnalImage.put(sessionId, new Integer (0)); 69 } 70 return true; 71 } 72 73 private Map transactionnalImage; 74 } 75 | Popular Tags |