Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » SDO Java - EDataGraph - serialize-transmit (RMI/IIOP)-deserialize then access via *static* SDO API?
SDO Java - EDataGraph - serialize-transmit (RMI/IIOP)-deserialize then access via *static* SDO API? [message #414988] Tue, 27 November 2007 15:14 Go to next message
Eclipse UserFriend
Originally posted by: GaryRMartin.insightbb.com

By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.
Re: SDO Java - EDataGraph - serialize-transmit (RMI/IIOP)-deserialize then access via *static* SDO [message #414989 is a reply to message #414988] Tue, 27 November 2007 15:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060405040609080503050101
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Gary,

Yes, that is possible:

Tutorial: Using the SDO Data Graph Editor
< http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.ecore.sdo.doc/tutorials/datagraph/datagraph.html>


Gary Martin wrote:
> By design (with any version of SDO and Tuscany Java implementation),
>
> should it be possible to generate "static" SDO classes from an .xsd, and
> then:
>
> a) use the generated classes to create an:
> org.eclipse.emf.ecore.sdo.EDataGraph
> b)call a method on the remote interface of an ejb that takes that
> EDataGraph as its only arguement
> c)use the *static* generated SDO classes to access the SDOs in the
> EDataGraph
>
> I've done a) and b) and can use the dynamic SDO API in my EJB method,
> but, I've yet to figure out how (or even if it should be possible by
> design) to use the generated "static" SDO classes in my EJB method.
>
>
>


--------------060405040609080503050101
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">
Gary,<br>
<br>
Yes, that is possible:<br>
<blockquote><a
href=" http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.ecore.sdo.doc/tutorials/datagraph/datagraph.html">Tutorial:
Using the SDO Data Graph Editor</a><br>
</blockquote>
<br>
Gary Martin wrote:
<blockquote cite="mid:fihc9v$c1p$1@build.eclipse.org" type="cite">
<pre wrap="">By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.


</pre>
</blockquote>
<br>
</body>
</html>

--------------060405040609080503050101--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: SDO Java - EDataGraph - serialize-transmit (RMI/IIOP)-followup ? [message #414993 is a reply to message #414989] Tue, 27 November 2007 18:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: GaryRMartin.insightbb.com

This is a multi-part message in MIME format.

------=_NextPart_000_002A_01C830F5.D76154A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,

Thank you. I'm not connecting the dots. Are you suggesting that the =
source code of
the SDO Data Graph Editor itself illustrates c) in my problem statement?

Here's a snippet of code from the method in my EJB where I'm able to use =
the dynamic
API, but unable to use the static API.

import com.ibm.ItemType;
import com.ibm.PurchaseOrderType;
import com.ibm.DocumentRoot;
import com.ibm.util.IbmResourceFactoryImpl;
import com.ibm.util.IbmResourceUtil;

import commonj.sdo.DataObject;
import commonj.sdo.Property;


import org.eclipse.emf.ecore.impl.EReferenceImpl;
import org.eclipse.emf.ecore.sdo.EDataGraph;
import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;



// method defined on the remote interface=20
public void acceptEDataGraph (EDataGraph eDG) {


DataObject rootObject =3D eDG.getRootObject(); // works
DataObject purchaseOrder =3D =
rootObject.getDataObject("purchaseOrder"); // works

java.util.Date orderDate =3D purchaseOrder.getDate("orderDate"); // =
works
System.out.println("orderDate: " + orderDate); // works=20


// This doesn't work=20
DocumentRoot documentRoot =3D (DocumentRoot)eDG.getERootObject(); =20
PurchaseOrderType aPOT =3D documentRoot.getPurchaseOrder(); // what =
I'm referring to as the "static" SDO API

// I get this exception=20
java.rmi.ServerException: RemoteException occurred in server thread; =
nested exception is:=20
java.rmi.RemoteException:=20
>> SERVER (id=3D4773e3aa, host=3DIBM-0CA191A407D) TRACE START:
>> java.rmi.RemoteException: ; nested exception is:=20
java.lang.ClassCastException: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with =
com.ibm.DocumentRoot
>> at =
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fihdh6$jpc$1@build.eclipse.org...
Gary,

Yes, that is possible:

Tutorial: Using the SDO Data Graph Editor


Gary Martin wrote:=20
By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


=20


------=_NextPart_000_002A_01C830F5.D76154A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thank you.&nbsp; I'm =
not&nbsp;connecting the=20
dots.&nbsp;&nbsp; Are you suggesting that the source code =
of</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the SDO Data Graph Editor itself =
illustrates c) in=20
my problem statement?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here's a snippet of code from the =
method in my EJB=20
where I'm able to use the dynamic</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>API, but unable to use the static =
API.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import com.ibm.ItemType;<BR>import=20
com.ibm.PurchaseOrderType;<BR>import com.ibm.DocumentRoot;<BR>import=20
com.ibm.util.IbmResourceFactoryImpl;<BR>import=20
com.ibm.util.IbmResourceUtil;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import =
commonj.sdo.DataObject;<BR>import=20
commonj.sdo.Property;</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=3DArial size=3D2>
<DIV><BR>import org.eclipse.emf.ecore.impl.EReferenceImpl;<BR>import=20
org.eclipse.emf.ecore.sdo.EDataGraph;<BR>import=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;</DIV >
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>// method defined on the remote interface <BR>public void =
acceptEDataGraph=20
(EDataGraph eDG)&nbsp; {</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;&nbsp;DataObject rootObject =3D eDG.getRootObject(); //=20
works<BR>&nbsp;&nbsp;DataObject purchaseOrder =3D=20
rootObject.getDataObject("purchaseOrder"); // works</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;java.util.Date orderDate =3D =
purchaseOrder.getDate("orderDate");=20
// works<BR>&nbsp;&nbsp;System.out.println("orderDate: " + orderDate); =
// works=20
</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;&nbsp;// This doesn't work <BR>&nbsp;&nbsp;DocumentRoot=20
documentRoot =3D=20
(DocumentRoot)eDG.getERootObject();&nbsp;&nbsp;<BR>&nbsp;&nbsp;PurchaseOr=
derType=20
aPOT =3D documentRoot.getPurchaseOrder(); // what I'm referring to as =
the "static"=20
SDO API</DIV>
<DIV>&nbsp;</DIV>
<DIV>// I get this exception <BR>java.rmi.ServerException: =
RemoteException=20
occurred in server thread; nested exception is:=20
<BR>&nbsp;java.rmi.RemoteException: <BR>&nbsp;&gt;&gt; SERVER =
(id=3D4773e3aa,=20
host=3DIBM-0CA191A407D) TRACE START:<BR>&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp; =

java.rmi.RemoteException: ; nested exception is:=20
<BR>&nbsp;java.lang.ClassCastException:=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with=20
com.ibm.DocumentRoot<BR>&nbsp;&gt;&gt;&nbsp; at=20
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=
</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:fihdh6$jpc$1@build.eclipse.org">news:fihdh6$jpc$1@build.ecli=
pse.org</A>...</DIV>Gary,<BR><BR>Yes,=20
that is possible:<BR>
<BLOCKQUOTE><A=20
=
href=3D" http://help.eclipse.org/help33/index.jsp?topic=3D/org.eclips e.emf=
..ecore.sdo.doc/tutorials/datagraph/datagraph.html">Tutorial:=20
Using the SDO Data Graph Editor</A><BR></BLOCKQUOTE><BR>Gary Martin =
wrote:=20
<BLOCKQUOTE cite=3Dmid:fihc9v$c1p$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">By design (with any version of SDO and =
Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: =
0px">&nbsp;</BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_002A_01C830F5.D76154A0--
Re: SDO Java - EDataGraph - serialize-transmit (RMI/IIOP)-followup ? [message #414994 is a reply to message #414993] Tue, 27 November 2007 18:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090008040604030603000903
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Gary,

Comments below.

Gary Martin wrote:
> Ed,
>
> Thank you. I'm not connecting the dots. Are you suggesting that the
> source code of
> the SDO Data Graph Editor itself illustrates c) in my problem statement?
No, I'm suggesting that the tutorial shows you the steps you need to
generate the static code for your SDO model and then the datagraph
editor shows your model being used to read and write instances or your
model using your generated code.
>
> Here's a snippet of code from the method in my EJB where I'm able to
> use the dynamic
> API, but unable to use the static API.
>
> import com.ibm.ItemType;
> import com.ibm.PurchaseOrderType;
> import com.ibm.DocumentRoot;
It looks like you've already generated the code so that makes me a bit
confused about why you asked how to generate the the code.
> import com.ibm.util.IbmResourceFactoryImpl;
> import com.ibm.util.IbmResourceUtil;
>
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
>
>
> import org.eclipse.emf.ecore.impl.EReferenceImpl;
> import org.eclipse.emf.ecore.sdo.EDataGraph;
> import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;
>
>
>
> // method defined on the remote interface
> public void acceptEDataGraph (EDataGraph eDG) {
>
>
> DataObject rootObject = eDG.getRootObject(); // works
> DataObject purchaseOrder =
> rootObject.getDataObject("purchaseOrder"); // works
>
> java.util.Date orderDate = purchaseOrder.getDate("orderDate"); // works
> System.out.println("orderDate: " + orderDate); // works
>
>
> // This doesn't work
> DocumentRoot documentRoot = (DocumentRoot)eDG.getERootObject();
> PurchaseOrderType aPOT = documentRoot.getPurchaseOrder(); // what
> I'm referring to as the "static" SDO API
>
> // I get this exception
> java.rmi.ServerException: RemoteException occurred in server thread;
> nested exception is:
> java.rmi.RemoteException:
> >> SERVER (id=4773e3aa, host=IBM-0CA191A407D) TRACE START:
> >> java.rmi.RemoteException: ; nested exception is:
> java.lang.ClassCastException:
> org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible
> with com.ibm.DocumentRoot
> >> at
> sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)
Oh, I see. Maybe all that's missing is the code to ensure that your
generated package is registered with the static registry. At some point
during the initialization of the server you should access the
XyzPackage.eINSTANCE to ensure that the package is registered.
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:fihdh6$jpc$1@build.eclipse.org...
> Gary,
>
> Yes, that is possible:
>
> Tutorial: Using the SDO Data Graph Editor
> < http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf..ecore.sdo.doc/tutorials/datagraph/datagraph.html>
>
>
> Gary Martin wrote:
>> By design (with any version of SDO and Tuscany Java implementation),
>>
>> should it be possible to generate "static" SDO classes from an .xsd, and
>> then:
>>
>> a) use the generated classes to create an:
>> org.eclipse.emf.ecore.sdo.EDataGraph
>> b)call a method on the remote interface of an ejb that takes that
>> EDataGraph as its only arguement
>> c)use the *static* generated SDO classes to access the SDOs in the
>> EDataGraph
>>
>> I've done a) and b) and can use the dynamic SDO API in my EJB method,
>> but, I've yet to figure out how (or even if it should be possible by
>> design) to use the generated "static" SDO classes in my EJB method.
>>
>>
>>
>
>
>


--------------090008040604030603000903
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">
Gary,<br>
<br>
Comments below.<br>
<br>
Gary Martin wrote:
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">
<div><font face="Arial" size="2">Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thank you.&nbsp; I'm not&nbsp;connecting the
dots.&nbsp;&nbsp; Are you suggesting that the source code of</font></div>
<div><font face="Arial" size="2">the SDO Data Graph Editor itself
illustrates c) in my problem statement?</font></div>
</font></div>
</blockquote>
No, I'm suggesting that the tutorial shows you the steps you need to
generate the static code for your SDO model and then the datagraph
editor shows your model being used to read and write instances or your
model using your generated code.<br>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">
<div>&nbsp;</div>
<div><font face="Arial" size="2">Here's a snippet of code from the
method in my EJB where I'm able to use the dynamic</font></div>
<div><font face="Arial" size="2">API, but unable to use the static
API.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">import com.ibm.ItemType;<br>
import com.ibm.PurchaseOrderType;<br>
import com.ibm.DocumentRoot;<br>
</font></div>
</font></div>
</blockquote>
It looks like you've already generated the code so that makes me a bit
confused about why you asked how to generate the the code.<br>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">
<div><font face="Arial" size="2">import
com.ibm.util.IbmResourceFactoryImpl;<br>
import com.ibm.util.IbmResourceUtil;</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">import commonj.sdo.DataObject;<br>
import commonj.sdo.Property;</font></div>
<div>&nbsp;</div>
<font face="Arial" size="2"></font>
<div><font face="Arial" size="2"><br>
import org.eclipse.emf.ecore.impl.EReferenceImpl;<br>
import org.eclipse.emf.ecore.sdo.EDataGraph;<br>
import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;</font ></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">// method defined on the remote
interface <br>
public void acceptEDataGraph (EDataGraph eDG)&nbsp; {</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2"><br>
&nbsp;&nbsp;DataObject rootObject = eDG.getRootObject(); // works<br>
&nbsp;&nbsp;DataObject purchaseOrder = rootObject.getDataObject("purchaseOrder");
// works</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">&nbsp;&nbsp;java.util.Date orderDate =
purchaseOrder.getDate("orderDate"); // works<br>
&nbsp;&nbsp;System.out.println("orderDate: " + orderDate); // works </font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2"><br>
&nbsp;&nbsp;// This doesn't work <br>
&nbsp;&nbsp;DocumentRoot documentRoot = (DocumentRoot)eDG.getERootObject();&nbsp;&nbsp;<br>
&nbsp;&nbsp;PurchaseOrderType aPOT = documentRoot.getPurchaseOrder(); // what I'm
referring to as the "static" SDO API</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">// I get this exception <br>
java.rmi.ServerException: RemoteException occurred in server thread;
nested exception is: <br>
&nbsp;java.rmi.RemoteException: <br>
&nbsp;&gt;&gt; SERVER (id=4773e3aa, host=IBM-0CA191A407D) TRACE START:<br>
&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp; java.rmi.RemoteException: ; nested exception is: <br>
&nbsp;java.lang.ClassCastException:
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with
com.ibm.DocumentRoot<br>
&nbsp;&gt;&gt;&nbsp; at
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89) </font></div>
</font></div>
</blockquote>
Oh, I see.&nbsp; Maybe all that's missing is the code to ensure that your
generated package is registered with the static registry. At some point
during the initialization of the server you should access the
XyzPackage.eINSTANCE to ensure that the package is registered.<br>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a moz-do-not-send="true"
href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt; wrote in
message <a moz-do-not-send="true"
href="news:fihdh6$jpc$1@build.eclipse.org">news:fihdh6$jpc$1@build.eclipse.org</a>...</div>
Gary,<br>
<br>
Yes, that is possible:<br>
<blockquote><a moz-do-not-send="true"
href=" http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf..ecore.sdo.doc/tutorials/datagraph/datagraph.html">Tutorial:
Using the SDO Data Graph Editor</a><br>
</blockquote>
<br>
Gary Martin wrote:
<blockquote cite="mid:fihc9v$c1p$1@build.eclipse.org" type="cite">
<pre wrap="">By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.


</pre>
</blockquote>
<br>
</blockquote>
</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">&nbsp;</blockquote>
</blockquote>
<br>
</body>
</html>

--------------090008040604030603000903--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: SDO Java -serialization/deserialization of EDataGraph - deliberate replacement of each EDataObj [message #415190 is a reply to message #414994] Tue, 04 December 2007 16:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: GaryRMartin.insightbb.com

This is a multi-part message in MIME format.

------=_NextPart_000_0019_01C8366A.535EBC90
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Upon further investigation:

Note: I'm using whatever implementation of SDO 1.0 spec IBM included in
WebSphere App Server v6.1.0.11 - =
...\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005.ja r

In a previous append - Tuesday, November 27, 2007 1:03 PM Eastern - I =
included a snippet of source code from a=20
method - acceptEDataGraph(EDataGraph) defined by a Stateless Session EJB =
and on the EJB's remote interface.

Based on your append - Tuesday, November 27, 2007 1:18 PM Eastern - I =
added:
IbmPackage anIbmPackage =3D IbmPackageImpl.init();
as the 1st statement in that method (This didn't appear to change the =
behavior about which I comment below.)


Snippet from EJB client (with comments on which I ask your feedback):

// create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and populate =
root Object and contained objects using
// generated IBMFactoryImpl and "static" SDOs (inherit from =
EDataObjectImpl

....

Object anObject =3D ((EDataGraphImpl) eDG).getWriteReplacement(); // =
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable
// just =
curious what Object was returned

aSDOExchanger.acceptEDataGraph(eDG); // defined on remote interface of =
Stateless Session EJB

// eDG's ERootObject was set earlier to instance of: =
com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits from =
EDataObjectImpl)
// DocumentRootImpl.setPurchaseOrder was set to instance of =
com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)
=20
// When accessed (after serialization / deserialization) in EJB, =
EDataGraph's rootObject is a: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
// When accessed in EJB, DocumentRootImpl.getPurchaseOrder is instance =
of: org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
=20
// I've concluded that this "replacement" (during serialization / =
deserialization) of instances of generated "static" SDOs
// (that inherit from EDataObjectImpl)
// with instances of DynamicEDataObjectImpl has to be a conscious design =
choice - not a bug.
// As a result, I can't use the generated "static" SDOs in the =
implementation of method acceptEDataGraph(EDataGraph)

Ed:

a) Do you agree / disagree with that conclusion?
b) Do you know if this behavior is different (by design) in newer =
Tuscany implementations of SDO 1.0 or 2.0?
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fihn1g$e1e$1@build.eclipse.org...
Gary,

Comments below.

Gary Martin wrote:=20
Ed,

Thank you. I'm not connecting the dots. Are you suggesting that =
the source code of
the SDO Data Graph Editor itself illustrates c) in my problem =
statement?
No, I'm suggesting that the tutorial shows you the steps you need to =
generate the static code for your SDO model and then the datagraph =
editor shows your model being used to read and write instances or your =
model using your generated code.


Here's a snippet of code from the method in my EJB where I'm able to =
use the dynamic
API, but unable to use the static API.

import com.ibm.ItemType;
import com.ibm.PurchaseOrderType;
import com.ibm.DocumentRoot;

It looks like you've already generated the code so that makes me a bit =
confused about why you asked how to generate the the code.

import com.ibm.util.IbmResourceFactoryImpl;
import com.ibm.util.IbmResourceUtil;

import commonj.sdo.DataObject;
import commonj.sdo.Property;


import org.eclipse.emf.ecore.impl.EReferenceImpl;
import org.eclipse.emf.ecore.sdo.EDataGraph;
import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;



// method defined on the remote interface=20
public void acceptEDataGraph (EDataGraph eDG) {


DataObject rootObject =3D eDG.getRootObject(); // works
DataObject purchaseOrder =3D =
rootObject.getDataObject("purchaseOrder"); // works

java.util.Date orderDate =3D purchaseOrder.getDate("orderDate"); =
// works
System.out.println("orderDate: " + orderDate); // works=20


// This doesn't work=20
DocumentRoot documentRoot =3D (DocumentRoot)eDG.getERootObject(); =

PurchaseOrderType aPOT =3D documentRoot.getPurchaseOrder(); // =
what I'm referring to as the "static" SDO API

// I get this exception=20
java.rmi.ServerException: RemoteException occurred in server thread; =
nested exception is:=20
java.rmi.RemoteException:=20
>> SERVER (id=3D4773e3aa, host=3DIBM-0CA191A407D) TRACE START:
>> java.rmi.RemoteException: ; nested exception is:=20
java.lang.ClassCastException: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with =
com.ibm.DocumentRoot
>> at =
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=

Oh, I see. Maybe all that's missing is the code to ensure that your =
generated package is registered with the static registry. At some point =
during the initialization of the server you should access the =
XyzPackage.eINSTANCE to ensure that the package is registered.

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fihdh6$jpc$1@build.eclipse.org...
Gary,

Yes, that is possible:

Tutorial: Using the SDO Data Graph Editor


Gary Martin wrote:=20
By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


=20




------=_NextPart_000_0019_01C8366A.535EBC90
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Upon further =
investigation:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Note: I'm using whatever implementation =
of SDO 1.0=20
spec IBM included in<BR>WebSphere App Server v6.1.0.11 -=20
...\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005.ja r </FONT></DIV>=

<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>In a previous append - Tuesday, =
November 27, 2007=20
1:03 PM Eastern - I included a snippet of source code from a <BR>method =
-=20
acceptEDataGraph(EDataGraph) defined by a Stateless Session EJB and on =
the EJB's=20
remote interface.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Based on your append - Tuesday, =
November 27, 2007=20
1:18 PM Eastern - I added:<BR>IbmPackage anIbmPackage =3D=20
IbmPackageImpl.init();<BR>as the 1st statement in that method&nbsp; =
(This didn't=20
appear to change the behavior about which I comment below.)</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=3DArial size=3D2>
<DIV><BR>Snippet from EJB client (with comments on which I ask your=20
feedback):</DIV>
<DIV>&nbsp;</DIV>
<DIV>// create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and =
populate root=20
Object and contained objects using<BR>// generated IBMFactoryImpl and =
"static"=20
SDOs (inherit from EDataObjectImpl</DIV>
<DIV>&nbsp;</DIV>
<DIV>...</DIV>
<DIV>&nbsp;</DIV>
<DIV>Object anObject =3D ((EDataGraphImpl) eDG).getWriteReplacement(); =
//=20
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable <BR=
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n b=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb s=
p;&nbsp;&nbsp;=20
// just curious what Object was returned</DIV>
<DIV>&nbsp;</DIV>
<DIV>aSDOExchanger.acceptEDataGraph(eDG); // defined on remote interface =
of=20
Stateless Session EJB</DIV>
<DIV>&nbsp;</DIV>
<DIV>// eDG's ERootObject was set earlier to instance of:=20
com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits from=20
EDataObjectImpl)<BR>// DocumentRootImpl.setPurchaseOrder was set to =
instance of=20
com.ibm.impl.PurchaseOrderTypeImpl (generated "static"=20
SDO)<BR>&nbsp;&nbsp;&nbsp;<BR>// When accessed (after serialization /=20
deserialization) in EJB, EDataGraph's rootObject is a:=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<BR>// When =
accessed in=20
EJB, DocumentRootImpl.getPurchaseOrder is instance of:=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<BR>&nbsp;&nbsp;&nbs=
p;<BR>//=20
I've concluded that this "replacement" (during serialization / =
deserialization)=20
of instances of generated "static" SDOs<BR>// (that inherit from=20
EDataObjectImpl)<BR>// with instances of DynamicEDataObjectImpl has to =
be a=20
conscious design choice - not a bug.<BR>// As a result, I can't use the=20
generated "static" SDOs in the implementation of method=20
acceptEDataGraph(EDataGraph)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Ed:</DIV>
<DIV>&nbsp;</DIV>
<DIV>a) Do you agree / disagree with that conclusion?<BR>b) Do you know =
if this=20
behavior is different (by design) in newer Tuscany implementations of =
SDO 1.0 or=20
2.0?</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:fihn1g$e1e$1@build.eclipse.org">news:fihn1g$e1e$1@build.ecli=
pse.org</A>...</DIV>Gary,<BR><BR>Comments=20
below.<BR><BR>Gary Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thank you.&nbsp; I'm =
not&nbsp;connecting the=20
dots.&nbsp;&nbsp; Are you suggesting that the source code =
of</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the SDO Data Graph Editor itself =
illustrates c)=20
in my problem statement?</FONT></DIV></FONT></DIV></BLOCKQUOTE>No, =
I'm=20
suggesting that the tutorial shows you the steps you need to generate =
the=20
static code for your SDO model and then the datagraph editor shows =
your model=20
being used to read and write instances or your model using your =
generated=20
code.<BR>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org type=3D"cite">
<DIV><FONT face=3DArial size=3D2>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here's a snippet of code from the =
method in my=20
EJB where I'm able to use the dynamic</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>API, but unable to use the static=20
API.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import com.ibm.ItemType;<BR>import=20
com.ibm.PurchaseOrderType;<BR>import=20
com.ibm.DocumentRoot;<BR></FONT></DIV></FONT></DIV></BLOCKQUOTE >It =
looks like=20
you've already generated the code so that makes me a bit confused =
about why=20
you asked how to generate the the code.<BR>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org type=3D"cite">
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>import=20
com.ibm.util.IbmResourceFactoryImpl;<BR>import=20
com.ibm.util.IbmResourceUtil;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import =
commonj.sdo.DataObject;<BR>import=20
commonj.sdo.Property;</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=3DArial size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2><BR>import=20
org.eclipse.emf.ecore.impl.EReferenceImpl;<BR>import=20
org.eclipse.emf.ecore.sdo.EDataGraph;<BR>import=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;</FONT ></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// method defined on the remote =
interface=20
<BR>public void acceptEDataGraph (EDataGraph eDG)&nbsp; =
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;DataObject =
rootObject =3D=20
eDG.getRootObject(); // works<BR>&nbsp;&nbsp;DataObject =
purchaseOrder =3D=20
rootObject.getDataObject("purchaseOrder"); // works</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;java.util.Date =
orderDate =3D=20
purchaseOrder.getDate("orderDate"); //=20
works<BR>&nbsp;&nbsp;System.out.println("orderDate: " + orderDate); =
// works=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;// This doesn't =
work=20
<BR>&nbsp;&nbsp;DocumentRoot documentRoot =3D=20
=
(DocumentRoot)eDG.getERootObject();&nbsp;&nbsp;<BR>&nbsp;&nbsp;PurchaseOr=
derType=20
aPOT =3D documentRoot.getPurchaseOrder(); // what I'm referring to =
as the=20
"static" SDO API</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// I get this exception=20
<BR>java.rmi.ServerException: RemoteException occurred in server =
thread;=20
nested exception is: <BR>&nbsp;java.rmi.RemoteException: =
<BR>&nbsp;&gt;&gt;=20
SERVER (id=3D4773e3aa, host=3DIBM-0CA191A407D) TRACE=20
START:<BR>&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp; java.rmi.RemoteException: =
;=20
nested exception is: <BR>&nbsp;java.lang.ClassCastException:=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible =
with=20
com.ibm.DocumentRoot<BR>&nbsp;&gt;&gt;&nbsp; at=20
=
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=
</FONT></DIV></FONT></DIV></BLOCKQUOTE>Oh,=20
I see.&nbsp; Maybe all that's missing is the code to ensure that your=20
generated package is registered with the static registry. At some =
point during=20
the initialization of the server you should access the =
XyzPackage.eINSTANCE to=20
ensure that the package is registered.<BR>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org type=3D"cite">
<DIV><FONT face=3DArial size=3D2>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; wrote in message =
<A=20
href=3D"news:fihdh6$jpc$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fihdh6$jpc$1@build.eclipse.org</A>...</DIV>=
Gary,<BR><BR>Yes,=20
that is possible:<BR>
<BLOCKQUOTE><A=20
=
href=3D" http://help.eclipse.org/help33/index.jsp?topic=3D/org.eclips e.emf=
...ecore.sdo.doc/tutorials/datagraph/datagraph.html"=20
moz-do-not-send=3D"true">Tutorial: Using the SDO Data Graph=20
Editor</A><BR></BLOCKQUOTE><BR>Gary Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fihc9v$c1p$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">By design (with any version of SDO and =
Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: =
0px">&nbsp;</BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BODY></HTML>

