Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » implementing my concrete create() methods for my EMF objects
implementing my concrete create() methods for my EMF objects [message #644638] Mon, 13 December 2010 15:16 Go to next message
Tom H is currently offline Tom HFriend
Messages: 139
Registered: July 2009
Senior Member
I have my ecore objects persisted using a implementation of ResourceFactoryImpl() to my various backends.

However for certain types of objects say "SMSAccount" I need to go away and create assets for that user in other systems, so I need to

so I have something like this;

AccountingSwitch saveSwitch = new AccountingSwtich()
{
public Object caseAccount(Account object)
{
createSomestuff();
}
}

which I can put in my ResourceFactoryImpl() for save, but at the moment I can only see how to call save() on a resource, and not on individual EObjects.

Thanks,
T

[Updated on: Mon, 13 December 2010 16:52]

Report message to a moderator

Re: implementing my concrete create() methods for my EMF objects [message #644681 is a reply to message #644638] Mon, 13 December 2010 18:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Tom,

Can you be a bit more concrete about what you're planning on doing in
the create methods. I have to say that it sounds like a bad idea up
front. When deserializing, objects are created and the populated based
on what's in the serialization; I doubt that should go off and do other
things as a side effect. Or suppose you used EcoreUtil.copy on your
objects; I doubt that should go off and create assets somewhere...


Tom H wrote:
> I have my ecore objects persisted using a implementation of
> ResourceFactoryImpl() to my various backends.
>
> However for certain types of objects say "SMSAccount" I need to go
> away and create assets for that user in other systems, so I need to
> hook in my "real" code to the create method.
>
> I see a generated switch class, should I be using that to call my
> class specific create logic?
>
> Thanks,
> T


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: implementing my concrete create() methods for my EMF objects [message #644720 is a reply to message #644681] Mon, 13 December 2010 22:30 Go to previous messageGo to next message
Tom H is currently offline Tom HFriend
Messages: 139
Registered: July 2009
Senior Member
well if for example one of my modelled objects was "User" I want to persist the user to XMI, but also I want to go and create a user in the OS or create a home directory as well in Java code.

so basically I want to call UserManager.save(User) somewhere, and also UserManager.changePassword(User) whenever the password attribute is changed.

At the moment I am decorating my Objects with a wrapper that provides load/save/delete methods and does a doSave() similar to the doSwitch utility to select Object specific logic.

However I would be keen to see how to do it the recommended way. I am guessing that an alternative would be to have a controller type class to dispatch creates and saves to the relevant back-end.

Thanks
T
Re: implementing my concrete create() methods for my EMF objects [message #644724 is a reply to message #644720] Mon, 13 December 2010 22:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Tom,

Comments below.


Tom H wrote:
> well if for example one of my modelled objects was "User" I want to
> persist the user to XMI, but also I want to go and create a user in
> the OS or create a home directory as well in Java code.
You'd better only do that during save then...

What happens if the XMI file is just deleted?
>
> so basically I want to call UserManager.save(User) somewhere, and also
> UserManager.changePassword(User) whenever the password attribute is
> changed.
Again, only during save. After all, one might close the editor or undo
a change...
>
> At the moment I am decorating my Objects with a wrapper that provides
> load/save/delete methods and does a doSave() similar to the doSwitch
> utility to select Object specific logic.
I see.
>
> However I would be keen to see how to do it the recommended way. I am
> guessing that an alternative would be to have a controller type class
> to dispatch creates and saves to the relevant back-end.
I imagine a specialized XyzSwitch for each of the "methods" would be
quite handy.
>
> Thanks
> T
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: implementing my concrete create() methods for my EMF objects [message #644728 is a reply to message #644724] Mon, 13 December 2010 23:50 Go to previous messageGo to next message
Tom H is currently offline Tom HFriend
Messages: 139
Registered: July 2009
Senior Member
Ed Merks wrote on Mon, 13 December 2010 17:48
Tom,
Comments below.
Tom H wrote:
> well if for example one of my modelled objects was "User" I want to
> persist the user to XMI, but also I want to go and create a user in
> the OS or create a home directory as well in Java code.
You'd better only do that during save then...

What happens if the XMI file is just deleted?
>
> so basically I want to call UserManager.save(User) somewhere, and also
> UserManager.changePassword(User) whenever the password attribute is
> changed.
Again, only during save. After all, one might close the editor or undo
a change...
>


so when you say, only during save, do you mean that I should be over-riding the XMIResourceImpl and adding my functions to the save() call??

or some other way?

Thanks,
T

Re: implementing my concrete create() methods for my EMF objects [message #644731 is a reply to message #644728] Tue, 14 December 2010 00:10 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Tom,

Yes, I imagine you should be overriding some aspect of doSave. And
doDelete? I'm a little concerned about how what you're describing
really hangs together. Clearly XMI files can be deleted without any
opportunity for your special processing to kick in. Clearly it's also
possible for the things you create to be destroyed or modified in some
other way. I.e., what keeps these things consistent?



Tom H wrote:
> Ed Merks wrote on Mon, 13 December 2010 17:48
>> Tom,
>> Comments below.
>> Tom H wrote:
>> > well if for example one of my modelled objects was "User" I want to
>> > persist the user to XMI, but also I want to go and create a user in
>> > the OS or create a home directory as well in Java code.
>> You'd better only do that during save then...
>>
>> What happens if the XMI file is just deleted?
>> >
>> > so basically I want to call UserManager.save(User) somewhere, and
>> also > UserManager.changePassword(User) whenever the password
>> attribute is > changed.
>> Again, only during save. After all, one might close the editor or
>> undo a change...
>> >
>
>
> so when you say, only during save, do you mean that I should be
> over-riding the XMIResourceImpl and adding my functions to the save()
> call??
>
> or some other way?
>
> Thanks,
> T
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Getting started
Next Topic:[CDO] Concurrent access of cdo servers
Goto Forum:
  


Current Time: Tue Apr 23 11:12:32 GMT 2024

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

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

Back to the top