Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [GWT] Server-side XMLResource
[GWT] Server-side XMLResource [message #1001378] Wed, 16 January 2013 15:40 Go to next message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Hi,

the scenario I'm evaluating is a follows.

The service has a method that returns the root of a data structure
modelled with EMF.

On the server side this method reads the XML file and turns it into the
data structure like so:

----- 8< --------------
ResourceSet resourceSet = new ResourceSetImpl();
Resource.Factory resourceFactory = new XYResourceFactoryImpl();
Map<String, Object> extensionToFactory = resourceSet
.getResourceFactoryRegistry().getExtensionToFactoryMap();
extensionToFactory.put("xml", resourceFactory);

// Dummy call just to register the package
GenLegacyRenderingPackage.eINSTANCE.eClass();

Resource resource =
resourceSet.createResource(URI.createFileURI("DUMMY.xml"));

Map<String, Object> options = new HashMap<String, Object>();

options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);

resource.load(inputStream, options);
----- >8 -------------------

Well the problem is that there seems to be no XMLResource class in the
emf.gwt packages.

Actually I even do not need that because on the server side there is no
need for JavaScript. My first idea was to simply let the project depend
on org.eclipse.emf.ecore.xmi but will it be a good idea to mix non-GWT
with GWT EMF packages?

I started off with the default GWT Web Application project which creates
the client as well as the server side inside the same project. So how
could I use regular EMF runtime jars on the server side and GWT EMF on
the client side and allow both to share the same data model and to
interchange data based on this model?

Are two projects where each has its own .genmodel an option?