------=_NextPart_000_0019_01C8366A.535EBC90--
Re: SDO Java -serialization/deserialization of EDataGraph - deliberate replacement of each EDataObj [message #415191 is a reply to message #415190] Tue, 04 December 2007 17:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080900060404060408060703
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Gary,

Comments below.

Gary Martin wrote:
> Upon further investigation:
>
> Note: I'm using whatever implementation of SDO 1.0 spec IBM included in
> WebSphere App Server v6.1.0.11 -
> ...\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005.ja r
>
> In a previous append - Tuesday, November 27, 2007 1:03 PM Eastern - I
> included a snippet of source code from a
> method - acceptEDataGraph(EDataGraph) defined by a Stateless Session
> EJB and on the EJB's remote interface.
>
> Based on your append - Tuesday, November 27, 2007 1:18 PM Eastern - I
> added:
> IbmPackage anIbmPackage = IbmPackageImpl.init();
IbmPackage.eINSTANCE would be the preferred way.
IbmPackage.eINSTANCE.eClass() is the idiom we typically use if we only
want to force initialize but don't really need the package.
> as the 1st statement in that method (This didn't appear to change the
> behavior about which I comment below.)
Is this done on both the client and the server?
>
>
> Snippet from EJB client (with comments on which I ask your feedback):
>
> // create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and populate
> root Object and contained objects using
> // generated IBMFactoryImpl and "static" SDOs (inherit from
> EDataObjectImpl
>
> ...
>
> Object anObject = ((EDataGraphImpl) eDG).getWriteReplacement(); //
> org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable
> //
> just curious what Object was returned
>
> aSDOExchanger.acceptEDataGraph(eDG); // defined on remote interface of
> Stateless Session EJB
You might want to try code like this (which we have in our JUnit tests):

eDataGraph.getDataGraphResource().save(System.out, null);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new
ObjectOutputStream(outputStream);
objectOutputStream.writeObject(eDataGraph);
objectOutputStream.close();
InputStream inputStream = new
ByteArrayInputStream(outputStream.toByteArray());
ObjectInputStream objectInputStream = new
ObjectInputStream(inputStream);
EDataGraph otherEDataGraph = (EDataGraph)objectInputStream.readObject();
otherEDataGraph.getDataGraphResource().save(System.out, null);

This should help demonstrate that the datagraph is properly serializable
and can be recovered from the serialization. Try this on the client.
If the server were configured the same way, it should be able to
deserialize the result.
>
> // eDG's ERootObject was set earlier to instance of:
> com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits from
> EDataObjectImpl)
> // DocumentRootImpl.setPurchaseOrder was set to instance of
> com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)
>
> // When accessed (after serialization / deserialization) in EJB,
> EDataGraph's rootObject is a:
> org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
> // When accessed in EJB, DocumentRootImpl.getPurchaseOrder is instance
> of: org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
>
> // I've concluded that this "replacement" (during serialization /
> deserialization) of instances of generated "static" SDOs
> // (that inherit from EDataObjectImpl)
> // with instances of DynamicEDataObjectImpl has to be a conscious
> design choice - not a bug.
No, it really depends on what type of models you have registered and
whether you are transmitting the model from the client to the server or
just assuming the server knows the model already.
> // As a result, I can't use the generated "static" SDOs in the
> implementation of method acceptEDataGraph(EDataGraph)
>
> Ed:
>
> a) Do you agree / disagree with that conclusion?
No. If you can get serialization and deserialization to work locally on
the client end, set a breakpoint in the constructor for your generated
DocumentRoot and see how the code gets there. Similarly, set a
breakpoint in the DynamicEDataObject constructor and look at how the
code path that gets you there is different in that case...
> b) Do you know if this behavior is different (by design) in newer
> Tuscany implementations of SDO 1.0 or 2.0?
I think Tuscany started out with EMF's SDO implementation, so I imagine
the issues will be very similar or the same.
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:fihn1g$e1e$1@build.eclipse.org...
> Gary,
>
> Comments below.
>
> Gary Martin wrote:
>> Ed,
>>
>> Thank you. I'm not connecting the dots. Are you suggesting
>> that the source code of
>> the SDO Data Graph Editor itself illustrates c) in my problem
>> statement?
> No, I'm suggesting that the tutorial shows you the steps you need
> to generate the static code for your SDO model and then the
> datagraph editor shows your model being used to read and write
> instances or your model using your generated code.
>>
>> Here's a snippet of code from the method in my EJB where I'm able
>> to use the dynamic
>> API, but unable to use the static API.
>>
>> import com.ibm.ItemType;
>> import com.ibm.PurchaseOrderType;
>> import com.ibm.DocumentRoot;
> It looks like you've already generated the code so that makes me a
> bit confused about why you asked how to generate the the code.
>> import com.ibm.util.IbmResourceFactoryImpl;
>> import com.ibm.util.IbmResourceUtil;
>>
>> import commonj.sdo.DataObject;
>> import commonj.sdo.Property;
>>
>>
>> import org.eclipse.emf.ecore.impl.EReferenceImpl;
>> import org.eclipse.emf.ecore.sdo.EDataGraph;
>> import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;
>>
>>
>>
>> // method defined on the remote interface
>> public void acceptEDataGraph (EDataGraph eDG) {
>>
>>
>> DataObject rootObject = eDG.getRootObject(); // works
>> DataObject purchaseOrder =
>> rootObject.getDataObject("purchaseOrder"); // works
>>
>> java.util.Date orderDate = purchaseOrder.getDate("orderDate");
>> // works
>> System.out.println("orderDate: " + orderDate); // works
>>
>>
>> // This doesn't work
>> DocumentRoot documentRoot = (DocumentRoot)eDG.getERootObject();
>> PurchaseOrderType aPOT = documentRoot.getPurchaseOrder(); //
>> what I'm referring to as the "static" SDO API
>>
>> // I get this exception
>> java.rmi.ServerException: RemoteException occurred in server
>> thread; nested exception is:
>> java.rmi.RemoteException:
>> >> SERVER (id=4773e3aa, host=IBM-0CA191A407D) TRACE START:
>> >> java.rmi.RemoteException: ; nested exception is:
>> java.lang.ClassCastException:
>> org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
>> incompatible with com.ibm.DocumentRoot
>> >> at
>> sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)
> Oh, I see. Maybe all that's missing is the code to ensure that
> your generated package is registered with the static registry. At
> some point during the initialization of the server you should
> access the XyzPackage.eINSTANCE to ensure that the package is
> registered.
>>
>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote
>> in message news:fihdh6$jpc$1@build.eclipse.org...
>> Gary,
>>
>> Yes, that is possible:
>>
>> Tutorial: Using the SDO Data Graph Editor
>> < http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf...ecore.sdo.doc/tutorials/datagraph/datagraph.html>
>>
>>
>> Gary Martin wrote:
>>> By design (with any version of SDO and Tuscany Java implementation),
>>>
>>> should it be possible to generate "static" SDO classes from an .xsd, and
>>> then:
>>>
>>> a) use the generated classes to create an:
>>> org.eclipse.emf.ecore.sdo.EDataGraph
>>> b)call a method on the remote interface of an ejb that takes that
>>> EDataGraph as its only arguement
>>> c)use the *static* generated SDO classes to access the SDOs in the
>>> EDataGraph
>>>
>>> I've done a) and b) and can use the dynamic SDO API in my EJB method,
>>> but, I've yet to figure out how (or even if it should be possible by
>>> design) to use the generated "static" SDO classes in my EJB method.
>>>
>>>
>>>
>>
>>
>>
>


--------------080900060404060408060703
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">
Gary,<br>
<br>
Comments below.<br>
<br>
Gary Martin wrote:
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
<div><font face="Arial" size="2">Upon further investigation:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Note: I'm using whatever
implementation of SDO 1.0 spec IBM included in<br>
WebSphere App Server v6.1.0.11 -
....\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005.j ar </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">In a previous append - Tuesday,
November 27, 2007 1:03 PM Eastern - I included a snippet of source code
from a <br>
method - acceptEDataGraph(EDataGraph) defined by a Stateless Session
EJB and on the EJB's remote interface.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Based on your append - Tuesday,
November 27, 2007 1:18 PM Eastern - I added:<br>
IbmPackage anIbmPackage = IbmPackageImpl.init();<br>
</font></div>
</blockquote>
IbmPackage.eINSTANCE would be the preferred way.&nbsp;
IbmPackage.eINSTANCE.eClass() is the idiom we typically use if we only
want to force initialize but don't really need the package.<br>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">as the 1st statement in that method&nbsp;
(This didn't appear to change the behavior about which I comment below.)</font></div>
</blockquote>
Is this done on both the client and the server?<br>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite">
<div>&nbsp;</div>
<font face="Arial" size="2"></font>
<div><font face="Arial" size="2"><br>
Snippet from EJB client (with comments on which I ask your feedback):</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">// create
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and populate root Object
and contained objects using<br>
// generated IBMFactoryImpl and "static" SDOs (inherit from
EDataObjectImpl</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">...</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">Object anObject = ((EDataGraphImpl)
eDG).getWriteReplacement(); //
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // just
curious what Object was returned</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">aSDOExchanger.acceptEDataGraph(eDG);
// defined on remote interface of Stateless Session EJB</font></div>
</blockquote>
You might want to try code like this (which we have in our JUnit tests):<br>
<br>
<small>&nbsp;&nbsp;&nbsp; eDataGraph.getDataGraphResource().save(System.out, null);<br>
&nbsp;&nbsp;&nbsp; ByteArrayOutputStream outputStream = new ByteArrayOutputStream();<br>
&nbsp;&nbsp;&nbsp; ObjectOutputStream objectOutputStream = new
ObjectOutputStream(outputStream);<br>
&nbsp;&nbsp;&nbsp; objectOutputStream.writeObject(eDataGraph);<br>
&nbsp;&nbsp;&nbsp; objectOutputStream.close();<br>
&nbsp;&nbsp;&nbsp; InputStream inputStream = new
ByteArrayInputStream(outputStream.toByteArray());<br>
&nbsp;&nbsp;&nbsp; ObjectInputStream objectInputStream = new
ObjectInputStream(inputStream);<br>
&nbsp;&nbsp;&nbsp; EDataGraph otherEDataGraph =
(EDataGraph)objectInputStream.readObject();<br>
&nbsp;&nbsp;&nbsp; otherEDataGraph.getDataGraphResource().save(System.out, null);<br>
</small><br>
This should help demonstrate that the datagraph is properly
serializable and can be recovered from the serialization.&nbsp; Try this on
the client.&nbsp; If the server were configured the same way, it should be
able to deserialize the result.<br>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">// eDG's ERootObject was set earlier
to instance of: com.ibm.impl.DocumentRootImpl (generated "static" SDO -
inherits from EDataObjectImpl)<br>
// DocumentRootImpl.setPurchaseOrder was set to instance of
com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)<br>
&nbsp;&nbsp;&nbsp;<br>
// When accessed (after serialization / deserialization) in EJB,
EDataGraph's rootObject is a:
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<br>
// When accessed in EJB, DocumentRootImpl.getPurchaseOrder is instance
of: org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<br>
&nbsp;&nbsp;&nbsp;<br>
// I've concluded that this "replacement" (during serialization /
deserialization) of instances of generated "static" SDOs<br>
// (that inherit from EDataObjectImpl)<br>
// with instances of DynamicEDataObjectImpl has to be a conscious
design choice - not a bug.<br>
</font></div>
</blockquote>
No, it really depends on what type of models you have registered and
whether you are transmitting the model from the client to the server or
just assuming the server knows the model already.<br>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">// As a result, I can't use the
generated "static" SDOs in the implementation of method
acceptEDataGraph(EDataGraph)</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">Ed:</font></div>
<div><font face="Arial" size="2">&nbsp;</font></div>
<div><font face="Arial" size="2">a) Do you agree / disagree with that
conclusion?<br>
</font></div>
</blockquote>
No.&nbsp; If you can get serialization and deserialization to work locally
on the client end, set a breakpoint in the constructor for your
generated DocumentRoot and see how the code gets there.&nbsp; Similarly, set
a breakpoint in the DynamicEDataObject constructor and look at how the
code path that gets you there is different in that case...<br>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">b) Do you know if this behavior is
different (by design) in newer Tuscany implementations of SDO 1.0 or
2.0?</font></div>
</blockquote>
I think Tuscany started out with EMF's SDO implementation, so I imagine
the issues will be very similar or the same.<br>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite">
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a moz-do-not-send="true"
href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt; wrote in
message <a moz-do-not-send="true"
href="news:fihn1g$e1e$1@build.eclipse.org">news:fihn1g$e1e$1@build.eclipse.org</a>...</div>
Gary,<br>
<br>
Comments below.<br>
<br>
Gary Martin wrote:
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">
<div><font face="Arial" size="2">Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thank you.&nbsp; I'm not&nbsp;connecting
the dots.&nbsp;&nbsp; Are you suggesting that the source code of</font></div>
<div><font face="Arial" size="2">the SDO Data Graph Editor itself
illustrates c) in my problem statement?</font></div>
</font></div>
</blockquote>
No, I'm suggesting that the tutorial shows you the steps you need to
generate the static code for your SDO model and then the datagraph
editor shows your model being used to read and write instances or your
model using your generated code.<br>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">
<div>&nbsp;</div>
<div><font face="Arial" size="2">Here's a snippet of code from
the method in my EJB where I'm able to use the dynamic</font></div>
<div><font face="Arial" size="2">API, but unable to use the
static API.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">import com.ibm.ItemType;<br>
import com.ibm.PurchaseOrderType;<br>
import com.ibm.DocumentRoot;<br>
</font></div>
</font></div>
</blockquote>
It looks like you've already generated the code so that makes me a bit
confused about why you asked how to generate the the code.<br>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">
<div><font face="Arial" size="2">import
com.ibm.util.IbmResourceFactoryImpl;<br>
import com.ibm.util.IbmResourceUtil;</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">import commonj.sdo.DataObject;<br>
import commonj.sdo.Property;</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><br>
import org.eclipse.emf.ecore.impl.EReferenceImpl;<br>
import org.eclipse.emf.ecore.sdo.EDataGraph;<br>
import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;</font ></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">// method defined on the remote
interface <br>
public void acceptEDataGraph (EDataGraph eDG)&nbsp; {</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><br>
&nbsp;&nbsp;DataObject rootObject = eDG.getRootObject(); // works<br>
&nbsp;&nbsp;DataObject purchaseOrder = rootObject.getDataObject("purchaseOrder");
// works</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;java.util.Date orderDate =
purchaseOrder.getDate("orderDate"); // works<br>
&nbsp;&nbsp;System.out.println("orderDate: " + orderDate); // works </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><br>
&nbsp;&nbsp;// This doesn't work <br>
&nbsp;&nbsp;DocumentRoot documentRoot = (DocumentRoot)eDG.getERootObject();&nbsp;&nbsp;<br>
&nbsp;&nbsp;PurchaseOrderType aPOT = documentRoot.getPurchaseOrder(); // what I'm
referring to as the "static" SDO API</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">// I get this exception <br>
java.rmi.ServerException: RemoteException occurred in server thread;
nested exception is: <br>
&nbsp;java.rmi.RemoteException: <br>
&nbsp;&gt;&gt; SERVER (id=4773e3aa, host=IBM-0CA191A407D) TRACE START:<br>
&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp; java.rmi.RemoteException: ; nested exception is: <br>
&nbsp;java.lang.ClassCastException:
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with
com.ibm.DocumentRoot<br>
&nbsp;&gt;&gt;&nbsp; at
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89) </font></div>
</font></div>
</blockquote>
Oh, I see.&nbsp; Maybe all that's missing is the code to ensure that your
generated package is registered with the static registry. At some point
during the initialization of the server you should access the
XyzPackage.eINSTANCE to ensure that the package is registered.<br>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2">
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com"
moz-do-not-send="true">merks@ca.ibm.com</a>&gt; wrote in message <a
href="news:fihdh6$jpc$1@build.eclipse.org" moz-do-not-send="true">news:fihdh6$jpc$1@build.eclipse.org</a>...</div>
Gary,<br>
<br>
Yes, that is possible:<br>
<blockquote><a
href=" http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf...ecore.sdo.doc/tutorials/datagraph/datagraph.html"
moz-do-not-send="true">Tutorial: Using the SDO Data Graph Editor</a><br>
</blockquote>
<br>
Gary Martin wrote:
<blockquote cite="mid:fihc9v$c1p$1@build.eclipse.org"
type="cite">
<pre wrap="">By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.


</pre>
</blockquote>
<br>
</blockquote>
</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">&nbsp;</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------080900060404060408060703--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: SDO Java -serialization/deserialization of EDataGraph *on client* - deliberate replacement of e [message #415193 is a reply to message #415191] Tue, 04 December 2007 20:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: GaryRMartin.insightbb.com

This is a multi-part message in MIME format.

------=_NextPart_000_004C_01C8368A.894F9520
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,

Thanks yet again.

I ran this code on my *client* (please note my comments //):

IbmPackage purchaseOrderPackage =3D IbmPackageImpl.eINSTANCE;

ResourceSet resourceSet =3D eDG.getResourceSet();

Resource packageResource =3D =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);

packageResource.getContents().add(purchaseOrderPackage);

resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(), =
purchaseOrderPackage);

....
System.out.println("eDG.getDataGraphResource().save(System.out, null); =
before serialization ****************************************");

System.out.println("eDG.getERootObject: " + eDG.getERootObject());

// eDG.getERootObject: com.ibm.impl.DocumentRootImpl@52565256 (mixed: =
[ibm:purchaseOrder=3Dcom.ibm.impl.PurchaseOrderTypeImpl@7a987a98 =
(comment: Overnight shipping, orderDate: 2007-03-10)])

eDG.getDataGraphResource().save(System.out, null);

ByteArrayOutputStream outputStream =3D new ByteArrayOutputStream();

ObjectOutputStream objectOutputStream =3D new =
ObjectOutputStream(outputStream);

objectOutputStream.writeObject(eDG);

objectOutputStream.close();

InputStream inputStream =3D new =
ByteArrayInputStream(outputStream.toByteArray());

ObjectInputStream objectInputStream =3D new =
ObjectInputStream(inputStream);

EDataGraph otherEDataGraph =3D =
(EDataGraph)objectInputStream.readObject();

System.out.println("otherEDataGraph.getDataGraphResource().save(System.ou=
t, null); after deserialization =
***************************************");

System.out.println("otherEDataGraph.getERootObject: " + =
otherEDataGraph.getERootObject());

// otherEDataGraph.getERootObject: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl@3ae63ae6 (eClass: =
org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name: DocumentRoot) =
(instanceClassName: null) (abstract: false, interface: false))

otherEDataGraph.getDataGraphResource().save(System.out, null);

So..somehow I need to "fix" the problem (EDataObjectImpl(s) replaced =
with DynamicEDataObjectImpl(s) during serialization / deserialization) =
** on my client **.

I saved the System.out output if it might be useful?






"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fj41hq$s5v$1@build.eclipse.org...
Gary,

Comments below.

Gary Martin wrote:=20
Upon further investigation:

Note: I'm using whatever implementation of SDO 1.0 spec IBM included =
in
WebSphere App Server v6.1.0.11 - =
....\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005.j ar

In a previous append - Tuesday, November 27, 2007 1:03 PM Eastern - =
I included a snippet of source code from a=20
method - acceptEDataGraph(EDataGraph) defined by a Stateless Session =
EJB and on the EJB's remote interface.

Based on your append - Tuesday, November 27, 2007 1:18 PM Eastern - =
I added:
IbmPackage anIbmPackage =3D IbmPackageImpl.init();

IbmPackage.eINSTANCE would be the preferred way. =
IbmPackage.eINSTANCE.eClass() is the idiom we typically use if we only =
want to force initialize but don't really need the package.

as the 1st statement in that method (This didn't appear to change =
the behavior about which I comment below.)
Is this done on both the client and the server?



Snippet from EJB client (with comments on which I ask your =
feedback):

// create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and populate =
root Object and contained objects using
// generated IBMFactoryImpl and "static" SDOs (inherit from =
EDataObjectImpl

