Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL and profiles
OCL and profiles [message #69952] Fri, 17 April 2009 17:20 Go to next message
Gisela is currently offline GiselaFriend
Messages: 1
Registered: July 2009
Junior Member
Hello, I'm trying to use OCL with a profile for Aspect Oriented Design.
Here's what I have: a stereotype of Class called Aspect, a stereotype of
Association called Pointcut and a stereotype of Operation called Advice.
My problem here is that Pointcuts can only have their source on an Aspect,
and not on a Class, and Advices can be executed only inside Aspects, not
inside Classes. I need to constrain this using OCL but can't find which
property gives me access to the source of an Association, or access to the
owner of an operation (to constrain Advice)...
If anyone could help me, that would be great!
Thanks in advance,
Regards,
Gisela.
Re: OCL and profiles [message #69971 is a reply to message #69952] Sat, 18 April 2009 19:38 Go to previous messageGo to next message
Marcellus Castro is currently offline Marcellus CastroFriend
Messages: 10
Registered: July 2009
Junior Member
Gisela

try this constraint in your pointcut stereotype

self.endType->forAll(t | let stereotype:Stereotype =
t.getApplicableStereotype('qualified name of aspect stereotype') in
t.isStereotypeApplied(stereotype))
Re: OCL and profiles [message #69991 is a reply to message #69971] Mon, 20 April 2009 13:25 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

--=-rW6ly3psIXAi1YjjIqb0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Marcellus, Gisela,

This should work in common scenarios where the profile is applied to the
root package and the end types may not be in other models (root
packages). However, the UML2 API will throw NPE in
isStereotypeApplied() if the getApplicableStereotype() call returns null
because an end type doesn't have the profile applied. Also, there would
be additional work required to account for stereotype generalization.

Another approach is to use the stereotypes like metaclasses:

context MyAOPProfile::Pointcut
inv source_is_aspect: self.endType->exists(t |
t.oclIsKindOf(uml::Class) and
t.oclAsType(Class).extension_Aspect->notEmpty())

context MyAOPProfile::Advice
inv owner_is_aspect: self.class <> null and
self.class.extension_Aspect->notEmpty()

This takes advantage of OCL's inverse navigation of associations
(including metaclass extensions) to access the applied stereotypes.

I am assuming that it is sufficient here to check that at least one end
of the <<pointcut>> association is an <<aspect>> class. The example can
be adapted for more rigorous checking of directionality of the
association and which end, in particular, is the <<aspect>>.

HTH,

Christian


On Sat, 2009-04-18 at 19:38 +0000, Marcellus Castro wrote:

> Gisela
>
> try this constraint in your pointcut stereotype
>
> self.endType->forAll(t | let stereotype:Stereotype =
> t.getApplicableStereotype('qualified name of aspect stereotype') in
> t.isStereotypeApplied(stereotype))
>

--=-rW6ly3psIXAi1YjjIqb0
Content-Type: text/html; charset="utf-8"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
Hi, Marcellus, Gisela,<BR>
<BR>
This should work in common scenarios where the profile is applied to the root package and the end types may not be in other models (root packages).&nbsp; However, the UML2 API will throw NPE in isStereotypeApplied() if the getApplicableStereotype() call returns null because an end type doesn't have the profile applied.&nbsp; Also, there would be additional work required to account for stereotype generalization.<BR>
<BR>
Another approach is to use the stereotypes like metaclasses:<BR>
<BR>
&nbsp; context MyAOPProfile::Pointcut<BR>
&nbsp; inv source_is_aspect: self.endType-&gt;exists(t |<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; t.oclIsKindOf(uml::Class) and t.oclAsType(Class).extension_Aspect-&gt;notEmpty())<BR>
<BR>
&nbsp; context MyAOPProfile::Advice<BR>
&nbsp; inv owner_is_aspect:&nbsp; self.class &lt;&gt; null and self.class.extension_Aspect-&gt;notEmpty()<BR>
<BR>
This takes advantage of OCL's inverse navigation of associations (including metaclass extensions) to access the applied stereotypes.<BR>
<BR>
I am assuming that it is sufficient here to check that at least one end of the &lt;&lt;pointcut&gt;&gt; association is an &lt;&lt;aspect&gt;&gt; class.&nbsp; The example can be adapted for more rigorous checking of directionality of the association and which end, in particular, is the &lt;&lt;aspect&gt;&gt;.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Sat, 2009-04-18 at 19:38 +0000, Marcellus Castro wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Gisela

try this constraint in your pointcut stereotype

self.endType-&gt;forAll(t | let stereotype:Stereotype =
t.getApplicableStereotype('qualified name of aspect stereotype') in
t.isStereotypeApplied(stereotype))

</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-rW6ly3psIXAi1YjjIqb0--
Previous Topic:EPL and OCL
Next Topic:Creating constraints with opaque expressions in a programmtic way
Goto Forum:
  


Current Time: Tue Apr 23 09:11:10 GMT 2024

Powered by FUDForum. Page generated in 0.03272 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top