o   Johan's really cool and impressive Home Page  
   /  \
     
  Home   
  Links  /
@ Research
@
  Personal  \
     
 o   Research Topics  
   /  \
     
  Thesis   
  Papers  /
@ acc
@
  FJacc  \
     
 
o      Download  ( (  Examples  ) (  Impl   Pitfalls    
Aspectual Collaborations  
   /  \
 
   Get all these examples by downloading acc from the download page.

The simplest collaboration is a package; java packages are trivially collaborations. As such, we have a very simple collaboration:

block variables not found
To this we want to add getters and setters. So first we define a getters and setters collaboration.
block adviceSetGetAttribute not found
Notice the collaboration and participant keywords; these indicate that we are writing something which can be more than a plain package. This is evidenced by the expected attribute.

Collaborations can have holes in their implementations; these holes are like abstract features, in that they are deferred definition, but unlike abstract features in that they do not inhibit instantiation of the class.

The above example defines a collaboration that, when given an instance variable definition, will define a getter and a setter for it. The type of the instance variable is not know of course, so we declare another participant to represent it. The limited keyword allows the type AttributeType to be mapped to external classes (like java.lang.String) as well - this because it prohibits the participant from defining any features. Because this participant doesn't even require (expect) any features from whatever host class it is mapped to, it can also be mapped to primitive types like int -- it is effectively a pure type variable.

block adviceSetGetFoo not found
We can compose the collaboration an the original package to add getters and setters. To do this for the foo variable, we would use the collaboration adviceSetGetFoo. This creates a new collaboration which extends variables and attaches adviceSetGetAttribute.

The participant HasAttribute is mapped to Vars. This means that all references to Vars (for example the variable Baz.var) will be replaced by HasAttribute. The mapping also indicates that set and get should be inserted into HasAttribute (although they will not be visible to the outside world until we export them.) By specifying that foo should provide the expected aName, we provide the link necessary for the inserted getters and setters to access the variable they will be working on.

block addAllSettersGetters not found
block counter not found
block usecounter not found
block fancyusecounter not found
block countedGetSet not found
  
   \  /
   \  /
   \  /
printable johan@ccs.neu.edu  http://www.ccs.neu.edu/home/johan/research/acc/examples.html  (c)2000-2003