...

Object anObject =3D ((EDataGraphImpl) eDG).getWriteReplacement(); // =
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable
// =
just curious what Object was returned

aSDOExchanger.acceptEDataGraph(eDG); // defined on remote interface =
of Stateless Session EJB
You might want to try code like this (which we have in our JUnit =
tests):

eDataGraph.getDataGraphResource().save(System.out, null);
ByteArrayOutputStream outputStream =3D new =
ByteArrayOutputStream();
ObjectOutputStream objectOutputStream =3D new =
ObjectOutputStream(outputStream);
objectOutputStream.writeObject(eDataGraph);
objectOutputStream.close();
InputStream inputStream =3D new =
ByteArrayInputStream(outputStream.toByteArray());
ObjectInputStream objectInputStream =3D new =
ObjectInputStream(inputStream);
EDataGraph otherEDataGraph =3D =
(EDataGraph)objectInputStream.readObject();
otherEDataGraph.getDataGraphResource().save(System.out, null);

This should help demonstrate that the datagraph is properly =
serializable and can be recovered from the serialization. Try this on =
the client. If the server were configured the same way, it should be =
able to deserialize the result.


// eDG's ERootObject was set earlier to instance of: =
com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits from =
EDataObjectImpl)
// DocumentRootImpl.setPurchaseOrder was set to instance of =
com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)
=20
// When accessed (after serialization / deserialization) in EJB, =
EDataGraph's rootObject is a: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
// When accessed in EJB, DocumentRootImpl.getPurchaseOrder is =
instance of: org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
=20
// I've concluded that this "replacement" (during serialization / =
deserialization) of instances of generated "static" SDOs
// (that inherit from EDataObjectImpl)
// with instances of DynamicEDataObjectImpl has to be a conscious =
design choice - not a bug.

No, it really depends on what type of models you have registered and =
whether you are transmitting the model from the client to the server or =
just assuming the server knows the model already.

// As a result, I can't use the generated "static" SDOs in the =
implementation of method acceptEDataGraph(EDataGraph)

Ed:

a) Do you agree / disagree with that conclusion?

No. If you can get serialization and deserialization to work locally =
on the client end, set a breakpoint in the constructor for your =
generated DocumentRoot and see how the code gets there. Similarly, set =
a breakpoint in the DynamicEDataObject constructor and look at how the =
code path that gets you there is different in that case...

b) Do you know if this behavior is different (by design) in newer =
Tuscany implementations of SDO 1.0 or 2.0?
I think Tuscany started out with EMF's SDO implementation, so I =
imagine the issues will be very similar or the same.

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fihn1g$e1e$1@build.eclipse.org...
Gary,

Comments below.

Gary Martin wrote:=20
Ed,

Thank you. I'm not connecting the dots. Are you suggesting =
that the source code of
the SDO Data Graph Editor itself illustrates c) in my problem =
statement?
No, I'm suggesting that the tutorial shows you the steps you need =
to generate the static code for your SDO model and then the datagraph =
editor shows your model being used to read and write instances or your =
model using your generated code.


Here's a snippet of code from the method in my EJB where I'm =
able to use the dynamic
API, but unable to use the static API.

import com.ibm.ItemType;
import com.ibm.PurchaseOrderType;
import com.ibm.DocumentRoot;

It looks like you've already generated the code so that makes me a =
bit confused about why you asked how to generate the the code.

import com.ibm.util.IbmResourceFactoryImpl;
import com.ibm.util.IbmResourceUtil;

import commonj.sdo.DataObject;
import commonj.sdo.Property;


import org.eclipse.emf.ecore.impl.EReferenceImpl;
import org.eclipse.emf.ecore.sdo.EDataGraph;
import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;



// method defined on the remote interface=20
public void acceptEDataGraph (EDataGraph eDG) {


DataObject rootObject =3D eDG.getRootObject(); // works
DataObject purchaseOrder =3D =
rootObject.getDataObject("purchaseOrder"); // works

java.util.Date orderDate =3D =
purchaseOrder.getDate("orderDate"); // works
System.out.println("orderDate: " + orderDate); // works=20


// This doesn't work=20
DocumentRoot documentRoot =3D =
(DocumentRoot)eDG.getERootObject(); =20
PurchaseOrderType aPOT =3D documentRoot.getPurchaseOrder(); // =
what I'm referring to as the "static" SDO API

// I get this exception=20
java.rmi.ServerException: RemoteException occurred in server =
thread; nested exception is:=20
java.rmi.RemoteException:=20
>> SERVER (id=3D4773e3aa, host=3DIBM-0CA191A407D) TRACE START:
>> java.rmi.RemoteException: ; nested exception is:=20
java.lang.ClassCastException: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with =
com.ibm.DocumentRoot
>> at =
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=

Oh, I see. Maybe all that's missing is the code to ensure that =
your generated package is registered with the static registry. At some =
point during the initialization of the server you should access the =
XyzPackage.eINSTANCE to ensure that the package is registered.

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fihdh6$jpc$1@build.eclipse.org...
Gary,

Yes, that is possible:

Tutorial: Using the SDO Data Graph Editor


Gary Martin wrote:=20
By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


=20






------=_NextPart_000_004C_01C8368A.894F9520
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks yet again.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I ran this code on my *client* (please =
note my=20
comments //):</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P align=3Dleft>IbmPackage purchaseOrderPackage =3D =
IbmPackageImpl.</FONT><I><FONT=20
color=3D#0000c0 size=3D2>eINSTANCE</I></FONT><FONT size=3D2>;</P>
<P align=3Dleft>ResourceSet resourceSet =3D eDG.getResourceSet();</P>
<P align=3Dleft>Resource packageResource =3D=20
resourceSet.createResource(URI.<I>createURI</I>(purchaseOrderPackage.getN=
sURI()));</P>
<P =
align=3Dleft>packageResource.getContents().add(purchaseOrderPackage); </P>=

<P> resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(), =

purchaseOrderPackage);</P></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>...</STRONG></FONT></DIV>
<DIV><FONT size=3D2><FONT size=3D2>
<P align=3Dleft>System.</FONT><I><FONT color=3D#0000c0 =
size=3D2>out</I></FONT><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff=20
size=3D2>"eDG.getDataGraphResource().save(System.out, null); before =
serialization=20
****************************************"</FONT><FONT size=3D2>);</P>
<P align=3Dleft>System.</FONT><I><FONT color=3D#0000c0 =
size=3D2>out</I></FONT><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff =
size=3D2>"eDG.getERootObject:=20
"</FONT><FONT size=3D2> + eDG.getERootObject());</FONT></P>
<P align=3Dleft>// <FONT size=3D2>eDG.getERootObject:=20
<STRONG>com.ibm.impl.DocumentRootImpl</STRONG>@52565256 (mixed:=20
[ibm:purchaseOrder=3Dcom.ibm.impl.PurchaseOrderTypeImpl@7a987a98 =
(comment:=20
Overnight shipping, </FONT><U><FONT color=3D#000080=20
size=3D2>orderDate</U></FONT><FONT size=3D2>: 2007-03-10)])</P>
<P align=3Dleft></FONT><FONT=20
size=3D2>eDG.getDataGraphResource().save(System.</FONT><I ><FONT =
color=3D#0000c0=20
size=3D2>out</I></FONT><FONT size=3D2>, </FONT><B><FONT color=3D#7f0055=20
size=3D2>null</B></FONT><FONT size=3D2>);</FONT></P>
<P align=3Dleft><FONT size=3D2>ByteArrayOutputStream outputStream =3D =
</FONT><B><FONT=20
color=3D#7f0055 size=3D2>new</B></FONT><FONT size=3D2> =
ByteArrayOutputStream();</P>
<P align=3Dleft>ObjectOutputStream objectOutputStream =3D =
</FONT><B><FONT=20
color=3D#7f0055 size=3D2>new</B></FONT><FONT size=3D2>=20
ObjectOutputStream(outputStream);</P>
<P align=3Dleft>objectOutputStream.writeObject(eDG);</P>
<P align=3Dleft>objectOutputStream.close();</P>
<P align=3Dleft>InputStream inputStream =3D </FONT><B><FONT =
color=3D#7f0055=20
size=3D2>new</B></FONT><FONT size=3D2>=20
ByteArrayInputStream(outputStream.toByteArray());</P>
<P align=3Dleft>ObjectInputStream objectInputStream =3D </FONT><B><FONT=20
color=3D#7f0055 size=3D2>new</B></FONT><FONT size=3D2>=20
ObjectInputStream(inputStream);</P>
<P align=3Dleft>EDataGraph otherEDataGraph =3D=20
(EDataGraph)objectInputStream.readObject();</P>
<P align=3Dleft>System.</FONT><I><FONT color=3D#0000c0 =
size=3D2>out</I></FONT><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff=20
size=3D2>"otherEDataGraph.getDataGraphResource().save(System.out, null); =
after=20
deserialization ***************************************"</FONT><FONT=20
size=3D2>);</P>
<P align=3Dleft>System.</FONT><I><FONT color=3D#0000c0 =
size=3D2>out</I></FONT><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff=20
size=3D2>"otherEDataGraph.getERootObject: "</FONT><FONT size=3D2> +=20
otherEDataGraph.getERootObject());</FONT></P>
<P align=3Dleft><FONT size=3D2>// <FONT =
size=3D2>otherEDataGraph.getERootObject:=20
<STRONG>org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl </STRONG>@3a=
e63ae6=20
(eClass: org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name: =
DocumentRoot)=20
(instanceClassName: null) (abstract: false, </FONT><U><FONT =
color=3D#000080=20
size=3D2>interface</U></FONT><FONT size=3D2>: false))</P></FONT><FONT =
size=3D2></FONT>
<P>otherEDataGraph.getDataGraphResource().save(System.</FONT ><I><FONT=20
color=3D#0000c0 size=3D2>out</I></FONT><FONT size=3D2>, </FONT><B><FONT =
color=3D#7f0055=20
size=3D2>null</B></FONT><FONT size=3D2>);</FONT></P>
<P><FONT face=3DArial size=3D2>So..somehow I need to "fix" the problem=20
(EDataObjectImpl(s) replaced with DynamicEDataObjectImpl(s) during =
serialization=20
/ deserialization) ** on my client **.</FONT></P>
<P><FONT face=3DArial>I saved the System.out output if it might be=20
useful?</FONT></P>
<P><FONT size=3D2><FONT =
face=3DArial></FONT>&nbsp;</P></FONT></FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><BR></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:fj41hq$s5v$1@build.eclipse.org">news:fj41hq$s5v$1@build.ecli=
pse.org</A>...</DIV>Gary,<BR><BR>Comments=20
below.<BR><BR>Gary Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Upon further =
investigation:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Note: I'm using whatever =
implementation of SDO=20
1.0 spec IBM included in<BR>WebSphere App Server v6.1.0.11 -=20
=
....\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005.j ar </FONT></DIV=
>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>In a previous append - Tuesday, =
November 27,=20
2007 1:03 PM Eastern - I included a snippet of source code from a =
<BR>method=20
- acceptEDataGraph(EDataGraph) defined by a Stateless Session EJB =
and on the=20
EJB's remote interface.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Based on your append - Tuesday, =
November 27,=20
2007 1:18 PM Eastern - I added:<BR>IbmPackage anIbmPackage =3D=20
=
IbmPackageImpl.init();<BR></FONT></DIV></BLOCKQUOTE>IbmPackage.eINSTANCE =
would=20
be the preferred way.&nbsp; IbmPackage.eINSTANCE.eClass() is the idiom =
we=20
typically use if we only want to force initialize but don't really =
need the=20
package.<BR>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org type=3D"cite">
<DIV><FONT face=3DArial size=3D2>as the 1st statement in that =
method&nbsp; (This=20
didn't appear to change the behavior about which I comment=20
below.)</FONT></DIV></BLOCKQUOTE>Is this done on both the client and =
the=20
server?<BR>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org type=3D"cite">
<DIV>&nbsp;</DIV><FONT face=3DArial size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2><BR>Snippet from EJB client (with =
comments on=20
which I ask your feedback):</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// create=20
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and populate root =
Object and=20
contained objects using<BR>// generated IBMFactoryImpl and "static" =
SDOs=20
(inherit from EDataObjectImpl</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Object anObject =3D =
((EDataGraphImpl)=20
eDG).getWriteReplacement(); //=20
=
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable <BR=
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n b=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb s=
p;&nbsp;&nbsp;=20
// just curious what Object was returned</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>aSDOExchanger.acceptEDataGraph(eDG); // defined=20
on remote interface of Stateless Session =
EJB</FONT></DIV></BLOCKQUOTE>You=20
might want to try code like this (which we have in our JUnit=20
tests):<BR><BR><SMALL>&nbsp;&nbsp;&nbsp;=20
eDataGraph.getDataGraphResource().save(System.out,=20
null);<BR>&nbsp;&nbsp;&nbsp; ByteArrayOutputStream outputStream =3D =
new=20
ByteArrayOutputStream();<BR>&nbsp;&nbsp;&nbsp; ObjectOutputStream=20
objectOutputStream =3D new=20
ObjectOutputStream(outputStream);<BR>&nbsp;&nbsp;&nbsp;=20
objectOutputStream.writeObject(eDataGraph);<BR>&nbsp;&nbsp;&nbsp;=20
objectOutputStream.close();<BR>&nbsp;&nbsp;&nbsp; InputStream =
inputStream =3D=20
new =
ByteArrayInputStream(outputStream.toByteArray());<BR>&nbsp;&nbsp;&nbsp;=20
ObjectInputStream objectInputStream =3D new=20
ObjectInputStream(inputStream);<BR>&nbsp;&nbsp;&nbsp; EDataGraph=20
otherEDataGraph =3D=20
(EDataGraph)objectInputStream.readObject();<BR>&nbsp;&nbsp;&nbsp;=20
otherEDataGraph.getDataGraphResource().save(System.out,=20
null);<BR></SMALL><BR>This should help demonstrate that the datagraph =
is=20
properly serializable and can be recovered from the =
serialization.&nbsp; Try=20
this on the client.&nbsp; If the server were configured the same way, =
it=20
should be able to deserialize the result.<BR>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org type=3D"cite">
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// eDG's ERootObject was set =
earlier to=20
instance of: com.ibm.impl.DocumentRootImpl (generated "static" SDO - =

inherits from EDataObjectImpl)<BR>// =
DocumentRootImpl.setPurchaseOrder was=20
set to instance of com.ibm.impl.PurchaseOrderTypeImpl (generated =
"static"=20
SDO)<BR>&nbsp;&nbsp;&nbsp;<BR>// When accessed (after serialization =
/=20
deserialization) in EJB, EDataGraph's rootObject is a:=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<BR>// When =
accessed in=20
EJB, DocumentRootImpl.getPurchaseOrder is instance of:=20
=
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<BR>&nbsp;&nbsp;&nbs=
p;<BR>//=20
I've concluded that this "replacement" (during serialization /=20
deserialization) of instances of generated "static" SDOs<BR>// (that =
inherit=20
from EDataObjectImpl)<BR>// with instances of DynamicEDataObjectImpl =
has to=20
be a conscious design choice - not a =
bug.<BR></FONT></DIV></BLOCKQUOTE>No, it=20
really depends on what type of models you have registered and whether =
you are=20
transmitting the model from the client to the server or just assuming =
the=20
server knows the model already.<BR>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org type=3D"cite">
<DIV><FONT face=3DArial size=3D2>// As a result, I can't use the =
generated=20
"static" SDOs in the implementation of method=20
acceptEDataGraph(EDataGraph)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ed:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>a) Do you agree / disagree with =
that=20
conclusion?<BR></FONT></DIV></BLOCKQUOTE>No.&nbsp; If you can get=20
serialization and deserialization to work locally on the client end, =
set a=20
breakpoint in the constructor for your generated DocumentRoot and see =
how the=20
code gets there.&nbsp; Similarly, set a breakpoint in the =
DynamicEDataObject=20
constructor and look at how the code path that gets you there is =
different in=20
that case...<BR>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org type=3D"cite">
<DIV><FONT face=3DArial size=3D2>b) Do you know if this behavior is =
different=20
(by design) in newer Tuscany implementations of SDO 1.0 or=20
2.0?</FONT></DIV></BLOCKQUOTE>I think Tuscany started out with EMF's =
SDO=20
implementation, so I imagine the issues will be very similar or the =
same.<BR>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org type=3D"cite">
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; wrote in message =
<A=20
href=3D"news:fihn1g$e1e$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fihn1g$e1e$1@build.eclipse.org</A>...</DIV>=
Gary,<BR><BR>Comments=20
below.<BR><BR>Gary Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thank you.&nbsp; I'm =
not&nbsp;connecting=20
the dots.&nbsp;&nbsp; Are you suggesting that the source code=20
of</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the SDO Data Graph Editor =
itself=20
illustrates c) in my problem=20
statement?</FONT></DIV></FONT></DIV></BLOCKQUOTE>No, I'm =
suggesting that=20
the tutorial shows you the steps you need to generate the static =
code for=20
your SDO model and then the datagraph editor shows your model =
being used=20
to read and write instances or your model using your generated =
code.<BR>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT face=3DArial size=3D2>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here's a snippet of code from =
the method in=20
my EJB where I'm able to use the dynamic</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>API, but unable to use the =
static=20
API.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import =
com.ibm.ItemType;<BR>import=20
com.ibm.PurchaseOrderType;<BR>import=20
=
com.ibm.DocumentRoot;<BR></FONT></DIV></FONT></DIV></BLOCKQUOTE >It looks =

