1 24 package org.objectweb.speedo.j2eedo.bo; 25 26 import java.util.ArrayList ; 27 import java.util.Vector ; 28 29 import javax.transaction.Synchronization ; 30 31 50 public class PollsSynchronizations implements Synchronization { 51 private ArrayList pools; 52 private ArrayList actionADDLists; 53 private ArrayList actionREMLists; 54 private boolean processed; 55 56 61 public void beforeCompletion() { 62 } 64 65 71 public void afterCompletion(int arg0) { 72 if (this.processed) 74 return; 75 this.processed = true; 76 if (0 == this.pools.size()) 78 return; 79 for (int i = 0; i < this.pools.size(); i++) { 80 if (0 != ((Vector ) this.actionADDLists.get(i)).size() 82 || 0 != ((Vector ) this.actionREMLists.get(i)).size()) { 83 for (int j = 0; 84 j < ((Vector ) this.actionADDLists.get(i)).size(); 85 j++) { 86 ((Vector ) this.pools.get(i)).add( 87 ((Vector ) this.actionADDLists.get(i)).get(j)); 88 } 89 for (int j = 0; 90 j < ((Vector ) this.actionREMLists.get(i)).size(); 91 j++) { 92 ((Vector ) this.pools.get(i)).remove( 93 ((Vector ) this.actionREMLists.get(i)).get(j)); 94 } 95 } 96 } 97 } 98 99 104 public void addInPool(Vector pool, long id) { 105 int i = 0; 106 for (i = 0; i < this.pools.size(); i++) { 108 if (pool == (Vector ) (this.pools.get(i))) 109 break; 110 } 111 if (i == this.pools.size()) { 113 this.pools.add(pool); 114 this.actionADDLists.add(new Vector ()); 115 this.actionREMLists.add(new Vector ()); 116 } 117 118 if (!((Vector ) this.actionADDLists.get(i)).contains(new Long (id))) 119 ((Vector ) this.actionADDLists.get(i)).add(new Long (id)); 120 } 121 122 127 public void removeFromPool(Vector pool, long id) { 128 int i = -1; 129 for (i = 0; i < this.pools.size(); i++) { 131 if (pool == (Vector ) (this.pools.get(i))) 132 break; 133 } 134 if (i == this.pools.size()) { 136 this.pools.add(pool); 137 this.actionADDLists.add(new Vector ()); 138 this.actionREMLists.add(new Vector ()); 139 } 140 141 if (!((Vector ) this.actionREMLists.get(i)).contains(new Long (id))) 142 ((Vector ) this.actionREMLists.get(i)).add(new Long (id)); 143 } 144 145 153 public PollsSynchronizations() { 154 super(); 155 this.pools = new ArrayList (); 156 this.actionADDLists = new ArrayList (); 157 this.actionREMLists = new ArrayList (); 158 this.processed = false; 159 } 160 } 161 | Popular Tags |