View Javadoc

1   package org.xvsm.core.aspect;
2   
3   import java.net.URI;
4   import java.util.List;
5   import java.util.Properties;
6   
7   import org.xvsm.core.ContainerRef;
8   import org.xvsm.core.Entry;
9   import org.xvsm.interfaces.ICoordinator;
10  import org.xvsm.selectors.Selector;
11  import org.xvsm.transactions.Transaction;
12  
13  /***
14   * 
15   * @author Christian Schreiber, Michael Proestler
16   * 
17   */
18  public class AspectContext {
19  
20  	/***
21  	 * The ipoint.
22  	 */
23  	private LocalIPoint localIPoint;
24  
25  	/***
26  	 * The GlovalIPoint. {@see GlobalIPoint}
27  	 */
28  	private GlobalIPoint globalIPoint;
29  
30  	/***
31  	 * indicates how often a read/write/take/destroy operation has been retried
32  	 * (0 on the first call).
33  	 */
34  	private int retrycount = 0;
35  
36  	/***
37  	 * The {@link ContainerRef}.
38  	 */
39  	private ContainerRef cref;
40  
41  	/***
42  	 * the {@link Transaction}.
43  	 */
44  	private Transaction tx;
45  
46  	/***
47  	 * The {@link Selector}s.
48  	 */
49  	private List<Selector> selectors;
50  
51  	/***
52  	 * The coordinators for newly created container.
53  	 */
54  	private ICoordinator[] coordinators;
55  
56  	/***
57  	 * The new or the read {@link Entry}s.
58  	 */
59  	private List<Entry> entries;
60  
61  	/***
62  	 * The deleted {@link Entry}s.
63  	 */
64  	private List<Entry> deleted;
65  
66  	/***
67  	 * The {@link LocalIPoint} for new aspects on Pre/PostAddAspect.
68  	 */
69  	private List<IPoint> ipoints;
70  
71  	/***
72  	 * The new aspect for Pre/PostAddAspect.
73  	 */
74  	private IAspect aspect;
75  
76  	/***
77  	 * The size of a new container.
78  	 */
79  	private int containerSize;
80  
81  	/***
82  	 * The timeout.
83  	 */
84  	private long timeout;
85  
86  	/***
87  	 * the current aspect context.
88  	 */
89  	private Properties aspectContext;
90  
91  	/***
92  	 * The uri of the aspect which shall be removed.
93  	 */
94  	private URI aspectURI;
95  
96  	/***
97  	 * Creates a new AspectContext.
98  	 * 
99  	 * @param p
100 	 *            the {@link LocalIPoint}
101 	 * @param cref
102 	 *            the {@link ContainerRef}.
103 	 * @param tx
104 	 *            the T{@link Transaction}.
105 	 * @param selectors
106 	 *            the {@link Selector}s.
107 	 * @param entries
108 	 *            the {@link Entry}s.
109 	 * @param deleted
110 	 *            the deleted {@link Entry}s.
111 	 * @param retrycount
112 	 *            the retry count.
113 	 * @param aspectContext
114 	 *            the aspect context.
115 	 */
116 	public AspectContext(IPoint p, ContainerRef cref, Transaction tx,
117 			List<Selector> selectors, List<Entry> entries, List<Entry> deleted,
118 			int retrycount, Properties aspectContext) {
119 		if (p instanceof LocalIPoint) {
120 			this.localIPoint = (LocalIPoint) p;
121 		} else {
122 			this.globalIPoint = (GlobalIPoint) p;
123 		}
124 		this.cref = cref;
125 		this.tx = tx;
126 		this.selectors = selectors;
127 		this.entries = entries;
128 		this.deleted = deleted;
129 		this.retrycount = retrycount;
130 		this.aspectContext = aspectContext;
131 	}
132 
133 	/***
134 	 * Creates a new AbstractAspect. You can use this constructor for
135 	 * [Pre|Post][Add|Remove]Aspects.
136 	 * 
137 	 * @param p
138 	 *            the {@link LocalIPoint}
139 	 * @param ipoints
140 	 *            the IPoints.
141 	 * @param aspect
142 	 *            the aspect.
143 	 * @param contextProperties
144 	 *            the properties of an AspectContext. Might be used to give
145 	 *            additional information to a custom aspect.
146 	 */
147 	public AspectContext(IPoint p, List<IPoint> ipoints, IAspect aspect,
148 			Properties contextProperties) {
149 		this(p, null, null, null, null, null, 0, contextProperties);
150 		this.ipoints = ipoints;
151 		this.aspect = aspect;
152 	}
153 
154 	/***
155 	 * Creates a new AbstractAspect. You can use this constructor for
156 	 * [Pre|Post][Remove]Aspects.
157 	 * 
158 	 * @param p
159 	 *            the {@link LocalIPoint}
160 	 * @param ipoints
161 	 *            the IPoints.
162 	 * @param aspectURI
163 	 *            the uri of the aspect
164 	 * @param contextProperties
165 	 *            the properties of an AspectContext. Might be used to give
166 	 *            additional information to a custom aspect.
167 	 */
168 	public AspectContext(IPoint p, List<IPoint> ipoints, URI aspectURI,
169 			Properties contextProperties) {
170 		this(p, null, null, null, null, null, 0, contextProperties);
171 		this.ipoints = ipoints;
172 		this.aspectURI = aspectURI;
173 	}
174 
175 	/***
176 	 * Creates a new AbstractAspect. You can use this constructor for Create and
177 	 * Destroy Container.
178 	 * 
179 	 * @param p
180 	 *            the {@link LocalIPoint}
181 	 * @param cref
182 	 *            the container ref.
183 	 * @param coordinators
184 	 *            the coordinators
185 	 * @param size
186 	 *            the size of the according container.
187 	 * @param contextProperties
188 	 *            the properties of an AspectContext. Might be used to give
189 	 *            additional information to a custom aspect.
190 	 */
191 	public AspectContext(IPoint p, ContainerRef cref,
192 			ICoordinator[] coordinators, int size, Properties contextProperties) {
193 		this(p, null, null, null, null, null, 0, contextProperties);
194 		this.cref = cref;
195 		this.coordinators = coordinators;
196 		this.containerSize = size;
197 	}
198 
199 	/***
200 	 * Creates a new AspectContext for transaction aspects.
201 	 * 
202 	 * @param p
203 	 *            the {@link LocalIPoint}
204 	 * @param tx
205 	 *            the transaction
206 	 * @param timeout
207 	 *            the timeout.
208 	 * @param contextProperties
209 	 *            the properties given by the client to give the aspect
210 	 *            additional information.
211 	 */
212 	public AspectContext(IPoint p, Transaction tx, long timeout,
213 			Properties contextProperties) {
214 		this(p, null, null, null, null, null, 0, contextProperties);
215 		this.tx = tx;
216 		this.timeout = timeout;
217 	}
218 
219 	/***
220 	 * Get the int of this AspectContext.
221 	 * 
222 	 * @return the retrycount
223 	 */
224 	public int getRetrycount() {
225 		return retrycount;
226 	}
227 
228 	/***
229 	 * Set the int of this AspectContext.
230 	 * 
231 	 * @param retrycount
232 	 *            the retrycount to set
233 	 */
234 	public void setRetrycount(int retrycount) {
235 		this.retrycount = retrycount;
236 	}
237 
238 	/***
239 	 * Get the Transaction of this AspectContext.
240 	 * 
241 	 * @return the tx
242 	 */
243 	public Transaction getTx() {
244 		return tx;
245 	}
246 
247 	/***
248 	 * Set the Transaction of this AspectContext.
249 	 * 
250 	 * @param tx
251 	 *            the tx to set
252 	 */
253 	public void setTx(Transaction tx) {
254 		this.tx = tx;
255 	}
256 
257 	/***
258 	 * Get the selectors of this AspectContext.
259 	 * 
260 	 * @return the selectors
261 	 */
262 	public List<Selector> getSelectors() {
263 		return selectors;
264 	}
265 
266 	/***
267 	 * Set the selectors of this AspectContext.
268 	 * 
269 	 * @param selectors
270 	 *            the selectors to set
271 	 */
272 	public void setSelectors(List<Selector> selectors) {
273 		this.selectors = selectors;
274 	}
275 
276 	/***
277 	 * Get the entries of this AspectContext.
278 	 * 
279 	 * @return the entries
280 	 */
281 	public List<Entry> getEntries() {
282 		return entries;
283 	}
284 
285 	/***
286 	 * Set the entries of this AspectContext.
287 	 * 
288 	 * @param entries
289 	 *            the entries to set
290 	 */
291 	public void setEntries(List<Entry> entries) {
292 		this.entries = entries;
293 	}
294 
295 	/***
296 	 * Get the deleted Entries of this AspectContext.
297 	 * 
298 	 * @return the deleted
299 	 */
300 	public List<Entry> getDeleted() {
301 		return deleted;
302 	}
303 
304 	/***
305 	 * Set the deleted Entries of this AspectContext.
306 	 * 
307 	 * @param deleted
308 	 *            the deleted to set
309 	 */
310 	public void setDeleted(List<Entry> deleted) {
311 		this.deleted = deleted;
312 	}
313 
314 	/***
315 	 * Get the ContainerRef of this AspectContext.
316 	 * 
317 	 * @return the cref
318 	 */
319 	public ContainerRef getCref() {
320 		return cref;
321 	}
322 
323 	/***
324 	 * Get the IPoints of this AspectContext.
325 	 * 
326 	 * @return the ipoint
327 	 */
328 	public LocalIPoint getLocalIPoint() {
329 		return localIPoint;
330 	}
331 
332 	/***
333 	 * Set the ipoint of this AspectContext.
334 	 * 
335 	 * @param ipoint
336 	 *            the ipoint to set
337 	 */
338 	public void setLocalIPoint(LocalIPoint ipoint) {
339 		this.localIPoint = ipoint;
340 	}
341 
342 	/***
343 	 * Get the aspect of this AspectContext.
344 	 * 
345 	 * @return the aspect
346 	 */
347 	public IAspect getAspect() {
348 		return aspect;
349 	}
350 
351 	/***
352 	 * Set the aspect of this AspectContext.
353 	 * 
354 	 * @param aspect
355 	 *            the aspect to set
356 	 */
357 	public void setAspect(IAspect aspect) {
358 		this.aspect = aspect;
359 	}
360 
361 	/***
362 	 * Get the ipoints of this AspectContext.
363 	 * 
364 	 * @return the ipoints
365 	 */
366 	public List<IPoint> getIpoints() {
367 		return ipoints;
368 	}
369 
370 	/***
371 	 * Set the ipoints of this AspectContext.
372 	 * 
373 	 * @param ipoints
374 	 *            the ipoints to set
375 	 */
376 	public void setIpoints(List<IPoint> ipoints) {
377 		this.ipoints = ipoints;
378 	}
379 
380 	/***
381 	 * Get the globalIPoint of this AspectContext.
382 	 * 
383 	 * @return the globalIPoint
384 	 */
385 	public GlobalIPoint getGlobalIPoint() {
386 		return globalIPoint;
387 	}
388 
389 	/***
390 	 * Set the globalIPoint of this AspectContext.
391 	 * 
392 	 * @param globalIPoint
393 	 *            the globalIPoint to set
394 	 */
395 	public void setGlobalIPoint(GlobalIPoint globalIPoint) {
396 		this.globalIPoint = globalIPoint;
397 	}
398 
399 	/***
400 	 * Set the cref of this AspectContext.
401 	 * 
402 	 * @param cref
403 	 *            the cref to set
404 	 */
405 	public void setCref(ContainerRef cref) {
406 		this.cref = cref;
407 	}
408 
409 	/***
410 	 * Get the coordinators of this AspectContext.
411 	 * 
412 	 * @return the coordinators
413 	 */
414 	public ICoordinator[] getCoordinators() {
415 		return coordinators;
416 	}
417 
418 	/***
419 	 * Set the coordinators of this AspectContext.
420 	 * 
421 	 * @param coordinators
422 	 *            the coordinators to set
423 	 */
424 	public void setCoordinators(ICoordinator[] coordinators) {
425 		this.coordinators = coordinators;
426 	}
427 
428 	/***
429 	 * Get the containerSize of this AspectContext.
430 	 * 
431 	 * @return the containerSize
432 	 */
433 	public int getContainerSize() {
434 		return containerSize;
435 	}
436 
437 	/***
438 	 * Set the containerSize of this AspectContext.
439 	 * 
440 	 * @param containerSize
441 	 *            the containerSize to set
442 	 */
443 	public void setContainerSize(int containerSize) {
444 		this.containerSize = containerSize;
445 	}
446 
447 	/***
448 	 * Get the timeout of this AspectContext.
449 	 * 
450 	 * @return the timeout
451 	 */
452 	public long getTimeout() {
453 		return timeout;
454 	}
455 
456 	/***
457 	 * Set the timeout of this AspectContext.
458 	 * 
459 	 * @param timeout
460 	 *            the timeout to set
461 	 */
462 	public void setTimeout(long timeout) {
463 		this.timeout = timeout;
464 	}
465 
466 	/***
467 	 * @return the aspectContext
468 	 */
469 	public Properties getAspectContext() {
470 		return aspectContext;
471 	}
472 
473 	/***
474 	 * @param aspectContext
475 	 *            the aspectContext to set
476 	 */
477 	public void setAspectContext(Properties aspectContext) {
478 		this.aspectContext = aspectContext;
479 	}
480 
481 	/***
482 	 * @return the aspectURI
483 	 */
484 	public URI getAspectURI() {
485 		return aspectURI;
486 	}
487 
488 	/***
489 	 * @param aspectURI
490 	 *            the aspectURI to set
491 	 */
492 	public void setAspectURI(URI aspectURI) {
493 		this.aspectURI = aspectURI;
494 	}
495 
496 }