like you've already generated the code so that makes me a bit =
confused=20
about why you asked how to generate the the code.<BR>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>import=20
com.ibm.util.IbmResourceFactoryImpl;<BR>import=20
com.ibm.util.IbmResourceUtil;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import =
commonj.sdo.DataObject;<BR>import=20
commonj.sdo.Property;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>import=20
org.eclipse.emf.ecore.impl.EReferenceImpl;<BR>import=20
org.eclipse.emf.ecore.sdo.EDataGraph;<BR>import=20
=
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;</FONT ></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// method defined on the remote =
interface=20
<BR>public void acceptEDataGraph (EDataGraph eDG)&nbsp; =
{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;DataObject =
rootObject =3D=20
eDG.getRootObject(); // works<BR>&nbsp;&nbsp;DataObject =
purchaseOrder =3D=20
rootObject.getDataObject("purchaseOrder"); // works</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;java.util.Date =
orderDate =3D=20
purchaseOrder.getDate("orderDate"); //=20
works<BR>&nbsp;&nbsp;System.out.println("orderDate: " + =
orderDate); //=20
works </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;// This doesn't =
work=20
<BR>&nbsp;&nbsp;DocumentRoot documentRoot =3D=20
=
(DocumentRoot)eDG.getERootObject();&nbsp;&nbsp;<BR>&nbsp;&nbsp;PurchaseOr=
derType=20
aPOT =3D documentRoot.getPurchaseOrder(); // what I'm referring =
to as the=20
"static" SDO API</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// I get this exception=20
<BR>java.rmi.ServerException: RemoteException occurred in server =
thread;=20
nested exception is: <BR>&nbsp;java.rmi.RemoteException:=20
<BR>&nbsp;&gt;&gt; SERVER (id=3D4773e3aa, =
host=3DIBM-0CA191A407D) TRACE=20
START:<BR>&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp; =
java.rmi.RemoteException: ;=20
nested exception is: <BR>&nbsp;java.lang.ClassCastException:=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl =
incompatible with=20
com.ibm.DocumentRoot<BR>&nbsp;&gt;&gt;&nbsp; at=20
=
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=
</FONT></DIV></FONT></DIV></BLOCKQUOTE>Oh,=20
I see.&nbsp; Maybe all that's missing is the code to ensure that =
your=20
generated package is registered with the static registry. At some =
point=20
during the initialization of the server you should access the=20
XyzPackage.eINSTANCE to ensure that the package is registered.<BR>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT face=3DArial size=3D2>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; wrote in =
message <A=20
href=3D"news:fihdh6$jpc$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fihdh6$jpc$1@build.eclipse.org</A>...</DIV>=
Gary,<BR><BR>Yes,=20
that is possible:<BR>
<BLOCKQUOTE><A=20
=
href=3D" http://help.eclipse.org/help33/index.jsp?topic=3D/org.eclips e.emf=
....ecore.sdo.doc/tutorials/datagraph/datagraph.html"=20
moz-do-not-send=3D"true">Tutorial: Using the SDO Data Graph=20
Editor</A><BR></BLOCKQUOTE><BR>Gary Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fihc9v$c1p$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">By design (with any version of SDO and =
Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: =
0px">&nbsp;</BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BLOCKQUOTE><BR></=
BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_004C_01C8368A.894F9520--
Re: SDO Java -serialization/deserialization of EDataGraph *on client* - deliberate replacement of e [message #415195 is a reply to message #415193] Tue, 04 December 2007 22:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000603090604090501050508
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Gary,

Comments below.

Gary Martin wrote:
> Ed,
>
> Thanks yet again.
>
> I ran this code on my *client* (please note my comments //):
>
>
> IbmPackage purchaseOrderPackage = IbmPackageImpl./eINSTANCE/;
>
> ResourceSet resourceSet = eDG.getResourceSet();
>
> Resource packageResource =
> resourceSet.createResource(URI./createURI/(purchaseOrderPack age.getNsURI()));
>
> packageResource.getContents().add(purchaseOrderPackage);
>
> resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(),
> purchaseOrderPackage);
>
So you are registering this package locally and sending it with your
data graph. That why the receiver will always use the dynamic package
that you sent it and told it do use. Can you omit this entirely? You
shouldn't need it and it's the cause of the problem.
> *...*
>
> System./out/.println("eDG.getDataGraphResource().save(System.out,
> null); before serialization ****************************************");
>
> System./out/.println("eDG.getERootObject: " + eDG.getERootObject());
>
> // eDG.getERootObject: *com.ibm.impl.DocumentRootImpl*@52565256
> (mixed: [ibm:purchaseOrder=com.ibm.impl.PurchaseOrderTypeImpl@7a987a98
> (comment: Overnight shipping, _orderDate_: 2007-03-10)])
>
> eDG.getDataGraphResource().save(System./out/, *null*);
>
> ByteArrayOutputStream outputStream = *new* ByteArrayOutputStream();
>
> ObjectOutputStream objectOutputStream = *new*
> ObjectOutputStream(outputStream);
>
> objectOutputStream.writeObject(eDG);
>
> objectOutputStream.close();
>
> InputStream inputStream = *new*
> ByteArrayInputStream(outputStream.toByteArray());
>
> ObjectInputStream objectInputStream = *new*
> ObjectInputStream(inputStream);
>
> EDataGraph otherEDataGraph = (EDataGraph)objectInputStream.readObject();
>
> System./out/.println("otherEDataGraph.getDataGraphResource().save(System.out,
> null); after deserialization ***************************************");
>
> System./out/.println("otherEDataGraph.getERootObject: " +
> otherEDataGraph.getERootObject());
>
> // otherEDataGraph.getERootObject:
> *org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl*@3ae6 3ae6
> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name:
> DocumentRoot) (instanceClassName: null) (abstract: false, _interface_:
> false))
>
> otherEDataGraph.getDataGraphResource().save(System./out/, *null*);
>
> So..somehow I need to "fix" the problem (EDataObjectImpl(s) replaced
> with DynamicEDataObjectImpl(s) during serialization / deserialization)
> ** on my client **.
>
> I saved the System.out output if it might be useful?
>
>
>
>
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:fj41hq$s5v$1@build.eclipse.org...
> Gary,
>
> Comments below.
>
> Gary Martin wrote:
>> Upon further investigation:
>>
>> Note: I'm using whatever implementation of SDO 1.0 spec IBM
>> included in
>> WebSphere App Server v6.1.0.11 -
>> ....\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005.j ar
>>
>> In a previous append - Tuesday, November 27, 2007 1:03 PM Eastern
>> - I included a snippet of source code from a
>> method - acceptEDataGraph(EDataGraph) defined by a Stateless
>> Session EJB and on the EJB's remote interface.
>>
>> Based on your append - Tuesday, November 27, 2007 1:18 PM Eastern
>> - I added:
>> IbmPackage anIbmPackage = IbmPackageImpl.init();
> IbmPackage.eINSTANCE would be the preferred way.
> IbmPackage.eINSTANCE.eClass() is the idiom we typically use if we
> only want to force initialize but don't really need the package.
>> as the 1st statement in that method (This didn't appear to
>> change the behavior about which I comment below.)
> Is this done on both the client and the server?
>>
>>
>> Snippet from EJB client (with comments on which I ask your feedback):
>>
>> // create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and
>> populate root Object and contained objects using
>> // generated IBMFactoryImpl and "static" SDOs (inherit from
>> EDataObjectImpl
>>
>> ...
>>
>> Object anObject = ((EDataGraphImpl) eDG).getWriteReplacement();
>> //
>> org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable
>>
>> // just curious what Object was returned
>>
>> aSDOExchanger.acceptEDataGraph(eDG); // defined on remote
>> interface of Stateless Session EJB
> You might want to try code like this (which we have in our JUnit
> tests):
>
> eDataGraph.getDataGraphResource().save(System.out, null);
> ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
> ObjectOutputStream objectOutputStream = new
> ObjectOutputStream(outputStream);
> objectOutputStream.writeObject(eDataGraph);
> objectOutputStream.close();
> InputStream inputStream = new
> ByteArrayInputStream(outputStream.toByteArray());
> ObjectInputStream objectInputStream = new
> ObjectInputStream(inputStream);
> EDataGraph otherEDataGraph =
> (EDataGraph)objectInputStream.readObject();
> otherEDataGraph.getDataGraphResource().save(System.out, null);
>
> This should help demonstrate that the datagraph is properly
> serializable and can be recovered from the serialization. Try
> this on the client. If the server were configured the same way,
> it should be able to deserialize the result.
>>
>> // eDG's ERootObject was set earlier to instance of:
>> com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits
>> from EDataObjectImpl)
>> // DocumentRootImpl.setPurchaseOrder was set to instance of
>> com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)
>>
>> // When accessed (after serialization / deserialization) in EJB,
>> EDataGraph's rootObject is a:
>> org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
>> // When accessed in EJB, DocumentRootImpl.getPurchaseOrder is
>> instance of: org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
>>
>> // I've concluded that this "replacement" (during serialization /
>> deserialization) of instances of generated "static" SDOs
>> // (that inherit from EDataObjectImpl)
>> // with instances of DynamicEDataObjectImpl has to be a conscious
>> design choice - not a bug.
> No, it really depends on what type of models you have registered
> and whether you are transmitting the model from the client to the
> server or just assuming the server knows the model already.
>> // As a result, I can't use the generated "static" SDOs in the
>> implementation of method acceptEDataGraph(EDataGraph)
>>
>> Ed:
>>
>> a) Do you agree / disagree with that conclusion?
> No. If you can get serialization and deserialization to work
> locally on the client end, set a breakpoint in the constructor for
> your generated DocumentRoot and see how the code gets there.
> Similarly, set a breakpoint in the DynamicEDataObject constructor
> and look at how the code path that gets you there is different in
> that case...
>> b) Do you know if this behavior is different (by design) in newer
>> Tuscany implementations of SDO 1.0 or 2.0?
> I think Tuscany started out with EMF's SDO implementation, so I
> imagine the issues will be very similar or the same.
>>
>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote
>> in message news:fihn1g$e1e$1@build.eclipse.org...
>> Gary,
>>
>> Comments below.
>>
>> Gary Martin wrote:
>>> Ed,
>>>
>>> Thank you. I'm not connecting the dots. Are you
>>> suggesting that the source code of
>>> the SDO Data Graph Editor itself illustrates c) in my
>>> problem statement?
>> No, I'm suggesting that the tutorial shows you the steps you
>> need to generate the static code for your SDO model and then
>> the datagraph editor shows your model being used to read and
>> write instances or your model using your generated code.
>>>
>>> Here's a snippet of code from the method in my EJB where I'm
>>> able to use the dynamic
>>> API, but unable to use the static API.
>>>
>>> import com.ibm.ItemType;
>>> import com.ibm.PurchaseOrderType;
>>> import com.ibm.DocumentRoot;
>> It looks like you've already generated the code so that makes
>> me a bit confused about why you asked how to generate the the
>> code.
>>> import com.ibm.util.IbmResourceFactoryImpl;
>>> import com.ibm.util.IbmResourceUtil;
>>>
>>> import commonj.sdo.DataObject;
>>> import commonj.sdo.Property;
>>>
>>>
>>> import org.eclipse.emf.ecore.impl.EReferenceImpl;
>>> import org.eclipse.emf.ecore.sdo.EDataGraph;
>>> import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;
>>>
>>>
>>>
>>> // method defined on the remote interface
>>> public void acceptEDataGraph (EDataGraph eDG) {
>>>
>>>
>>> DataObject rootObject = eDG.getRootObject(); // works
>>> DataObject purchaseOrder =
>>> rootObject.getDataObject("purchaseOrder"); // works
>>>
>>> java.util.Date orderDate =
>>> purchaseOrder.getDate("orderDate"); // works
>>> System.out.println("orderDate: " + orderDate); // works
>>>
>>>
>>> // This doesn't work
>>> DocumentRoot documentRoot =
>>> (DocumentRoot)eDG.getERootObject();
>>> PurchaseOrderType aPOT = documentRoot.getPurchaseOrder();
>>> // what I'm referring to as the "static" SDO API
>>>
>>> // I get this exception
>>> java.rmi.ServerException: RemoteException occurred in server
>>> thread; nested exception is:
>>> java.rmi.RemoteException:
>>> >> SERVER (id=4773e3aa, host=IBM-0CA191A407D) TRACE START:
>>> >> java.rmi.RemoteException: ; nested exception is:
>>> java.lang.ClassCastException:
>>> org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
>>> incompatible with com.ibm.DocumentRoot
>>> >> at
>>> sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)
>> Oh, I see. Maybe all that's missing is the code to ensure
>> that your generated package is registered with the static
>> registry. At some point during the initialization of the
>> server you should access the XyzPackage.eINSTANCE to ensure
>> that the package is registered.
>>>
>>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>>
>>> wrote in message news:fihdh6$jpc$1@build.eclipse.org...
>>> Gary,
>>>
>>> Yes, that is possible:
>>>
>>> Tutorial: Using the SDO Data Graph Editor
>>> < http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf....ecore.sdo.doc/tutorials/datagraph/datagraph.html>
>>>
>>>
>>> Gary Martin wrote:
>>>> By design (with any version of SDO and Tuscany Java implementation),
>>>>
>>>> should it be possible to generate "static" SDO classes from an .xsd, and
>>>> then:
>>>>
>>>> a) use the generated classes to create an:
>>>> org.eclipse.emf.ecore.sdo.EDataGraph
>>>> b)call a method on the remote interface of an ejb that takes that
>>>> EDataGraph as its only arguement
>>>> c)use the *static* generated SDO classes to access the SDOs in the
>>>> EDataGraph
>>>>
>>>> I've done a) and b) and can use the dynamic SDO API in my EJB method,
>>>> but, I've yet to figure out how (or even if it should be possible by
>>>> design) to use the generated "static" SDO classes in my EJB method.
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>


--------------000603090604090501050508
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">
Gary,<br>
<br>
Comments below.<br>
<br>
Gary Martin wrote:
<blockquote cite="mid:fj4dcs$pb1$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
<div><font face="Arial" size="2">Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks yet again.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I ran this code on my *client*
(please note my comments //):</font></div>
<div>&nbsp;</div>
<div><font size="2">
</font>
<p align="left"><font size="2">IbmPackage purchaseOrderPackage =
IbmPackageImpl.</font><i><font color="#0000c0" size="2">eINSTANCE</font></i><font
size="2">;</font></p>
<p align="left"><font size="2">ResourceSet resourceSet =
eDG.getResourceSet();</font></p>
<p align="left"><font size="2">Resource packageResource =
resourceSet.createResource(URI.<i>createURI</i>(purchaseOrderPackage.getNsURI())); </font></p>
<p align="left"><font size="2">packageResource.getContents().add(purchaseOrderPackage); </font></p>
<p><font size="2"> resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(),
purchaseOrderPackage);</font></p>
</div>
</blockquote>
So you are registering this package locally and sending it with your
data graph.&nbsp; That why the receiver will always use the dynamic package
that you sent it and told it do use.&nbsp; Can you omit this entirely?&nbsp; You
shouldn't need it and it's the cause of the problem.<br>
<blockquote cite="mid:fj4dcs$pb1$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2"><strong>...</strong></font></div>
<div><font size="2"><font size="2">
</font>
<p align="left"><font size="2">System.</font><i><font color="#0000c0"
size="2">out</font></i><font color="#0000c0" size="2"><font size="2">.println(</font><font
color="#2a00ff" size="2">"eDG.getDataGraphResource().save(System.out,
null); before serialization ****************************************"</font><font
size="2">);</font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2">System.</font><i><font
color="#0000c0" size="2">out</font></i><font size="2">.println(</font><font
color="#2a00ff" size="2">"eDG.getERootObject: "</font><font size="2">
+ eDG.getERootObject());</font></font></p>
<p align="left"><font color="#0000c0" size="2">// <font size="2">eDG.getERootObject:
<strong>com.ibm.impl.DocumentRootImpl</strong>@52565256 (mixed:
[ibm:purchaseOrder=com.ibm.impl.PurchaseOrderTypeImpl@7a987a98
(comment: Overnight shipping, </font><u><font color="#000080" size="2">orderDate</font></u><font
size="2">: 2007-03-10)])</font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">eDG.getDataGraphResource().save(System.</font><i ><font
color="#0000c0" size="2">out</font></i><font size="2">, </font><b><font
color="#7f0055" size="2">null</font></b><font size="2">);</font></font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">ByteArrayOutputStream outputStream = </font><b><font
color="#7f0055" size="2">new</font></b><font size="2">
ByteArrayOutputStream();</font></font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">ObjectOutputStream objectOutputStream = </font><b><font
color="#7f0055" size="2">new</font></b><font size="2">
ObjectOutputStream(outputStream);</font></font></font></p >
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">objectOutputStream.writeObject(eDG);</font></font ></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">objectOutputStream.close();</font></font></font ></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">InputStream inputStream = </font><b><font color="#7f0055"
size="2">new</font></b><font size="2">
ByteArrayInputStream(outputStream.toByteArray());</font></font ></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">ObjectInputStream objectInputStream = </font><b><font
color="#7f0055" size="2">new</font></b><font size="2">
ObjectInputStream(inputStream);</font></font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">EDataGraph otherEDataGraph =
(EDataGraph)objectInputStream.readObject();</font></font></font ></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">System.</font><i><font color="#0000c0" size="2">out</font></i><font
size="2">.println(</font><font color="#2a00ff" size="2">"otherEDataGraph.getDataGraphResource().save(System.out,
null); after deserialization ***************************************"</font><font
size="2">);</font></font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">System.</font><i><font color="#0000c0" size="2">out</font></i><font
size="2">.println(</font><font color="#2a00ff" size="2">"otherEDataGraph.getERootObject:
"</font><font size="2"> + otherEDataGraph.getERootObject());</font></font></font></p >
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">// <font size="2">otherEDataGraph.getERootObject: <strong>org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl </strong>@3ae63ae6
(eClass: org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name:
DocumentRoot) (instanceClassName: null) (abstract: false, </font><u><font
color="#000080" size="2">interface</font></u><font size="2">: false))</font></font></font></font></p>
<font color="#0000c0" size="2"><font size="2"><font size="2"></font></font></font>
<p><font color="#0000c0" size="2"><font size="2"><font size="2">otherEDataGraph.getDataGraphResource().save(System. </font><i><font
color="#0000c0" size="2">out</font></i><font size="2">, </font><b><font
color="#7f0055" size="2">null</font></b><font size="2">);</font></font></font></p>
<p><font color="#0000c0" size="2"><font size="2"><font face="Arial"
size="2">So..somehow I need to "fix" the problem (EDataObjectImpl(s)
replaced with DynamicEDataObjectImpl(s) during serialization /
deserialization) ** on my client **.</font></font></font></p>
<p><font color="#0000c0" size="2"><font size="2"><font face="Arial">I
saved the System.out output if it might be useful?</font></font></font></p>
<p><font color="#0000c0" size="2"><font size="2"><font size="2">&nbsp;</font></font></font></p>
</font></div>
<div><font size="2"><font color="#0000c0" size="2">&nbsp;</font></font></div>
<div><font size="2"><font color="#0000c0" size="2"><br>
</font></font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<font size="2"><font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">"Ed Merks" &lt;<a
moz-do-not-send="true" href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a moz-do-not-send="true"
href="news:fj41hq$s5v$1@build.eclipse.org">news:fj41hq$s5v$1@build.eclipse.org</a>...</font></div>
<font color="#0000c0" size="2">Gary,<br>
<br>
Comments below.<br>
<br>
Gary Martin wrote: </font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite"><font
color="#0000c0" size="2">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
</font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">Upon
further investigation:</font></font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">Note:
I'm using whatever implementation of SDO 1.0 spec IBM included in<br>
WebSphere App Server v6.1.0.11 -
.....\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005. jar </font></font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">In
a previous append - Tuesday, November 27, 2007 1:03 PM Eastern - I
included a snippet of source code from a <br>
method - acceptEDataGraph(EDataGraph) defined by a Stateless Session
EJB and on the EJB's remote interface.</font></font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">Based
on your append - Tuesday, November 27, 2007 1:18 PM Eastern - I added:<br>
IbmPackage anIbmPackage = IbmPackageImpl.init();<br>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">IbmPackage.eINSTANCE would be the
preferred way.&nbsp; IbmPackage.eINSTANCE.eClass() is the idiom we typically
use if we only want to force initialize but don't really need the
package.<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite"><font
color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">as
the 1st statement in that method&nbsp; (This didn't appear to change the
behavior about which I comment below.)</font></font></div>
</blockquote>
<font color="#0000c0" size="2">Is this done on both the client and
the server?<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite"><font
color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2"><br>
Snippet from EJB client (with comments on which I ask your feedback):</font></font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">//
create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and populate root
Object and contained objects using<br>
// generated IBMFactoryImpl and "static" SDOs (inherit from
EDataObjectImpl</font></font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">...</font></font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">Object
anObject = ((EDataGraphImpl) eDG).getWriteReplacement(); //
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // just
curious what Object was returned</font></font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">aSDOExchanger.acceptEDataGraph(eDG);
// defined on remote interface of Stateless Session EJB</font></font></div>
</blockquote>
<font color="#0000c0" size="2">You might want to try code like this
(which we have in our JUnit tests):<br>
<br>
<small>&nbsp;&nbsp;&nbsp; eDataGraph.getDataGraphResource().save(System.out, null);<br>
&nbsp;&nbsp;&nbsp; ByteArrayOutputStream outputStream = new ByteArrayOutputStream();<br>
&nbsp;&nbsp;&nbsp; ObjectOutputStream objectOutputStream = new
ObjectOutputStream(outputStream);<br>
&nbsp;&nbsp;&nbsp; objectOutputStream.writeObject(eDataGraph);<br>
&nbsp;&nbsp;&nbsp; objectOutputStream.close();<br>
&nbsp;&nbsp;&nbsp; InputStream inputStream = new
ByteArrayInputStream(outputStream.toByteArray());<br>
&nbsp;&nbsp;&nbsp; ObjectInputStream objectInputStream = new
ObjectInputStream(inputStream);<br>
&nbsp;&nbsp;&nbsp; EDataGraph otherEDataGraph =
(EDataGraph)objectInputStream.readObject();<br>
&nbsp;&nbsp;&nbsp; otherEDataGraph.getDataGraphResource().save(System.out, null);<br>
</small><br>
This should help demonstrate that the datagraph is properly
serializable and can be recovered from the serialization.&nbsp; Try this on
the client.&nbsp; If the server were configured the same way, it should be
able to deserialize the result.<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite"><font
color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">//
eDG's ERootObject was set earlier to instance of:
com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits from
EDataObjectImpl)<br>
// DocumentRootImpl.setPurchaseOrder was set to instance of
com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)<br>
&nbsp;&nbsp;&nbsp;<br>
// When accessed (after serialization / deserialization) in EJB,
EDataGraph's rootObject is a:
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<br>
// When accessed in EJB, DocumentRootImpl.getPurchaseOrder is instance
of: org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<br>
&nbsp;&nbsp;&nbsp;<br>
// I've concluded that this "replacement" (during serialization /
deserialization) of instances of generated "static" SDOs<br>
// (that inherit from EDataObjectImpl)<br>
// with instances of DynamicEDataObjectImpl has to be a conscious
design choice - not a bug.<br>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">No, it really depends on what type
of models you have registered and whether you are transmitting the
model from the client to the server or just assuming the server knows
the model already.<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite"><font
color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">//
As a result, I can't use the generated "static" SDOs in the
implementation of method acceptEDataGraph(EDataGraph)</font></font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">Ed:</font></font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">&nbsp;</font></div>
<font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">a)
Do you agree / disagree with that conclusion?<br>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">No.&nbsp; If you can get serialization
and deserialization to work locally on the client end, set a breakpoint
in the constructor for your generated DocumentRoot and see how the code
gets there.&nbsp; Similarly, set a breakpoint in the DynamicEDataObject
constructor and look at how the code path that gets you there is
different in that case...<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite"><font
color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial" size="2">b)
Do you know if this behavior is different (by design) in newer Tuscany
implementations of SDO 1.0 or 2.0?</font></font></div>
</blockquote>
<font color="#0000c0" size="2">I think Tuscany started out with
EMF's SDO implementation, so I imagine the issues will be very similar
or the same.<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org" type="cite"><font
color="#0000c0" size="2"> </font>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;"><font
color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2">"Ed Merks" &lt;<a
href="mailto:merks@ca.ibm.com" moz-do-not-send="true">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:fihn1g$e1e$1@build.eclipse.org"
moz-do-not-send="true">news:fihn1g$e1e$1@build.eclipse.org</a>...</font></div>
<font color="#0000c0" size="2">Gary,<br>
<br>
Comments below.<br>
<br>
Gary Martin wrote: </font>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org"
type="cite"><font color="#0000c0" size="2">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
<style></style> </font>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">
<div><font face="Arial" size="2">Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thank you.&nbsp; I'm
not&nbsp;connecting the dots.&nbsp;&nbsp; Are you suggesting that the source code of</font></div>
<div><font face="Arial" size="2">the SDO Data Graph Editor
itself illustrates c) in my problem statement?</font></div>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">No, I'm suggesting that the
tutorial shows you the steps you need to generate the static code for
your SDO model and then the datagraph editor shows your model being
used to read and write instances or your model using your generated
code.<br>
</font>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org"
type="cite"><font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">
<div>&nbsp;</div>
<div><font face="Arial" size="2">Here's a snippet of code
from the method in my EJB where I'm able to use the dynamic</font></div>
<div><font face="Arial" size="2">API, but unable to use the
static API.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">import com.ibm.ItemType;<br>
import com.ibm.PurchaseOrderType;<br>
import com.ibm.DocumentRoot;<br>
</font></div>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">It looks like you've already
generated the code so that makes me a bit confused about why you asked
how to generate the the code.<br>
</font>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org"
type="cite"><font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">
<div><font face="Arial" size="2">import
com.ibm.util.IbmResourceFactoryImpl;<br>
import com.ibm.util.IbmResourceUtil;</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">import
commonj.sdo.DataObject;<br>
import commonj.sdo.Property;</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><br>
import org.eclipse.emf.ecore.impl.EReferenceImpl;<br>
import org.eclipse.emf.ecore.sdo.EDataGraph;<br>
import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;</font ></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">// method defined on the
remote interface <br>
public void acceptEDataGraph (EDataGraph eDG)&nbsp; {</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><br>
&nbsp;&nbsp;DataObject rootObject = eDG.getRootObject(); // works<br>
&nbsp;&nbsp;DataObject purchaseOrder = rootObject.getDataObject("purchaseOrder");
// works</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;java.util.Date orderDate =
purchaseOrder.getDate("orderDate"); // works<br>
&nbsp;&nbsp;System.out.println("orderDate: " + orderDate); // works </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><br>
&nbsp;&nbsp;// This doesn't work <br>
&nbsp;&nbsp;DocumentRoot documentRoot = (DocumentRoot)eDG.getERootObject();&nbsp;&nbsp;<br>
&nbsp;&nbsp;PurchaseOrderType aPOT = documentRoot.getPurchaseOrder(); // what I'm
referring to as the "static" SDO API</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">// I get this exception <br>
java.rmi.ServerException: RemoteException occurred in server thread;
nested exception is: <br>
&nbsp;java.rmi.RemoteException: <br>
&nbsp;&gt;&gt; SERVER (id=4773e3aa, host=IBM-0CA191A407D) TRACE START:<br>
&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp; java.rmi.RemoteException: ; nested exception is: <br>
&nbsp;java.lang.ClassCastException:
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with
com.ibm.DocumentRoot<br>
&nbsp;&gt;&gt;&nbsp; at
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89) </font></div>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">Oh, I see.&nbsp; Maybe all that's
missing is the code to ensure that your generated package is registered
with the static registry. At some point during the initialization of
the server you should access the XyzPackage.eINSTANCE to ensure that
the package is registered.<br>
</font>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org"
type="cite"><font color="#0000c0" size="2"> </font>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com"
moz-do-not-send="true">merks@ca.ibm.com</a>&gt; wrote in message <a
href="news:fihdh6$jpc$1@build.eclipse.org" moz-do-not-send="true">news:fihdh6$jpc$1@build.eclipse.org</a>...</div>
Gary,<br>
<br>
Yes, that is possible:<br>
<blockquote><a
href=" http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf....ecore.sdo.doc/tutorials/datagraph/datagraph.html"
moz-do-not-send="true">Tutorial: Using the SDO Data Graph Editor</a><br>
</blockquote>
<br>
Gary Martin wrote:
<blockquote cite="mid:fihc9v$c1p$1@build.eclipse.org"
type="cite">
<pre wrap="">By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.


</pre>
</blockquote>
<br>
</blockquote>
</font></font></div>
<font color="#0000c0" size="2"> </font>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;"><font
color="#0000c0" size="2">&nbsp;</font></blockquote>
</blockquote>
<font color="#0000c0" size="2"><br>
</font></blockquote>
</blockquote>
<font color="#0000c0" size="2"><br>
</font></font></blockquote>
</blockquote>
<br>
</body>
</html>

--------------000603090604090501050508--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: SDO Java -serialization/deserialization of EDataGraph - use Static SDO API after deserializatio [message #415210 is a reply to message #415195] Wed, 05 December 2007 14:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: GaryRMartin.insightbb.com

This is a multi-part message in MIME format.

------=_NextPart_000_005E_01C8371E.9A4970F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,

Success! Thanks again for all your help.

For those following this thread, what finally worked was:

Snippet from client:

IbmPackage purchaseOrderPackage =3D IbmPackageImpl.eINSTANCE;
ResourceSet resourceSet =3D eDG.getResourceSet();
Resource packageResource =3D =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);
// packageResource.getContents().add(purchaseOrderPackage); =20
// resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(), =
purchaseOrderPackage);=20
=20
// ************************************************** eye catcher ******
// news://news.eclipse.org/eclipse.tools.emf - Tuesday, December 04, =
2007 5:40 PM Eastern
// So you are registering this package locally and sending it with your =
data graph.
// That why the receiver will always use the dynamic package that you =
sent it and told it do use.
// Can you omit this entirely? You shouldn't need it and it's the cause =
of the problem.
// ************************************************** eye catcher ****** =


