Home » Modeling » EMF » [CDO] model management?(ResourceFactory, ResourceSet, Factoryregistry, transaction vs Resourceset)
[CDO] model management? [message #762893] |
Thu, 08 December 2011 14:26  |
Eclipse User |
|
|
|
I am trying to do my homework, but could not find a documentation on these things for such a dummy like me.
As I understand, a ResourceSet is to handle related documents. It have a registry, in which one can associate ResourceFactories with either the extension or the protocol of the URI. The role of the ResourceFactory is to create a type of resource. As I understand a Resource implements the structure of the document, and maybe not the way to persist it (but I am not sure).
A CDO transaction can be opened on a ResourceSet, in which case resource.save() actually calls transaction.commit(). The transaction is clearly related to persistence, it deals with one CDO repository.
The functionality I try to achieve:
- the application handles multiple models. There is an existing resource factory for those models. I use that for both CDO and file based persistence.
- the application is able to use files to load/save resources. Currently it directly uses the createResource() method of the factory, which I guess is suboptimal, because cannot easily aligned with the below functionality.
- the application should be able to use CDO repositories to load/save resources. Currently saving is implemented by removing the existing model from the resource and replacing it with the new version. I guess it is extraordinarily suboptimal, for example change management capabilities of CDO cannot be used (not as I yet had a clue on how to use them, but I plan to).
- the user should be able to load a model from either file or CDO, and save it to either CDO or file. This is my immediate concern.
Should I use one resourceset for file based and another one for cdo based models?
Or is it possible to use one resourceset for all, maybe by somehow modifying resourcefactory?
|
|
|
Re: [CDO] model management? [message #763120 is a reply to message #762893] |
Fri, 09 December 2011 03:03   |
Eclipse User |
|
|
|
Am 08.12.2011 20:26, schrieb mag:
> I am trying to do my homework, but could not find a documentation on these things for such a dummy like me.
Good ;-)
>
> As I understand, a ResourceSet is to handle related documents. It have a registry, in which one can associate
> ResourceFactories
Notice the plural!
> with either the extension or the protocol of the URI. The role of the ResourceFactory is to create a type of resource.
> As I understand a Resource implements the structure of the document, and maybe not the way to persist it (but I am not
> sure).
A resource usually has some own "data", e.g., a URI and a contents list. But its primary role is to persist the
contained instances (you seem to call that a model).
> A CDO transaction can be opened on a ResourceSet, in which case resource.save() actually calls transaction.commit().
> The transaction is clearly related to persistence, it deals with one CDO repository.
Yes.
>
> The functionality I try to achieve:
> - the application handles multiple models.
Resources?
> There is an existing resource factory for those models. I use that for both CDO and file based persistence.
That sounds odd to me.
> - the application is able to use files to load/save resources. Currently it directly uses the createResource() method
> of the factory, which I guess is suboptimal, because cannot easily aligned with the below functionality.
Definitely not the intended usage.
> - the application should be able to use CDO repositories to load/save resources. Currently saving is implemented by
> removing the existing model from the resource and replacing it with the new version. I guess it is extraordinarily
> suboptimal, for example change management capabilities of CDO cannot be used (not as I yet had a clue on how to use
> them, but I plan to).
Yes, that might become a challenge then. But if you're trying to change the persistence mechanism of a subtree of your
model instance then copying this tree to a separate resource is a common trick.
> - the user should be able to load a model from either file or CDO, and save it to either CDO or file. This is my
> immediate concern.
Both is easily possible but be aware that non-CDO resources usually don't preserve the CDOIDs of your model instances!
You won't be easily able to relate different versions of the same *logical* objects this way.
>
> Should I use one resourceset for file based and another one for cdo based models?
> Or is it possible to use one resourceset for all, maybe by somehow modifying resourcefactory?
Just register your two resource factories with a single resource set.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] model management? [message #763303 is a reply to message #763120] |
Fri, 09 December 2011 09:36   |
Eclipse User |
|
|
|
Quote:>
> The functionality I try to achieve:
> - the application handles multiple models.
Resources?
Now it looks like this:
- there are multiple models
- when a model gets saved, a new resource is created for it, the model added to the resource, the resource gets persisted, then the model gets deleted from it
This is the legacy behaviour, maybe suboptimal. I am trying to figure out how to do it optimally to cover both file and CDO based persistence.
Quote:> There is an existing resource factory for those models. I use that for both CDO and file based persistence.
That sounds odd to me.
Quote:Just register your two resource factories with a single resource set.
Now I am starting to understand. What I did is that I have modified the legacy resourcefactory's createResource() method to return a cdo resource in case of a http uri, and go on original code path in case of file one.
I should have descended a new resource factory from the legacy one, override its createResource(), and register the legacy for file protocol, and the new one for http protocol.
One point of confusion left though: In the openSessionAndUseTransaction example I see session.openTransaction(resourceSet). This would imply to me that any resource in the resourceset would be persisted by CDO. What this actually does?
If I don't believe that the users will reach the same repositories, would it be beneficial to say that each resourceset should be dedicated to one repository (thinking about not just cdo repos, but e.g. directories of file based ones as well). This way cross-resource links are guaranteed not to be broken (at least in the cdo case). Am I understanding it right?
[Updated on: Fri, 09 December 2011 09:38] by Moderator
|
|
|
Re: [CDO] model management? [message #763376 is a reply to message #763303] |
Fri, 09 December 2011 11:48   |
Eclipse User |
|
|
|
Am 09.12.2011 15:37, schrieb mag:
> Quote:
>> >
>> > The functionality I try to achieve:
>> > - the application handles multiple models.
>> Resources?
>
>
> Now it looks like this:
> - there are multiple models
While it's not incorrect to call anything a model we use to call those "instances of a model" to avoid the term "meta"
on the next higher level.
> - when a model gets saved, a new resource is created for it, the model added to the resource, the resource gets
> persisted, then the model gets deleted from it
> This is the legacy behaviour, maybe suboptimal. I am trying to figure out how to do it optimally to cover both file
> and CDO based persistence.
>
> Quote:
>> > There is an existing resource factory for those models. I use that for both CDO and file based persistence.
>> That sounds odd to me.
>
> Quote:
>> Just register your two resource factories with a single resource set.
>
> Now I am starting to understand. What I did is that I have modified the legacy resourcefactory's createResource()
> method to return a cdo resource in case of a file uri, and a cdo one in case of http one.
> I should have descended a new resource factory from the legacy one, override its createResource(), and register the
> legacy for file protocol, and the new one for http protocol.
That still confuses me. Only resource implementors usually need to implement or specialize resource factories.
>
> One point of confusion left though: In the openSessionAndUseTransaction example I see
> session.openTransaction(resourceSet). This would imply to me that any resource in the resourceset would be persisted
> by CDO. What this actually does?
Any type of resource can be in that resource set. The CDOTransaction only manages the CDOResources (of the particular
repository) in thatresource set.
>
> If I don't believe that the users will reach the same repositories,
What do you mean? Why do you just "believe" it, or not?
> would it be beneficial to say that each resourceset should be dedicated to one repository (thinking about not just cdo
> repos, but e.g. directories of file based ones as well). This way cross-resource links are guaranteed not to be broken
> (at least in the cdo case).
Because you have none then? I don't see the rationale behind this assumption.
> Am I understanding it right?
Hm, probably not. But I have no clue what you're trying to achieve and what your typical deployment situation is.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
| |
Goto Forum:
Current Time: Wed Jul 23 10:15:37 EDT 2025
Powered by FUDForum. Page generated in 0.04792 seconds
|