1 package ch.ethz.prose.tools; 27 28 import java.rmi.RemoteException ; 29 import java.util.List ; 30 import java.util.Vector ; 31 32 import ch.ethz.prose.Aspect; 33 import ch.ethz.prose.AspectManager; 34 import ch.ethz.prose.ProseSystem; 35 import ch.ethz.inf.util.Logger; 36 import ch.ethz.prose.query.QueryManager; 37 import ch.ethz.prose.query.AspectSurrogate; 38 39 46 public 47 class RemoteAspectManagerImpl implements RemoteAspectManager 48 { 49 50 private boolean isReal; 51 private boolean isRemote; 52 private AspectManager extMgr; 53 private QueryManager qMgr; 54 55 public RemoteAspectManagerImpl(boolean real) throws RemoteException  56 { 57 isReal = real; 58 } 59 60 public void init() throws RemoteException  61 { 62 if (extMgr==null) 63 { 64 if (isReal) 65 extMgr = ProseSystem.getAspectManager(); 66 else 67 extMgr = ProseSystem.getTestAspectManager(); 68 qMgr = new QueryManager(extMgr); 69 } 70 } 71 72 73 public void insert(Aspect ext) throws RemoteException  74 { 75 init(); 76 insert(ext,null); 77 } 78 79 public void withdraw(AspectSurrogate ext) throws RemoteException ,ClassNotFoundException  80 { 81 init(); 82 withdraw(ext,null); 83 } 84 85 public void insert(Aspect ext, Object txId) throws RemoteException  86 { 87 try 88 { 89 init(); 90 if (txId == null) 91 extMgr.insert(ext); 92 else 93 extMgr.insert(ext,txId); 94 } 95 catch (Throwable t) 96 { 97 throw new RemoteException (t.toString()); 98 } 99 } 100 101 public void withdraw(AspectSurrogate ext,Object txId) throws RemoteException ,ClassNotFoundException  102 { 103 init(); 104 Aspect asp = qMgr.reconstructAspect(ext); 105 106 List x = new Vector ((extMgr.getAllAspects())); 107 int extIndx = x.indexOf(asp); 108 if (extIndx >= 0) 109 { 110 if (txId == null) 111 { 112 extMgr.withdraw((Aspect)(x.get(extIndx))); 113 } 114 else 115 extMgr.withdraw((Aspect)(x.get(extIndx)),txId); 116 } 117 else 118 { 119 Logger.message("extension " + ext + " not known"); 120 throw new RuntimeException ( "extension " + ext + " not known"); 121 } 122 } 123 124 public void commit(Object txId) throws RemoteException  125 { 126 init(); 127 extMgr.commit(txId); 128 } 129 130 public void abort(Object txId) throws RemoteException  131 { 132 init(); 133 extMgr.abort(txId); 134 } 135 138 public List allAspects() throws RemoteException  139 { 140 init(); 141 return qMgr.queryAllAspects(); 142 } 143 144 public List allJoinpoints() throws RemoteException  145 { 146 init(); 147 return qMgr.queryAllJoinpoints(); 148 } 149 150 154 public List queryAspects(List aspectList, int selectFields, int groupBy) throws RemoteException  155 { 156 init(); 157 return qMgr.queryAspects(aspectList,selectFields,groupBy); 158 } 159 160 164 public List queryCrosscuts(List crosscutList, int selectFields, int groupBy) throws RemoteException  165 { 166 init(); 167 return qMgr.queryCrosscuts(crosscutList,selectFields,groupBy); 168 } 169 170 174 public List queryJoinpoints(List joinpointList, int selectFields, int groupBy) throws RemoteException  175 { 176 init(); 177 return qMgr.queryJoinpoints(joinpointList,selectFields,groupBy); 178 } 179 180 } 181 182 183
| Popular Tags
|