"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fj4l1s$ttp$1@build.eclipse.org...
Gary,

Comments below.

Gary Martin wrote:=20
Ed,

Thanks yet again.

I ran this code on my *client* (please note my comments //):

IbmPackage purchaseOrderPackage =3D IbmPackageImpl.eINSTANCE;

ResourceSet resourceSet =3D eDG.getResourceSet();

Resource packageResource =3D =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);

packageResource.getContents().add(purchaseOrderPackage);

=
resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(), =
purchaseOrderPackage);

So you are registering this package locally and sending it with your =
data graph. That why the receiver will always use the dynamic package =
that you sent it and told it do use. Can you omit this entirely? You =
shouldn't need it and it's the cause of the problem.

...
System.out.println("eDG.getDataGraphResource().save(System.out, =
null); before serialization ****************************************");

System.out.println("eDG.getERootObject: " + eDG.getERootObject());

// eDG.getERootObject: com.ibm.impl.DocumentRootImpl@52565256 =
(mixed: [ibm:purchaseOrder=3Dcom.ibm.impl.PurchaseOrderTypeImpl@7a987a98 =
(comment: Overnight shipping, orderDate: 2007-03-10)])

eDG.getDataGraphResource().save(System.out, null);

ByteArrayOutputStream outputStream =3D new ByteArrayOutputStream();

ObjectOutputStream objectOutputStream =3D new =
ObjectOutputStream(outputStream);

objectOutputStream.writeObject(eDG);

objectOutputStream.close();

InputStream inputStream =3D new =
ByteArrayInputStream(outputStream.toByteArray());

ObjectInputStream objectInputStream =3D new =
ObjectInputStream(inputStream);

EDataGraph otherEDataGraph =3D =
(EDataGraph)objectInputStream.readObject();

=
System.out.println("otherEDataGraph.getDataGraphResource().save(System.ou=
t, null); after deserialization =
***************************************");

System.out.println("otherEDataGraph.getERootObject: " + =
otherEDataGraph.getERootObject());

// otherEDataGraph.getERootObject: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl@3ae63ae6 (eClass: =
org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name: DocumentRoot) =
(instanceClassName: null) (abstract: false, interface: false))

otherEDataGraph.getDataGraphResource().save(System.out, null);

So..somehow I need to "fix" the problem (EDataObjectImpl(s) replaced =
with DynamicEDataObjectImpl(s) during serialization / deserialization) =
** on my client **.

I saved the System.out output if it might be useful?






"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fj41hq$s5v$1@build.eclipse.org...
Gary,

Comments below.

Gary Martin wrote:=20
Upon further investigation:

Note: I'm using whatever implementation of SDO 1.0 spec IBM =
included in
WebSphere App Server v6.1.0.11 - =
.....\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005. jar

In a previous append - Tuesday, November 27, 2007 1:03 PM =
Eastern - I included a snippet of source code from a=20
method - acceptEDataGraph(EDataGraph) defined by a Stateless =
Session EJB and on the EJB's remote interface.

Based on your append - Tuesday, November 27, 2007 1:18 PM =
Eastern - I added:
IbmPackage anIbmPackage =3D IbmPackageImpl.init();

IbmPackage.eINSTANCE would be the preferred way. =
IbmPackage.eINSTANCE.eClass() is the idiom we typically use if we only =
want to force initialize but don't really need the package.

as the 1st statement in that method (This didn't appear to =
change the behavior about which I comment below.)
Is this done on both the client and the server?



Snippet from EJB client (with comments on which I ask your =
feedback):

// create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and =
populate root Object and contained objects using
// generated IBMFactoryImpl and "static" SDOs (inherit from =
EDataObjectImpl

...

Object anObject =3D ((EDataGraphImpl) =
eDG).getWriteReplacement(); // =
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable
=
// just curious what Object was returned

aSDOExchanger.acceptEDataGraph(eDG); // defined on remote =
interface of Stateless Session EJB
You might want to try code like this (which we have in our JUnit =
tests):

eDataGraph.getDataGraphResource().save(System.out, null);
ByteArrayOutputStream outputStream =3D new =
ByteArrayOutputStream();
ObjectOutputStream objectOutputStream =3D new =
ObjectOutputStream(outputStream);
objectOutputStream.writeObject(eDataGraph);
objectOutputStream.close();
InputStream inputStream =3D new =
ByteArrayInputStream(outputStream.toByteArray());
ObjectInputStream objectInputStream =3D new =
ObjectInputStream(inputStream);
EDataGraph otherEDataGraph =3D =
(EDataGraph)objectInputStream.readObject();
otherEDataGraph.getDataGraphResource().save(System.out, null);

This should help demonstrate that the datagraph is properly =
serializable and can be recovered from the serialization. Try this on =
the client. If the server were configured the same way, it should be =
able to deserialize the result.


// eDG's ERootObject was set earlier to instance of: =
com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits from =
EDataObjectImpl)
// DocumentRootImpl.setPurchaseOrder was set to instance of =
com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)
=20
// When accessed (after serialization / deserialization) in EJB, =
EDataGraph's rootObject is a: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
// When accessed in EJB, DocumentRootImpl.getPurchaseOrder is =
instance of: org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
=20
// I've concluded that this "replacement" (during serialization =
/ deserialization) of instances of generated "static" SDOs
// (that inherit from EDataObjectImpl)
// with instances of DynamicEDataObjectImpl has to be a =
conscious design choice - not a bug.

No, it really depends on what type of models you have registered =
and whether you are transmitting the model from the client to the server =
or just assuming the server knows the model already.

// As a result, I can't use the generated "static" SDOs in the =
implementation of method acceptEDataGraph(EDataGraph)

Ed:

a) Do you agree / disagree with that conclusion?

No. If you can get serialization and deserialization to work =
locally on the client end, set a breakpoint in the constructor for your =
generated DocumentRoot and see how the code gets there. Similarly, set =
a breakpoint in the DynamicEDataObject constructor and look at how the =
code path that gets you there is different in that case...

b) Do you know if this behavior is different (by design) in =
newer Tuscany implementations of SDO 1.0 or 2.0?
I think Tuscany started out with EMF's SDO implementation, so I =
imagine the issues will be very similar or the same.

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fihn1g$e1e$1@build.eclipse.org...
Gary,

Comments below.

Gary Martin wrote:=20
Ed,

Thank you. I'm not connecting the dots. Are you =
suggesting that the source code of
the SDO Data Graph Editor itself illustrates c) in my =
problem statement?
No, I'm suggesting that the tutorial shows you the steps you =
need to generate the static code for your SDO model and then the =
datagraph editor shows your model being used to read and write instances =
or your model using your generated code.


Here's a snippet of code from the method in my EJB where I'm =
able to use the dynamic
API, but unable to use the static API.

import com.ibm.ItemType;
import com.ibm.PurchaseOrderType;
import com.ibm.DocumentRoot;

It looks like you've already generated the code so that makes =
me a bit confused about why you asked how to generate the the code.

import com.ibm.util.IbmResourceFactoryImpl;
import com.ibm.util.IbmResourceUtil;

import commonj.sdo.DataObject;
import commonj.sdo.Property;


import org.eclipse.emf.ecore.impl.EReferenceImpl;
import org.eclipse.emf.ecore.sdo.EDataGraph;
import =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;



// method defined on the remote interface=20
public void acceptEDataGraph (EDataGraph eDG) {


DataObject rootObject =3D eDG.getRootObject(); // works
DataObject purchaseOrder =3D =
rootObject.getDataObject("purchaseOrder"); // works

java.util.Date orderDate =3D =
purchaseOrder.getDate("orderDate"); // works
System.out.println("orderDate: " + orderDate); // works=20


// This doesn't work=20
DocumentRoot documentRoot =3D =
(DocumentRoot)eDG.getERootObject(); =20
PurchaseOrderType aPOT =3D =
documentRoot.getPurchaseOrder(); // what I'm referring to as the =
"static" SDO API

// I get this exception=20
java.rmi.ServerException: RemoteException occurred in server =
thread; nested exception is:=20
java.rmi.RemoteException:=20
>> SERVER (id=3D4773e3aa, host=3DIBM-0CA191A407D) TRACE =
START:
>> java.rmi.RemoteException: ; nested exception is:=20
java.lang.ClassCastException: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with =
com.ibm.DocumentRoot
>> at =
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=

Oh, I see. Maybe all that's missing is the code to ensure =
that your generated package is registered with the static registry. At =
some point during the initialization of the server you should access the =
XyzPackage.eINSTANCE to ensure that the package is registered.

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fihdh6$jpc$1@build.eclipse.org...
Gary,

Yes, that is possible:

Tutorial: Using the SDO Data Graph Editor


Gary Martin wrote:=20
By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


=20








------=_NextPart_000_005E_01C8371E.9A4970F0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Success!&nbsp; Thanks again for all =
your=20
help.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>For those following this thread, what =
finally=20
worked was:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Snippet from client:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>IbmPackage purchaseOrderPackage =3D=20
IbmPackageImpl.eINSTANCE;<BR>ResourceSet resourceSet =3D=20
eDG.getResourceSet();<BR>Resource packageResource =3D=20
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);<BR>//=20
packageResource.getContents().add(purchaseOrderPackage);& ;nbsp;&nbsp; <BR>/=
/=20
resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(),=20
purchaseOrderPackage); <BR>&nbsp;&nbsp;<BR>//=20
************************************************** eye catcher =
******<BR>// <A=20
href=3D"news://news.eclipse.org/eclipse.tools.emf">news://news.eclipse.or=
g/eclipse.tools.emf</A>=20
- Tuesday, December 04, 2007 5:40 PM Eastern<BR>// So you are =
registering this=20
package locally and sending it with your data graph.<BR>// That why the =
receiver=20
will always use the dynamic package that you sent it and told it do =
use.<BR>//=20
Can you omit this entirely?&nbsp; You shouldn't need it and it's the =
cause of=20
the problem.<BR>// ************************************************** =
eye=20
catcher ****** <BR></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:fj4l1s$ttp$1@build.eclipse.org">news:fj4l1s$ttp$1@build.ecli=
pse.org</A>...</DIV>Gary,<BR><BR>Comments=20
below.<BR><BR>Gary Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fj4dcs$pb1$1@build.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks yet again.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I ran this code on my *client* =
(please note my=20
comments //):</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>
<P align=3Dleft><FONT size=3D2>IbmPackage purchaseOrderPackage =3D=20
IbmPackageImpl.</FONT><I><FONT color=3D#0000c0=20
size=3D2>eINSTANCE</FONT></I><FONT size=3D2>;</FONT></P>
<P align=3Dleft><FONT size=3D2>ResourceSet resourceSet =3D=20
eDG.getResourceSet();</FONT></P>
<P align=3Dleft><FONT size=3D2>Resource packageResource =3D=20
=
resourceSet.createResource(URI.<I>createURI</I>(purchaseOrderPackage.getN=
sURI()));</FONT></P>
<P align=3Dleft><FONT=20
=
size=3D2>packageResource.getContents().add(purchaseOrderPackage); </FONT><=
/P>
<P><FONT=20
=
size=3D2> resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsU=
RI(),=20
purchaseOrderPackage);</FONT></P></DIV></BLOCKQUOTE>So you are =
registering=20
this package locally and sending it with your data graph.&nbsp; That =
why the=20
receiver will always use the dynamic package that you sent it and told =
it do=20
use.&nbsp; Can you omit this entirely?&nbsp; You shouldn't need it and =
it's=20
the cause of the problem.<BR>
<BLOCKQUOTE cite=3Dmid:fj4dcs$pb1$1@build.eclipse.org type=3D"cite">
<DIV><FONT face=3DArial size=3D2><STRONG>...</STRONG></FONT></DIV>
<DIV><FONT size=3D2><FONT size=3D2></FONT>
<P align=3Dleft><FONT size=3D2>System.</FONT><I><FONT =
color=3D#0000c0=20
size=3D2>out</FONT></I><FONT color=3D#0000c0 size=3D2><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff=20
size=3D2>"eDG.getDataGraphResource().save(System.out, null); before=20
serialization ****************************************"</FONT><FONT=20
size=3D2>);</FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2>System.</FONT><I><FONT=20
color=3D#0000c0 size=3D2>out</FONT></I><FONT =
size=3D2>.println(</FONT><FONT=20
color=3D#2a00ff size=3D2>"eDG.getERootObject: "</FONT><FONT =
size=3D2> +=20
eDG.getERootObject());</FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2>// <FONT =
size=3D2>eDG.getERootObject:=20
<STRONG>com.ibm.impl.DocumentRootImpl</STRONG>@52565256 (mixed:=20
[ibm:purchaseOrder=3Dcom.ibm.impl.PurchaseOrderTypeImpl@7a987a98 =
(comment:=20
Overnight shipping, </FONT><U><FONT color=3D#000080=20
size=3D2>orderDate</FONT></U><FONT size=3D2>: =
2007-03-10)])</FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2>eDG.getDataGraphResource().save(System.</FONT><I ><FONT =
color=3D#0000c0=20
size=3D2>out</FONT></I><FONT size=3D2>, </FONT><B><FONT =
color=3D#7f0055=20
size=3D2>null</FONT></B><FONT size=3D2>);</FONT></FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2>ByteArrayOutputStream outputStream =3D </FONT><B><FONT =
color=3D#7f0055=20
size=3D2>new</FONT></B><FONT size=3D2>=20
ByteArrayOutputStream();</FONT></FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2>ObjectOutputStream objectOutputStream =3D </FONT><B><FONT =
color=3D#7f0055=20
size=3D2>new</FONT></B><FONT size=3D2>=20
ObjectOutputStream(outputStream);</FONT></FONT></FONT></P >
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
=
size=3D2>objectOutputStream.writeObject(eDG);</FONT></FONT ></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2>objectOutputStream.close();</FONT></FONT></FONT ></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2>InputStream inputStream =3D </FONT><B><FONT color=3D#7f0055 =

size=3D2>new</FONT></B><FONT size=3D2>=20
=
ByteArrayInputStream(outputStream.toByteArray());</FONT></FONT ></FONT></P=
>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2>ObjectInputStream objectInputStream =3D </FONT><B><FONT =
color=3D#7f0055=20
size=3D2>new</FONT></B><FONT size=3D2>=20
ObjectInputStream(inputStream);</FONT></FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2>EDataGraph otherEDataGraph =3D=20
(EDataGraph)objectInputStream.readObject();</FONT></FONT></FONT ></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2>System.</FONT><I><FONT color=3D#0000c0 =
size=3D2>out</FONT></I><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff=20
size=3D2>"otherEDataGraph.getDataGraphResource().save(System.out, =
null); after=20
deserialization ***************************************"</FONT><FONT =

size=3D2>);</FONT></FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2>System.</FONT><I><FONT color=3D#0000c0 =
size=3D2>out</FONT></I><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff=20
size=3D2>"otherEDataGraph.getERootObject: "</FONT><FONT size=3D2> +=20
otherEDataGraph.getERootObject());</FONT></FONT></FONT></P >
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT =
size=3D2>// <FONT=20
size=3D2>otherEDataGraph.getERootObject:=20
=
<STRONG>org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl </STRONG>@3a=
e63ae6=20
(eClass: org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name: =
DocumentRoot)=20
(instanceClassName: null) (abstract: false, </FONT><U><FONT =
color=3D#000080=20
size=3D2>interface</FONT></U><FONT size=3D2>:=20
false))</FONT></FONT></FONT></FONT></P><FONT color=3D#0000c0 =
size=3D2><FONT=20
size=3D2><FONT size=3D2></FONT></FONT></FONT>
<P><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
=
size=3D2>otherEDataGraph.getDataGraphResource().save(System. </FONT><I><FO=
NT=20
color=3D#0000c0 size=3D2>out</FONT></I><FONT size=3D2>, =
</FONT><B><FONT=20
color=3D#7f0055 size=3D2>null</FONT></B><FONT =
size=3D2>);</FONT></FONT></FONT></P>
<P><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT face=3DArial=20
size=3D2>So..somehow I need to "fix" the problem (EDataObjectImpl(s) =
replaced=20
with DynamicEDataObjectImpl(s) during serialization / =
deserialization) ** on=20
my client **.</FONT></FONT></FONT></P>
<P><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT =
face=3DArial>I saved the=20
System.out output if it might be useful?</FONT></FONT></FONT></P>
<P><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
size=3D2></FONT></FONT></FONT>&nbsp;</P></FONT></DIV >
<DIV><FONT size=3D2><FONT color=3D#0000c0 =
size=3D2></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2><FONT color=3D#0000c0 =
size=3D2><BR></FONT></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px"><FONT=20
size=3D2><FONT color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; wrote in message =
<A=20
href=3D"news:fj41hq$s5v$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fj41hq$s5v$1@build.eclipse.org</A>...</FONT=
></DIV><FONT=20
color=3D#0000c0 size=3D2>Gary,<BR><BR>Comments below.<BR><BR>Gary =
Martin=20
wrote: </FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite"><FONT=20
color=3D#0000c0 size=3D2>
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>Upon further=20
investigation:</FONT></FONT></DIV><FONT color=3D#0000c0 =
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>Note: I'm using=20
whatever implementation of SDO 1.0 spec IBM included =
in<BR>WebSphere App=20
Server v6.1.0.11 -=20
=
.....\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005. jar </FONT></FO=
NT></DIV><FONT=20
color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>In a previous=20
append - Tuesday, November 27, 2007 1:03 PM Eastern - I included =
a=20
snippet of source code from a <BR>method - =
acceptEDataGraph(EDataGraph)=20
defined by a Stateless Session EJB and on the EJB's remote=20
interface.</FONT></FONT></DIV><FONT color=3D#0000c0 =
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>Based on your=20
append - Tuesday, November 27, 2007 1:18 PM Eastern - I=20
added:<BR>IbmPackage anIbmPackage =3D=20
IbmPackageImpl.init();<BR></FONT></FONT></DIV></BLOCKQUOTE ><FONT =

color=3D#0000c0 size=3D2>IbmPackage.eINSTANCE would be the =
preferred=20
way.&nbsp; IbmPackage.eINSTANCE.eClass() is the idiom we typically =
use if=20
we only want to force initialize but don't really need the=20
package.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite"><FONT=20
color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>as the 1st=20
statement in that method&nbsp; (This didn't appear to change the =

behavior about which I comment=20
below.)</FONT></FONT></DIV></BLOCKQUOTE><FONT color=3D#0000c0 =
size=3D2>Is this=20
done on both the client and the server?<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite"><FONT=20
color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2><BR>Snippet from=20
EJB client (with comments on which I ask your=20
feedback):</FONT></FONT></DIV><FONT color=3D#0000c0 =
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>// create=20
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and populate root =
Object=20
and contained objects using<BR>// generated IBMFactoryImpl and =
"static"=20
SDOs (inherit from EDataObjectImpl</FONT></FONT></DIV><FONT=20
color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial=20
size=3D2>...</FONT></FONT></DIV><FONT color=3D#0000c0 =
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>Object anObject=20
=3D ((EDataGraphImpl) eDG).getWriteReplacement(); //=20
=
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable <BR=
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n b=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb s=
p;&nbsp;&nbsp;=20
// just curious what Object was =
returned</FONT></FONT></DIV><FONT=20
color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial=20
size=3D2>aSDOExchanger.acceptEDataGraph(eDG); // defined on =
remote=20
interface of Stateless Session =
EJB</FONT></FONT></DIV></BLOCKQUOTE><FONT=20
color=3D#0000c0 size=3D2>You might want to try code like this =
(which we have=20
in our JUnit tests):<BR><BR><SMALL>&nbsp;&nbsp;&nbsp;=20
eDataGraph.getDataGraphResource().save(System.out,=20
null);<BR>&nbsp;&nbsp;&nbsp; ByteArrayOutputStream outputStream =
=3D new=20
ByteArrayOutputStream();<BR>&nbsp;&nbsp;&nbsp; ObjectOutputStream=20
objectOutputStream =3D new=20
ObjectOutputStream(outputStream);<BR>&nbsp;&nbsp;&nbsp;=20
objectOutputStream.writeObject(eDataGraph);<BR>&nbsp;&nbsp;&nbsp;=20
objectOutputStream.close();<BR>&nbsp;&nbsp;&nbsp; InputStream =
inputStream=20
=3D new=20
=
ByteArrayInputStream(outputStream.toByteArray());<BR>&nbsp;&nbsp;&nbsp;=20
ObjectInputStream objectInputStream =3D new=20
ObjectInputStream(inputStream);<BR>&nbsp;&nbsp;&nbsp; EDataGraph=20
otherEDataGraph =3D=20
(EDataGraph)objectInputStream.readObject();<BR>&nbsp;&nbsp;&nbsp;=20
otherEDataGraph.getDataGraphResource().save(System.out,=20
null);<BR></SMALL><BR>This should help demonstrate that the =
datagraph is=20
properly serializable and can be recovered from the =
serialization.&nbsp;=20
Try this on the client.&nbsp; If the server were configured the =
same way,=20
it should be able to deserialize the result.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite"><FONT=20
color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>// eDG's=20
ERootObject was set earlier to instance of:=20
com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits =
from=20
EDataObjectImpl)<BR>// DocumentRootImpl.setPurchaseOrder was set =
to=20
instance of com.ibm.impl.PurchaseOrderTypeImpl (generated =
"static"=20
SDO)<BR>&nbsp;&nbsp;&nbsp;<BR>// When accessed (after =
serialization /=20
deserialization) in EJB, EDataGraph's rootObject is a:=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<BR>// When =

accessed in EJB, DocumentRootImpl.getPurchaseOrder is instance =
of:=20
=
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<BR>&nbsp;&nbsp;&nbs=
p;<BR>//=20
I've concluded that this "replacement" (during serialization /=20
deserialization) of instances of generated "static" SDOs<BR>// =
(that=20
inherit from EDataObjectImpl)<BR>// with instances of=20
DynamicEDataObjectImpl has to be a conscious design choice - not =
a=20
bug.<BR></FONT></FONT></DIV></BLOCKQUOTE><FONT color=3D#0000c0 =
size=3D2>No, it=20
really depends on what type of models you have registered and =
whether you=20
are transmitting the model from the client to the server or just =
assuming=20
the server knows the model already.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite"><FONT=20
color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>// As a result,=20
I can't use the generated "static" SDOs in the implementation of =
method=20
acceptEDataGraph(EDataGraph)</FONT></FONT></DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial=20
size=3D2>Ed:</FONT></FONT></DIV><FONT color=3D#0000c0 =
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2></FONT>&nbsp;</DIV><FONT =
color=3D#0000c0=20
size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>a) Do you agree=20
/ disagree with that =
conclusion?<BR></FONT></FONT></DIV></BLOCKQUOTE><FONT=20
color=3D#0000c0 size=3D2>No.&nbsp; If you can get serialization =
and=20
deserialization to work locally on the client end, set a =
breakpoint in the=20
constructor for your generated DocumentRoot and see how the code =
gets=20
there.&nbsp; Similarly, set a breakpoint in the DynamicEDataObject =

