27.03.2014 Views

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1 public privileged aspect Update {<br />

2 void aroundAdvBody( Fig fe ) {<br />

3 Display . update ();<br />

4 }<br />

5<br />

6 @AroundAdviceUpdateConcern<br />

7 @XCall("void aspects.update.Update.<br />

8 aroundAdvBody(classes.Fig)" )<br />

9 @Call("proceed(fe)")<br />

10 void around( Fig fe ) : XDRUpdate . jp ( fe ){<br />

11 proceed(fe);<br />

12 aroundAdvBody( fe );<br />

13 }<br />

14 }<br />

Figure 4. The Update aspect implementation.<br />

1 /∗ Collection internal control flow join points<br />

2 ∗ of the @UpdateConcern ∗/<br />

3 before ( UpdateConcern upc ): upcWC(upc )<br />

4 && XDRUpdate. staticxpidrscope (){<br />

5 Util . addTrace(thisJoinPoint );<br />

6 }<br />

7 /∗ Collection internal control flow join points<br />

8 ∗ of the @AroundAdviceUpdateConcern ∗/<br />

9 before ( ) : aroundAdvWC ( ) {<br />

10 Util . addTrace(thisJoinPoint );<br />

11 }<br />

Figure 5. Aspect code for tracing control flow<br />

join points.<br />

stating that such an advice must have a exclusive call (line<br />

7) to the method Update.aroundAdvBody. The latter stating<br />

that it must call the proceed method (line 9).<br />

3 Contract Enforcement Implementation<br />

In this section we describe how to implement the contract<br />

enforcement of the XPIDRs previously discussed.<br />

Due to the lack of space, secondary implementation details<br />

are discussed in our technical report available at<br />

http://www.cin.ufpe.br/˜hemr/seke12. The<br />

main points of our strategy are covered in this section.<br />

3.1 Checking Structural rules<br />

Structural rules [9] are design rules that describe constraints<br />

about classes and aspects members. Its realization<br />

is similar to Java interfaces, but additional constraints<br />

(beyond required public methods) such as required f elds<br />

or expected AspectJ inter-type declarations. By using our<br />

XPIDRs, we can force a developer to implement the required<br />

types, methods and f elds we declare. For example,<br />

in Figure 3 in line 8, we expose the method Point .setX. Until<br />

the class Point is declared we got a warning message saying<br />

that “no match for this type name”. Once the required<br />

type is declared, we got a compile-time error saying that the<br />

method “void Point .setX( int ) does not exist”. In this case<br />

the developer is forced to implement the exposed member<br />

by the XPIDR. This is an interesting feature described by<br />

LSD design rule language [9] that we can support using the<br />

AspectJ declare @ syntax (also known as supplying<br />

annotation syntax). In summary, as with LSD [9],<br />

XPIDRs enforce structural rules at compile-time.<br />

3.2 Checking Behavioral Rules and Contracts<br />

As discussed, a XPIDR interface adopts mechanisms<br />

such as behavioral rules and contracts to provide a detailed<br />

design specif cation in a grey box style [3] for program<br />

modules like classes and aspects. Before checking such design<br />

rules and contracts of the Update concern, we gather<br />

information (using a trace-based mechanism) about all the<br />

control f ow join points related to the Update concern.<br />

Figure 5 presents the two before advice (lines 1−11)used<br />

to trace all control f ow join points of the update concern.<br />

The f rst one (lines 3−6) traces all the join points that occurs<br />

within any join point marked with the Update concern annotation.<br />

The second before advice (lines 9−11) traces all the<br />

join points within the around advice, which is marked with<br />

a specif c annotation, of the aspect Update. As observed, we<br />

store each monitored join point (lines 5 and 10)byusingthe<br />

method Util .addTrace. Such a method is available as a part<br />

of the XPIDR API.<br />

4 Discussion<br />

We showed that AOP can be used to provide expressive<br />

contract checking of aspect-oriented code. The main motivation<br />

of our approach is that it does not requires any new<br />

AOP-like construct to provide contract checking of AOP<br />

code. Instead of new constructs, we reuse and combine<br />

existing features like metadata annotations, pointcuts and<br />

advice.<br />

With the grey box specif cation approach, the specif er<br />

can decide the degree in which the details are revealed.<br />

Hence, our XPIDR illustrated in Figure 3 exposes that we<br />

must have a class Point and a method setX. Also, the @Set<br />

design rule states that the method Point .setX must have a<br />

f eld state change to f eld Point .x. Suppose now that the<br />

specif er decided to keep details more hidden and still obeying<br />

the @Set design rule:<br />

declare @method: ∗ Fig+. set ∗ (..): @Set( "* Fig+.*" );<br />

This syntax abstracts the previous one by making details<br />

more hidden. However, the @Set design rule still guarantee<br />

properties of these set methods. Now, we just known that<br />

any set method declared in any type Fig must have a f eld<br />

state change to any f eld declared in type Fig.<br />

152

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!