Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Instrumenting field class on Operation?
Instrumenting field class on Operation? [message #477638] Mon, 28 July 2008 19:16 Go to next message
Hector M Chavez is currently offline Hector M ChavezFriend
Messages: 18
Registered: July 2009
Junior Member
I've been trying to instrument the field ownedOperation in Class and the
field class in Operation, I added the corresponding annotation to the
field ownedOperation in Class but I can't find the field class to add the
annotation to it anywhere in Operation, what I'm trying to do is to
instrument the association between Operation and Class.

I appreciate any help, I've been trying to solve this for some time now
without getting any results. Thank you.

Hector
Re: Instrumenting field class on Operation? [message #477640 is a reply to message #477638] Tue, 29 July 2008 02:20 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Hector, I don't think I have enough context to help you. What do you
mean by "instrumenting a field"? And what kind of annotations are you
talking about?

In case it helps, an operation is owned by its class, which also
provides its namespace, so you can retrieve it by invoking
Operation#getClass_() or NamedElement#getNamespace() or
EObject#eContainer().

Rafael

Hector Chavez wrote:
> I've been trying to instrument the field ownedOperation in Class and the
> field class in Operation, I added the corresponding annotation to the
> field ownedOperation in Class but I can't find the field class to add
> the annotation to it anywhere in Operation, what I'm trying to do is to
> instrument the association between Operation and Class.
>
> I appreciate any help, I've been trying to solve this for some time now
> without getting any results. Thank you.
>
> Hector
>
Re: Instrumenting field class on Operation? [message #477642 is a reply to message #477640] Tue, 29 July 2008 16:17 Go to previous messageGo to next message
Hector M Chavez is currently offline Hector M ChavezFriend
Messages: 18
Registered: July 2009
Junior Member
Rafael, thanks for your reply,

For example in ClassImpl over the field ownedOperation I'm adding the
annotation @Association( ... ) with information I later use for testing
purposes, so by instrumenting I just mean adding the annotation to the
field, and I also need to add the annotation @Association to the opposite
end (of the association between class and operation) in the class
OperationImpl, but there I don't see the field class or something like
that. I thought I would find something like this:

In ClassImpl a variable "ownedOperation" (which is there)
In OperationImpl a variable "class" (but there I don't find it)

I tried looking on parent classes but I didn't have luck.

Hector
Re: Instrumenting field class on Operation? [message #477643 is a reply to message #477642] Wed, 30 July 2008 04:06 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Hector, so it seems you are you hacking the UML2 code base itself or you
generated a new metamodel implementation based on UML2's Ecore model.
Trying to answer your question, it seems the field representing the
class of a UML operation would be EObjectImpl#eContainer in EMF itself,
i.e. is off-limits. Not only that, but the eContainer reference holds
the opposite to many different associations so I don't think that even
if you could access it, it would be a good idea.

The in-memory representation of an EMF based model is not as trivial as
a network of objects that refer to each other using plain fields.
References are often part of multiple associations. There is also
caching, lazy-loading, derived lists, etc. I don't really know what you
are trying to achieve, so this suggestion might be useless, but any
information you need about a UML model and/or the UML metamodel can be
easily obtained from the model/metamodel itself by using the UML2 and/or
EMF API, no need to mess with the generated code.

Sorry if I could not actually help much. I guess it could help if could
tell us what you are trying to achieve, and why do you think annotating
the generated code is the best way.

Cheers,

Rafael

Hector Chavez wrote:
> Rafael, thanks for your reply,
> For example in ClassImpl over the field ownedOperation I'm adding the
> annotation @Association( ... ) with information I later use for testing
> purposes, so by instrumenting I just mean adding the annotation to the
> field, and I also need to add the annotation @Association to the
> opposite end (of the association between class and operation) in the
> class OperationImpl, but there I don't see the field class or something
> like that. I thought I would find something like this:
>
> In ClassImpl a variable "ownedOperation" (which is there)
> In OperationImpl a variable "class" (but there I don't find it)
> I tried looking on parent classes but I didn't have luck.
> Hector
>
>
>
Re: Instrumenting field class on Operation? [message #477644 is a reply to message #477643] Wed, 30 July 2008 15:44 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
If one is trying to determine the opposite end of an association, then
having a look at the interface (or javadoc) will provide clues. In this
case, have a look at org.eclipse.uml2.uml.Class.

The javadoc looks like the following:

/**
* Returns the value of the '<em><b>Owned Operation</b></em>' containment
reference list.

* The list contents are of type {@link org.eclipse.uml2.uml.Operation}.

* It is bidirectional and its opposite is '{@link
org.eclipse.uml2.uml.Operation#getClass_ <em>Class</em>}'.

* <p>

* This feature subsets the following features:

* <ul>

* <li>'{@link org.eclipse.uml2.uml.Classifier#getFeatures()
<em>Feature</em>}'</li>

* <li>'{@link org.eclipse.uml2.uml.Namespace#getOwnedMembers() <em>Owned
Member</em>}'</li>

* </ul>

* </p>

* <!-- begin-user-doc -->

* <!-- end-user-doc -->

* <!-- begin-model-doc -->

* The operations owned by the class.

* <!-- end-model-doc -->

* @return the value of the '<em>Owned Operation</em>' containment reference
list.

* @see org.eclipse.uml2.uml.UMLPackage#getClass_OwnedOperation()

* @see org.eclipse.uml2.uml.Operation#getClass_

* @model opposite="class" containment="true" resolveProxies="true"

* @generated

*/

So the the opposite is * It is bidirectional and its opposite is '{@link
org.eclipse.uml2.uml.Operation#getClass_ <em>Class</em>}'.

If you are poking around at the EMF level and want to discover the opposite
end programatically, you can use EReference.getEOpposite().


HTH,

- James.


"Rafael Chaves" <rafael@abstratt.com> wrote in message
news:g6opbh$j0q$1@build.eclipse.org...
> Hector, so it seems you are you hacking the UML2 code base itself or you
> generated a new metamodel implementation based on UML2's Ecore model.
> Trying to answer your question, it seems the field representing the class
> of a UML operation would be EObjectImpl#eContainer in EMF itself, i.e. is
> off-limits. Not only that, but the eContainer reference holds the opposite
> to many different associations so I don't think that even if you could
> access it, it would be a good idea.
>
> The in-memory representation of an EMF based model is not as trivial as a
> network of objects that refer to each other using plain fields. References
> are often part of multiple associations. There is also caching,
> lazy-loading, derived lists, etc. I don't really know what you are trying
> to achieve, so this suggestion might be useless, but any information you
> need about a UML model and/or the UML metamodel can be easily obtained
> from the model/metamodel itself by using the UML2 and/or EMF API, no need
> to mess with the generated code.
>
> Sorry if I could not actually help much. I guess it could help if could
> tell us what you are trying to achieve, and why do you think annotating
> the generated code is the best way.
>
> Cheers,
>
> Rafael
>
> Hector Chavez wrote:
>> Rafael, thanks for your reply,
>> For example in ClassImpl over the field ownedOperation I'm adding the
>> annotation @Association( ... ) with information I later use for testing
>> purposes, so by instrumenting I just mean adding the annotation to the
>> field, and I also need to add the annotation @Association to the opposite
>> end (of the association between class and operation) in the class
>> OperationImpl, but there I don't see the field class or something like
>> that. I thought I would find something like this:
>>
>> In ClassImpl a variable "ownedOperation" (which is there)
>> In OperationImpl a variable "class" (but there I don't find it)
>> I tried looking on parent classes but I didn't have luck.
>> Hector
>>
>>
Re: Instrumenting field class on Operation? [message #477647 is a reply to message #477643] Wed, 30 July 2008 22:20 Go to previous message
Hector M Chavez is currently offline Hector M ChavezFriend
Messages: 18
Registered: July 2009
Junior Member
Rafael, thanks for your help, I think the best thing for me to do is to
learn a little bit more about EMF and then decide if the approach I'm
trying is feasible, I'm actually not trying to modify the code, just
adding info to latter with the help of ASM instrument the code to keep
track of fields read and other info while the destroy methods are
executed, I did it with other classes (not uml) that implement ownership
but the structure was not as complex. Thanks for your prompt responses.

Hector
Re: Instrumenting field class on Operation? [message #626831 is a reply to message #477638] Tue, 29 July 2008 02:20 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Hector, I don't think I have enough context to help you. What do you
mean by "instrumenting a field"? And what kind of annotations are you
talking about?

In case it helps, an operation is owned by its class, which also
provides its namespace, so you can retrieve it by invoking
Operation#getClass_() or NamedElement#getNamespace() or
EObject#eContainer().

Rafael

Hector Chavez wrote:
> I've been trying to instrument the field ownedOperation in Class and the
> field class in Operation, I added the corresponding annotation to the
> field ownedOperation in Class but I can't find the field class to add
> the annotation to it anywhere in Operation, what I'm trying to do is to
> instrument the association between Operation and Class.
>
> I appreciate any help, I've been trying to solve this for some time now
> without getting any results. Thank you.
>
> Hector
>
Re: Instrumenting field class on Operation? [message #626833 is a reply to message #477640] Tue, 29 July 2008 16:17 Go to previous message
Hector M Chavez is currently offline Hector M ChavezFriend
Messages: 18
Registered: July 2009
Junior Member
Rafael, thanks for your reply,

For example in ClassImpl over the field ownedOperation I'm adding the
annotation @Association( ... ) with information I later use for testing
purposes, so by instrumenting I just mean adding the annotation to the
field, and I also need to add the annotation @Association to the opposite
end (of the association between class and operation) in the class
OperationImpl, but there I don't see the field class or something like
that. I thought I would find something like this:

In ClassImpl a variable "ownedOperation" (which is there)
In OperationImpl a variable "class" (but there I don't find it)

I tried looking on parent classes but I didn't have luck.

Hector
Re: Instrumenting field class on Operation? [message #626834 is a reply to message #477642] Wed, 30 July 2008 04:06 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Hector, so it seems you are you hacking the UML2 code base itself or you
generated a new metamodel implementation based on UML2's Ecore model.
Trying to answer your question, it seems the field representing the
class of a UML operation would be EObjectImpl#eContainer in EMF itself,
i.e. is off-limits. Not only that, but the eContainer reference holds
the opposite to many different associations so I don't think that even
if you could access it, it would be a good idea.

The in-memory representation of an EMF based model is not as trivial as
a network of objects that refer to each other using plain fields.
References are often part of multiple associations. There is also
caching, lazy-loading, derived lists, etc. I don't really know what you
are trying to achieve, so this suggestion might be useless, but any
information you need about a UML model and/or the UML metamodel can be
easily obtained from the model/metamodel itself by using the UML2 and/or
EMF API, no need to mess with the generated code.

Sorry if I could not actually help much. I guess it could help if could
tell us what you are trying to achieve, and why do you think annotating
the generated code is the best way.

Cheers,

Rafael

Hector Chavez wrote:
> Rafael, thanks for your reply,
> For example in ClassImpl over the field ownedOperation I'm adding the
> annotation @Association( ... ) with information I later use for testing
> purposes, so by instrumenting I just mean adding the annotation to the
> field, and I also need to add the annotation @Association to the
> opposite end (of the association between class and operation) in the
> class OperationImpl, but there I don't see the field class or something
> like that. I thought I would find something like this:
>
> In ClassImpl a variable "ownedOperation" (which is there)
> In OperationImpl a variable "class" (but there I don't find it)
> I tried looking on parent classes but I didn't have luck.
> Hector
>
>
>
Re: Instrumenting field class on Operation? [message #626835 is a reply to message #477643] Wed, 30 July 2008 15:44 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
If one is trying to determine the opposite end of an association, then
having a look at the interface (or javadoc) will provide clues. In this
case, have a look at org.eclipse.uml2.uml.Class.

The javadoc looks like the following:

/**
* Returns the value of the '<em><b>Owned Operation</b></em>' containment
reference list.

* The list contents are of type {@link org.eclipse.uml2.uml.Operation}.

* It is bidirectional and its opposite is '{@link
org.eclipse.uml2.uml.Operation#getClass_ <em>Class</em>}'.

* <p>

* This feature subsets the following features:

* <ul>

* <li>'{@link org.eclipse.uml2.uml.Classifier#getFeatures()
<em>Feature</em>}'</li>

* <li>'{@link org.eclipse.uml2.uml.Namespace#getOwnedMembers() <em>Owned
Member</em>}'</li>

* </ul>

* </p>

* <!-- begin-user-doc -->

* <!-- end-user-doc -->

* <!-- begin-model-doc -->

* The operations owned by the class.

* <!-- end-model-doc -->

* @return the value of the '<em>Owned Operation</em>' containment reference
list.

* @see org.eclipse.uml2.uml.UMLPackage#getClass_OwnedOperation()

* @see org.eclipse.uml2.uml.Operation#getClass_

* @model opposite="class" containment="true" resolveProxies="true"

* @generated

*/

So the the opposite is * It is bidirectional and its opposite is '{@link
org.eclipse.uml2.uml.Operation#getClass_ <em>Class</em>}'.

If you are poking around at the EMF level and want to discover the opposite
end programatically, you can use EReference.getEOpposite().


HTH,

- James.


"Rafael Chaves" <rafael@abstratt.com> wrote in message
news:g6opbh$j0q$1@build.eclipse.org...
> Hector, so it seems you are you hacking the UML2 code base itself or you
> generated a new metamodel implementation based on UML2's Ecore model.
> Trying to answer your question, it seems the field representing the class
> of a UML operation would be EObjectImpl#eContainer in EMF itself, i.e. is
> off-limits. Not only that, but the eContainer reference holds the opposite
> to many different associations so I don't think that even if you could
> access it, it would be a good idea.
>
> The in-memory representation of an EMF based model is not as trivial as a
> network of objects that refer to each other using plain fields. References
> are often part of multiple associations. There is also caching,
> lazy-loading, derived lists, etc. I don't really know what you are trying
> to achieve, so this suggestion might be useless, but any information you
> need about a UML model and/or the UML metamodel can be easily obtained
> from the model/metamodel itself by using the UML2 and/or EMF API, no need
> to mess with the generated code.
>
> Sorry if I could not actually help much. I guess it could help if could
> tell us what you are trying to achieve, and why do you think annotating
> the generated code is the best way.
>
> Cheers,
>
> Rafael
>
> Hector Chavez wrote:
>> Rafael, thanks for your reply,
>> For example in ClassImpl over the field ownedOperation I'm adding the
>> annotation @Association( ... ) with information I later use for testing
>> purposes, so by instrumenting I just mean adding the annotation to the
>> field, and I also need to add the annotation @Association to the opposite
>> end (of the association between class and operation) in the class
>> OperationImpl, but there I don't see the field class or something like
>> that. I thought I would find something like this:
>>
>> In ClassImpl a variable "ownedOperation" (which is there)
>> In OperationImpl a variable "class" (but there I don't find it)
>> I tried looking on parent classes but I didn't have luck.
>> Hector
>>
>>
Re: Instrumenting field class on Operation? [message #626838 is a reply to message #477643] Wed, 30 July 2008 22:20 Go to previous message
Hector M Chavez is currently offline Hector M ChavezFriend
Messages: 18
Registered: July 2009
Junior Member
Rafael, thanks for your help, I think the best thing for me to do is to
learn a little bit more about EMF and then decide if the approach I'm
trying is feasible, I'm actually not trying to modify the code, just
adding info to latter with the help of ASM instrument the code to keep
track of fields read and other info while the destroy methods are
executed, I did it with other classes (not uml) that implement ownership
but the structure was not as complex. Thanks for your prompt responses.

Hector
Previous Topic:RSA/RSM comments are not saved properly
Next Topic:Redefinition code generation issue
Goto Forum:
  


Current Time: Fri Mar 29 08:46:37 GMT 2024

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

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

Back to the top