Thanks and Regards,
Dirk
Re: [GWT] Server-side XMLResource [message #1001384 is a reply to message #1001378] Wed, 16 January 2013 15:46 Go to previous messageGo to next message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Another question along the same lines:

What if I wanted to send the XML file over the wire and parse it into a
data structure on the client. Is there an equivalent of

resource.load(inputStream, options);

for the GWT client.

Dirk

Am 16.01.2013 16:40, schrieb Dirk Hoffmann:
> Hi,
>
> the scenario I'm evaluating is a follows.
>
> The service has a method that returns the root of a data structure
> modelled with EMF.
>
> On the server side this method reads the XML file and turns it into the
> data structure like so:
>
> ----- 8< --------------
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
> Map<String, Object> extensionToFactory = resourceSet
> .getResourceFactoryRegistry().getExtensionToFactoryMap();
> extensionToFactory.put("xml", resourceFactory);
>
> // Dummy call just to register the package
> GenLegacyRenderingPackage.eINSTANCE.eClass();
>
> Resource resource =
> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>
> Map<String, Object> options = new HashMap<String, Object>();
>
> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>
> resource.load(inputStream, options);
> ----- >8 -------------------
>
> Well the problem is that there seems to be no XMLResource class in the
> emf.gwt packages.
>
> Actually I even do not need that because on the server side there is no
> need for JavaScript. My first idea was to simply let the project depend
> on org.eclipse.emf.ecore.xmi but will it be a good idea to mix non-GWT
> with GWT EMF packages?
>
> I started off with the default GWT Web Application project which creates
> the client as well as the server side inside the same project. So how
> could I use regular EMF runtime jars on the server side and GWT EMF on
> the client side and allow both to share the same data model and to
> interchange data based on this model?
>
> Are two projects where each has its own .genmodel an option?
>
> Thanks and Regards,
> Dirk
>
Re: [GWT] Server-side XMLResource [message #1001405 is a reply to message #1001378] Wed, 16 January 2013 16:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26283
Registered: July 2009
Senior Member
Dirk,

Comments below.

On 16/01/2013 4:40 PM, Dirk Hoffmann wrote:
> Hi,
>
> the scenario I'm evaluating is a follows.
>
> The service has a method that returns the root of a data structure
> modelled with EMF.
>
> On the server side this method reads the XML file and turns it into
> the data structure like so:
>
> ----- 8< --------------
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
> Map<String, Object> extensionToFactory = resourceSet
> .getResourceFactoryRegistry().getExtensionToFactoryMap();
> extensionToFactory.put("xml", resourceFactory);
>
> // Dummy call just to register the package
> GenLegacyRenderingPackage.eINSTANCE.eClass();
>
> Resource resource =
> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>
> Map<String, Object> options = new HashMap<String, Object>();
>
> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>
> resource.load(inputStream, options);
> ----- >8 -------------------
>
> Well the problem is that there seems to be no XMLResource class in the
> emf.gwt packages.
Nor much in the way of something equivalent to SAX in the GWT runtime.
>
> Actually I even do not need that because on the server side there is
> no need for JavaScript. My first idea was to simply let the project
> depend on org.eclipse.emf.ecore.xmi but will it be a good idea to mix
> non-GWT with GWT EMF packages?
Probably not. I have no experience with that...
>
> I started off with the default GWT Web Application project which
> creates the client as well as the server side inside the same project.
> So how could I use regular EMF runtime jars on the server side and GWT
> EMF on the client side and allow both to share the same data model and
> to interchange data based on this model?
Not sure. The binary serialization that's produced by the standard
runtime should be consumable by the GWT client.
>
> Are two projects where each has its own .genmodel an option?
I'm not sure I understand this question... If you want to use the
standard runtime on the server, then I think you'll need a separated
generated model for that environment verses the generated model you use
in the GWT client.
>
> Thanks and Regards,
> Dirk
>
Re: [GWT] Server-side XMLResource [message #1001408 is a reply to message #1001384] Wed, 16 January 2013 16:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26283
Registered: July 2009
Senior Member
Dirk,

No, there's not even an equivalent of an input stream on the client...

On 16/01/2013 4:46 PM, Dirk Hoffmann wrote:
> Another question along the same lines:
>
> What if I wanted to send the XML file over the wire and parse it into
> a data structure on the client. Is there an equivalent of
>
> resource.load(inputStream, options);
>
> for the GWT client.
>
> Dirk
>
> Am 16.01.2013 16:40, schrieb Dirk Hoffmann:
>> Hi,
>>
>> the scenario I'm evaluating is a follows.
>>
>> The service has a method that returns the root of a data structure
>> modelled with EMF.
>>
>> On the server side this method reads the XML file and turns it into the
>> data structure like so:
>>
>> ----- 8< --------------
>> ResourceSet resourceSet = new ResourceSetImpl();
>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>> Map<String, Object> extensionToFactory = resourceSet
>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>> extensionToFactory.put("xml", resourceFactory);
>>
>> // Dummy call just to register the package
>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>
>> Resource resource =
>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>
>> Map<String, Object> options = new HashMap<String, Object>();
>>
>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>
>> resource.load(inputStream, options);
>> ----- >8 -------------------
>>
>> Well the problem is that there seems to be no XMLResource class in the
>> emf.gwt packages.
>>
>> Actually I even do not need that because on the server side there is no
>> need for JavaScript. My first idea was to simply let the project depend
>> on org.eclipse.emf.ecore.xmi but will it be a good idea to mix non-GWT
>> with GWT EMF packages?
>>
>> I started off with the default GWT Web Application project which creates
>> the client as well as the server side inside the same project. So how
>> could I use regular EMF runtime jars on the server side and GWT EMF on
>> the client side and allow both to share the same data model and to
>> interchange data based on this model?
>>
>> Are two projects where each has its own .genmodel an option?
>>
>> Thanks and Regards,
>> Dirk
>>
>
Re: [GWT] Server-side XMLResource [message #1001690 is a reply to message #1001408] Thu, 17 January 2013 08:11 Go to previous messageGo to next message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Hi Ed,

see below...
Am 16.01.2013 17:41, schrieb Ed Merks:
> Dirk,
>
> No, there's not even an equivalent of an input stream on the client...
Well, maybe not. I'm just looking for a way to deserialize some XML
serialized model into a data structure whose classes are generated from
an Ecore meta model.

I assume quite some code of the EMF/GWT projects was derived from the
regular EMF code. How difficult was that?
Do you think it would be achievable without too much effort to turn
org.eclipse.emf.ecore.xmi into its GWT counterpart, of course replacing
input stream with string?
Answering myself I think the biggest problem would be to replace the SAX
parser as browsers do not provide that natively. It would have to use
the dom returned by the browser's XMLParser.

After all deserialize some XML serialized model into a data structure
whose classes are generated from an Ecore meta model doesn't seem to be
an option, so I have to find a way to do this on the server or go
without EMF.

Dirk

(Why did they add this Followup button?)
> On 16/01/2013 4:46 PM, Dirk Hoffmann wrote:
>> Another question along the same lines:
>>
>> What if I wanted to send the XML file over the wire and parse it into
>> a data structure on the client. Is there an equivalent of
>>
>> resource.load(inputStream, options);
>>
>> for the GWT client.
>>
>> Dirk
>>
>> Am 16.01.2013 16:40, schrieb Dirk Hoffmann:
>>> Hi,
>>>
>>> the scenario I'm evaluating is a follows.
>>>
>>> The service has a method that returns the root of a data structure
>>> modelled with EMF.
>>>
>>> On the server side this method reads the XML file and turns it into the
>>> data structure like so:
>>>
>>> ----- 8< --------------
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>>> Map<String, Object> extensionToFactory = resourceSet
>>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>>> extensionToFactory.put("xml", resourceFactory);
>>>
>>> // Dummy call just to register the package
>>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>>
>>> Resource resource =
>>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>>
>>> Map<String, Object> options = new HashMap<String, Object>();
>>>
>>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>>
>>> resource.load(inputStream, options);
>>> ----- >8 -------------------
>>>
>>> Well the problem is that there seems to be no XMLResource class in the
>>> emf.gwt packages.
>>>
>>> Actually I even do not need that because on the server side there is no
>>> need for JavaScript. My first idea was to simply let the project depend
>>> on org.eclipse.emf.ecore.xmi but will it be a good idea to mix non-GWT
>>> with GWT EMF packages?
>>>
>>> I started off with the default GWT Web Application project which creates
>>> the client as well as the server side inside the same project. So how
>>> could I use regular EMF runtime jars on the server side and GWT EMF on
>>> the client side and allow both to share the same data model and to
>>> interchange data based on this model?
>>>
>>> Are two projects where each has its own .genmodel an option?
>>>
>>> Thanks and Regards,
>>> Dirk
>>>
>>
>
Re: [GWT] Server-side XMLResource [message #1001723 is a reply to message #1001690] Thu, 17 January 2013 09:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26283
Registered: July 2009
Senior Member
Dirk,

Comments below.

On 17/01/2013 9:11 AM, Dirk Hoffmann wrote:
> Hi Ed,
>
> see below...
> Am 16.01.2013 17:41, schrieb Ed Merks:
>> Dirk,
>>
>> No, there's not even an equivalent of an input stream on the client...
> Well, maybe not. I'm just looking for a way to deserialize some XML
> serialized model into a data structure whose classes are generated
> from an Ecore meta model.
>
> I assume quite some code of the EMF/GWT projects was derived from the
> regular EMF code. How difficult was that?
Yes, all of it. Most was quite straight forward. In normal generated
models, there's actually almost nothing to do. I've been told that
solve folks use stubs for the GWT dependencies to make the same
generated model work in the standard runtime...
> Do you think it would be achievable without too much effort to turn
> org.eclipse.emf.ecore.xmi into its GWT counterpart, of course
> replacing input stream with string?
I looked at that a bit. Deserialization is quite heavily driven by SAX
events, so if there's a way to produce those, it should be relatively
straight forward. Serialization should be quite easily; it's heavily
focused on producing an efficient in-memory serialization using standard
Java libraries that should work well with GWT.
> Answering myself I think the biggest problem would be to replace the
> SAX parser as browsers do not provide that natively. It would have to
> use the dom returned by the browser's XMLParser.
Yes, exactly.
>
> After all deserialize some XML serialized model into a data structure
> whose classes are generated from an Ecore meta model doesn't seem to
> be an option, so I have to find a way to do this on the server or go
> without EMF.
If you can do all the work on the server, exchanging binary between the
client and the server is fast and effective.
>
> Dirk
>
> (Why did they add this Followup button?)
Good question. :-P
>> On 16/01/2013 4:46 PM, Dirk Hoffmann wrote:
>>> Another question along the same lines:
>>>
>>> What if I wanted to send the XML file over the wire and parse it into
>>> a data structure on the client. Is there an equivalent of
>>>
>>> resource.load(inputStream, options);
>>>
>>> for the GWT client.
>>>
>>> Dirk
>>>
>>> Am 16.01.2013 16:40, schrieb Dirk Hoffmann:
>>>> Hi,
>>>>
>>>> the scenario I'm evaluating is a follows.
>>>>
>>>> The service has a method that returns the root of a data structure
>>>> modelled with EMF.
>>>>
>>>> On the server side this method reads the XML file and turns it into
>>>> the
>>>> data structure like so:
>>>>
>>>> ----- 8< --------------
>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>>>> Map<String, Object> extensionToFactory = resourceSet
>>>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>>>> extensionToFactory.put("xml", resourceFactory);
>>>>
>>>> // Dummy call just to register the package
>>>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>>>
>>>> Resource resource =
>>>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>>>
>>>> Map<String, Object> options = new HashMap<String, Object>();
>>>>
>>>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>>>
>>>> resource.load(inputStream, options);
>>>> ----- >8 -------------------
>>>>
>>>> Well the problem is that there seems to be no XMLResource class in the
>>>> emf.gwt packages.
>>>>
>>>> Actually I even do not need that because on the server side there
>>>> is no
>>>> need for JavaScript. My first idea was to simply let the project
>>>> depend
>>>> on org.eclipse.emf.ecore.xmi but will it be a good idea to mix non-GWT
>>>> with GWT EMF packages?
>>>>
>>>> I started off with the default GWT Web Application project which
>>>> creates
>>>> the client as well as the server side inside the same project. So how
>>>> could I use regular EMF runtime jars on the server side and GWT EMF on
>>>> the client side and allow both to share the same data model and to
>>>> interchange data based on this model?
>>>>
>>>> Are two projects where each has its own .genmodel an option?
>>>>
>>>> Thanks and Regards,
>>>> Dirk
>>>>
>>>
>>
>
Re: [GWT] Server-side XMLResource [message #1001742 is a reply to message #1001405] Thu, 17 January 2013 10:11 Go to previous messageGo to next message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Hi Ed,

the approach is now to deserialize on the server using standard EMF and
return that to the client somehow.

I just added the standard ecore.xmi package to the dependencies to see
what happens. That gets me an Exception, more below...

Am 16.01.2013 17:40, schrieb Ed Merks:
> Dirk,
>
> Comments below.
>
> On 16/01/2013 4:40 PM, Dirk Hoffmann wrote:
>> Hi,
>>
>> the scenario I'm evaluating is a follows.
>>
>> The service has a method that returns the root of a data structure
>> modelled with EMF.
>>
>> On the server side this method reads the XML file and turns it into
>> the data structure like so:
>>
>> ----- 8< --------------
>> ResourceSet resourceSet = new ResourceSetImpl();
>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>> Map<String, Object> extensionToFactory = resourceSet
>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>> extensionToFactory.put("xml", resourceFactory);
>>
>> // Dummy call just to register the package
>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>
>> Resource resource =
>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>
>> Map<String, Object> options = new HashMap<String, Object>();
>>
>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>
Up to here all went through
>> resource.load(inputStream, options);
This comes back with an InvocationTargetException with target pointing
to a SecurityException saying
class "org.eclipse.emf.ecore.xml.type.internal.QName"'s signer
information does not match signer information of other classes in the
same package.

Not too surprising that it went wrong. This looks like if I had to
create a GWT version of the exore.xmi package (and maybe dependencies as
well) not to be run on the client but on the server just to make it
compatible with the emf.gwt jars.

Any other ideas?

What is the easiest way today to download the sources of the EMF projects?

Dirk

>> ----- >8 -------------------
>>
>> Well the problem is that there seems to be no XMLResource class in the
>> emf.gwt packages.
> Nor much in the way of something equivalent to SAX in the GWT runtime.
>>
>> Actually I even do not need that because on the server side there is
>> no need for JavaScript. My first idea was to simply let the project
>> depend on org.eclipse.emf.ecore.xmi but will it be a good idea to mix
>> non-GWT with GWT EMF packages?
> Probably not. I have no experience with that...
>>
>> I started off with the default GWT Web Application project which
>> creates the client as well as the server side inside the same project.
>> So how could I use regular EMF runtime jars on the server side and GWT
>> EMF on the client side and allow both to share the same data model and
>> to interchange data based on this model?
> Not sure. The binary serialization that's produced by the standard
> runtime should be consumable by the GWT client.
>>
>> Are two projects where each has its own .genmodel an option?
> I'm not sure I understand this question... If you want to use the
> standard runtime on the server, then I think you'll need a separated
> generated model for that environment verses the generated model you use
> in the GWT client.
>>
>> Thanks and Regards,
>> Dirk
>>
>
Re: [GWT] Server-side XMLResource [message #1001778 is a reply to message #1001690] Thu, 17 January 2013 10:59 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
Registered: July 2009
Senior Member
Hi Dirk, Ed,
I don't want to break into the thread but still wanted to mention another direction. The EMFT Texo project supports JSON
serialization with a server side solution also. There is also a EMF JSON resource which can be used in a RCP client.
Would it be an idea to consider using Texo on the server side and EMF GWT on the client side?

See these blogs with further links to the docs inside:
http://martintaal.wordpress.com/2012/04/05/emf-texo-json-rest-web-service-support-connecting-your-client-to-an-emf-supporting-web-server/
http://martintaal.wordpress.com/2012/08/30/taking-emf-to-the-third-tier-the-texo-json-resource/
http://martintaal.wordpress.com/2012/05/09/emft-texo-model-driven-rcp-using-texo-generated-jpa-entities/

gr. Martin

On 01/17/2013 09:11 AM, Dirk Hoffmann wrote:
> Hi Ed,
>
> see below...
> Am 16.01.2013 17:41, schrieb Ed Merks:
>> Dirk,
>>
>> No, there's not even an equivalent of an input stream on the client...
> Well, maybe not. I'm just looking for a way to deserialize some XML serialized model into a data structure whose classes
> are generated from an Ecore meta model.
>
> I assume quite some code of the EMF/GWT projects was derived from the regular EMF code. How difficult was that?
> Do you think it would be achievable without too much effort to turn org.eclipse.emf.ecore.xmi into its GWT counterpart,
> of course replacing input stream with string?
> Answering myself I think the biggest problem would be to replace the SAX parser as browsers do not provide that
> natively. It would have to use the dom returned by the browser's XMLParser.
>
> After all deserialize some XML serialized model into a data structure whose classes are generated from an Ecore meta
> model doesn't seem to be an option, so I have to find a way to do this on the server or go without EMF.
>
> Dirk
>
> (Why did they add this Followup button?)
>> On 16/01/2013 4:46 PM, Dirk Hoffmann wrote:
>>> Another question along the same lines:
>>>
>>> What if I wanted to send the XML file over the wire and parse it into
>>> a data structure on the client. Is there an equivalent of
>>>
>>> resource.load(inputStream, options);
>>>
>>> for the GWT client.
>>>
>>> Dirk
>>>
>>> Am 16.01.2013 16:40, schrieb Dirk Hoffmann:
>>>> Hi,
>>>>
>>>> the scenario I'm evaluating is a follows.
>>>>
>>>> The service has a method that returns the root of a data structure
>>>> modelled with EMF.
>>>>
>>>> On the server side this method reads the XML file and turns it into the
>>>> data structure like so:
>>>>
>>>> ----- 8< --------------
>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>>>> Map<String, Object> extensionToFactory = resourceSet
>>>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>>>> extensionToFactory.put("xml", resourceFactory);
>>>>
>>>> // Dummy call just to register the package
>>>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>>>
>>>> Resource resource =
>>>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>>>
>>>> Map<String, Object> options = new HashMap<String, Object>();
>>>>
>>>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>>>
>>>> resource.load(inputStream, options);
>>>> ----- >8 -------------------
>>>>
>>>> Well the problem is that there seems to be no XMLResource class in the
>>>> emf.gwt packages.
>>>>
>>>> Actually I even do not need that because on the server side there is no
>>>> need for JavaScript. My first idea was to simply let the project depend
>>>> on org.eclipse.emf.ecore.xmi but will it be a good idea to mix non-GWT
>>>> with GWT EMF packages?
>>>>
>>>> I started off with the default GWT Web Application project which creates
>>>> the client as well as the server side inside the same project. So how
>>>> could I use regular EMF runtime jars on the server side and GWT EMF on
>>>> the client side and allow both to share the same data model and to
>>>> interchange data based on this model?
>>>>
>>>> Are two projects where each has its own .genmodel an option?
>>>>
>>>> Thanks and Regards,
>>>> Dirk
>>>>
>>>
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [GWT] Server-side XMLResource [message #1001789 is a reply to message #1001778] Thu, 17 January 2013 11:23 Go to previous messageGo to next message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Hi Martin,

thanks for the hint. Looks interesting. I've come across Texo recently
but thought that it would not solve my problem. I have to use GWT for
the code executed on the browser so I wonder how Texo is to be used in
conjunction with GWT.

I want to use EMF for the client and server side because I already used
it for an Eclipse based application and hope to reuse as much of the
code I've written for it. The task basically is to port the application
from Eclipse to the GWT client.

Regards,
Dirk

Am 17.01.2013 11:59, schrieb Martin Taal:
> Hi Dirk, Ed,
> I don't want to break into the thread but still wanted to mention
> another direction. The EMFT Texo project supports JSON serialization
> with a server side solution also. There is also a EMF JSON resource
> which can be used in a RCP client. Would it be an idea to consider using
> Texo on the server side and EMF GWT on the client side?
>
> See these blogs with further links to the docs inside:
> http://martintaal.wordpress.com/2012/04/05/emf-texo-json-rest-web-service-support-connecting-your-client-to-an-emf-supporting-web-server/
>
> http://martintaal.wordpress.com/2012/08/30/taking-emf-to-the-third-tier-the-texo-json-resource/
>
> http://martintaal.wordpress.com/2012/05/09/emft-texo-model-driven-rcp-using-texo-generated-jpa-entities/
>
>
> gr. Martin
>
> On 01/17/2013 09:11 AM, Dirk Hoffmann wrote:
>> Hi Ed,
>>
>> see below...
>> Am 16.01.2013 17:41, schrieb Ed Merks:
>>> Dirk,
>>>
>>> No, there's not even an equivalent of an input stream on the client...
>> Well, maybe not. I'm just looking for a way to deserialize some XML
>> serialized model into a data structure whose classes
>> are generated from an Ecore meta model.
>>
>> I assume quite some code of the EMF/GWT projects was derived from the
>> regular EMF code. How difficult was that?
>> Do you think it would be achievable without too much effort to turn
>> org.eclipse.emf.ecore.xmi into its GWT counterpart,
>> of course replacing input stream with string?
>> Answering myself I think the biggest problem would be to replace the
>> SAX parser as browsers do not provide that
>> natively. It would have to use the dom returned by the browser's
>> XMLParser.
>>
>> After all deserialize some XML serialized model into a data structure
>> whose classes are generated from an Ecore meta
>> model doesn't seem to be an option, so I have to find a way to do this
>> on the server or go without EMF.
>>
>> Dirk
>>
>> (Why did they add this Followup button?)
>>> On 16/01/2013 4:46 PM, Dirk Hoffmann wrote:
>>>> Another question along the same lines:
>>>>
>>>> What if I wanted to send the XML file over the wire and parse it into
>>>> a data structure on the client. Is there an equivalent of
>>>>
>>>> resource.load(inputStream, options);
>>>>
>>>> for the GWT client.
>>>>
>>>> Dirk
>>>>
>>>> Am 16.01.2013 16:40, schrieb Dirk Hoffmann:
>>>>> Hi,
>>>>>
>>>>> the scenario I'm evaluating is a follows.
>>>>>
>>>>> The service has a method that returns the root of a data structure
>>>>> modelled with EMF.
>>>>>
>>>>> On the server side this method reads the XML file and turns it into
>>>>> the
>>>>> data structure like so:
>>>>>
>>>>> ----- 8< --------------
>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>>>>> Map<String, Object> extensionToFactory = resourceSet
>>>>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>>>>> extensionToFactory.put("xml", resourceFactory);
>>>>>
>>>>> // Dummy call just to register the package
>>>>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>>>>
>>>>> Resource resource =
>>>>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>>>>
>>>>> Map<String, Object> options = new HashMap<String, Object>();
>>>>>
>>>>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>>>>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>>>>
>>>>> resource.load(inputStream, options);
>>>>> ----- >8 -------------------
>>>>>
>>>>> Well the problem is that there seems to be no XMLResource class in the
>>>>> emf.gwt packages.
>>>>>
>>>>> Actually I even do not need that because on the server side there
>>>>> is no
>>>>> need for JavaScript. My first idea was to simply let the project
>>>>> depend
>>>>> on org.eclipse.emf.ecore.xmi but will it be a good idea to mix non-GWT
>>>>> with GWT EMF packages?
>>>>>
>>>>> I started off with the default GWT Web Application project which
>>>>> creates
>>>>> the client as well as the server side inside the same project. So how
>>>>> could I use regular EMF runtime jars on the server side and GWT EMF on
>>>>> the client side and allow both to share the same data model and to
>>>>> interchange data based on this model?
>>>>>
>>>>> Are two projects where each has its own .genmodel an option?
>>>>>
>>>>> Thanks and Regards,
>>>>> Dirk
>>>>>
>>>>
>>>
>>
>
>
Re: [GWT] Server-side XMLResource [message #1001825 is a reply to message #1001789] Thu, 17 January 2013 12:23 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
Registered: July 2009
Senior Member
Hi Dirk,
I haven't tried it but maybe the EMFJSONResource can be used in a EMF GWT client. Then on the server you can run Texo in
a webserver environment. The EMFJSONResource works out-of-the-box with a Texo EMF webserver.

Another option is to use another GWT solution, many GWT solutions (exjs/sencha, smartclient) use json as the
communication data format, then on the server you can use Texo also.

gr. Martin

On 01/17/2013 12:23 PM, Dirk Hoffmann wrote:
> Hi Martin,
>
> thanks for the hint. Looks interesting. I've come across Texo recently but thought that it would not solve my problem. I
> have to use GWT for the code executed on the browser so I wonder how Texo is to be used in conjunction with GWT.
>
> I want to use EMF for the client and server side because I already used it for an Eclipse based application and hope to
> reuse as much of the code I've written for it. The task basically is to port the application from Eclipse to the GWT
> client.
>
> Regards,
> Dirk
>
> Am 17.01.2013 11:59, schrieb Martin Taal:
>> Hi Dirk, Ed,
>> I don't want to break into the thread but still wanted to mention
>> another direction. The EMFT Texo project supports JSON serialization
>> with a server side solution also. There is also a EMF JSON resource
>> which can be used in a RCP client. Would it be an idea to consider using
>> Texo on the server side and EMF GWT on the client side?
>>
>> See these blogs with further links to the docs inside:
>> http://martintaal.wordpress.com/2012/04/05/emf-texo-json-rest-web-service-support-connecting-your-client-to-an-emf-supporting-web-server/
>>
>>
>> http://martintaal.wordpress.com/2012/08/30/taking-emf-to-the-third-tier-the-texo-json-resource/
>>
>> http://martintaal.wordpress.com/2012/05/09/emft-texo-model-driven-rcp-using-texo-generated-jpa-entities/
>>
>>
>> gr. Martin
>>
>> On 01/17/2013 09:11 AM, Dirk Hoffmann wrote:
>>> Hi Ed,
>>>
>>> see below...
>>> Am 16.01.2013 17:41, schrieb Ed Merks:
>>>> Dirk,
>>>>
>>>> No, there's not even an equivalent of an input stream on the client...
>>> Well, maybe not. I'm just looking for a way to deserialize some XML
>>> serialized model into a data structure whose classes
>>> are generated from an Ecore meta model.
>>>
>>> I assume quite some code of the EMF/GWT projects was derived from the
>>> regular EMF code. How difficult was that?
>>> Do you think it would be achievable without too much effort to turn
>>> org.eclipse.emf.ecore.xmi into its GWT counterpart,
>>> of course replacing input stream with string?
>>> Answering myself I think the biggest problem would be to replace the
>>> SAX parser as browsers do not provide that
>>> natively. It would have to use the dom returned by the browser's
>>> XMLParser.
>>>
>>> After all deserialize some XML serialized model into a data structure
>>> whose classes are generated from an Ecore meta
>>> model doesn't seem to be an option, so I have to find a way to do this
>>> on the server or go without EMF.
>>>
>>> Dirk
>>>
>>> (Why did they add this Followup button?)
>>>> On 16/01/2013 4:46 PM, Dirk Hoffmann wrote:
>>>>> Another question along the same lines:
>>>>>
>>>>> What if I wanted to send the XML file over the wire and parse it into
>>>>> a data structure on the client. Is there an equivalent of
>>>>>
>>>>> resource.load(inputStream, options);
>>>>>
>>>>> for the GWT client.
>>>>>
>>>>> Dirk
>>>>>
>>>>> Am 16.01.2013 16:40, schrieb Dirk Hoffmann:
>>>>>> Hi,
>>>>>>
>>>>>> the scenario I'm evaluating is a follows.
>>>>>>
>>>>>> The service has a method that returns the root of a data structure
>>>>>> modelled with EMF.
>>>>>>
>>>>>> On the server side this method reads the XML file and turns it into
>>>>>> the
>>>>>> data structure like so:
>>>>>>
>>>>>> ----- 8< --------------
>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>>>>>> Map<String, Object> extensionToFactory = resourceSet
>>>>>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>>>>>> extensionToFactory.put("xml", resourceFactory);
>>>>>>
>>>>>> // Dummy call just to register the package
>>>>>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>>>>>
>>>>>> Resource resource =
>>>>>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>>>>>
>>>>>> Map<String, Object> options = new HashMap<String, Object>();
>>>>>>
>>>>>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>>>>>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>>>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>>>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>>>>>
>>>>>> resource.load(inputStream, options);
>>>>>> ----- >8 -------------------
>>>>>>
>>>>>> Well the problem is that there seems to be no XMLResource class in the
>>>>>> emf.gwt packages.
>>>>>>
>>>>>> Actually I even do not need that because on the server side there
>>>>>> is no
>>>>>> need for JavaScript. My first idea was to simply let the project
>>>>>> depend
>>>>>> on org.eclipse.emf.ecore.xmi but will it be a good idea to mix non-GWT
>>>>>> with GWT EMF packages?
>>>>>>
>>>>>> I started off with the default GWT Web Application project which
>>>>>> creates
>>>>>> the client as well as the server side inside the same project. So how
>>>>>> could I use regular EMF runtime jars on the server side and GWT EMF on
>>>>>> the client side and allow both to share the same data model and to
>>>>>> interchange data based on this model?
>>>>>>
>>>>>> Are two projects where each has its own .genmodel an option?
>>>>>>
>>>>>> Thanks and Regards,
>>>>>> Dirk
>>>>>>
>>>>>
>>>>
>>>
>>
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [GWT] Server-side XMLResource [message #1001845 is a reply to message #1001742] Thu, 17 January 2013 12:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26283
Registered: July 2009
Senior Member
Dirk,

Comments below.

On 17/01/2013 11:11 AM, Dirk Hoffmann wrote:
> Hi Ed,
>
> the approach is now to deserialize on the server using standard EMF
> and return that to the client somehow.
BinaryResourceImpl should do the trick for the "somehow."
>
> I just added the standard ecore.xmi package to the dependencies to see
> what happens. That gets me an Exception, more below...
>
> Am 16.01.2013 17:40, schrieb Ed Merks:
>> Dirk,
>>
>> Comments below.
>>
>> On 16/01/2013 4:40 PM, Dirk Hoffmann wrote:
>>> Hi,
>>>
>>> the scenario I'm evaluating is a follows.
>>>
>>> The service has a method that returns the root of a data structure
>>> modelled with EMF.
>>>
>>> On the server side this method reads the XML file and turns it into
>>> the data structure like so:
>>>
>>> ----- 8< --------------
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>>> Map<String, Object> extensionToFactory = resourceSet
>>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>>> extensionToFactory.put("xml", resourceFactory);
>>>
>>> // Dummy call just to register the package
>>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>>
>>> Resource resource =
>>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>>
>>> Map<String, Object> options = new HashMap<String, Object>();
>>>
>>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>>
> Up to here all went through
>>> resource.load(inputStream, options);
> This comes back with an InvocationTargetException with target pointing
> to a SecurityException saying
> class "org.eclipse.emf.ecore.xml.type.internal.QName"'s signer
> information does not match signer information of other classes in the
> same package.
XMI depends on the standard EMF runtime, so you can't just mix that into
the GWT compatible runtime...
>
> Not too surprising that it went wrong. This looks like if I had to
> create a GWT version of the exore.xmi package (and maybe dependencies
> as well) not to be run on the client but on the server just to make it
> compatible with the emf.gwt jars.
Yes, I suppose so. Differences in the Resource APIs (because of lack of
support for Streams) is going to cause a problem...
>
> Any other ideas?
Perhaps some kind of compatibility layer for the models you want to use
in both contexts would work. I.e., something that depends on the
standard *.emf.ecore and *.emf.common, but has the GWT bundle names and
also include stubs for the GWT-specific things generated in the models
would do the trick. Or maybe hand modify the generated manifest to use
package imports rather than bundle imports so they can resolve
differently depending on what's in your target platform. Then you'd
only need some stubs to keep the compiler happy.

So imagine that you have the same generated model in two different
workspaces, one with the GWT runtime in the target platform and the
other with the standard runtime in the target platform. It should be
possible that the same generated model code could compile properly in
both those workspace. All sharing of data between client and server
could be accomplished with binary. Note that there's
XMLResource.OPTION_BINARY which can be used to produce binary from an
XMLResource.
>
> What is the easiest way today to download the sources of the EMF
> projects?
From http://git.eclipse.org/c/emf/org.eclipse.emf.git
>
> Dirk
>
>>> ----- >8 -------------------
>>>
>>> Well the problem is that there seems to be no XMLResource class in the
>>> emf.gwt packages.
>> Nor much in the way of something equivalent to SAX in the GWT runtime.
>>>
>>> Actually I even do not need that because on the server side there is
>>> no need for JavaScript. My first idea was to simply let the project
>>> depend on org.eclipse.emf.ecore.xmi but will it be a good idea to mix
>>> non-GWT with GWT EMF packages?
>> Probably not. I have no experience with that...
>>>
>>> I started off with the default GWT Web Application project which
>>> creates the client as well as the server side inside the same project.
>>> So how could I use regular EMF runtime jars on the server side and GWT
>>> EMF on the client side and allow both to share the same data model and
>>> to interchange data based on this model?
>> Not sure. The binary serialization that's produced by the standard
>> runtime should be consumable by the GWT client.
>>>
>>> Are two projects where each has its own .genmodel an option?
>> I'm not sure I understand this question... If you want to use the
>> standard runtime on the server, then I think you'll need a separated
>> generated model for that environment verses the generated model you use
>> in the GWT client.
>>>
>>> Thanks and Regards,
>>> Dirk
>>>
>>
>
Re: [GWT] Server-side XMLResource [message #1001950 is a reply to message #1001845] Thu, 17 January 2013 15:45 Go to previous messageGo to next message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Wow, a lot to chew.

So on the server side (compiled with standard EMF) the XMLResource would
do load(inputStream, options) and then save(outputStream, options) to a
ByteArrayOutputStream with OPTION_BINARY set to true. The byte array
from the ByteArrayOutputStream would then be returned to the client. On
the client side (compiled with EMF for GWT) the byte array would be fed
into a ByteArrayInputStream which would then be passed to the
load(inputStream, options) method of a newly created BinaryResourceImpl.

I'm curious if this will be debuggable in GWT's hosted mode.

Dirk

(Sorry for spamming your mail folder, Ed; never getting used to the
Followup button)
Am 17.01.2013 13:48, schrieb Ed Merks:
> Dirk,
>
> Comments below.
>
> On 17/01/2013 11:11 AM, Dirk Hoffmann wrote:
>> Hi Ed,
>>
>> the approach is now to deserialize on the server using standard EMF
>> and return that to the client somehow.
> BinaryResourceImpl should do the trick for the "somehow."
>>
>> I just added the standard ecore.xmi package to the dependencies to see
>> what happens. That gets me an Exception, more below...
>>
>> Am 16.01.2013 17:40, schrieb Ed Merks:
>>> Dirk,
>>>
>>> Comments below.
>>>
>>> On 16/01/2013 4:40 PM, Dirk Hoffmann wrote:
>>>> Hi,
>>>>
>>>> the scenario I'm evaluating is a follows.
>>>>
>>>> The service has a method that returns the root of a data structure
>>>> modelled with EMF.
>>>>
>>>> On the server side this method reads the XML file and turns it into
>>>> the data structure like so:
>>>>
>>>> ----- 8< --------------
>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>>>> Map<String, Object> extensionToFactory = resourceSet
>>>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>>>> extensionToFactory.put("xml", resourceFactory);
>>>>
>>>> // Dummy call just to register the package
>>>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>>>
>>>> Resource resource =
>>>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>>>
>>>> Map<String, Object> options = new HashMap<String, Object>();
>>>>
>>>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>>>
>> Up to here all went through
>>>> resource.load(inputStream, options);
>> This comes back with an InvocationTargetException with target pointing
>> to a SecurityException saying
>> class "org.eclipse.emf.ecore.xml.type.internal.QName"'s signer
>> information does not match signer information of other classes in the
>> same package.
> XMI depends on the standard EMF runtime, so you can't just mix that into
> the GWT compatible runtime...
>>
>> Not too surprising that it went wrong. This looks like if I had to
>> create a GWT version of the exore.xmi package (and maybe dependencies
>> as well) not to be run on the client but on the server just to make it
>> compatible with the emf.gwt jars.
> Yes, I suppose so. Differences in the Resource APIs (because of lack of
> support for Streams) is going to cause a problem...
>>
>> Any other ideas?
> Perhaps some kind of compatibility layer for the models you want to use
> in both contexts would work. I.e., something that depends on the
> standard *.emf.ecore and *.emf.common, but has the GWT bundle names and
> also include stubs for the GWT-specific things generated in the models
> would do the trick. Or maybe hand modify the generated manifest to use
> package imports rather than bundle imports so they can resolve
> differently depending on what's in your target platform. Then you'd
> only need some stubs to keep the compiler happy.
>
> So imagine that you have the same generated model in two different
> workspaces, one with the GWT runtime in the target platform and the
> other with the standard runtime in the target platform. It should be
> possible that the same generated model code could compile properly in
> both those workspace. All sharing of data between client and server
> could be accomplished with binary. Note that there's
> XMLResource.OPTION_BINARY which can be used to produce binary from an
> XMLResource.
>>
>> What is the easiest way today to download the sources of the EMF
>> projects?
> From http://git.eclipse.org/c/emf/org.eclipse.emf.git
>>
>> Dirk
>>
>>>> ----- >8 -------------------
>>>>
>>>> Well the problem is that there seems to be no XMLResource class in the
>>>> emf.gwt packages.
>>> Nor much in the way of something equivalent to SAX in the GWT runtime.
>>>>
>>>> Actually I even do not need that because on the server side there is
>>>> no need for JavaScript. My first idea was to simply let the project
>>>> depend on org.eclipse.emf.ecore.xmi but will it be a good idea to mix
>>>> non-GWT with GWT EMF packages?
>>> Probably not. I have no experience with that...
>>>>
>>>> I started off with the default GWT Web Application project which
>>>> creates the client as well as the server side inside the same project.
>>>> So how could I use regular EMF runtime jars on the server side and GWT
>>>> EMF on the client side and allow both to share the same data model and
>>>> to interchange data based on this model?
>>> Not sure. The binary serialization that's produced by the standard
>>> runtime should be consumable by the GWT client.
>>>>
>>>> Are two projects where each has its own .genmodel an option?
>>> I'm not sure I understand this question... If you want to use the
>>> standard runtime on the server, then I think you'll need a separated
>>> generated model for that environment verses the generated model you use
>>> in the GWT client.
>>>>
>>>> Thanks and Regards,
>>>> Dirk
>>>>
>>>
>>
>
Re: [GWT] Server-side XMLResource [message #1002234 is a reply to message #1001950] Fri, 18 January 2013 08:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26283
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Dirk,<br>
<br>
Comments below.<br>
<br>
<div class="moz-cite-prefix">On 17/01/2013 4:45 PM, Dirk Hoffmann
wrote:<br>
</div>
<blockquote cite="mid:kd96a0$c7o$1@xxxxxxxxe.org" type="cite">Wow,
a lot to chew.
<br>
<br>
So on the server side (compiled with standard EMF) the XMLResource
would do load(inputStream, options) and then save(outputStream,
options) to a ByteArrayOutputStream with OPTION_BINARY set to
true. The byte array from the ByteArrayOutputStream would then be
returned to the client. On the client side (compiled with EMF for
GWT) the byte array would be fed into a ByteArrayInputStream which
would then be passed to the load(inputStream, options) method of a
newly created BinaryResourceImpl.
<br>
</blockquote>
Yes, exactly.<br>
<blockquote cite="mid:kd96a0$c7o$1@xxxxxxxxe.org" type="cite">
<br>
I'm curious if this will be debuggable in GWT's hosted mode.
<br>
</blockquote>
Yes, you should be able to debug the client and server code.<br>
<blockquote cite="mid:kd96a0$c7o$1@xxxxxxxxe.org" type="cite">
<br>
Dirk
<br>
<br>
(Sorry for spamming your mail folder, Ed; never getting used to
the Followup button)
<br>
</blockquote>
Somehow I configured something (probably via the account
preferences) so I have a follow up button as the default like this:<br>
<blockquote><img src="http://www.eclipse.org/forums/index.php?t=getfile&amp;id=13012" alt=""><br>
</blockquote>
<blockquote cite="mid:kd96a0$c7o$1@xxxxxxxxe.org" type="cite">Am
17.01.2013 13:48, schrieb Ed Merks:
<br>
<blockquote type="cite">Dirk,
<br>
<br>
Comments below.
<br>
<br>
On 17/01/2013 11:11 AM, Dirk Hoffmann wrote:
<br>
<blockquote type="cite">Hi Ed,
<br>
<br>
the approach is now to deserialize on the server using
standard EMF
<br>
and return that to the client somehow.
<br>
</blockquote>
BinaryResourceImpl should do the trick for the "somehow."
<br>
<blockquote type="cite">
<br>
I just added the standard ecore.xmi package to the
dependencies to see
<br>
what happens. That gets me an Exception, more below...
<br>
<br>
Am 16.01.2013 17:40, schrieb Ed Merks:
<br>
<blockquote type="cite">Dirk,
<br>
<br>
Comments below.
<br>
<br>
On 16/01/2013 4:40 PM, Dirk Hoffmann wrote:
<br>
<blockquote type="cite">Hi,
<br>
<br>
the scenario I'm evaluating is a follows.
<br>
<br>
The service has a method that returns the root of a data
structure
<br>
modelled with EMF.
<br>
<br>
On the server side this method reads the XML file and
turns it into
<br>
the data structure like so:
<br>
<br>
----- 8&lt; --------------
<br>
ResourceSet resourceSet = new ResourceSetImpl();
<br>
Resource.Factory resourceFactory = new
XYResourceFactoryImpl();
<br>
Map&lt;String, Object&gt; extensionToFactory = resourceSet
<br>
 
.getResourceFactoryRegistry().getExtensionToFactoryMap();
<br>
extensionToFactory.put("xml", resourceFactory);
<br>
<br>
// Dummy call just to register the package
<br>
GenLegacyRenderingPackage.eINSTANCE.eClass();
<br>
<br>
Resource resource =
<br>
 
resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
<br>
<br>
Map&lt;String, Object&gt; options = new HashMap&lt;String,
Object&gt;();
<br>
<br>
options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,
Boolean.TRUE);
<br>
options.put(XMLResource.OPTION_DEFER_ATTACHMENT,
Boolean.TRUE);
<br>
options.put(XMLResource.OPTION_DISABLE_NOTIFY,
Boolean.TRUE);
<br>
options.put(XMLResource.OPTION_DISABLE_NOTIFY,
Boolean.TRUE);
<br>
options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE,
Boolean.TRUE);
<br>
<br>
</blockquote>
</blockquote>
Up to here all went through
<br>
<blockquote type="cite">
<blockquote type="cite">resource.load(inputStream, options);
<br>
</blockquote>
</blockquote>
This comes back with an InvocationTargetException with target
pointing
<br>
to a SecurityException saying
<br>
class "org.eclipse.emf.ecore.xml.type.internal.QName"'s signer
<br>
information does not match signer information of other classes
in the
<br>
same package.
<br>
</blockquote>
XMI depends on the standard EMF runtime, so you can't just mix
that into
<br>
the GWT compatible runtime...
<br>
<blockquote type="cite">
<br>
Not too surprising that it went wrong. This looks like if I
had to
<br>
create a GWT version of the exore.xmi package (and maybe
dependencies
<br>
as well) not to be run on the client but on the server just to
make it
<br>
compatible with the emf.gwt jars.
<br>
</blockquote>
Yes, I suppose so.  Differences in the Resource APIs (because of
lack of
<br>
support for Streams) is going to cause a problem...
<br>
<blockquote type="cite">
<br>
Any other ideas?
<br>
</blockquote>
Perhaps some kind of compatibility layer for the models you want
to use
<br>
in both contexts would work.  I.e., something that depends on
the
<br>
standard *.emf.ecore and *.emf.common,  but has the GWT bundle
names and
<br>
also include stubs for the GWT-specific things generated in the
models
<br>
would do the trick.   Or maybe hand modify the generated
manifest to use
<br>
package imports rather than bundle imports so they can resolve
<br>
differently depending on what's in your target platform.  Then
you'd
<br>
only need some stubs to keep the compiler happy.
<br>
<br>
So imagine that you have the same generated model in two
different
<br>
workspaces, one with the GWT runtime in the target platform and
the
<br>
other with the standard runtime in the target platform.  It
should be
<br>
possible that the same generated model code could compile
properly in
<br>
both those workspace.  All sharing of data between client and
server
<br>
could be accomplished with binary.  Note that there's
<br>
XMLResource.OPTION_BINARY which can be used to produce binary
from an
<br>
XMLResource.
<br>
<blockquote type="cite">
<br>
What is the easiest way today to download the sources of the
EMF
<br>
projects?
<br>
</blockquote>
 From <a class="moz-txt-link-freetext" href="http://git.eclipse.org/c/emf/org.eclipse.emf.git">http://git.eclipse.org/c/emf/org.eclipse.emf.git</a>
<br>
<blockquote type="cite">
<br>
Dirk
<br>
<br>
<blockquote type="cite">
<blockquote type="cite">----- &gt;8 -------------------
<br>
<br>
Well the problem is that there seems to be no XMLResource
class in the
<br>
emf.gwt packages.
<br>
</blockquote>
Nor much in the way of something equivalent to SAX in the
GWT runtime.
<br>
<blockquote type="cite">
<br>
Actually I even do not need that because on the server
side there is
<br>
no need for JavaScript. My first idea was to simply let
the project
<br>
depend on org.eclipse.emf.ecore.xmi but will it be a good
idea to mix
<br>
non-GWT with GWT EMF packages?
<br>
</blockquote>
Probably not.  I have no experience with that...
<br>
<blockquote type="cite">
<br>
I started off with the default GWT Web Application project
which
<br>
creates the client as well as the server side inside the
same project.
<br>
So how could I use regular EMF runtime jars on the server
side and GWT
<br>
EMF on the client side and allow both to share the same
data model and
<br>
to interchange data based on this model?
<br>
</blockquote>
Not sure.  The binary serialization that's produced by the
standard
<br>
runtime should be consumable by the GWT client.
<br>
<blockquote type="cite">
<br>
Are two projects where each has its own .genmodel an
option?
<br>
</blockquote>
I'm not sure I understand this question...   If you want to
use the
<br>
standard runtime on the server, then I think you'll need a
separated
<br>
generated model for that environment verses the generated
model you use
<br>
in the GWT client.
<br>
<blockquote type="cite">
<br>
Thanks and Regards,
<br>
Dirk
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>
  • Attachment: gfaifdha.png
    (Size: 7.03KB, Downloaded 54 times)
Re: [GWT] Server-side XMLResource [message #1003498 is a reply to message #1002234] Mon, 21 January 2013 11:20 Go to previous message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Hi Ed,

this is how it went on:

I started creating a "DomResource" interface and its implementation
before I realized that DOM is already supported through XMLResource.

So I tried to convert ecore.xmi into its GWT counterpart. I managed to
remove all compile problems and finally got it running.

I had to modify the source code of EFactoryImpl in the gwt.ecore package
so it can run on the server as well as on the client. I have attached
the piece of code I modified. It is in the static initializer at the
bottom of the file.

I've chosen the DOM approach for the server just to see how it would go
if I moved the loading of the model from the XML contents to the server.
I could have done it with SAX as well I believe. If I really want to use
my new gwt.ecore.xmi package on the client I need to create a variation
of it because on the client the DOM classes are not located under
org.w3c.dom but under com.google.gwt.dom.client.

Should I find the time to try the BinaryResourceImpl approach I will let
you know.

Thanks so far,
Dirk



Am 18.01.2013 09:16, schrieb Ed Merks:
> Dirk,
>
> Comments below.
>
> On 17/01/2013 4:45 PM, Dirk Hoffmann wrote:
>> Wow, a lot to chew.
>>
>> So on the server side (compiled with standard EMF) the XMLResource
>> would do load(inputStream, options) and then save(outputStream,
>> options) to a ByteArrayOutputStream with OPTION_BINARY set to true.
>> The byte array from the ByteArrayOutputStream would then be returned
>> to the client. On the client side (compiled with EMF for GWT) the byte
>> array would be fed into a ByteArrayInputStream which would then be
>> passed to the load(inputStream, options) method of a newly created
>> BinaryResourceImpl.
> Yes, exactly.
>>
>> I'm curious if this will be debuggable in GWT's hosted mode.
> Yes, you should be able to debug the client and server code.
>>
>> Dirk
>>
>> (Sorry for spamming your mail folder, Ed; never getting used to the
>> Followup button)
> Somehow I configured something (probably via the account preferences) so
> I have a follow up button as the default like this:
>
>
>> Am 17.01.2013 13:48, schrieb Ed Merks:
>>> Dirk,
>>>
>>> Comments below.
>>>
>>> On 17/01/2013 11:11 AM, Dirk Hoffmann wrote:
>>>> Hi Ed,
>>>>
>>>> the approach is now to deserialize on the server using standard EMF
>>>> and return that to the client somehow.
>>> BinaryResourceImpl should do the trick for the "somehow."
>>>>
>>>> I just added the standard ecore.xmi package to the dependencies to see
>>>> what happens. That gets me an Exception, more below...
>>>>
>>>> Am 16.01.2013 17:40, schrieb Ed Merks:
>>>>> Dirk,
>>>>>
>>>>> Comments below.
>>>>>
>>>>> On 16/01/2013 4:40 PM, Dirk Hoffmann wrote:
>>>>>> Hi,
>>>>>>
>>>>>> the scenario I'm evaluating is a follows.
>>>>>>
>>>>>> The service has a method that returns the root of a data structure
>>>>>> modelled with EMF.
>>>>>>
>>>>>> On the server side this method reads the XML file and turns it into
>>>>>> the data structure like so:
>>>>>>
>>>>>> ----- 8< --------------
>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>> Resource.Factory resourceFactory = new XYResourceFactoryImpl();
>>>>>> Map<String, Object> extensionToFactory = resourceSet
>>>>>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>>>>>> extensionToFactory.put("xml", resourceFactory);
>>>>>>
>>>>>> // Dummy call just to register the package
>>>>>> GenLegacyRenderingPackage.eINSTANCE.eClass();
>>>>>>
>>>>>> Resource resource =
>>>>>> resourceSet.createResource(URI.createFileURI("DUMMY.xml"));
>>>>>>
>>>>>> Map<String, Object> options = new HashMap<String, Object>();
>>>>>>
>>>>>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>>>>>> options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
>>>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>>>> options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE);
>>>>>> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
>>>>>>
>>>> Up to here all went through
>>>>>> resource.load(inputStream, options);
>>>> This comes back with an InvocationTargetException with target pointing
>>>> to a SecurityException saying
>>>> class "org.eclipse.emf.ecore.xml.type.internal.QName"'s signer
>>>> information does not match signer information of other classes in the
>>>> same package.
>>> XMI depends on the standard EMF runtime, so you can't just mix that into
>>> the GWT compatible runtime...
>>>>
>>>> Not too surprising that it went wrong. This looks like if I had to
>>>> create a GWT version of the exore.xmi package (and maybe dependencies
>>>> as well) not to be run on the client but on the server just to make it
>>>> compatible with the emf.gwt jars.
>>> Yes, I suppose so. Differences in the Resource APIs (because of lack of
>>> support for Streams) is going to cause a problem...
>>>>
>>>> Any other ideas?
>>> Perhaps some kind of compatibility layer for the models you want to use
>>> in both contexts would work. I.e., something that depends on the
>>> standard *.emf.ecore and *.emf.common, but has the GWT bundle names and
>>> also include stubs for the GWT-specific things generated in the models
>>> would do the trick. Or maybe hand modify the generated manifest to use
>>> package imports rather than bundle imports so they can resolve
>>> differently depending on what's in your target platform. Then you'd
>>> only need some stubs to keep the compiler happy.
>>>
>>> So imagine that you have the same generated model in two different
>>> workspaces, one with the GWT runtime in the target platform and the
>>> other with the standard runtime in the target platform. It should be
>>> possible that the same generated model code could compile properly in
>>> both those workspace. All sharing of data between client and server
>>> could be accomplished with binary. Note that there's
>>> XMLResource.OPTION_BINARY which can be used to produce binary from an
>>> XMLResource.
>>>>
>>>> What is the easiest way today to download the sources of the EMF
>>>> projects?
>>> From http://git.eclipse.org/c/emf/org.eclipse.emf.git
>>>>
>>>> Dirk
>>>>
>>>>>> ----- >8 -------------------
>>>>>>
>>>>>> Well the problem is that there seems to be no XMLResource class in
>>>>>> the
>>>>>> emf.gwt packages.
>>>>> Nor much in the way of something equivalent to SAX in the GWT runtime.
>>>>>>
>>>>>> Actually I even do not need that because on the server side there is
>>>>>> no need for JavaScript. My first idea was to simply let the project
>>>>>> depend on org.eclipse.emf.ecore.xmi but will it be a good idea to mix
>>>>>> non-GWT with GWT EMF packages?
>>>>> Probably not. I have no experience with that...
>>>>>>
>>>>>> I started off with the default GWT Web Application project which
>>>>>> creates the client as well as the server side inside the same
>>>>>> project.
>>>>>> So how could I use regular EMF runtime jars on the server side and
>>>>>> GWT
>>>>>> EMF on the client side and allow both to share the same data model
>>>>>> and
>>>>>> to interchange data based on this model?
>>>>> Not sure. The binary serialization that's produced by the standard
>>>>> runtime should be consumable by the GWT client.
>>>>>>
>>>>>> Are two projects where each has its own .genmodel an option?
>>>>> I'm not sure I understand this question... If you want to use the
>>>>> standard runtime on the server, then I think you'll need a separated
>>>>> generated model for that environment verses the generated model you
>>>>> use
>>>>> in the GWT client.
>>>>>>
>>>>>> Thanks and Regards,
>>>>>> Dirk
>>>>>>
>>>>>
>>>>
>>>
>>
>


static {
try {
if (GWT.isClient()) {
// This only works on the client.
//
class ClientInternalEDateTimeFormat implements
InternalEDateTimeFormat {
DateTimeFormat dateTimeFormat;

ClientInternalEDateTimeFormat(DateTimeFormat dateTimeFormat) {
this.dateTimeFormat = dateTimeFormat;
}

public Date parse(String value) {
return dateTimeFormat.parse(value);
}

public String format(Date value) {
return dateTimeFormat.format(value);
}
}

EDATE_FORMATS = new InternalEDateTimeFormat[] {
new ClientInternalEDateTimeFormat(
DateTimeFormat
.getFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ")),
new ClientInternalEDateTimeFormat(
DateTimeFormat
.getFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS")),
new ClientInternalEDateTimeFormat(
DateTimeFormat
.getFormat("yyyy-MM-dd'T'HH:mm:ss")),
new ClientInternalEDateTimeFormat(
DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm")),
new ClientInternalEDateTimeFormat(
DateTimeFormat.getFormat("yyyy-MM-dd")) };
} else {
class ServerInternalEDateTimeFormat implements
InternalEDateTimeFormat {
DateFormat dateFormat;

ServerInternalEDateTimeFormat(DateFormat dateFormat) {
this.dateFormat = dateFormat;
}

public Date parse(String value) {
try {
return dateFormat.parse(value);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}

public String format(Date value) {
return dateFormat.format(value);
}
}

EDATE_FORMATS = new InternalEDateTimeFormat[] {
new ServerInternalEDateTimeFormat(new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'.'SSSZ")),
new ServerInternalEDateTimeFormat(new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'.'SSS")),
new ServerInternalEDateTimeFormat(new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss")),
new ServerInternalEDateTimeFormat(new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm")),
new ServerInternalEDateTimeFormat(new SimpleDateFormat(
"yyyy-MM-dd")) };
}
} catch (Throwable exception) {
// Ignore.
}
}
Previous Topic:[Teneo] One-To-One Mappings Ignoring Column Names
Next Topic:[CDO] Get negative version objects in CDOQuery
Goto Forum:
  


Current Time: Fri Dec 19 15:14:46 GMT 2014

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

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