OCL and profiles [message #69952] |
Fri, 17 April 2009 13:20  |
Eclipse User |
|
|
|
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 #69991 is a reply to message #69971] |
Mon, 20 April 2009 09:25  |
Eclipse User |
|
|
|
--=-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). 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.<BR>
<BR>
Another approach is to use the stereotypes like metaclasses:<BR>
<BR>
context MyAOPProfile::Pointcut<BR>
inv source_is_aspect: self.endType->exists(t |<BR>
t.oclIsKindOf(uml::Class) and t.oclAsType(Class).extension_Aspect->notEmpty())<BR>
<BR>
context MyAOPProfile::Advice<BR>
inv owner_is_aspect: self.class <> null and self.class.extension_Aspect->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 <<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>>.<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->forAll(t | let stereotype:Stereotype =
t.getApplicableStereotype('qualified name of aspect stereotype') in
t.isStereotypeApplied(stereotype))
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-rW6ly3psIXAi1YjjIqb0--
|
|
|
Powered by
FUDForum. Page generated in 0.03605 seconds