Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » CDOPackageRegistry role in CDO
CDOPackageRegistry role in CDO [message #429362] Tue, 21 April 2009 11:35 Go to next message
Rimvydas is currently offline RimvydasFriend
Messages: 47
Registered: July 2009
Member
In order to save an object into CDO repository the model's package must be
registered into CDOPackageRegistry. I have a model's implementation where
every model's object implementation has a reference to one object
(MyRepository). Model's factory must be configured before creating an
object. Factory creates implementation of the model object and sets
reference to MyRepository.

MyModelFactory factory = MyModelFactory.eINSTANCE;
factory.setMyRepository(myRepository);
ObjectA object = factory.createObjectA();

If CDO will use registered in CDOPackageRegistry my model's package to
retrieve model's factory and will try to create model objects then created
objects will be in inconsistent state (reference to MyRepository will be
null).
It is normal because CDO can't know that the factory must be configured
before creating an object.

My questions are: What are the objectives the CDO uses packages registered
in CDOPackageRegistry? Is such a model like I have described above will
work with CDO?
Re: CDOPackageRegistry role in CDO [message #429363 is a reply to message #429362] Tue, 21 April 2009 12:06 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Rimvydas wrote:

> In order to save an object into CDO repository the model's package must be
> registered into CDOPackageRegistry. I have a model's implementation where
> every model's object implementation has a reference to one object
> (MyRepository). Model's factory must be configured before creating an
> object. Factory creates implementation of the model object and sets
> reference to MyRepository.

> MyModelFactory factory = MyModelFactory.eINSTANCE;
> factory.setMyRepository(myRepository);
> ObjectA object = factory.createObjectA();

> If CDO will use registered in CDOPackageRegistry my model's package to
> retrieve model's factory and will try to create model objects then created
> objects will be in inconsistent state (reference to MyRepository will be
> null).
> It is normal because CDO can't know that the factory must be configured
> before creating an object.

> My questions are: What are the objectives the CDO uses packages registered
> in CDOPackageRegistry? Is such a model like I have described above will
> work with CDO?

One of the goal of CDOPackageRegistry is to keep the integrity of the
packages between the repository and the client for one session. Each
CDOSession have their own CDOPackageRegistry.

Now the other question was : Will it work with CDO ?
Only if you configure your factory...Obviously. :-)

I mean, when CDO will load your objects CDOPackageRegistry will load
automatically your Package(the same instance that you have) retrieve your
EClass and from there create an instance like the following :
EcoreUtil.create(eClass);

At the end, EcoreUtil.create will use the same factory that you set up
correctly.... Yes it should work only...If at the beginning of your
application you setup correctly your Factory.

Does it make senses ? Did I miss something ?

Simon
Re: CDOPackageRegistry role in CDO [message #429365 is a reply to message #429363] Tue, 21 April 2009 13:07 Go to previous messageGo to next message
Rimvydas is currently offline RimvydasFriend
Messages: 47
Registered: July 2009
Member
Simon,

Thank you for quick response.

My concern is related with the places which I can not control. I mean if
for example CDO will try to create my model's object on the server side I
will have no possibility to configure the factory.

Maybe such model can work with CDO but only minimal CDO services can be
used (save, read). Will it work for example with CDO Queries ?
Re: CDOPackageRegistry role in CDO [message #429367 is a reply to message #429365] Tue, 21 April 2009 13:38 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Rimvydas wrote:

> Simon,

> Thank you for quick response.

> My concern is related with the places which I can not control. I mean if
> for example CDO will try to create my model's object on the server side I
> will have no possibility to configure the factory.
I understand your point. For now we do not create instance at the server
but it could happen in the future. (OCL query, etc..)

> Maybe such model can work with CDO but only minimal CDO services can be
> used (save, read). Will it work for example with CDO Queries ?

In this case two things could happen:
1- If the server have the Factory in the classpath it will try to use it
and will fail based on what you are saying.

2- The server doesn`t have the Factory in the classpath, in this case we
will use CDOObjectImpl as is.

So number 1 we have no problem.

Number 2 ... could be a problem. Does your configuration will change for
one specific cdo repository ? I mean... at what time do you need to change
the configuration of your Factory ?


Simon
Re: CDOPackageRegistry role in CDO [message #429370 is a reply to message #429367] Tue, 21 April 2009 14:12 Go to previous messageGo to next message
Rimvydas is currently offline RimvydasFriend
Messages: 47
Registered: July 2009
Member
My application can have several projects opened at one time but only one
is active. Each project has its own MyRepository object and model objects
in one project are related (have reference to) MyRepository instance of
the project. So then a user switches to specific project the application
will configure Factory instance.

Actually I can not imagine how CDO query will work without creating an
instance of the model's object. Lets say we have UML model in CDO
repository and we want to search for owned elements of actors with
specific names. In this case only implementation of the Actor knows which
features the feature ownedElement actually subsets. One possible solution
how to bypass instantiating model's object implementation is to create a
query which would check for all subsetted elements but in this we will
have a code what knows about subsetted features in two places.
Re: CDOPackageRegistry role in CDO [message #429377 is a reply to message #429370] Tue, 21 April 2009 15:08 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Hi Rimvydas,

Rimvydas wrote:

> My application can have several projects opened at one time but only one
> is active. Each project has its own MyRepository object and model objects
> in one project are related (have reference to) MyRepository instance of
> the project. So then a user switches to specific project the application
> will configure Factory instance.

> Actually I can not imagine how CDO query will work without creating an
> instance of the model's object.

[SIMON] It could work by using the internal object. (CDORevision) The
query of resources of made that way. (CDOrevision is the object that is
passed between the server and client).

Lets say we have UML model in CDO
> repository and we want to search for owned elements of actors with
> specific names. In this case only implementation of the Actor knows which
> features the feature ownedElement actually subsets. One possible solution
> how to bypass instantiating model's object implementation is to create a
> query which would check for all subsetted elements but in this we will
> have a code what knows about subsetted features in two places.

[SIMON] HUmm... Does ownedElement a derived features or an operations or a
simple features Feature? If it is a simple features (not transient and
not derived) the data is kept internally in a CDORevision. When that data
is transfered to the server, we can access that info without having the
implementation. Make sense ?

Can you define why MyRepository exist ? What are the difference between
implementation ?
Re: CDOPackageRegistry role in CDO [message #429381 is a reply to message #429367] Tue, 21 April 2009 17:50 Go to previous messageGo to next message
Rimvydas is currently offline RimvydasFriend
Messages: 47
Registered: July 2009
Member
ownedElement from my example is derived union feature. So the data is
actually kept in other features but value of ownedElement is a special
collection that contains or knows how to return values from subsetted
properties.
As I imagine CDO query could be (my fantasy):
select obj.ownedElement from Actor as obj where obj.name like 'ABC'
So CDO server must somehow to know that ownedElement property actually
consists of several other properties. As I understand the server can know
that only if
it creates the model's object instance or programmer who writes the query
will be forced to write more complex queries:
select obj.ownedComment, obj.elementImport, obj.ownedMember, ... from
Actor as obj where obj.name like 'ABC'

MyRepository contains/knows about all model elements related to the
repository and each model element uses services provided by MyRepository.
Re: CDOPackageRegistry role in CDO [message #429508 is a reply to message #429367] Fri, 24 April 2009 09:17 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Guys,

Comments below...



Simon Mc Duff schrieb:
>> My concern is related with the places which I can not control. I mean
>> if for example CDO will try to create my model's object on the server
>> side I will have no possibility to configure the factory.
> I understand your point. For now we do not create instance at the
> server but it could happen in the future. (OCL query, etc..)
For this purpose I just filed :

273562: Make EObjects available at the server-side
https://bugs.eclipse.org/bugs/show_bug.cgi?id=273562

Cheers
/Eike

----
http://thegordian.blogspot.com


Re: CDOPackageRegistry role in CDO [message #429509 is a reply to message #429365] Fri, 24 April 2009 09:23 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Rimvydas schrieb:
> Simon,
> Thank you for quick response.
>
> My concern is related with the places which I can not control. I mean
> if for example CDO will try to create my model's object on the server
> side I will have no possibility to configure the factory.
Only recently we added the ability to register EPackages with the
server-side. These packages would use whatever factory you want them to
use. As Simon said, currently we don't have EObjects at the server-side
at all. But when we will have them, they will be created by your factory
implementation. I guess what you really need is a way to listen to
package registrations, so that you're able to configure the state of the
factories before they're being used. Please file a bugzilla so that we
can add this notification.

Btw. preferrably I'd like to see a respective bugzilla against EMF Core! :P

Cheers
/Eike

----
http://thegordian.blogspot.com


>
> Maybe such model can work with CDO but only minimal CDO services can
> be used (save, read). Will it work for example with CDO Queries ?
>
>


Re: CDOPackageRegistry role in CDO [message #429511 is a reply to message #429381] Fri, 24 April 2009 09:29 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Rimvydas schrieb:
> ownedElement from my example is derived union feature. So the data is
> actually kept in other features but value of ownedElement is a special
> collection that contains or knows how to return values from subsetted
> properties. As I imagine CDO query could be (my fantasy):
> select obj.ownedElement from Actor as obj where obj.name like 'ABC'
> So CDO server must somehow to know that ownedElement property actually
> consists of several other properties. As I understand the server can
> know that only if
> it creates the model's object instance or programmer who writes the
> query will be forced to write more complex queries:
> select obj.ownedComment, obj.elementImport, obj.ownedMember, ... from
> Actor as obj where obj.name like 'ABC'
For this purpose we intend to provide the optional ability to have
CDOObjects on the server.

That said, I believe that it's generally not a good idea to modify the
default factory methods in order to modify the business state of objects
to be created. Consider that these methods are also called for objects
when you deserialize a resource. I think it's mostly useful for altering
some technical or internal state.

Cheers
/Eike

----
http://thegordian.blogspot.com


>
> MyRepository contains/knows about all model elements related to the
> repository and each model element uses services provided by MyRepository.


Previous Topic:[Teneo] Deep copying of detached entities
Next Topic:[CDO/TENEO] Problems running up server.
Goto Forum:
  


Current Time: Thu Apr 25 05:15:34 GMT 2024

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

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

Back to the top