constructor and look at how the code path that gets you there is =
different=20
in that case...<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite"><FONT=20
color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>b) Do you know=20
if this behavior is different (by design) in newer Tuscany=20
implementations of SDO 1.0 or =
2.0?</FONT></FONT></DIV></BLOCKQUOTE><FONT=20
color=3D#0000c0 size=3D2>I think Tuscany started out with EMF's =
SDO=20
implementation, so I imagine the issues will be very similar or =
the=20
same.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite"><FONT=20
color=3D#0000c0 size=3D2></FONT>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px"><FONT=20
color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; wrote in =
message <A=20
href=3D"news:fihn1g$e1e$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fihn1g$e1e$1@build.eclipse.org</A>...</FONT=
></DIV><FONT=20
color=3D#0000c0 size=3D2>Gary,<BR><BR>Comments =
below.<BR><BR>Gary Martin=20
wrote: </FONT>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org=20
type=3D"cite"><FONT color=3D#0000c0 size=3D2>
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR>
<STYLE></STYLE>
</FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thank you.&nbsp; I'm=20
not&nbsp;connecting the dots.&nbsp;&nbsp; Are you suggesting =
that=20
the source code of</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the SDO Data Graph Editor =
itself=20
illustrates c) in my problem=20
=
statement?</FONT></DIV></FONT></FONT></DIV></BLOCKQUOTE ><FONT=20
color=3D#0000c0 size=3D2>No, I'm suggesting that the tutorial =
shows you=20
the steps you need to generate the static code for your SDO =
model and=20
then the datagraph editor shows your model being used to read =
and=20
write instances or your model using your generated =
code.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org=20
type=3D"cite"><FONT color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here's a snippet of code =
from the=20
method in my EJB where I'm able to use the =
dynamic</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>API, but unable to use the =
static=20
API.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import =
com.ibm.ItemType;<BR>import=20
com.ibm.PurchaseOrderType;<BR>import=20
=
com.ibm.DocumentRoot;<BR></FONT></DIV></FONT></FONT></DIV ></BLOCKQUOTE><F=
ONT=20
color=3D#0000c0 size=3D2>It looks like you've already =
generated the code=20
so that makes me a bit confused about why you asked how to =
generate=20
the the code.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org=20
type=3D"cite"><FONT color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>
<DIV><FONT face=3DArial size=3D2>import=20
com.ibm.util.IbmResourceFactoryImpl;<BR>import=20
com.ibm.util.IbmResourceUtil;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import=20
commonj.sdo.DataObject;<BR>import =
commonj.sdo.Property;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>import=20
org.eclipse.emf.ecore.impl.EReferenceImpl;<BR>import=20
org.eclipse.emf.ecore.sdo.EDataGraph;<BR>import=20
=
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;</FONT ></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// method defined on the =
remote=20
interface <BR>public void acceptEDataGraph (EDataGraph =
eDG)&nbsp;=20
{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;DataObject =
rootObject =3D=20
eDG.getRootObject(); // works<BR>&nbsp;&nbsp;DataObject=20
purchaseOrder =3D rootObject.getDataObject("purchaseOrder"); =
//=20
works</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;java.util.Date =
orderDate =3D=20
purchaseOrder.getDate("orderDate"); //=20
works<BR>&nbsp;&nbsp;System.out.println("orderDate: " + =
orderDate);=20
// works </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;// This =
doesn't work=20
<BR>&nbsp;&nbsp;DocumentRoot documentRoot =3D=20
=
(DocumentRoot)eDG.getERootObject();&nbsp;&nbsp;<BR>&nbsp;&nbsp;PurchaseOr=
derType=20
aPOT =3D documentRoot.getPurchaseOrder(); // what I'm =
referring to as=20
the "static" SDO API</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// I get this exception=20
<BR>java.rmi.ServerException: RemoteException occurred in =
server=20
thread; nested exception is: =
<BR>&nbsp;java.rmi.RemoteException:=20
<BR>&nbsp;&gt;&gt; SERVER (id=3D4773e3aa, =
host=3DIBM-0CA191A407D) TRACE=20
START:<BR>&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp; =
java.rmi.RemoteException:=20
; nested exception is: =
<BR>&nbsp;java.lang.ClassCastException:=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl =
incompatible=20
with com.ibm.DocumentRoot<BR>&nbsp;&gt;&gt;&nbsp; at=20
=
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=
</FONT></DIV></FONT></FONT></DIV></BLOCKQUOTE><FONT=20
color=3D#0000c0 size=3D2>Oh, I see.&nbsp; Maybe all that's =
missing is the=20
code to ensure that your generated package is registered with =
the=20
static registry. At some point during the initialization of =
the server=20
you should access the XyzPackage.eINSTANCE to ensure that the =
package=20
is registered.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org=20
type=3D"cite"><FONT color=3D#0000c0 size=3D2></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; wrote in =
message=20
<A href=3D"news:fihdh6$jpc$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fihdh6$jpc$1@build.eclipse.org</A>...</DIV>=
Gary,<BR><BR>Yes,=20
that is possible:<BR>
<BLOCKQUOTE><A=20
=
href=3D" http://help.eclipse.org/help33/index.jsp?topic=3D/org.eclips e.emf=
.....ecore.sdo.doc/tutorials/datagraph/datagraph.html"=20
moz-do-not-send=3D"true">Tutorial: Using the SDO Data =
Graph=20
Editor</A><BR></BLOCKQUOTE><BR>Gary Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fihc9v$c1p$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">By design (with any version of SDO and =
Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></FONT></FONT></DIV ><FONT=20
color=3D#0000c0 size=3D2></FONT>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px"><FONT=20
color=3D#0000c0 =
size=3D2></FONT>&nbsp;</BLOCKQUOTE></BLOCKQUOTE><FONT=20
color=3D#0000c0 =
size=3D2><BR></FONT></BLOCKQUOTE></BLOCKQUOTE><FONT=20
color=3D#0000c0=20
size=3D2><BR></FONT></FONT></BLOCKQUOTE></BLOCKQUOTE><BR ></BLOCKQUOTE></B=
ODY></HTML>

------=_NextPart_000_005E_01C8371E.9A4970F0--
Re: SDO Java -serialization/deserialization of EDataGraph - use Static SDO API after deserializatio [message #415213 is a reply to message #415210] Wed, 05 December 2007 14:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090106010808080206020409
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Gary,

I wonder if this is even needed?

Resource packageResource =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI()));

Gary Martin wrote:
> Ed,
>
> Success! Thanks again for all your help.
>
> For those following this thread, what finally worked was:
>
> Snippet from client:
>
> IbmPackage purchaseOrderPackage = IbmPackageImpl.eINSTANCE;
> ResourceSet resourceSet = eDG.getResourceSet();
> Resource packageResource =
> resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI()));
> // packageResource.getContents().add(purchaseOrderPackage);
> //
> resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(),
> purchaseOrderPackage);
>
> // ************************************************** eye catcher ******
> // news://news.eclipse.org/eclipse.tools.emf - Tuesday, December 04,
> 2007 5:40 PM Eastern
> // So you are registering this package locally and sending it with
> your data graph.
> // That why the receiver will always use the dynamic package that you
> sent it and told it do use.
> // Can you omit this entirely? You shouldn't need it and it's the
> cause of the problem.
> // ************************************************** eye catcher ******
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:fj4l1s$ttp$1@build.eclipse.org...
> Gary,
>
> Comments below.
>
> Gary Martin wrote:
>> Ed,
>>
>> Thanks yet again.
>>
>> I ran this code on my *client* (please note my comments //):
>>
>>
>> IbmPackage purchaseOrderPackage = IbmPackageImpl./eINSTANCE/;
>>
>> ResourceSet resourceSet = eDG.getResourceSet();
>>
>> Resource packageResource =
>> resourceSet.createResource(URI./createURI/(purchaseOrderPack age.getNsURI()));
>>
>> packageResource.getContents().add(purchaseOrderPackage);
>>
>> resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(),
>> purchaseOrderPackage);
>>
> So you are registering this package locally and sending it with
> your data graph. That why the receiver will always use the
> dynamic package that you sent it and told it do use. Can you omit
> this entirely? You shouldn't need it and it's the cause of the
> problem.
>> *...*
>>
>> System./out/.println("eDG.getDataGraphResource().save(System.out,
>> null); before serialization
>> ****************************************");
>>
>> System./out/.println("eDG.getERootObject: " + eDG.getERootObject());
>>
>> // eDG.getERootObject: *com.ibm.impl.DocumentRootImpl*@52565256
>> (mixed:
>> [ibm:purchaseOrder=com.ibm.impl.PurchaseOrderTypeImpl@7a987a98
>> (comment: Overnight shipping, _orderDate_: 2007-03-10)])
>>
>> eDG.getDataGraphResource().save(System./out/, *null*);
>>
>> ByteArrayOutputStream outputStream = *new* ByteArrayOutputStream();
>>
>> ObjectOutputStream objectOutputStream = *new*
>> ObjectOutputStream(outputStream);
>>
>> objectOutputStream.writeObject(eDG);
>>
>> objectOutputStream.close();
>>
>> InputStream inputStream = *new*
>> ByteArrayInputStream(outputStream.toByteArray());
>>
>> ObjectInputStream objectInputStream = *new*
>> ObjectInputStream(inputStream);
>>
>> EDataGraph otherEDataGraph =
>> (EDataGraph)objectInputStream.readObject();
>>
>> System./out/.println("otherEDataGraph.getDataGraphResource().save(System.out,
>> null); after deserialization
>> ***************************************");
>>
>> System./out/.println("otherEDataGraph.getERootObject: " +
>> otherEDataGraph.getERootObject());
>>
>> // otherEDataGraph.getERootObject:
>> *org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl*@3ae6 3ae6
>> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name:
>> DocumentRoot) (instanceClassName: null) (abstract: false,
>> _interface_: false))
>>
>> otherEDataGraph.getDataGraphResource().save(System./out/, *null*);
>>
>> So..somehow I need to "fix" the problem (EDataObjectImpl(s)
>> replaced with DynamicEDataObjectImpl(s) during serialization /
>> deserialization) ** on my client **.
>>
>> I saved the System.out output if it might be useful?
>>
>>
>>
>>
>>
>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote
>> in message news:fj41hq$s5v$1@build.eclipse.org...
>> Gary,
>>
>> Comments below.
>>
>> Gary Martin wrote:
>>> Upon further investigation:
>>>
>>> Note: I'm using whatever implementation of SDO 1.0 spec IBM
>>> included in
>>> WebSphere App Server v6.1.0.11 -
>>> .....\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005. jar
>>>
>>> In a previous append - Tuesday, November 27, 2007 1:03 PM
>>> Eastern - I included a snippet of source code from a
>>> method - acceptEDataGraph(EDataGraph) defined by a Stateless
>>> Session EJB and on the EJB's remote interface.
>>>
>>> Based on your append - Tuesday, November 27, 2007 1:18 PM
>>> Eastern - I added:
>>> IbmPackage anIbmPackage = IbmPackageImpl.init();
>> IbmPackage.eINSTANCE would be the preferred way.
>> IbmPackage.eINSTANCE.eClass() is the idiom we typically use
>> if we only want to force initialize but don't really need the
>> package.
>>> as the 1st statement in that method (This didn't appear to
>>> change the behavior about which I comment below.)
>> Is this done on both the client and the server?
>>>
>>>
>>> Snippet from EJB client (with comments on which I ask your
>>> feedback):
>>>
>>> // create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and
>>> populate root Object and contained objects using
>>> // generated IBMFactoryImpl and "static" SDOs (inherit from
>>> EDataObjectImpl
>>>
>>> ...
>>>
>>> Object anObject = ((EDataGraphImpl)
>>> eDG).getWriteReplacement(); //
>>> org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable
>>>
>>> // just curious what Object was returned
>>>
>>> aSDOExchanger.acceptEDataGraph(eDG); // defined on remote
>>> interface of Stateless Session EJB
>> You might want to try code like this (which we have in our
>> JUnit tests):
>>
>> eDataGraph.getDataGraphResource().save(System.out, null);
>> ByteArrayOutputStream outputStream = new
>> ByteArrayOutputStream();
>> ObjectOutputStream objectOutputStream = new
>> ObjectOutputStream(outputStream);
>> objectOutputStream.writeObject(eDataGraph);
>> objectOutputStream.close();
>> InputStream inputStream = new
>> ByteArrayInputStream(outputStream.toByteArray());
>> ObjectInputStream objectInputStream = new
>> ObjectInputStream(inputStream);
>> EDataGraph otherEDataGraph =
>> (EDataGraph)objectInputStream.readObject();
>> otherEDataGraph.getDataGraphResource().save(System.out,
>> null);
>>
>> This should help demonstrate that the datagraph is properly
>> serializable and can be recovered from the serialization.
>> Try this on the client. If the server were configured the
>> same way, it should be able to deserialize the result.
>>>
>>> // eDG's ERootObject was set earlier to instance of:
>>> com.ibm.impl.DocumentRootImpl (generated "static" SDO -
>>> inherits from EDataObjectImpl)
>>> // DocumentRootImpl.setPurchaseOrder was set to instance of
>>> com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)
>>>
>>> // When accessed (after serialization / deserialization) in
>>> EJB, EDataGraph's rootObject is a:
>>> org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
>>> // When accessed in EJB, DocumentRootImpl.getPurchaseOrder
>>> is instance of:
>>> org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
>>>
>>> // I've concluded that this "replacement" (during
>>> serialization / deserialization) of instances of generated
>>> "static" SDOs
>>> // (that inherit from EDataObjectImpl)
>>> // with instances of DynamicEDataObjectImpl has to be a
>>> conscious design choice - not a bug.
>> No, it really depends on what type of models you have
>> registered and whether you are transmitting the model from
>> the client to the server or just assuming the server knows
>> the model already.
>>> // As a result, I can't use the generated "static" SDOs in
>>> the implementation of method acceptEDataGraph(EDataGraph)
>>>
>>> Ed:
>>>
>>> a) Do you agree / disagree with that conclusion?
>> No. If you can get serialization and deserialization to work
>> locally on the client end, set a breakpoint in the
>> constructor for your generated DocumentRoot and see how the
>> code gets there. Similarly, set a breakpoint in the
>> DynamicEDataObject constructor and look at how the code path
>> that gets you there is different in that case...
>>> b) Do you know if this behavior is different (by design) in
>>> newer Tuscany implementations of SDO 1.0 or 2.0?
>> I think Tuscany started out with EMF's SDO implementation, so
>> I imagine the issues will be very similar or the same.
>>>
>>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>>
>>> wrote in message news:fihn1g$e1e$1@build.eclipse.org...
>>> Gary,
>>>
>>> Comments below.
>>>
>>> Gary Martin wrote:
>>>> Ed,
>>>>
>>>> Thank you. I'm not connecting the dots. Are you
>>>> suggesting that the source code of
>>>> the SDO Data Graph Editor itself illustrates c) in my
>>>> problem statement?
>>> No, I'm suggesting that the tutorial shows you the steps
>>> you need to generate the static code for your SDO model
>>> and then the datagraph editor shows your model being
>>> used to read and write instances or your model using
>>> your generated code.
>>>>
>>>> Here's a snippet of code from the method in my EJB
>>>> where I'm able to use the dynamic
>>>> API, but unable to use the static API.
>>>>
>>>> import com.ibm.ItemType;
>>>> import com.ibm.PurchaseOrderType;
>>>> import com.ibm.DocumentRoot;
>>> It looks like you've already generated the code so that
>>> makes me a bit confused about why you asked how to
>>> generate the the code.
>>>> import com.ibm.util.IbmResourceFactoryImpl;
>>>> import com.ibm.util.IbmResourceUtil;
>>>>
>>>> import commonj.sdo.DataObject;
>>>> import commonj.sdo.Property;
>>>>
>>>>
>>>> import org.eclipse.emf.ecore.impl.EReferenceImpl;
>>>> import org.eclipse.emf.ecore.sdo.EDataGraph;
>>>> import
>>>> org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;
>>>>
>>>>
>>>>
>>>> // method defined on the remote interface
>>>> public void acceptEDataGraph (EDataGraph eDG) {
>>>>
>>>>
>>>> DataObject rootObject = eDG.getRootObject(); // works
>>>> DataObject purchaseOrder =
>>>> rootObject.getDataObject("purchaseOrder"); // works
>>>>
>>>> java.util.Date orderDate =
>>>> purchaseOrder.getDate("orderDate"); // works
>>>> System.out.println("orderDate: " + orderDate); // works
>>>>
>>>>
>>>> // This doesn't work
>>>> DocumentRoot documentRoot =
>>>> (DocumentRoot)eDG.getERootObject();
>>>> PurchaseOrderType aPOT =
>>>> documentRoot.getPurchaseOrder(); // what I'm referring
>>>> to as the "static" SDO API
>>>>
>>>> // I get this exception
>>>> java.rmi.ServerException: RemoteException occurred in
>>>> server thread; nested exception is:
>>>> java.rmi.RemoteException:
>>>> >> SERVER (id=4773e3aa, host=IBM-0CA191A407D) TRACE START:
>>>> >> java.rmi.RemoteException: ; nested exception is:
>>>> java.lang.ClassCastException:
>>>> org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
>>>> incompatible with com.ibm.DocumentRoot
>>>> >> at
>>>> sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)
>>> Oh, I see. Maybe all that's missing is the code to
>>> ensure that your generated package is registered with
>>> the static registry. At some point during the
>>> initialization of the server you should access the
>>> XyzPackage.eINSTANCE to ensure that the package is
>>> registered.
>>>>
>>>> "Ed Merks" <merks@ca.ibm.com
>>>> <mailto:merks@ca.ibm.com>> wrote in message
>>>> news:fihdh6$jpc$1@build.eclipse.org...
>>>> Gary,
>>>>
>>>> Yes, that is possible:
>>>>
>>>> Tutorial: Using the SDO Data Graph Editor
>>>> < http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.....ecore.sdo.doc/tutorials/datagraph/datagraph.html>
>>>>
>>>>
>>>> Gary Martin wrote:
>>>>> By design (with any version of SDO and Tuscany Java implementation),
>>>>>
>>>>> should it be possible to generate "static" SDO classes from an .xsd, and
>>>>> then:
>>>>>
>>>>> a) use the generated classes to create an:
>>>>> org.eclipse.emf.ecore.sdo.EDataGraph
>>>>> b)call a method on the remote interface of an ejb that takes that
>>>>> EDataGraph as its only arguement
>>>>> c)use the *static* generated SDO classes to access the SDOs in the
>>>>> EDataGraph
>>>>>
>>>>> I've done a) and b) and can use the dynamic SDO API in my EJB method,
>>>>> but, I've yet to figure out how (or even if it should be possible by
>>>>> design) to use the generated "static" SDO classes in my EJB method.
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>


