Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » GMT (Generative Modeling Technologies) » [MOFScript] Aspect extension
[MOFScript] Aspect extension [message #383960] Thu, 17 July 2008 18:09 Go to next message
Anderson Ledo is currently offline Anderson LedoFriend
Messages: 13
Registered: July 2009
Junior Member
Hi,

I'm trying to use the aspect extension of MOFScript, but the examples I
found in the User Guide v0.6 are not so clear.

Could anyone provide a more clear, or concrete, example of the use of
aspects in MOFScript?

Thanks in advance !


Anderson Ledo
Campina Grande, Brazil
Re: [MOFScript] Aspect extension [message #384264 is a reply to message #383960] Wed, 23 July 2008 05:08 Go to previous messageGo to next message
Jon Oldevik is currently offline Jon OldevikFriend
Messages: 17
Registered: July 2009
Junior Member
Hi,

as a warning: the aspect feature in MOFScript was developed as an
experimental feature; it has really not been thoroughly tested. However, it
has been used on some minor case studies, but it has not been tested on
latest releases.

I will give a brief overview here. The aspect concept in MOFScript works
similarly to aspects in AspectJ.

As shown in the documentation/Eclipse help, an aspect is defined by the
'aspect' keyword - an aspect in MOFScript is a special kind (a subtype of) a
text transformation. It may contain pointcuts and advices, but also standard
MOFScript transformation rules.

The pointcut can be either of type 'call' or 'execute'. If it is of type
call, code is attempted inserted at 'call-to-transformation-rule'. If it is
of type 'execute', code is inserted at the location of the targeted
transformation rule.

The pointcut further may define the context type of the target
transformation rule:

pointcut myVeryOwnPointcut (Property) execute ("get.*")

This pointcut will apply to all rules with a context type "Property" that
starts with 'get'. The syntax for the match criteria is according to Java
regular expressions (--- which is different from what you will find in e.g.
AspectJ --- look at the doc for Java SDK for details)

An advice defines the transformation code to be inserted at the joinpoints
defined by the referenced pointcut.

Example:
before myVeryOwnPointcut {
stdout.println ("This was generated by my aspect...")
}

The advice may be defined as an 'after', 'before', or 'around' type. The
before type inserts the advice code before other transformation code at the
location(s) defined by the pointcut. Similarly for 'after'. Around replaces
transformation code.


Below is a simple example that illustrates... However, while testing this
now on the latest MOFScript release, I see that there is a malfunction in
the aspect transformation somewhere that need fixing. You probably will not
get this working without that fix. (I will have that looked at ASAP).

Best regards,
Jon Oldevik


aspect JavaAspect {

pointcut classPrivateAttributeCall(Class) execute
("classPrivateAttribute");

pointcut propertyGetterCall call ("propertyGetter");

pointcut propertySetterExecute execute ("propertySetter")



before classPrivateAttributeCall {

'

// declaration of private attributes for ' self.name '

'

}


around propertyGetterCall {

p.alternativePropertyGetter ()

}


uml.Property::alternativePropertyGetter () {

// this is the alternative property getter generator - from the aspect

}


before propertySetterExecute {

'

// before propertySetter execute

'

}


after propertySetterExecute {

'


public void set ' self.name 'Alternative () {

// todo: implement

}

'

}


}




"Anderson Ledo" <anderson.ledo@gmail.com> wrote in message
news:c16466be956cf8e1aa63b7b44a79e230$1@www.eclipse.org...
> Hi,
>
> I'm trying to use the aspect extension of MOFScript, but the examples I
> found in the User Guide v0.6 are not so clear.
>
> Could anyone provide a more clear, or concrete, example of the use of
> aspects in MOFScript?
>
> Thanks in advance !
>
Re: [MOFScript] Aspect extension [message #384772 is a reply to message #384264] Mon, 11 August 2008 17:49 Go to previous message
Anderson Ledo is currently offline Anderson LedoFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Jon,

Actually, I was not getting it working. So, I supposed I was doing
something wrong.
Thanks for the explanation. I will consider using a previous version, or
another solution without aspects.
By the way, good job. MOFScript is a pretty good tool.

Best regards,
Anderso Ledo.


Anderson Ledo
Campina Grande, Brazil
Re: [MOFScript] Aspect extension [message #618530 is a reply to message #383960] Wed, 23 July 2008 05:08 Go to previous message
Jon Oldevik is currently offline Jon OldevikFriend
Messages: 17
Registered: July 2009
Junior Member
Hi,

as a warning: the aspect feature in MOFScript was developed as an
experimental feature; it has really not been thoroughly tested. However, it
has been used on some minor case studies, but it has not been tested on
latest releases.

I will give a brief overview here. The aspect concept in MOFScript works
similarly to aspects in AspectJ.

As shown in the documentation/Eclipse help, an aspect is defined by the
'aspect' keyword - an aspect in MOFScript is a special kind (a subtype of) a
text transformation. It may contain pointcuts and advices, but also standard
MOFScript transformation rules.

The pointcut can be either of type 'call' or 'execute'. If it is of type
call, code is attempted inserted at 'call-to-transformation-rule'. If it is
of type 'execute', code is inserted at the location of the targeted
transformation rule.

The pointcut further may define the context type of the target
transformation rule:

pointcut myVeryOwnPointcut (Property) execute ("get.*")

This pointcut will apply to all rules with a context type "Property" that
starts with 'get'. The syntax for the match criteria is according to Java
regular expressions (--- which is different from what you will find in e.g.
AspectJ --- look at the doc for Java SDK for details)

An advice defines the transformation code to be inserted at the joinpoints
defined by the referenced pointcut.

Example:
before myVeryOwnPointcut {
stdout.println ("This was generated by my aspect...")
}

The advice may be defined as an 'after', 'before', or 'around' type. The
before type inserts the advice code before other transformation code at the
location(s) defined by the pointcut. Similarly for 'after'. Around replaces
transformation code.


Below is a simple example that illustrates... However, while testing this
now on the latest MOFScript release, I see that there is a malfunction in
the aspect transformation somewhere that need fixing. You probably will not
get this working without that fix. (I will have that looked at ASAP).

Best regards,
Jon Oldevik


aspect JavaAspect {

pointcut classPrivateAttributeCall(Class) execute
("classPrivateAttribute");

pointcut propertyGetterCall call ("propertyGetter");

pointcut propertySetterExecute execute ("propertySetter")



before classPrivateAttributeCall {

'

// declaration of private attributes for ' self.name '

'

}


around propertyGetterCall {

p.alternativePropertyGetter ()

}


uml.Property::alternativePropertyGetter () {

// this is the alternative property getter generator - from the aspect

}


before propertySetterExecute {

'

// before propertySetter execute

'

}


after propertySetterExecute {

'


public void set ' self.name 'Alternative () {

// todo: implement

}

'

}


}




"Anderson Ledo" <anderson.ledo@gmail.com> wrote in message
news:c16466be956cf8e1aa63b7b44a79e230$1@www.eclipse.org...
> Hi,
>
> I'm trying to use the aspect extension of MOFScript, but the examples I
> found in the User Guide v0.6 are not so clear.
>
> Could anyone provide a more clear, or concrete, example of the use of
> aspects in MOFScript?
>
> Thanks in advance !
>
Re: [MOFScript] Aspect extension [message #619468 is a reply to message #384264] Mon, 11 August 2008 17:49 Go to previous message
Anderson Ledo is currently offline Anderson LedoFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Jon,

Actually, I was not getting it working. So, I supposed I was doing
something wrong.
Thanks for the explanation. I will consider using a previous version, or
another solution without aspects.
By the way, good job. MOFScript is a pretty good tool.

Best regards,
Anderso Ledo.


Anderson Ledo
Campina Grande, Brazil
Previous Topic:[AM3] AM3 and Eclipse3.4
Next Topic:Resolving element references after injection
Goto Forum:
  


Current Time: Thu Apr 25 02:04:49 GMT 2024

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

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

Back to the top