Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Transient references and views
[CDO] Transient references and views [message #489464] Sat, 03 October 2009 13:02 Go to next message
Anders Forsell is currently offline Anders ForsellFriend
Messages: 127
Registered: July 2009
Senior Member
Hello,

I have an application which currently can work "standalone" or connected
to a CDO repository.

When the application is in "standalone" mode it uses the CDO enabled
generated model but without connecting to a repository (using XMI
resources in the ResourceSet).

To make use of CDO transactions to solve threading problems in
standalone mode I am thinking of using a CDO memory repository with a
JVM connection (to the same application process).

In the CDO "Gastro" example a nice pattern is used where a read-only
global view is accessible from the application. Changes to the model is
done by opening short-lived transactions that are committed and closed
when done.

A problem to use this approach for us is that we have many transient
references in our model, and as far as I understand the CDO view will
always have null values for these (I cannot set them because the view is
read-only). Thus, it seems I have to come with another way of
referencing these objects so that they are accessible from the view (GUI
elements).

Did I understand this correct?

---
Anders
Re: [CDO] Transient references and views [message #489468 is a reply to message #489464] Sat, 03 October 2009 15:33 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020208050804070605000404
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi Anders,

Setting a transient feature should also be possible in a read-only view,
because of this code from CDOObjectImpl:

| @Override
*public **void *dynamicSet(*int *dynamicFeatureID, Object value)
{
EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
*if *(eStructuralFeature.isTransient())
{
eSettings[dynamicFeatureID] = value;
}
*else*
{
eStore().set(this, eStructuralFeature, InternalEObject.EStore.NO_INDEX, value);
*if *(eIsCaching())
{
eSettings[dynamicFeatureID] = value;
}
}
}|


Or are you talking about TRANSIENT objects?

Cheers
/Eike

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



Anders Forsell schrieb:
> Hello,
>
> I have an application which currently can work "standalone" or
> connected to a CDO repository.
>
> When the application is in "standalone" mode it uses the CDO enabled
> generated model but without connecting to a repository (using XMI
> resources in the ResourceSet).
>
> To make use of CDO transactions to solve threading problems in
> standalone mode I am thinking of using a CDO memory repository with a
> JVM connection (to the same application process).
>
> In the CDO "Gastro" example a nice pattern is used where a read-only
> global view is accessible from the application. Changes to the model
> is done by opening short-lived transactions that are committed and
> closed when done.
>
> A problem to use this approach for us is that we have many transient
> references in our model, and as far as I understand the CDO view will
> always have null values for these (I cannot set them because the view
> is read-only). Thus, it seems I have to come with another way of
> referencing these objects so that they are accessible from the view
> (GUI elements).
>
> Did I understand this correct?
>
> ---
> Anders
>

--------------020208050804070605000404
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Anders,<br>
<br>
Setting a transient feature should also be possible in a read-only
view, because of this code from CDOObjectImpl:<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#ffffff">&nbsp;&nbsp;</font><font
color="#646464">@Override</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font
color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">dynamicSet</font><font
color="#000000">(</font><font color="#7f0055"><b>int&nbsp;</b></font><font
color="#000000">dynamicFeatureID,&nbsp;Object&nbsp;value </font><font
color="#000000">)</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> EStructuralFeature&nbsp;eStructuralFeature&nbsp;=&am p;nbsp;eDynamicFeature </font><font
color="#000000">(</font><font color="#000000">dynamicFeatureID</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>if&nbsp;</b></font><font
color="#000000">(</font><font color="#000000">eStructuralFeature.isTransient</font><font
color="#000000">())</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">eSettings</font><font
color="#000000">[</font><font color="#000000">dynamicFeatureID</font><font
color="#000000">]&nbsp;</font><font color="#000000">=&nbsp;value;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">}</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>else</b></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">eStore</font><font
color="#000000">()</font><font color="#000000">.set</font><font
color="#000000">(</font><font color="#000000"> this,&nbsp;eStructuralFeature,&nbsp;InternalEObject. EStore.NO_INDEX,&nbsp;value </font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#7f0055"><b>if&nbsp;</b></font><font
color="#000000">(</font><font color="#000000">eIsCaching</font><font
color="#000000">())</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">eSettings</font><font
color="#000000">[</font><font color="#000000">dynamicFeatureID</font><font
color="#000000">]&nbsp;</font><font color="#000000">=&nbsp;value;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">}</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">}</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font></code>
</td>
<!-- end source code --> </tr>
</tbody>
</table>
</div>
<!-- = END of automatically generated HTML code = -->
<!-- ======================================================== --><br>
Or are you talking about TRANSIENT objects?<br>
<br>
Cheers<br>
/Eike<br>
<br>
----<br>
<a class="moz-txt-link-freetext" href="http://thegordian.blogspot.com">http://thegordian.blogspot.com</a><br>
<a class="moz-txt-link-freetext" href="http://twitter.com/eikestepper">http://twitter.com/eikestepper</a><br>
<br>
<br>
<br>
Anders Forsell schrieb:
<blockquote cite="mid:ha7i0r$9hm$1@build.eclipse.org" type="cite">Hello,
<br>
<br>
I have an application which currently can work "standalone" or
connected to a CDO repository.
<br>
<br>
When the application is in "standalone" mode it uses the CDO enabled
generated model but without connecting to a repository (using XMI
resources in the ResourceSet).
<br>
<br>
To make use of CDO transactions to solve threading problems in
standalone mode I am thinking of using a CDO memory repository with a
JVM connection (to the same application process).
<br>
<br>
In the CDO "Gastro" example a nice pattern is used where a read-only
global view is accessible from the application. Changes to the model is
done by opening short-lived transactions that are committed and closed
when done.
<br>
<br>
A problem to use this approach for us is that we have many transient
references in our model, and as far as I understand the CDO view will
always have null values for these (I cannot set them because the view
is read-only). Thus, it seems I have to come with another way of
referencing these objects so that they are accessible from the view
(GUI elements).
<br>
<br>
Did I understand this correct?
<br>
<br>
---
<br>
Anders
<br>
<br>
</blockquote>
</body>
</html>

--------------020208050804070605000404--


Re: [CDO] Transient references and views [message #489470 is a reply to message #489468] Sat, 03 October 2009 15:39 Go to previous messageGo to next message
Anders Forsell is currently offline Anders ForsellFriend
Messages: 127
Registered: July 2009
Senior Member
Thanks Eike,

I thought I tried it but it must have been for a non-transient feature.

Then I just need to come up with a pattern of delegating the
non-transient feature getter/setter to always use the global view
instead of the transaction.

---
Anders



Eike Stepper wrote:
> Hi Anders,
>
> Setting a transient feature should also be possible in a read-only view,
> because of this code from CDOObjectImpl:
>
> | @Override
> *public **void *dynamicSet(*int *dynamicFeatureID, Object value)
> {
> EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
> *if *(eStructuralFeature.isTransient())
> {
> eSettings[dynamicFeatureID] = value;
> }
> *else*
> {
> eStore().set(this, eStructuralFeature, InternalEObject.EStore.NO_INDEX, value);
> *if *(eIsCaching())
> {
> eSettings[dynamicFeatureID] = value;
> }
> }
> }|
>
>
> Or are you talking about TRANSIENT objects?
>
> Cheers
> /Eike
>
> ----
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
>
> Anders Forsell schrieb:
>> Hello,
>>
>> I have an application which currently can work "standalone" or
>> connected to a CDO repository.
>>
>> When the application is in "standalone" mode it uses the CDO enabled
>> generated model but without connecting to a repository (using XMI
>> resources in the ResourceSet).
>>
>> To make use of CDO transactions to solve threading problems in
>> standalone mode I am thinking of using a CDO memory repository with a
>> JVM connection (to the same application process).
>>
>> In the CDO "Gastro" example a nice pattern is used where a read-only
>> global view is accessible from the application. Changes to the model
>> is done by opening short-lived transactions that are committed and
>> closed when done.
>>
>> A problem to use this approach for us is that we have many transient
>> references in our model, and as far as I understand the CDO view will
>> always have null values for these (I cannot set them because the view
>> is read-only). Thus, it seems I have to come with another way of
>> referencing these objects so that they are accessible from the view
>> (GUI elements).
>>
>> Did I understand this correct?
>>
>> ---
>> Anders
>>
Re: [CDO] Transient references and views [message #489473 is a reply to message #489470] Sat, 03 October 2009 15:56 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Anders Forsell schrieb:
> Thanks Eike,
>
> I thought I tried it but it must have been for a non-transient feature.
Well, the code snippet does not cover modification of many-valued
features. Maybe you can demonstrate the behaviour in a test case?

>
> Then I just need to come up with a pattern of delegating the
> non-transient feature getter/setter to always use the global view
> instead of the transaction.
That sounds strange. I still wonder why a view/transaction is related to
this at all. Are you talking about TRANSIENT objects?

Cheers
/Eike

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


>
> ---
> Anders
>
>
>
> Eike Stepper wrote:
>> Hi Anders,
>>
>> Setting a transient feature should also be possible in a read-only
>> view, because of this code from CDOObjectImpl:
>>
>> | @Override
>> *public **void *dynamicSet(*int *dynamicFeatureID, Object value)
>> {
>> EStructuralFeature eStructuralFeature =
>> eDynamicFeature(dynamicFeatureID);
>> *if *(eStructuralFeature.isTransient())
>> {
>> eSettings[dynamicFeatureID] = value;
>> }
>> *else*
>> {
>> eStore().set(this, eStructuralFeature,
>> InternalEObject.EStore.NO_INDEX, value);
>> *if *(eIsCaching())
>> {
>> eSettings[dynamicFeatureID] = value;
>> }
>> }
>> }|
>>
>>
>> Or are you talking about TRANSIENT objects?
>>
>> Cheers
>> /Eike
>>
>> ----
>> http://thegordian.blogspot.com
>> http://twitter.com/eikestepper
>>
>>
>>
>> Anders Forsell schrieb:
>>> Hello,
>>>
>>> I have an application which currently can work "standalone" or
>>> connected to a CDO repository.
>>>
>>> When the application is in "standalone" mode it uses the CDO enabled
>>> generated model but without connecting to a repository (using XMI
>>> resources in the ResourceSet).
>>>
>>> To make use of CDO transactions to solve threading problems in
>>> standalone mode I am thinking of using a CDO memory repository with
>>> a JVM connection (to the same application process).
>>>
>>> In the CDO "Gastro" example a nice pattern is used where a read-only
>>> global view is accessible from the application. Changes to the model
>>> is done by opening short-lived transactions that are committed and
>>> closed when done.
>>>
>>> A problem to use this approach for us is that we have many transient
>>> references in our model, and as far as I understand the CDO view
>>> will always have null values for these (I cannot set them because
>>> the view is read-only). Thus, it seems I have to come with another
>>> way of referencing these objects so that they are accessible from
>>> the view (GUI elements).
>>>
>>> Did I understand this correct?
>>>
>>> ---
>>> Anders
>>>


Re: [CDO] Transient references and views [message #489474 is a reply to message #489473] Sat, 03 October 2009 17:17 Go to previous messageGo to next message
Anders Forsell is currently offline Anders ForsellFriend
Messages: 127
Registered: July 2009
Senior Member
Eike Stepper wrote:
> Anders Forsell schrieb:
>> Thanks Eike,
>>
>> I thought I tried it but it must have been for a non-transient feature.
> Well, the code snippet does not cover modification of many-valued
> features. Maybe you can demonstrate the behaviour in a test case?
I'll do some more tests to see if it is possible or not, but at least it
seems like you have thought about it in the code snippet.
>
>> Then I just need to come up with a pattern of delegating the
>> non-transient feature getter/setter to always use the global view
>> instead of the transaction.
> That sounds strange. I still wonder why a view/transaction is related to
> this at all. Are you talking about TRANSIENT objects?
Sorry, my mistake in not thinking clear. Of course, I have to transfer
the value of the transient features from the transaction at commit time
to the global view.
If it is possible to set transient features on the view, in my setup
it's a matter of reading the transient features values from the
transaction and setting the corresponding on the view (since I'm within
the same process). I'll have to come up with a way of doing this
generically, otherwise I believe I cannot easily utilize the global view
pattern.
>
> Cheers
> /Eike
>
> ----
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
>> ---
>> Anders
>>
>>
>>
>> Eike Stepper wrote:
>>> Hi Anders,
>>>
>>> Setting a transient feature should also be possible in a read-only
>>> view, because of this code from CDOObjectImpl:
>>>
>>> | @Override
>>> *public **void *dynamicSet(*int *dynamicFeatureID, Object value)
>>> {
>>> EStructuralFeature eStructuralFeature =
>>> eDynamicFeature(dynamicFeatureID);
>>> *if *(eStructuralFeature.isTransient())
>>> {
>>> eSettings[dynamicFeatureID] = value;
>>> }
>>> *else*
>>> {
>>> eStore().set(this, eStructuralFeature,
>>> InternalEObject.EStore.NO_INDEX, value);
>>> *if *(eIsCaching())
>>> {
>>> eSettings[dynamicFeatureID] = value;
>>> }
>>> }
>>> }|
>>>
>>>
>>> Or are you talking about TRANSIENT objects?
>>>
>>> Cheers
>>> /Eike
>>>
>>> ----
>>> http://thegordian.blogspot.com
>>> http://twitter.com/eikestepper
>>>
>>>
>>>
>>> Anders Forsell schrieb:
>>>> Hello,
>>>>
>>>> I have an application which currently can work "standalone" or
>>>> connected to a CDO repository.
>>>>
>>>> When the application is in "standalone" mode it uses the CDO enabled
>>>> generated model but without connecting to a repository (using XMI
>>>> resources in the ResourceSet).
>>>>
>>>> To make use of CDO transactions to solve threading problems in
>>>> standalone mode I am thinking of using a CDO memory repository with
>>>> a JVM connection (to the same application process).
>>>>
>>>> In the CDO "Gastro" example a nice pattern is used where a read-only
>>>> global view is accessible from the application. Changes to the model
>>>> is done by opening short-lived transactions that are committed and
>>>> closed when done.
>>>>
>>>> A problem to use this approach for us is that we have many transient
>>>> references in our model, and as far as I understand the CDO view
>>>> will always have null values for these (I cannot set them because
>>>> the view is read-only). Thus, it seems I have to come with another
>>>> way of referencing these objects so that they are accessible from
>>>> the view (GUI elements).
>>>>
>>>> Did I understand this correct?
>>>>
>>>> ---
>>>> Anders
>>>>
Re: [CDO] Transient references and views [message #489476 is a reply to message #489474] Sat, 03 October 2009 17:28 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Anders Forsell schrieb:
> Sorry, my mistake in not thinking clear. Of course, I have to transfer
> the value of the transient features from the transaction at commit
> time to the global view.
> If it is possible to set transient features on the view, in my setup
> it's a matter of reading the transient features values from the
> transaction and setting the corresponding on the view (since I'm
> within the same process). I'll have to come up with a way of doing
> this generically, otherwise I believe I cannot easily utilize the
> global view pattern.
If it's possible to modify transient features in a view at all then it's
certainly possible to do it generically, too ;-)

Cheers
/Eike

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


Re: [CDO] Transient references and views [message #489495 is a reply to message #489476] Sun, 04 October 2009 06:10 Go to previous messageGo to next message
Anders Forsell is currently offline Anders ForsellFriend
Messages: 127
Registered: July 2009
Senior Member
Eike Stepper wrote:
> If it's possible to modify transient features in a view at all then it's
> certainly possible to do it generically, too ;-)

How about eviction from the view cache. Can view objects be evicted even
if it has transient features that have been set? (I am mostly interested
in how the MEM repository cache works).

If so, can you prevent these objects from being evicted somehow?

---
Anders
Re: [CDO] Transient references and views [message #489496 is a reply to message #489495] Sun, 04 October 2009 06:56 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Anders Forsell schrieb:
> Eike Stepper wrote:
>> If it's possible to modify transient features in a view at all then it's
>> certainly possible to do it generically, too ;-)
>
> How about eviction from the view cache. Can view objects be evicted
> even if it has transient features that have been set? (I am mostly
> interested in how the MEM repository cache works).
>
> If so, can you prevent these objects from being evicted somehow?
The targets of transient referenecs are not "cached" in CDO.

Cheers
/Eike

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


Re: [CDO] Transient references and views [message #489501 is a reply to message #489496] Sun, 04 October 2009 07:29 Go to previous message
Anders Forsell is currently offline Anders ForsellFriend
Messages: 127
Registered: July 2009
Senior Member
Eike Stepper wrote:
> The targets of transient referenecs are not "cached" in CDO.

I am not talking about the targets, but the CDO objects that keep the
transient references to the objects. If these objects are evicted and
then read back later the transient references will be null, right?

---
Anders
Previous Topic:XML Customizing using Extended MetaData
Next Topic:Suppressing document root but loosing name of top element.
Goto Forum:
  


Current Time: Fri Mar 29 05:19:37 GMT 2024

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

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

Back to the top