--------------090106010808080206020409
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">
Gary,<br>
<br>
I wonder if this is even needed?<br>
<blockquote><font face="Arial" size="2">Resource packageResource =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())); </font><br>
<br>
</blockquote>
Gary Martin wrote:
<blockquote cite="mid:fj6bg5$50a$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
<div><font face="Arial" size="2">Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Success!&nbsp; Thanks again for all your
help.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">For those following this thread,
what finally worked was:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Snippet from client:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">IbmPackage purchaseOrderPackage =
IbmPackageImpl.eINSTANCE;<br>
ResourceSet resourceSet = eDG.getResourceSet();<br>
Resource packageResource =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())); <br>
// packageResource.getContents().add(purchaseOrderPackage);& ;nbsp;&nbsp; <br>
//
resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(),
purchaseOrderPackage); <br>
&nbsp;&nbsp;<br>
// ************************************************** eye catcher ******<br>
// <a moz-do-not-send="true"
href="news://news.eclipse.org/eclipse.tools.emf">news://news.eclipse.org/eclipse.tools.emf</a>
- Tuesday, December 04, 2007 5:40 PM Eastern<br>
// So you are registering this package locally and sending it with your
data graph.<br>
// That why the receiver will always use the dynamic package that you
sent it and told it do use.<br>
// Can you omit this entirely?&nbsp; You shouldn't need it and it's the
cause of the problem.<br>
// ************************************************** eye catcher
****** <br>
</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a moz-do-not-send="true"
href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt; wrote in
message <a moz-do-not-send="true"
href="news:fj4l1s$ttp$1@build.eclipse.org">news:fj4l1s$ttp$1@build.eclipse.org</a>...</div>
Gary,<br>
<br>
Comments below.<br>
<br>
Gary Martin wrote:
<blockquote cite="mid:fj4dcs$pb1$1@build.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
<div><font face="Arial" size="2">Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks yet again.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I ran this code on my *client*
(please note my comments //):</font></div>
<div>&nbsp;</div>
<div>
<p align="left"><font size="2">IbmPackage purchaseOrderPackage =
IbmPackageImpl.</font><i><font color="#0000c0" size="2">eINSTANCE</font></i><font
size="2">;</font></p>
<p align="left"><font size="2">ResourceSet resourceSet =
eDG.getResourceSet();</font></p>
<p align="left"><font size="2">Resource packageResource =
resourceSet.createResource(URI.<i>createURI</i>(purchaseOrderPackage.getNsURI())); </font></p>
<p align="left"><font size="2">packageResource.getContents().add(purchaseOrderPackage); </font></p>
<p><font size="2"> resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(),
purchaseOrderPackage);</font></p>
</div>
</blockquote>
So you are registering this package locally and sending it with your
data graph.&nbsp; That why the receiver will always use the dynamic package
that you sent it and told it do use.&nbsp; Can you omit this entirely?&nbsp; You
shouldn't need it and it's the cause of the problem.<br>
<blockquote cite="mid:fj4dcs$pb1$1@build.eclipse.org" type="cite">
<div><font face="Arial" size="2"><strong>...</strong></font></div>
<div><font size="2">
<p align="left"><font size="2">System.</font><i><font
color="#0000c0" size="2">out</font></i><font color="#0000c0" size="2"><font
size="2">.println(</font><font color="#2a00ff" size="2">"eDG.getDataGraphResource().save(System.out,
null); before serialization ****************************************"</font><font
size="2">);</font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2">System.</font><i><font
color="#0000c0" size="2">out</font></i><font size="2">.println(</font><font
color="#2a00ff" size="2">"eDG.getERootObject: "</font><font size="2">
+ eDG.getERootObject());</font></font></p>
<p align="left"><font color="#0000c0" size="2">// <font size="2">eDG.getERootObject:
<strong>com.ibm.impl.DocumentRootImpl</strong>@52565256 (mixed:
[ibm:purchaseOrder=com.ibm.impl.PurchaseOrderTypeImpl@7a987a98
(comment: Overnight shipping, </font><u><font color="#000080" size="2">orderDate</font></u><font
size="2">: 2007-03-10)])</font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">eDG.getDataGraphResource().save(System.</font><i ><font
color="#0000c0" size="2">out</font></i><font size="2">, </font><b><font
color="#7f0055" size="2">null</font></b><font size="2">);</font></font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">ByteArrayOutputStream outputStream = </font><b><font
color="#7f0055" size="2">new</font></b><font size="2">
ByteArrayOutputStream();</font></font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">ObjectOutputStream objectOutputStream = </font><b><font
color="#7f0055" size="2">new</font></b><font size="2">
ObjectOutputStream(outputStream);</font></font></font></p >
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">objectOutputStream.writeObject(eDG);</font></font ></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">objectOutputStream.close();</font></font></font ></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">InputStream inputStream = </font><b><font color="#7f0055"
size="2">new</font></b><font size="2">
ByteArrayInputStream(outputStream.toByteArray());</font></font ></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">ObjectInputStream objectInputStream = </font><b><font
color="#7f0055" size="2">new</font></b><font size="2">
ObjectInputStream(inputStream);</font></font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">EDataGraph otherEDataGraph =
(EDataGraph)objectInputStream.readObject();</font></font></font ></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">System.</font><i><font color="#0000c0" size="2">out</font></i><font
size="2">.println(</font><font color="#2a00ff" size="2">"otherEDataGraph.getDataGraphResource().save(System.out,
null); after deserialization ***************************************"</font><font
size="2">);</font></font></font></p>
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">System.</font><i><font color="#0000c0" size="2">out</font></i><font
size="2">.println(</font><font color="#2a00ff" size="2">"otherEDataGraph.getERootObject:
"</font><font size="2"> + otherEDataGraph.getERootObject());</font></font></font></p >
<p align="left"><font color="#0000c0" size="2"><font size="2"><font
size="2">// <font size="2">otherEDataGraph.getERootObject: <strong>org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl </strong>@3ae63ae6
(eClass: org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name:
DocumentRoot) (instanceClassName: null) (abstract: false, </font><u><font
color="#000080" size="2">interface</font></u><font size="2">: false))</font></font></font></font></p>
<p><font color="#0000c0" size="2"><font size="2"><font size="2">otherEDataGraph.getDataGraphResource().save(System. </font><i><font
color="#0000c0" size="2">out</font></i><font size="2">, </font><b><font
color="#7f0055" size="2">null</font></b><font size="2">);</font></font></font></p>
<p><font color="#0000c0" size="2"><font size="2"><font
face="Arial" size="2">So..somehow I need to "fix" the problem
(EDataObjectImpl(s) replaced with DynamicEDataObjectImpl(s) during
serialization / deserialization) ** on my client **.</font></font></font></p>
<p><font color="#0000c0" size="2"><font size="2"><font
face="Arial">I saved the System.out output if it might be useful?</font></font></font></p>
<p>&nbsp;</p>
</font></div>
<div>&nbsp;</div>
<div><font size="2"><font color="#0000c0" size="2"><br>
</font></font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;"><font
size="2">
<div><font color="#0000c0" size="2">"Ed Merks" &lt;<a
href="mailto:merks@ca.ibm.com" moz-do-not-send="true">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:fj41hq$s5v$1@build.eclipse.org"
moz-do-not-send="true">news:fj41hq$s5v$1@build.eclipse.org</a>...</font></div>
<font color="#0000c0" size="2">Gary,<br>
<br>
Comments below.<br>
<br>
Gary Martin wrote: </font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org"
type="cite"><font color="#0000c0" size="2">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
</font>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">Upon further investigation:</font></font></div>
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">Note: I'm using whatever implementation of SDO 1.0 spec IBM
included in<br>
WebSphere App Server v6.1.0.11 -
......\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005 .jar </font></font></div>
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">In a previous append - Tuesday, November 27, 2007 1:03 PM
Eastern - I included a snippet of source code from a <br>
method - acceptEDataGraph(EDataGraph) defined by a Stateless Session
EJB and on the EJB's remote interface.</font></font></div>
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">Based on your append - Tuesday, November 27, 2007 1:18 PM
Eastern - I added:<br>
IbmPackage anIbmPackage = IbmPackageImpl.init();<br>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">IbmPackage.eINSTANCE would be
the preferred way.&nbsp; IbmPackage.eINSTANCE.eClass() is the idiom we
typically use if we only want to force initialize but don't really need
the package.<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org"
type="cite">
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">as the 1st statement in that method&nbsp; (This didn't appear to
change the behavior about which I comment below.)</font></font></div>
</blockquote>
<font color="#0000c0" size="2">Is this done on both the client
and the server?<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org"
type="cite">
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2"><br>
Snippet from EJB client (with comments on which I ask your feedback):</font></font></div>
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">// create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and
populate root Object and contained objects using<br>
// generated IBMFactoryImpl and "static" SDOs (inherit from
EDataObjectImpl</font></font></div>
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">...</font></font></div>
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">Object anObject = ((EDataGraphImpl)
eDG).getWriteReplacement(); //
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // just
curious what Object was returned</font></font></div>
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">aSDOExchanger.acceptEDataGraph(eDG); // defined on remote
interface of Stateless Session EJB</font></font></div>
</blockquote>
<font color="#0000c0" size="2">You might want to try code like
this (which we have in our JUnit tests):<br>
<br>
<small>&nbsp;&nbsp;&nbsp; eDataGraph.getDataGraphResource().save(System.out,
null);<br>
&nbsp;&nbsp;&nbsp; ByteArrayOutputStream outputStream = new ByteArrayOutputStream();<br>
&nbsp;&nbsp;&nbsp; ObjectOutputStream objectOutputStream = new
ObjectOutputStream(outputStream);<br>
&nbsp;&nbsp;&nbsp; objectOutputStream.writeObject(eDataGraph);<br>
&nbsp;&nbsp;&nbsp; objectOutputStream.close();<br>
&nbsp;&nbsp;&nbsp; InputStream inputStream = new
ByteArrayInputStream(outputStream.toByteArray());<br>
&nbsp;&nbsp;&nbsp; ObjectInputStream objectInputStream = new
ObjectInputStream(inputStream);<br>
&nbsp;&nbsp;&nbsp; EDataGraph otherEDataGraph =
(EDataGraph)objectInputStream.readObject();<br>
&nbsp;&nbsp;&nbsp; otherEDataGraph.getDataGraphResource().save(System.out, null);<br>
</small><br>
This should help demonstrate that the datagraph is properly
serializable and can be recovered from the serialization.&nbsp; Try this on
the client.&nbsp; If the server were configured the same way, it should be
able to deserialize the result.<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org"
type="cite">
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">// eDG's ERootObject was set earlier to instance of:
com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits from
EDataObjectImpl)<br>
// DocumentRootImpl.setPurchaseOrder was set to instance of
com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)<br>
&nbsp;&nbsp;&nbsp;<br>
// When accessed (after serialization / deserialization) in EJB,
EDataGraph's rootObject is a:
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<br>
// When accessed in EJB, DocumentRootImpl.getPurchaseOrder is instance
of: org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<br>
&nbsp;&nbsp;&nbsp;<br>
// I've concluded that this "replacement" (during serialization /
deserialization) of instances of generated "static" SDOs<br>
// (that inherit from EDataObjectImpl)<br>
// with instances of DynamicEDataObjectImpl has to be a conscious
design choice - not a bug.<br>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">No, it really depends on what
type of models you have registered and whether you are transmitting the
model from the client to the server or just assuming the server knows
the model already.<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org"
type="cite">
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">// As a result, I can't use the generated "static" SDOs in
the implementation of method acceptEDataGraph(EDataGraph)</font></font></div>
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">Ed:</font></font></div>
<div>&nbsp;</div>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">a) Do you agree / disagree with that conclusion?<br>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">No.&nbsp; If you can get
serialization and deserialization to work locally on the client end,
set a breakpoint in the constructor for your generated DocumentRoot and
see how the code gets there.&nbsp; Similarly, set a breakpoint in the
DynamicEDataObject constructor and look at how the code path that gets
you there is different in that case...<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org"
type="cite">
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">b) Do you know if this behavior is different (by design) in
newer Tuscany implementations of SDO 1.0 or 2.0?</font></font></div>
</blockquote>
<font color="#0000c0" size="2">I think Tuscany started out with
EMF's SDO implementation, so I imagine the issues will be very similar
or the same.<br>
</font>
<blockquote cite="mid:fj3vsh$82p$1@build.eclipse.org"
type="cite">
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div><font color="#0000c0" size="2">"Ed Merks" &lt;<a
href="mailto:merks@ca.ibm.com" moz-do-not-send="true">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:fihn1g$e1e$1@build.eclipse.org"
moz-do-not-send="true">news:fihn1g$e1e$1@build.eclipse.org</a>...</font></div>
<font color="#0000c0" size="2">Gary,<br>
<br>
Comments below.<br>
<br>
Gary Martin wrote: </font>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org"
type="cite"><font color="#0000c0" size="2">
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR">
<style></style> </font>
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">
<div><font face="Arial" size="2">Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thank you.&nbsp; I'm
not&nbsp;connecting the dots.&nbsp;&nbsp; Are you suggesting that the source code of</font></div>
<div><font face="Arial" size="2">the SDO Data Graph
Editor itself illustrates c) in my problem statement?</font></div>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">No, I'm suggesting that the
tutorial shows you the steps you need to generate the static code for
your SDO model and then the datagraph editor shows your model being
used to read and write instances or your model using your generated
code.<br>
</font>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org"
type="cite">
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">
<div>&nbsp;</div>
<div><font face="Arial" size="2">Here's a snippet of code
from the method in my EJB where I'm able to use the dynamic</font></div>
<div><font face="Arial" size="2">API, but unable to use
the static API.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">import com.ibm.ItemType;<br>
import com.ibm.PurchaseOrderType;<br>
import com.ibm.DocumentRoot;<br>
</font></div>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">It looks like you've already
generated the code so that makes me a bit confused about why you asked
how to generate the the code.<br>
</font>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org"
type="cite">
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">
<div><font face="Arial" size="2">import
com.ibm.util.IbmResourceFactoryImpl;<br>
import com.ibm.util.IbmResourceUtil;</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">import
commonj.sdo.DataObject;<br>
import commonj.sdo.Property;</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><br>
import org.eclipse.emf.ecore.impl.EReferenceImpl;<br>
import org.eclipse.emf.ecore.sdo.EDataGraph;<br>
import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;</font ></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">// method defined on the
remote interface <br>
public void acceptEDataGraph (EDataGraph eDG)&nbsp; {</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><br>
&nbsp;&nbsp;DataObject rootObject = eDG.getRootObject(); // works<br>
&nbsp;&nbsp;DataObject purchaseOrder = rootObject.getDataObject("purchaseOrder");
// works</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;java.util.Date
orderDate = purchaseOrder.getDate("orderDate"); // works<br>
&nbsp;&nbsp;System.out.println("orderDate: " + orderDate); // works </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><br>
&nbsp;&nbsp;// This doesn't work <br>
&nbsp;&nbsp;DocumentRoot documentRoot = (DocumentRoot)eDG.getERootObject();&nbsp;&nbsp;<br>
&nbsp;&nbsp;PurchaseOrderType aPOT = documentRoot.getPurchaseOrder(); // what I'm
referring to as the "static" SDO API</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">// I get this exception <br>
java.rmi.ServerException: RemoteException occurred in server thread;
nested exception is: <br>
&nbsp;java.rmi.RemoteException: <br>
&nbsp;&gt;&gt; SERVER (id=4773e3aa, host=IBM-0CA191A407D) TRACE START:<br>
&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp; java.rmi.RemoteException: ; nested exception is: <br>
&nbsp;java.lang.ClassCastException:
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with
com.ibm.DocumentRoot<br>
&nbsp;&gt;&gt;&nbsp; at
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89) </font></div>
</font></font></div>
</blockquote>
<font color="#0000c0" size="2">Oh, I see.&nbsp; Maybe all that's
missing is the code to ensure that your generated package is registered
with the static registry. At some point during the initialization of
the server you should access the XyzPackage.eINSTANCE to ensure that
the package is registered.<br>
</font>
<blockquote cite="mid:fihm57$brk$1@build.eclipse.org"
type="cite">
<div><font color="#0000c0" size="2"><font face="Arial"
size="2">
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com"
moz-do-not-send="true">merks@ca.ibm.com</a>&gt; wrote in message <a
href="news:fihdh6$jpc$1@build.eclipse.org" moz-do-not-send="true">news:fihdh6$jpc$1@build.eclipse.org</a>...</div>
Gary,<br>
<br>
Yes, that is possible:<br>
<blockquote><a
href=" http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.....ecore.sdo.doc/tutorials/datagraph/datagraph.html"
moz-do-not-send="true">Tutorial: Using the SDO Data Graph Editor</a><br>
</blockquote>
<br>
Gary Martin wrote:
<blockquote cite="mid:fihc9v$c1p$1@build.eclipse.org"
type="cite">
<pre wrap="">By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.


</pre>
</blockquote>
<br>
</blockquote>
</font></font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">&nbsp;</blockquote>
</blockquote>
<font color="#0000c0" size="2"><br>
</font></blockquote>
</blockquote>
<font color="#0000c0" size="2"><br>
</font></font></blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------090106010808080206020409--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: SDO Java -serialization/deserialization of EDataGraph - simplified (as you suggested) code work [message #415217 is a reply to message #415213] Wed, 05 December 2007 15:45 Go to previous message
Eclipse UserFriend
Originally posted by: GaryRMartin.insightbb.com

This is a multi-part message in MIME format.

------=_NextPart_000_006E_01C8372B.FF0CF5E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,

It's not.

This snippet of code from the client worked (i.e. can use Dynamic and/or =
Static SDOs in EJB method implementation):

IbmPackage purchaseOrderPackage =3D IbmPackageImpl.eINSTANCE; // *also* =
in EJB's ejbCreate() method

// ResourceSet resourceSet =3D eDG.getResourceSet();=20

// Resource packageResource =3D =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);

// packageResource.getContents().add(purchaseOrderPackage);=20

// resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(), =
purchaseOrderPackage); // register locally - serialized and sent??


// ************************************************** eye catcher =
******************************************

// news://news.eclipse.org/eclipse.tools.emf - Tuesday, December 04, =
2007 5:40 PM Eastern

// So you are registering this package locally and sending it with your =
data graph.

// That why the receiver will always use the dynamic package that you =
sent it and told it do use.

// Can you omit this entirely? You shouldn't need it and it's the cause =
of the problem.

// ************************************************** eye catcher =
******************************************

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fj6c56$c38$1@build.eclipse.org...
Gary,

I wonder if this is even needed?

Resource packageResource =3D =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);


Gary Martin wrote:=20
Ed,

Success! Thanks again for all your help.

For those following this thread, what finally worked was:

Snippet from client:

IbmPackage purchaseOrderPackage =3D IbmPackageImpl.eINSTANCE;
ResourceSet resourceSet =3D eDG.getResourceSet();
Resource packageResource =3D =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);
// packageResource.getContents().add(purchaseOrderPackage); =20
// =
resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(), =
purchaseOrderPackage);=20
=20
// ************************************************** eye catcher =
******
// news://news.eclipse.org/eclipse.tools.emf - Tuesday, December 04, =
2007 5:40 PM Eastern
// So you are registering this package locally and sending it with =
your data graph.
// That why the receiver will always use the dynamic package that =
you sent it and told it do use.
// Can you omit this entirely? You shouldn't need it and it's the =
cause of the problem.
// ************************************************** eye catcher =
******=20

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fj4l1s$ttp$1@build.eclipse.org...
Gary,

Comments below.

Gary Martin wrote:=20
Ed,

Thanks yet again.

I ran this code on my *client* (please note my comments //):

IbmPackage purchaseOrderPackage =3D IbmPackageImpl.eINSTANCE;

ResourceSet resourceSet =3D eDG.getResourceSet();

Resource packageResource =3D =
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);

packageResource.getContents().add(purchaseOrderPackage);

=
resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(), =
purchaseOrderPackage);

So you are registering this package locally and sending it with =
your data graph. That why the receiver will always use the dynamic =
package that you sent it and told it do use. Can you omit this =
entirely? You shouldn't need it and it's the cause of the problem.

...
System.out.println("eDG.getDataGraphResource().save(System.out, =
null); before serialization ****************************************");

System.out.println("eDG.getERootObject: " + =
eDG.getERootObject());

// eDG.getERootObject: com.ibm.impl.DocumentRootImpl@52565256 =
(mixed: [ibm:purchaseOrder=3Dcom.ibm.impl.PurchaseOrderTypeImpl@7a987a98 =
(comment: Overnight shipping, orderDate: 2007-03-10)])

eDG.getDataGraphResource().save(System.out, null);

ByteArrayOutputStream outputStream =3D new =
ByteArrayOutputStream();

ObjectOutputStream objectOutputStream =3D new =
ObjectOutputStream(outputStream);

objectOutputStream.writeObject(eDG);

objectOutputStream.close();

InputStream inputStream =3D new =
ByteArrayInputStream(outputStream.toByteArray());

ObjectInputStream objectInputStream =3D new =
ObjectInputStream(inputStream);

EDataGraph otherEDataGraph =3D =
(EDataGraph)objectInputStream.readObject();

=
System.out.println("otherEDataGraph.getDataGraphResource().save(System.ou=
t, null); after deserialization =
***************************************");

System.out.println("otherEDataGraph.getERootObject: " + =
otherEDataGraph.getERootObject());

// otherEDataGraph.getERootObject: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl@3ae63ae6 (eClass: =
org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name: DocumentRoot) =
(instanceClassName: null) (abstract: false, interface: false))

otherEDataGraph.getDataGraphResource().save(System.out, null);

So..somehow I need to "fix" the problem (EDataObjectImpl(s) =
replaced with DynamicEDataObjectImpl(s) during serialization / =
deserialization) ** on my client **.

I saved the System.out output if it might be useful?






"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fj41hq$s5v$1@build.eclipse.org...
Gary,

Comments below.

Gary Martin wrote:=20
Upon further investigation:

Note: I'm using whatever implementation of SDO 1.0 spec IBM =
included in
WebSphere App Server v6.1.0.11 - =
......\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005 .jar

In a previous append - Tuesday, November 27, 2007 1:03 PM =
Eastern - I included a snippet of source code from a=20
method - acceptEDataGraph(EDataGraph) defined by a Stateless =
Session EJB and on the EJB's remote interface.

Based on your append - Tuesday, November 27, 2007 1:18 PM =
Eastern - I added:
IbmPackage anIbmPackage =3D IbmPackageImpl.init();

IbmPackage.eINSTANCE would be the preferred way. =
IbmPackage.eINSTANCE.eClass() is the idiom we typically use if we only =
want to force initialize but don't really need the package.

as the 1st statement in that method (This didn't appear to =
change the behavior about which I comment below.)
Is this done on both the client and the server?



Snippet from EJB client (with comments on which I ask your =
feedback):

// create org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and =
populate root Object and contained objects using
// generated IBMFactoryImpl and "static" SDOs (inherit from =
EDataObjectImpl

...

Object anObject =3D ((EDataGraphImpl) =
eDG).getWriteReplacement(); // =
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable
=
// just curious what Object was returned

aSDOExchanger.acceptEDataGraph(eDG); // defined on remote =
interface of Stateless Session EJB
You might want to try code like this (which we have in our =
JUnit tests):

eDataGraph.getDataGraphResource().save(System.out, null);
ByteArrayOutputStream outputStream =3D new =
ByteArrayOutputStream();
ObjectOutputStream objectOutputStream =3D new =
ObjectOutputStream(outputStream);
objectOutputStream.writeObject(eDataGraph);
objectOutputStream.close();
InputStream inputStream =3D new =
ByteArrayInputStream(outputStream.toByteArray());
ObjectInputStream objectInputStream =3D new =
ObjectInputStream(inputStream);
EDataGraph otherEDataGraph =3D =
(EDataGraph)objectInputStream.readObject();
otherEDataGraph.getDataGraphResource().save(System.out, =
null);

This should help demonstrate that the datagraph is properly =
serializable and can be recovered from the serialization. Try this on =
the client. If the server were configured the same way, it should be =
able to deserialize the result.


// eDG's ERootObject was set earlier to instance of: =
com.ibm.impl.DocumentRootImpl (generated "static" SDO - inherits from =
EDataObjectImpl)
// DocumentRootImpl.setPurchaseOrder was set to instance of =
com.ibm.impl.PurchaseOrderTypeImpl (generated "static" SDO)
=20
// When accessed (after serialization / deserialization) in =
EJB, EDataGraph's rootObject is a: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
// When accessed in EJB, DocumentRootImpl.getPurchaseOrder =
is instance of: org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl
=20
// I've concluded that this "replacement" (during =
serialization / deserialization) of instances of generated "static" SDOs
// (that inherit from EDataObjectImpl)
// with instances of DynamicEDataObjectImpl has to be a =
conscious design choice - not a bug.

No, it really depends on what type of models you have =
registered and whether you are transmitting the model from the client to =
the server or just assuming the server knows the model already.

// As a result, I can't use the generated "static" SDOs in =
the implementation of method acceptEDataGraph(EDataGraph)

Ed:

a) Do you agree / disagree with that conclusion?

No. If you can get serialization and deserialization to work =
locally on the client end, set a breakpoint in the constructor for your =
generated DocumentRoot and see how the code gets there. Similarly, set =
a breakpoint in the DynamicEDataObject constructor and look at how the =
code path that gets you there is different in that case...

b) Do you know if this behavior is different (by design) in =
newer Tuscany implementations of SDO 1.0 or 2.0?
I think Tuscany started out with EMF's SDO implementation, so =
I imagine the issues will be very similar or the same.

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fihn1g$e1e$1@build.eclipse.org...
Gary,

Comments below.

Gary Martin wrote:=20
Ed,

Thank you. I'm not connecting the dots. Are you =
suggesting that the source code of
the SDO Data Graph Editor itself illustrates c) in my =
problem statement?
No, I'm suggesting that the tutorial shows you the steps =
you need to generate the static code for your SDO model and then the =
datagraph editor shows your model being used to read and write instances =
or your model using your generated code.


Here's a snippet of code from the method in my EJB where =
I'm able to use the dynamic
API, but unable to use the static API.

import com.ibm.ItemType;
import com.ibm.PurchaseOrderType;
import com.ibm.DocumentRoot;

It looks like you've already generated the code so that =
makes me a bit confused about why you asked how to generate the the =
code.

import com.ibm.util.IbmResourceFactoryImpl;
import com.ibm.util.IbmResourceUtil;

import commonj.sdo.DataObject;
import commonj.sdo.Property;


import org.eclipse.emf.ecore.impl.EReferenceImpl;
import org.eclipse.emf.ecore.sdo.EDataGraph;
import =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;



