KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > emn > info > eaop > aspect > Aspect


1 /* ----------------------------------------------------------------------------
2  * EAOP 1.0, 2002-12-19
3  * (c) 2002 Remi Douence, Mario Sudholt; OBASCO group; EMN/INRIA; France
4  * THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY
5   -------------------------------------------------------------------------- */

6
7 package fr.emn.info.eaop.aspect;
8
9 import fr.emn.info.eaop.Monitor;
10 import fr.emn.info.eaop.event.*;
11
12 import java.util.*;
13 import java.lang.reflect.*;
14 import java.io.*;
15
16
17 /**
18  * This class implements the basic notion of a simple aspect (i.e., non
19  * composed aspects).
20  *
21  * @author RD
22  * @version 1.0
23  */

24
25 public abstract class Aspect extends Coroutining {
26
27     public boolean isRunning;
28     public String JavaDoc name = this.getClass().toString();
29
30     public Aspect() {
31     this(null);
32     }
33
34     public Aspect(AspectS up) {
35     super(up);
36     }
37
38     public void run() {
39     Event.names.push(this.name);
40     super.run();
41     }
42
43     /**
44      * Return the next event if it is available, or block if it is
45      * not available. This method is also responsible for pushing on
46      * the monitor stack the identity of the currently running
47      * aspect. The identity of the aspect is based on the name of the
48      * class. isCrosscuting is false by default, and isRunning is
49      * true between two calls to block.
50      */

51     public Event nextEvent() {
52     Event.names.pop();
53     this.isRunning = false;
54     this.block();
55     this.isRunning = true;
56     Event.names.push(this.name);
57     this.isCrosscutting = false;
58     return this.currentEvent();
59     }
60
61     /**
62      * return the current event
63      */

64     public Event currentEvent() {
65     return Monitor.monitor.currentEvent();
66     }
67
68     /**
69      * this method is called by the caller (monitor or aspect) in
70      * order to resume the current aspect (this)
71      */

72     public void go() {
73     if (! this.isRunning) {
74         super.go();
75     }
76     }
77
78     /**
79      * Insert an aspect locally in the tree of aspects. Default tree
80      * dynamic restructuration defined for node only (Root and
81      * BinaryAspectS). The user can program more sophisitcated
82      * restructuration of the tree.
83      */

84     public void insert(AspectS a) {
85     this.up.insert(this, a);
86     }
87
88     /**
89      * This method inserts an aspect in the aspects tree. Default
90      * behavior defined in the class Aspect inserts the aspect
91      * locally. should be abstract
92      */

93     public void insert(AspectS child, AspectS newAspect) {
94     System.out.println("AspectS.insert(AspectS,AspectS) abstract method never to be called");
95     System.exit(0);
96     }
97 }
98
Popular Tags