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.

Table 1. Behavioral Rules in LSD [9].<br />

Rule Description<br />

call(method)<br />

xcall(method)<br />

get(field)<br />

xget(field)<br />

set(field)<br />

xset(field)<br />

It must have a method call within the def ned<br />

scope.<br />

It must have a method call exclusively within<br />

the def ned scope.<br />

It must have a field state access within the<br />

def ned scope.<br />

It must have a field state access exclusively<br />

within the def ned scope.<br />

It must have a field state change within the<br />

def ned scope.<br />

It must have a field state change exclusively<br />

within the def ned scope.<br />

pect code, we can observe the xcall behavioral rule in line<br />

14. Such a rule states that the around advice of aspect Update<br />

must have a call to Display.update () method. Also, since the<br />

xcall rule starts with an ‘x’, the method Display.update ()<br />

cannot be called in other place inside the scope of the design<br />

rule interface Changed.<br />

Since a specif er using LSD can decide what to hide and<br />

reveal, in relation to specif c internal control f ow effects,<br />

we would say that LSD is also a grey box approach [3].<br />

However, LSD does not support behavioral contracts such<br />

as preconditions. This can be mitigated by incorporating<br />

JML features to LSD design rule language. It is important<br />

to note that LSD is not a standard AspectJ program. It is a<br />

good proposal to be implemented in the current AspectJ language.<br />

Therefore, currently, the authors of LSD are working<br />

towards a release for AO developers [9].<br />

Another work on these problems uses the notion of<br />

translucid contracts [1]. A translucid contract describes in<br />

a detailed way the behavior of aspects when applied to the<br />

AO interfaces. With translucid contracts, the specif er decide<br />

to hide some details, while revealing others. Translucid<br />

contracts are based on grey box specif cation approach [3].<br />

Translucid contracts are similar to XPIs (Figure 1), but<br />

instead of AspectJ, translucid contract is implemented in<br />

Ptolemy with its quantif ed typed events [10].<br />

Finally, the AO community has a plenty of techniques to<br />

reason about their programs [14, 4, 9, 1]. But the existing<br />

behavioral contracts for AO interfaces, which are AspectJbased<br />

[4, 14], are insuff ciently to advert developers about<br />

inconsistencies in AO program designs and implementations.<br />

Therefore, the AO community is lacking for an approach<br />

to def ne expressive contracts for AO programs using<br />

aspect constructs.<br />

1.3 Contributions to the State-of-the-art<br />

Then main contribution of this work is the use of standard<br />

AO constructs like those of AspectJ to enforce control<br />

f ow effects. We extend the XPI approach [4] to add<br />

more expressive contract checking properties for AO programs.<br />

Likewise XPI [4], we employ aspects to enforce AO<br />

contracts combined with grey box specif cation based approach<br />

[3] taken from LSD [9] and translucid contracts [1].<br />

To provide the grey box specif cation approach, we draw on<br />

the work of LSD. Hence, we demonstrate how to apply behavioral<br />

rules, such as xcall , using plain aspect constructs.<br />

In this paper we focus on three mechanisms to enforce<br />

contracts for AOP: (i) metadata annotations, (ii) pointcuts<br />

and (iii) advice [6]. Our goal is understand how the combination<br />

of these approaches can provide a more expressive<br />

way to check contracts for aspects than those already researched<br />

[14, 4]. We discuss some benef ts of the use of<br />

annotations as a part of our solution to promote contracts<br />

for AO programs.<br />

2 XPIs with Design Rules<br />

The key idea behind our design methodology is to introduce<br />

a design phase for each crosscutting concern. Hence,<br />

a designer establishes a crosscutting design rule interface to<br />

decouple the base and the aspect design. Such a crosscutting<br />

design rule is based on a previous work by Griswold<br />

et al. [4], the well known crosscut programming interfaces<br />

(XPIs). The main difference is that we extend XPIs with<br />

the notion of behavioral rules [9]. Hence with such behavioral<br />

rules, we enhance XPIs with a grey box specif cation<br />

capability [3]. We call our enhanced XPI as crosscut programming<br />

interface with design rule,orXPIDR.<br />

We implement XPIDRs as syntactic constructs in AspectJ.<br />

A XPIDR is composed of the following elements: (i)<br />

a name; (ii) a set of one or more abstract join points; (iii)<br />

a scope in which the abstract join points are def ned; (iv)<br />

during the system’s concern specif cation, the specif er can<br />

expose or hide specif c join points, and (v) all the exposed<br />

join points should also present their specif cations using behavioral<br />

rules and contracts.<br />

All of these elements are declared by using standard AspectJ<br />

constructs. Such elements enable one to provide an<br />

expressive interface to be respected by the base and crosscutting<br />

concern implementation of the system.<br />

2.1 The Figure Editor with XPIDRs<br />

Figure 3 illustrates the use of XPIDR, written in AspectJ,<br />

for the f gure editor example (lines 1−16). By convention,<br />

aspects that specify XPIDRs begin with an “XDR” to distinguish<br />

them from non-interface aspects. Hence, the XPIDR<br />

XDRUpdate declared in Figure 3 is the same aspect illustrated<br />

previously in Figures 1 and 2 named Changed.<br />

XPIDR comprehends simple pointcut declarations in<br />

which aspects can provide the advising code without needing<br />

to refer directly to the underlying source code (lines<br />

2−3). In addition, we can also specify properties of the underlying<br />

pointcuts in a grey box style. Thus, the specif er<br />

150

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

Saved successfully!

Ooh no, something went wrong!