// method defined on the remote interface=20
public void acceptEDataGraph (EDataGraph eDG) {


DataObject rootObject =3D eDG.getRootObject(); // =
works
DataObject purchaseOrder =3D =
rootObject.getDataObject("purchaseOrder"); // works

java.util.Date orderDate =3D =
purchaseOrder.getDate("orderDate"); // works
System.out.println("orderDate: " + orderDate); // =
works=20


// This doesn't work=20
DocumentRoot documentRoot =3D =
(DocumentRoot)eDG.getERootObject(); =20
PurchaseOrderType aPOT =3D =
documentRoot.getPurchaseOrder(); // what I'm referring to as the =
"static" SDO API

// I get this exception=20
java.rmi.ServerException: RemoteException occurred in =
server thread; nested exception is:=20
java.rmi.RemoteException:=20
>> SERVER (id=3D4773e3aa, host=3DIBM-0CA191A407D) TRACE =
START:
>> java.rmi.RemoteException: ; nested exception is:=20
java.lang.ClassCastException: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl incompatible with =
com.ibm.DocumentRoot
>> at =
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=

Oh, I see. Maybe all that's missing is the code to ensure =
that your generated package is registered with the static registry. At =
some point during the initialization of the server you should access the =
XyzPackage.eINSTANCE to ensure that the package is registered.

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fihdh6$jpc$1@build.eclipse.org...
Gary,

Yes, that is possible:

Tutorial: Using the SDO Data Graph Editor


Gary Martin wrote:=20
By design (with any version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


=20










------=_NextPart_000_006E_01C8372B.FF0CF5E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>It's not.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This snippet of code from the client =
worked (i.e.=20
can use Dynamic and/or Static SDOs in EJB method =
implementation):</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P align=3Dleft><STRONG>IbmPackage purchaseOrderPackage =3D=20
IbmPackageImpl.</STRONG></FONT><I><FONT color=3D#0000c0=20
size=3D2><STRONG>eINSTANCE</STRONG></I></FONT><FONT =
size=3D2><STRONG>;&nbsp; //=20
*also* in EJB's ejbCreate() method</STRONG></P>
<P align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2>// ResourceSet =
resourceSet =3D=20
eDG.getResourceSet(); </P></FONT><FONT size=3D2>
<P align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2>// Resource =
packageResource =3D=20
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);</P></FONT><FONT=20
size=3D2>
<P align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2>//=20
packageResource.getContents().add(purchaseOrderPackage); =
</P></FONT><FONT=20
size=3D2>
<P align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2>//=20
resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(),=20
purchaseOrderPackage); // register locally - serialized and=20
sent??</P></FONT><FONT size=3D2>
<P align=3Dleft></P>
<P align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2>//=20
************************************************** eye catcher=20
******************************************</P></FONT><FONT size=3D2>
<P align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2>//=20
news://news.eclipse.org/eclipse.tools.emf - Tuesday, December 04, 2007 =
5:40 PM=20
Eastern</P></FONT><FONT size=3D2>
<P align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2>// So you are =
registering this=20
package locally and sending it with your data graph.</P></FONT><FONT =
size=3D2>
<P align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2>// That why the =
receiver will=20
always use the dynamic package that you sent it and told it do=20
use.</P></FONT><FONT size=3D2>
<P align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2>// Can you omit =
this entirely?=20
You shouldn't need it and it's the cause of the problem.</P></FONT><FONT =
size=3D2>
<P></FONT><FONT color=3D#3f7f5f size=3D2>//=20
************************************************** eye catcher=20
******************************************</P></FONT></DIV >
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:fj6c56$c38$1@build.eclipse.org">news:fj6c56$c38$1@build.ecli=
pse.org</A>...</DIV>Gary,<BR><BR>I=20
wonder if this is even needed?<BR>
<BLOCKQUOTE><FONT face=3DArial size=3D2>Resource packageResource =3D=20
=
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);</FONT><BR><BR></BLOCKQUOTE>Gary=20
Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fj6bg5$50a$1@build.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Success!&nbsp; Thanks again for all =
your=20
help.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>For those following this thread, =
what finally=20
worked was:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Snippet from client:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>IbmPackage purchaseOrderPackage =3D =

IbmPackageImpl.eINSTANCE;<BR>ResourceSet resourceSet =3D=20
eDG.getResourceSet();<BR>Resource packageResource =3D=20
=
resourceSet.createResource(URI.createURI(purchaseOrderPackag e.getNsURI())=
);<BR>//=20
=
packageResource.getContents().add(purchaseOrderPackage);& ;nbsp;&nbsp; <BR>/=
/=20
=
resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsURI(),=20
purchaseOrderPackage); <BR>&nbsp;&nbsp;<BR>//=20
************************************************** eye catcher =
******<BR>//=20
<A href=3D"news://news.eclipse.org/eclipse.tools.emf"=20
=
moz-do-not-send=3D"true">news://news.eclipse.org/eclipse.tools.emf</A> - =

Tuesday, December 04, 2007 5:40 PM Eastern<BR>// So you are =
registering this=20
package locally and sending it with your data graph.<BR>// That why =
the=20
receiver will always use the dynamic package that you sent it and =
told it do=20
use.<BR>// Can you omit this entirely?&nbsp; You shouldn't need it =
and it's=20
the cause of the problem.<BR>//=20
************************************************** eye catcher =
******=20
<BR></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; wrote in message =
<A=20
href=3D"news:fj4l1s$ttp$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fj4l1s$ttp$1@build.eclipse.org</A>...</DIV>=
Gary,<BR><BR>Comments=20
below.<BR><BR>Gary Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fj4dcs$pb1$1@build.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.3199" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks yet again.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I ran this code on my *client* =
(please note=20
my comments //):</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>
<P align=3Dleft><FONT size=3D2>IbmPackage purchaseOrderPackage =
=3D=20
IbmPackageImpl.</FONT><I><FONT color=3D#0000c0=20
size=3D2>eINSTANCE</FONT></I><FONT size=3D2>;</FONT></P>
<P align=3Dleft><FONT size=3D2>ResourceSet resourceSet =3D=20
eDG.getResourceSet();</FONT></P>
<P align=3Dleft><FONT size=3D2>Resource packageResource =3D=20
=
resourceSet.createResource(URI.<I>createURI</I>(purchaseOrderPackage.getN=
sURI()));</FONT></P>
<P align=3Dleft><FONT=20
=
size=3D2>packageResource.getContents().add(purchaseOrderPackage); </FONT><=
/P>
<P><FONT=20
=
size=3D2> resourceSet.getPackageRegistry().put(purchaseOrderPackage.ge tNsU=
RI(),=20
purchaseOrderPackage);</FONT></P></DIV></BLOCKQUOTE>So you are =
registering=20
this package locally and sending it with your data graph.&nbsp; =
That why=20
the receiver will always use the dynamic package that you sent it =
and told=20
it do use.&nbsp; Can you omit this entirely?&nbsp; You shouldn't =
need it=20
and it's the cause of the problem.<BR>
<BLOCKQUOTE cite=3Dmid:fj4dcs$pb1$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT face=3DArial =
size=3D2><STRONG>...</STRONG></FONT></DIV>
<DIV><FONT size=3D2>
<P align=3Dleft><FONT size=3D2>System.</FONT><I><FONT =
color=3D#0000c0=20
size=3D2>out</FONT></I><FONT color=3D#0000c0 size=3D2><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff=20
size=3D2>"eDG.getDataGraphResource().save(System.out, null); =
before=20
serialization =
****************************************"</FONT><FONT=20
size=3D2>);</FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT=20
size=3D2>System.</FONT><I><FONT color=3D#0000c0 =
size=3D2>out</FONT></I><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff =
size=3D2>"eDG.getERootObject:=20
"</FONT><FONT size=3D2> + =
eDG.getERootObject());</FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2>// <FONT=20
size=3D2>eDG.getERootObject:=20
<STRONG>com.ibm.impl.DocumentRootImpl</STRONG>@52565256 (mixed:=20
[ibm:purchaseOrder=3Dcom.ibm.impl.PurchaseOrderTypeImpl@7a987a98 =
(comment:=20
Overnight shipping, </FONT><U><FONT color=3D#000080=20
size=3D2>orderDate</FONT></U><FONT size=3D2>:=20
2007-03-10)])</FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
size=3D2>eDG.getDataGraphResource().save(System.</FONT><I ><FONT=20
color=3D#0000c0 size=3D2>out</FONT></I><FONT size=3D2>, =
</FONT><B><FONT=20
color=3D#7f0055 size=3D2>null</FONT></B><FONT=20
size=3D2>);</FONT></FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
size=3D2>ByteArrayOutputStream outputStream =3D </FONT><B><FONT=20
color=3D#7f0055 size=3D2>new</FONT></B><FONT size=3D2>=20
ByteArrayOutputStream();</FONT></FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
size=3D2>ObjectOutputStream objectOutputStream =3D =
</FONT><B><FONT=20
color=3D#7f0055 size=3D2>new</FONT></B><FONT size=3D2>=20
ObjectOutputStream(outputStream);</FONT></FONT></FONT></P >
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
=
size=3D2>objectOutputStream.writeObject(eDG);</FONT></FONT ></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
size=3D2>objectOutputStream.close();</FONT></FONT></FONT ></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
size=3D2>InputStream inputStream =3D </FONT><B><FONT =
color=3D#7f0055=20
size=3D2>new</FONT></B><FONT size=3D2>=20
=
ByteArrayInputStream(outputStream.toByteArray());</FONT></FONT ></FONT></P=
>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
size=3D2>ObjectInputStream objectInputStream =3D </FONT><B><FONT =

color=3D#7f0055 size=3D2>new</FONT></B><FONT size=3D2>=20
ObjectInputStream(inputStream);</FONT></FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
size=3D2>EDataGraph otherEDataGraph =3D=20
=
(EDataGraph)objectInputStream.readObject();</FONT></FONT></FONT ></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
size=3D2>System.</FONT><I><FONT color=3D#0000c0 =
size=3D2>out</FONT></I><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff=20
=
size=3D2>"otherEDataGraph.getDataGraphResource().save(System.out, null); =

after deserialization=20
***************************************"</FONT><FONT=20
size=3D2>);</FONT></FONT></FONT></P>
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT=20
size=3D2>System.</FONT><I><FONT color=3D#0000c0 =
size=3D2>out</FONT></I><FONT=20
size=3D2>.println(</FONT><FONT color=3D#2a00ff=20
size=3D2>"otherEDataGraph.getERootObject: "</FONT><FONT =
size=3D2> +=20
otherEDataGraph.getERootObject());</FONT></FONT></FONT></P >
<P align=3Dleft><FONT color=3D#0000c0 size=3D2><FONT =
size=3D2><FONT size=3D2>//=20
<FONT size=3D2>otherEDataGraph.getERootObject:=20
=
<STRONG>org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl </STRONG>@3a=
e63ae6=20
(eClass: org.eclipse.emf.ecore.impl.EClassImpl@42f242f2 (name:=20
DocumentRoot) (instanceClassName: null) (abstract: false,=20
</FONT><U><FONT color=3D#000080 =
size=3D2>interface</FONT></U><FONT size=3D2>:=20
false))</FONT></FONT></FONT></FONT></P>
<P><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT=20
=
size=3D2>otherEDataGraph.getDataGraphResource().save(System. </FONT><I><FO=
NT=20
color=3D#0000c0 size=3D2>out</FONT></I><FONT size=3D2>, =
</FONT><B><FONT=20
color=3D#7f0055 size=3D2>null</FONT></B><FONT=20
size=3D2>);</FONT></FONT></FONT></P>
<P><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT =
face=3DArial=20
size=3D2>So..somehow I need to "fix" the problem =
(EDataObjectImpl(s)=20
replaced with DynamicEDataObjectImpl(s) during serialization /=20
deserialization) ** on my client **.</FONT></FONT></FONT></P>
<P><FONT color=3D#0000c0 size=3D2><FONT size=3D2><FONT =
face=3DArial>I saved the=20
System.out output if it might be =
useful?</FONT></FONT></FONT></P>
<P>&nbsp;</P></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2><FONT color=3D#0000c0 =
size=3D2><BR></FONT></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px"><FONT=20
size=3D2>
<DIV><FONT color=3D#0000c0 size=3D2>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; wrote in =
message <A=20
href=3D"news:fj41hq$s5v$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fj41hq$s5v$1@build.eclipse.org</A>...</FONT=
></DIV><FONT=20
color=3D#0000c0 size=3D2>Gary,<BR><BR>Comments =
below.<BR><BR>Gary Martin=20
wrote: </FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org=20
type=3D"cite"><FONT color=3D#0000c0 size=3D2>
<META content=3D"MSHTML 6.00.2900.3199" =
name=3DGENERATOR></FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>Upon further=20
investigation:</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>Note: I'm=20
using whatever implementation of SDO 1.0 spec IBM included=20
in<BR>WebSphere App Server v6.1.0.11 -=20
=
......\plugins\org.eclipse.emf.ecore.sdo_2.2.0.v200609210005 .jar </FONT></F=
ONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>In a=20
previous append - Tuesday, November 27, 2007 1:03 PM Eastern =
- I=20
included a snippet of source code from a <BR>method -=20
acceptEDataGraph(EDataGraph) defined by a Stateless Session =
EJB and=20
on the EJB's remote interface.</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>Based on=20
your append - Tuesday, November 27, 2007 1:18 PM Eastern - I =

added:<BR>IbmPackage anIbmPackage =3D=20
=
IbmPackageImpl.init();<BR></FONT></FONT></DIV></BLOCKQUOTE ><FONT=20
color=3D#0000c0 size=3D2>IbmPackage.eINSTANCE would be the =
preferred=20
way.&nbsp; IbmPackage.eINSTANCE.eClass() is the idiom we =
typically use=20
if we only want to force initialize but don't really need the=20
package.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>as the 1st=20
statement in that method&nbsp; (This didn't appear to change =
the=20
behavior about which I comment=20
below.)</FONT></FONT></DIV></BLOCKQUOTE><FONT color=3D#0000c0 =
size=3D2>Is=20
this done on both the client and the server?<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite">
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2><BR>Snippet=20
from EJB client (with comments on which I ask your=20
feedback):</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>// create=20
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl and populate =
root=20
Object and contained objects using<BR>// generated =
IBMFactoryImpl=20
and "static" SDOs (inherit from =
EDataObjectImpl</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial=20
size=3D2>...</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>Object=20
anObject =3D ((EDataGraphImpl) eDG).getWriteReplacement(); =
//=20
=
org.eclipse.emf.ecore.sdo.impl.EDataGraphImpl$EDataGraphExte rnalizable <BR=
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n b=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb s=
p;&nbsp;&nbsp;=20
// just curious what Object was returned</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial=20
size=3D2>aSDOExchanger.acceptEDataGraph(eDG); // defined on =
remote=20
interface of Stateless Session=20
EJB</FONT></FONT></DIV></BLOCKQUOTE><FONT color=3D#0000c0 =
size=3D2>You=20
might want to try code like this (which we have in our JUnit=20
tests):<BR><BR><SMALL>&nbsp;&nbsp;&nbsp;=20
eDataGraph.getDataGraphResource().save(System.out,=20
null);<BR>&nbsp;&nbsp;&nbsp; ByteArrayOutputStream =
outputStream =3D new=20
ByteArrayOutputStream();<BR>&nbsp;&nbsp;&nbsp; =
ObjectOutputStream=20
objectOutputStream =3D new=20
ObjectOutputStream(outputStream);<BR>&nbsp;&nbsp;&nbsp;=20
=
objectOutputStream.writeObject(eDataGraph);<BR>&nbsp;&nbsp;&nbsp;=20
objectOutputStream.close();<BR>&nbsp;&nbsp;&nbsp; InputStream=20
inputStream =3D new=20
=
ByteArrayInputStream(outputStream.toByteArray());<BR>&nbsp;&nbsp;&nbsp;=20
ObjectInputStream objectInputStream =3D new=20
ObjectInputStream(inputStream);<BR>&nbsp;&nbsp;&nbsp; =
EDataGraph=20
otherEDataGraph =3D=20
=
(EDataGraph)objectInputStream.readObject();<BR>&nbsp;&nbsp;&nbsp;=20
otherEDataGraph.getDataGraphResource().save(System.out,=20
null);<BR></SMALL><BR>This should help demonstrate that the =
datagraph=20
is properly serializable and can be recovered from the=20
serialization.&nbsp; Try this on the client.&nbsp; If the =
server were=20
configured the same way, it should be able to deserialize the=20
result.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite">
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>// eDG's=20
ERootObject was set earlier to instance of:=20
com.ibm.impl.DocumentRootImpl (generated "static" SDO - =
inherits=20
from EDataObjectImpl)<BR>// =
DocumentRootImpl.setPurchaseOrder was=20
set to instance of com.ibm.impl.PurchaseOrderTypeImpl =
(generated=20
"static" SDO)<BR>&nbsp;&nbsp;&nbsp;<BR>// When accessed =
(after=20
serialization / deserialization) in EJB, EDataGraph's =
rootObject is=20
a: =
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<BR>// When=20
accessed in EJB, DocumentRootImpl.getPurchaseOrder is =
instance of:=20
=
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl<BR>&nbsp;&nbsp;&nbs=
p;<BR>//=20
I've concluded that this "replacement" (during serialization =
/=20
deserialization) of instances of generated "static" =
SDOs<BR>// (that=20
inherit from EDataObjectImpl)<BR>// with instances of=20
DynamicEDataObjectImpl has to be a conscious design choice - =
not a=20
bug.<BR></FONT></FONT></DIV></BLOCKQUOTE><FONT =
color=3D#0000c0=20
size=3D2>No, it really depends on what type of models you have =

registered and whether you are transmitting the model from the =
client=20
to the server or just assuming the server knows the model=20
already.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>// As a=20
result, I can't use the generated "static" SDOs in the=20
implementation of method=20
acceptEDataGraph(EDataGraph)</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial=20
size=3D2>Ed:</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>a) Do you=20
agree / disagree with that=20
conclusion?<BR></FONT></FONT></DIV></BLOCKQUOTE><FONT =
color=3D#0000c0=20
size=3D2>No.&nbsp; If you can get serialization and =
deserialization to=20
work locally on the client end, set a breakpoint in the =
constructor=20
for your generated DocumentRoot and see how the code gets =
there.&nbsp;=20
Similarly, set a breakpoint in the DynamicEDataObject =
constructor and=20
look at how the code path that gets you there is different in =
that=20
case...<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>b) Do you=20
know if this behavior is different (by design) in newer =
Tuscany=20
implementations of SDO 1.0 or=20
2.0?</FONT></FONT></DIV></BLOCKQUOTE><FONT color=3D#0000c0 =
size=3D2>I=20
think Tuscany started out with EMF's SDO implementation, so I =
imagine=20
the issues will be very similar or the same.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fj3vsh$82p$1@build.eclipse.org =
type=3D"cite">
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT color=3D#0000c0 size=3D2>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; wrote in =
message=20
<A href=3D"news:fihn1g$e1e$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fihn1g$e1e$1@build.eclipse.org</A>...</FONT=
></DIV><FONT=20
color=3D#0000c0 size=3D2>Gary,<BR><BR>Comments =
below.<BR><BR>Gary=20
Martin wrote: </FONT>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org=20
type=3D"cite"><FONT color=3D#0000c0 size=3D2>
<META content=3D"MSHTML 6.00.2900.3199" =
name=3DGENERATOR>
<STYLE></STYLE>
</FONT>
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thank you.&nbsp; I'm=20
not&nbsp;connecting the dots.&nbsp;&nbsp; Are you =
suggesting=20
that the source code of</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the SDO Data Graph =
Editor itself=20
illustrates c) in my problem=20
=
statement?</FONT></DIV></FONT></FONT></DIV></BLOCKQUOTE ><FONT=20
color=3D#0000c0 size=3D2>No, I'm suggesting that the =
tutorial shows=20
you the steps you need to generate the static code for =
your SDO=20
model and then the datagraph editor shows your model being =
used to=20
read and write instances or your model using your =
generated=20
code.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here's a snippet of =
code from the=20
method in my EJB where I'm able to use the =
dynamic</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>API, but unable to use =
the static=20
API.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import =
com.ibm.ItemType;<BR>import=20
com.ibm.PurchaseOrderType;<BR>import=20
=
com.ibm.DocumentRoot;<BR></FONT></DIV></FONT></FONT></DIV ></BLOCKQUOTE><F=
ONT=20
color=3D#0000c0 size=3D2>It looks like you've already =
generated the=20
code so that makes me a bit confused about why you asked =
how to=20
generate the the code.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>
<DIV><FONT face=3DArial size=3D2>import=20
com.ibm.util.IbmResourceFactoryImpl;<BR>import=20
com.ibm.util.IbmResourceUtil;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import=20
commonj.sdo.DataObject;<BR>import=20
commonj.sdo.Property;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>import=20
org.eclipse.emf.ecore.impl.EReferenceImpl;<BR>import=20
org.eclipse.emf.ecore.sdo.EDataGraph;<BR>import=20
=
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;</FONT ></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// method defined on =
the remote=20
interface <BR>public void acceptEDataGraph (EDataGraph=20
eDG)&nbsp; {</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2><BR>&nbsp;&nbsp;DataObject=20
rootObject =3D eDG.getRootObject(); //=20
works<BR>&nbsp;&nbsp;DataObject purchaseOrder =3D=20
rootObject.getDataObject("purchaseOrder"); // =
works</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;java.util.Date=20
orderDate =3D purchaseOrder.getDate("orderDate"); //=20
works<BR>&nbsp;&nbsp;System.out.println("orderDate: " +=20
orderDate); // works </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;// This =
doesn't=20
work <BR>&nbsp;&nbsp;DocumentRoot documentRoot =3D=20
=
(DocumentRoot)eDG.getERootObject();&nbsp;&nbsp;<BR>&nbsp;&nbsp;PurchaseOr=
derType=20
aPOT =3D documentRoot.getPurchaseOrder(); // what I'm =
referring to=20
as the "static" SDO API</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// I get this exception =

<BR>java.rmi.ServerException: RemoteException occurred =
in server=20
thread; nested exception is: =
<BR>&nbsp;java.rmi.RemoteException:=20
<BR>&nbsp;&gt;&gt; SERVER (id=3D4773e3aa, =
host=3DIBM-0CA191A407D)=20
TRACE START:<BR>&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp;=20
java.rmi.RemoteException: ; nested exception is:=20
<BR>&nbsp;java.lang.ClassCastException:=20
org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl=20
incompatible with =
com.ibm.DocumentRoot<BR>&nbsp;&gt;&gt;&nbsp;=20
at=20
=
sdo.exchanger.SDOExchangerBean.acceptEDataGraph(SDOExchanger Bean.java:89)=
</FONT></DIV></FONT></FONT></DIV></BLOCKQUOTE><FONT=20
color=3D#0000c0 size=3D2>Oh, I see.&nbsp; Maybe all that's =
missing is=20
the code to ensure that your generated package is =
registered with=20
the static registry. At some point during the =
initialization of=20
the server you should access the XyzPackage.eINSTANCE to =
ensure=20
that the package is registered.<BR></FONT>
<BLOCKQUOTE cite=3Dmid:fihm57$brk$1@build.eclipse.org =
type=3D"cite">
<DIV><FONT color=3D#0000c0 size=3D2><FONT face=3DArial =
size=3D2>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; =
MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com"=20
moz-do-not-send=3D"true">merks@ca.ibm.com</A>&gt; =
wrote in=20
message <A =
href=3D"news:fihdh6$jpc$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:fihdh6$jpc$1@build.eclipse.org</A>...</DIV>=
Gary,<BR><BR>Yes,=20
that is possible:<BR>
<BLOCKQUOTE><A=20
=
href=3D" http://help.eclipse.org/help33/index.jsp?topic=3D/org.eclips e.emf=
......ecore.sdo.doc/tutorials/datagraph/datagraph.html"=20
moz-do-not-send=3D"true">Tutorial: Using the SDO =
Data Graph=20
Editor</A><BR></BLOCKQUOTE><BR>Gary Martin wrote:=20
<BLOCKQUOTE cite=3Dmid:fihc9v$c1p$1@build.eclipse.org=20
type=3D"cite"><PRE wrap=3D"">By design (with any =
version of SDO and Tuscany Java implementation),

should it be possible to generate "static" SDO classes from an .xsd, and
then:

a) use the generated classes to create an:
org.eclipse.emf.ecore.sdo.EDataGraph
b)call a method on the remote interface of an ejb that takes that
EDataGraph as its only arguement
c)use the *static* generated SDO classes to access the SDOs in the
EDataGraph

I've done a) and b) and can use the dynamic SDO API in my EJB method,
but, I've yet to figure out how (or even if it should be possible by
design) to use the generated "static" SDO classes in my EJB method.=20


</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></FONT></FONT></DIV >
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; =
MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: =
0px">&nbsp;</BLOCKQUOTE></BLOCKQUOTE><FONT=20
color=3D#0000c0 =
size=3D2><BR></FONT></BLOCKQUOTE></BLOCKQUOTE><FONT=20
color=3D#0000c0=20
=
size=3D2><BR></FONT></FONT></BLOCKQUOTE></BLOCKQUOTE><BR ></BLOCKQUOTE></B=
LOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_006E_01C8372B.FF0CF5E0--
Previous Topic:Modify standard XMI serialization
Next Topic:autoincremented id
Goto Forum:
  


Current Time: Fri Apr 26 10:05:58 GMT 2024

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

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

Back to the top