KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > tools > RemoteAspectManagerImpl


1 //
2
// This file is part of the midas package.
3
//
4
// The contents of this file are subject to the Mozilla Public License
5
// Version 1.1 (the "License"); you may not use this file except in
6
// compliance with the License. You may obtain a copy of the License at
7
// http://www.mozilla.org/MPL/
8
//
9
// Software distributed under the License is distributed on an "AS IS" basis,
10
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
// for the specific language governing rights and limitations under the
12
// License.
13
//
14
// The Original Code is midas.
15
//
16
// The Initial Developer of the Original Code is Andrei Popovici. Portions
17
// created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
18
// All Rights Reserved.
19
//
20
// Contributor(s):
21
// $Id: RemoteAspectManagerImpl.java,v 1.2 2003/08/26 19:55:01 anicoara Exp $
22
// =====================================================================
23
//
24
// (history at end)
25
//
26
package ch.ethz.prose.tools;
27
28 import java.rmi.RemoteException JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.Vector JavaDoc;
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 /** Class <code>RemoteAspectManagerImpl</code> a simple implementation for the
40  * <code>RemoteAspectManager</code> prose instance.
41  *
42  * <code>RemoteAspectManagerImpl</code> DOES NOT export the created objects;
43  * @version $Revision: 1.2 $
44  * @author Andrei Popovici
45  */

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 JavaDoc
56   {
57       isReal = real;
58   }
59     
60   public void init() throws RemoteException JavaDoc
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   /** Insert an extension into the underlying <code>ProseSystem</code>. */
73   public void insert(Aspect ext) throws RemoteException JavaDoc
74   {
75       init();
76       insert(ext,null);
77   }
78
79   public void withdraw(AspectSurrogate ext) throws RemoteException JavaDoc,ClassNotFoundException JavaDoc
80   {
81       init();
82       withdraw(ext,null);
83   }
84
85   public void insert(Aspect ext, Object JavaDoc txId) throws RemoteException JavaDoc
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 JavaDoc t)
96       {
97           throw new RemoteException JavaDoc(t.toString());
98       }
99   }
100
101   public void withdraw(AspectSurrogate ext,Object JavaDoc txId) throws RemoteException JavaDoc,ClassNotFoundException JavaDoc
102   {
103       init();
104       Aspect asp = qMgr.reconstructAspect(ext);
105
106       List JavaDoc x = new Vector JavaDoc((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 JavaDoc( "extension " + ext + " not known");
121       }
122   }
123
124     public void commit(Object JavaDoc txId) throws RemoteException JavaDoc
125     {
126         init();
127         extMgr.commit(txId);
128     }
129
130     public void abort(Object JavaDoc txId) throws RemoteException JavaDoc
131     {
132         init();
133         extMgr.abort(txId);
134     }
135     /**
136      * Return a list of the current inserted extensions.
137      */

138     public List JavaDoc allAspects() throws RemoteException JavaDoc
139     {
140         init();
141         return qMgr.queryAllAspects();
142     }
143
144     public List JavaDoc allJoinpoints() throws RemoteException JavaDoc
145     {
146         init();
147         return qMgr.queryAllJoinpoints();
148     }
149
150     /**
151      * Return a List of Tupel objects (without duplicates) that represents the result of querying the system
152      * with a list of Aspects.
153      */

154     public List JavaDoc queryAspects(List JavaDoc aspectList, int selectFields, int groupBy) throws RemoteException JavaDoc
155     {
156         init();
157         return qMgr.queryAspects(aspectList,selectFields,groupBy);
158     }
159
160     /**
161      * Return a List of Tupel objects (without duplicates) that represents the result of querying the system
162      * with a list of Crosscuts.
163      */

164     public List JavaDoc queryCrosscuts(List JavaDoc crosscutList, int selectFields, int groupBy) throws RemoteException JavaDoc
165     {
166         init();
167         return qMgr.queryCrosscuts(crosscutList,selectFields,groupBy);
168     }
169
170   /**
171    * Return a List of Tupel objects (without duplicates) that represents the result of querying the system
172    * with a list of JoinPointRequests.
173    */

174   public List JavaDoc queryJoinpoints(List JavaDoc joinpointList, int selectFields, int groupBy) throws RemoteException JavaDoc
175   {
176       init();
177       return qMgr.queryJoinpoints(joinpointList,selectFields,groupBy);
178   }
179
180 }
181
182
183 //======================================================================
184
//
185
// $Log: RemoteAspectManagerImpl.java,v $
186
// Revision 1.2 2003/08/26 19:55:01 anicoara
187
// Bug fix: JVM1.4.1 blocks (add the init method)
188
//
189
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
190
// Imported from ETH Zurich
191
//
192
// Revision 1.1 2003/05/25 13:25:17 popovici
193
// Refactoring
194
// inf.iks.tools is now prose.tools
195
// Stupid 'MyTableModel' renamed to 'WorksheetClientMode'
196
// - other renamings from bad names to reasonable names
197
//
198
// Revision 1.8 2003/05/25 11:48:51 popovici
199
// Major transformation of the prose tools:
200
// - GUI now stable and supports aspect insertion from another classpath than its own
201
// - CommandlineProseClient supports transactions test managers, independent classpath and has a better errhanling
202
//
203
// Revision 1.7 2003/05/20 16:05:00 popovici
204
//
205
// New QueryManager replaces functionality in AspectManager (better Soc)
206
// New 'Surrogate' classes for usage in the QueryManager
207
// The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
208
//
209
// Revision 1.6 2003/05/05 14:03:13 popovici
210
// renaming from runes to prose
211
//
212
// Revision 1.5 2003/04/17 15:14:56 popovici
213
// Extension->Aspect renaming
214
//
215
// Revision 1.4 2003/04/17 12:49:45 popovici
216
// Refactoring of the crosscut package
217
// ExceptionCut renamed to ThrowCut
218
// McutSignature is now SignaturePattern
219
//
220
// Revision 1.3 2003/04/17 08:47:06 popovici
221
// Important functionality additions
222
// - Cflow specializers
223
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
224
// - Transactional capabilities
225
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
226
// between static and dynamic specializers.
227
// - Functionality pulled up in abstract classes
228
// - Uniformization of advice methods patterns and names
229
//
230
// Revision 1.2 2003/03/04 18:35:57 popovici
231
// Organization of imprts
232
//
233
// Revision 1.1 2003/02/17 09:23:53 popovici
234
// RemoteAspectManager interface, implementation, and client added;
235
// Benchmark changed to work with the remote aspect manager;
236
// Benchmark changed to include aspect insertion;
237
//
238
// Revision 1.2 2002/07/25 08:55:39 popovici
239
// Mozilla Licensing
240
//
241
// Revision 1.1.1.1 2001/11/30 14:50:28 popovici
242
// Sources from runes
243
//
244
// Revision 1.1.2.1 2001/03/26 15:05:43 mrmuller
245
// adapted to new package structure
246
//
247
// Revision 1.1.2.4 2001/02/20 10:13:14 popovici
248
// -Bug fix: 'withdrawExtnesion' now matches specified extension against
249
// existing ones, thus complying to the new 'ProseSystem' specs.
250
// -'insertExtensions' throws on 'AspectManagerException'
251
//
252
// Revision 1.1.2.3 2001/02/15 15:20:08 popovici
253
// Removed some messages to stderr.
254
//
255
// Revision 1.1.2.2 2001/02/15 11:40:57 popovici
256
// Documentation Improvements
257
//
258
// Revision 1.1.2.1 2001/02/14 13:44:40 popovici
259
// Initial Revision
260
//
261
// Revision 1.1.2.2 2001/01/23 09:28:08 popovici
262
// extensions() now returns a set of Exensions
263
//
264
// Revision 1.1.2.1 2000/10/24 17:45:54 popovici
265
// 'addExtension' renamed to 'insertExtension'
266
// 'removeExtension' renamed to 'withdrawExtension'
267
// method 'extensions' added
268
//
269
// Revision 1.1 2000/10/16 11:53:25 popovici
270
// Initial Revision
271
//
272
Popular Tags