Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generate model only once for different domains
Generate model only once for different domains [message #539357] Thu, 10 June 2010 14:19 Go to next message
Udo Walker is currently offline Udo WalkerFriend
Messages: 81
Registered: July 2009
Member
Hi,

I have a model which I created by Java annotated interfaces. In the generated model I added additional business logic (added method to interface and implementation to impl class).

I use the model in an Eclipse editor where I need the notification mechanism to edit the data of my model. I also use it in a server runtime where I do not want to have the notification code in the generated model.

How should I set up my model? At the moment I have one bundle which consits of my annotated Java interfaces, the generated EMF implementations and my additional business logic methods in the interfaces and the generated EMF implementations. I generated with "Supress notification=false" to get the right model for the editor.

But how can I get rid of the generated notification code in the bundle for my runtime environment in the server? Do I have to generate another bundle? Can I subclass a model which has no notification and in the subclassed model i have notification, i.e. the EMF generator adds the additonal functionality to the second bundle?

For your ideas I would be glad.

With regards
Udo
Re: Generate model only once for different domains [message #539381 is a reply to message #539357] Thu, 10 June 2010 15:13 Go to previous messageGo to next message
Udo Walker is currently offline Udo WalkerFriend
Messages: 81
Registered: July 2009
Member
I tried to create 2 bundles:

First bundle consits of my core implementation. Notification is turned of.
Second bundle extends first bundle but notification is turned on.

-> Notification is not generated but the second model just subclasses the first model without any new functionality Sad

So what should I do?
Re: Generate model only once for different domains [message #539396 is a reply to message #539357] Thu, 10 June 2010 14:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Udo,

Comments below.

Udo.Walker@abas.de wrote:
> Hi,
>
> I have a model which I created by Java annotated interfaces. In the
> generated model I added additional business logic (added method to
> interface and implementation to impl class).
>
> I use the model in an Eclipse editor where I need the notification
> mechanism to edit the data of my model. I also use it in a server
> runtime where I do not want to have the notification code in the
> generated model.
What's wrong with pretending it's not there?
> How should I set up my model? At the moment I have one bundle which
> consits of my annotated Java interfaces, the generated EMF
> implementations and my additional business logic methods in the
> interfaces and the generated EMF implementations. I generated with
> "Supress notification=false" to get the right model for the editor.
>
> But how can I get rid of the generated notification code in the bundle
> for my runtime environment in the server?
Why do you need that?
> Do I have to generate another bundle? Can I subclass a model which has
> no notification and in the subclassed model i have notification, i.e.
> the EMF generator adds the additonal functionality to the second bundle?
What's prompting this concern? The notification scheme is designed to
not produce notifications when there are no listeners.
>
> For your ideas I would be glad.
>
> With regards
> Udo


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generate model only once for different domains [message #539402 is a reply to message #539381] Thu, 10 June 2010 15:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Udo,

Please explain why this is a concern in the first place.


Udo wrote:
> I tried to create 2 bundles:
>
> First bundle consits of my core implementation. Notification is turned
> of.
> Second bundle extends first bundle but notification is turned on.
>
> -> Notification is not generated but the second model just subclasses
> the first model without any new functionality :(
> So what should I do?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generate model only once for different domains [message #539532 is a reply to message #539402] Fri, 11 June 2010 08:30 Go to previous messageGo to next message
Udo Walker is currently offline Udo WalkerFriend
Messages: 81
Registered: July 2009
Member
Hi Ed,

in my server code I want to get rid of the extra operations in each setter.

Instead of having this:

public void setKey(String newKey) {
  String oldKey = key;
  key = newKey;
  if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, 
      MenuPackage.DESCRIPTION__KEY, oldKey, key));
}


I want to have this:

public void setKey(String newKey) {
   key = newKey;
}


But in an editor in my Eclipse plugin I do want to have the first piece of code.

To solve this I tried to create a bundle where notification is turned off (code of 2nd piece is generated) and a second bundle, where the setter is overwritten by the 2nd piece of code. The second bundle inherits the model from 1st bundle. I want that the EMF is generating that for me in some way. But how I did it it did not work.

Udo

[Updated on: Fri, 11 June 2010 09:10]

Report message to a moderator

Re: Generate model only once for different domains [message #539633 is a reply to message #539532] Fri, 11 June 2010 14:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Udo,

Comments below.


Udo wrote:
> Hi Ed,
>
> in my server code I want to get rid of the extra operations in each
> setter.
>
> Instead of having this:
>
>
> public void setKey(String newKey) {
> String oldKey = key;
> key = newKey;
> if (eNotificationRequired())
> eNotify(new ENotificationImpl(this, Notification.SET,
> MenuPackage.DESCRIPTION__KEY, oldKey, key));
> }
>
>
> I want to have this:
>
>
> public void setKey(String newKey) {
> key = newKey;
> }
>
Why? Is your server running low on bytes? What specific benefits do
you hope to gain at the cost of maintaining two separate implementations?
>
> But in an editor in my Eclipse plugin I do want to have the first
> piece of code.
> To solve this I tried to create a bundle where notification is turned
> of (code of 2nd piece is generated) and a second bundle, where the
> setter is overwritten by the 2nd piece of code. The second bundle
> inherits the model from 1st bundle. I want that the EMF is generating
> that for me in some way. But how I did it it did not work.
> Udo
Note that even if you got rid of it for the setters, the list
implementations, at least the ones that support bidirectional
references, proxy resolution, and containment, still include it.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generate model only once for different domains [message #552431 is a reply to message #539633] Thu, 12 August 2010 08:32 Go to previous message
Udo Walker is currently offline Udo WalkerFriend
Messages: 81
Registered: July 2009
Member
Hi Ed,

I forgot to turn off the proxy resolving. After I turned it off my model querying was much faster and there is no problem anymore with the additional code for event handling which is as you wrote turned off anyways if I do not attach an adapter.

Regards,
Udo
Previous Topic:[TENEO] Order of attributes
Next Topic:[CDO] Cross references and xmi serialization
Goto Forum:
  


Current Time: Fri Apr 19 20:15:03 GMT 2024

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

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

Back to the top