Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Howto implement own serializiation format?
Howto implement own serializiation format? [message #556621] Thu, 02 September 2010 07:04 Go to next message
Michael Frey is currently offline Michael FreyFriend
Messages: 48
Registered: August 2010
Member
Hi,

I've created a ecore model from a mdl file, created the corresponding gencore file and generated the code from the gencore file. While EMF has a own serialization mechanism based on XMI I want to support my project with a own serializiation mechanism. I've had a look on the EMF book as well as on the FAQ but I haven't found what I'm looking for. Maybe somebody can point me into the right direction or to the corresponding section in the documentation for my intents?

Thanks in advance!
Regards,
Michael

[Updated on: Thu, 02 September 2010 07:40]

Report message to a moderator

Re: Howto implement own serializiation format? [message #556644 is a reply to message #556621] Thu, 02 September 2010 08:12 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You can define your own Resource system by implementing the Resource Interface. There, you can code your own loading/saving mechanism. You'll probably have to code your own resource factory that creates your resources and register that factory using the extension point org.eclipse.emf.ecore.extension_parser.
Re: Howto implement own serializiation format? [message #556647 is a reply to message #556644] Thu, 02 September 2010 08:21 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6481
Registered: July 2009
Senior Member
Hi Michael

On 02/09/2010 09:12, Sylvain EVEILLARD wrote:
> You can define your own Resource system by implementing the Resource
> Interface. There, you can code your own loading/saving mechanism. You'll
> probably have to code your own resource factory that creates your
> resources and register that factory using the extension point
> org.eclipse.emf.ecore.extension_parser.

If you set the Package/Model/Resource Type to XMI in genmodel when you
first genmodel, you will get all the framework and registration created
automatically.

Then set Resource Type back to None and then rewrite XXXResourceImpl.

Regards

Ed Willink
Re: Howto implement own serializiation format? [message #556658 is a reply to message #556644] Thu, 02 September 2010 08:48 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
Am 02.09.2010 10:12, schrieb Sylvain EVEILLARD:
> You can define your own Resource system by implementing the Resource Interface.
Please note that the JavaDoc of the Resource interface says:

* Clients must extend the default {@link org.eclipse.emf.ecore.resource.impl.ResourceImpl implementation},
* or one of its derived classes, since methods can and will be added to this API.

Cheers
/Eike


Re: Howto implement own serializiation format? [message #556746 is a reply to message #556658] Thu, 02 September 2010 13:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30546
Registered: July 2009
Senior Member
Yes, please don't directly implement the Resource interface. Extend
ResourceImpl and implement overrides for doSave and doLoad. You might
look at BinaryResourceImpl as an example of an alternative serialization.


Eike Stepper wrote:
> Am 02.09.2010 10:12, schrieb Sylvain EVEILLARD:
>> You can define your own Resource system by implementing the Resource
>> Interface.
> Please note that the JavaDoc of the Resource interface says:
>
> * Clients must extend the default {@link
> org.eclipse.emf.ecore.resource.impl.ResourceImpl implementation},
> * or one of its derived classes, since methods can and will be added
> to this API.
>
> Cheers
> /Eike
Re: Howto implement own serializiation format? [message #556773 is a reply to message #556621] Thu, 02 September 2010 15:02 Go to previous messageGo to next message
Michael Frey is currently offline Michael FreyFriend
Messages: 48
Registered: August 2010
Member
Thank you all for your replies!

Regards,
Michael
Re: Howto implement own serializiation format? [message #558818 is a reply to message #556621] Tue, 14 September 2010 14:21 Go to previous messageGo to next message
Michael Frey is currently offline Michael FreyFriend
Messages: 48
Registered: August 2010
Member
Hi,

I've tried to implement my own serialization format but I'm running into some trouble. I've got four projects which were generated from the genmodel.

- de.hs_rm.cs.vs.owl
- de.hs_rm.cs.vs.owl.edit
- de.hs_rm.cs.vs.owl.editor
- de.hs_rm.cs.vs.owl.tests

So far, I've done the following steps:

1. I've created a class OWLResourceFactoryImpl which implements Resource.Factory
2. Also I've created a class OWLResourceImpl which extends the ResourceImpl class and overwrites doSave and doLoad methods
3. I've added a extension point to de.hs_rm.cs.vs.owl plugin:

<extension point="org.eclipse.emf.ecore.extension_parser">
   <parser type="owl" class="owl.util.OWLResourceFactoryImpl">
</extension>


If I try to run the code I get a NoClassDefFoundError (the exception is caused while I'm calling the constructor of OWLResourceImpl in the OWLResourceFactoryImpl createResource method).

I've had a look on the EMF book and there is a description in the EMF Persistence API chapter (pages 457 and following). The book states that I should for stand alone applications add the following code:

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("owl", new OWLResourceFactoryImpl());


I'm not really sure where I should put the code. I've added the code in the createModel() method in the OWLEditor class in the de.hs_rm.cs.vs.owl.editor plugin but I'm not really sure that this is the right place. If I run the code as eclipse application I get still the NoClassDefFoundError Exception So probably that was not the right place to put the code.

Maybe somebody knows what I'm missing? Thanks in advance!
Michael

[Updated on: Tue, 14 September 2010 14:39]

Report message to a moderator

Re: Howto implement own serializiation format? [message #558825 is a reply to message #558818] Tue, 14 September 2010 14:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30546
Registered: July 2009
Senior Member
Michael,

Comments below.

Michael Frey wrote:
> Hi,
>
> I've tried to implement my own serialization format but I'm running
> into some trouble. I've got four projects which were generated from
> the genmodel.
>
> - de.hs_rm.cs.vs.owl
> - de.hs_rm.cs.vs.owl.edit
> - de.hs_rm.cs.vs.owl.editor
> - de.hs_rm.cs.vs.owl.tests
>
> So far, I've done the following steps:
>
> 1. I've created a class OWLResourceFactoryImpl which implements
> Resource.Factory
> 2. Also I've created a class OWLResourceImpl which extends the
> ResourceImpl class and overwrites doSave and doLoad methods
> 3. I've added a extension point to de.hs_rm.cs.vs.owl plugin:
>
> <extension point="org.eclipse.emf.ecore.extension_parser">
> <parser type="owl" class="owl.util.OWLResourceFactoryImpl">
> </extension>
>
>
> If I try to run the code I get a NoClassDefFoundError if I try to call
> the constructor of OWLResourceImpl in the OWLResourceFactoryImpl
> createResource method.
That sounds more like a classpath issue. Is the util folder listed in
the bundle manifests's packages?
> I've had a look on the EMF book and there is a description in the EMF
> Persistence API chapter (pages 457 and following). The book states
> that I should for stand alone applications add the following code:
>
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "owl",
> new OWLResourceFactoryImpl());
>
>
> I'm not really sure where I should put the code.
Look at the XyzExample. java in the *.owl.tests project.
> I've added the code in the createModel() method in the OWLEditor class
> in the de.hs_rm.cs.vs.owl.editor plugin
The editor isn't stand alone though so no need for that.
> but I'm not really sure that this is the right place.
No.
> If I run the code as eclipse application I get an NullPointerException.
What's null?
> So probably that was not the right place to put the code.
>
> Maybe somebody knows what I'm missing? Thanks in advance!
Be sure the util package is an exported package.in the manifest.
> Michael
Re: Howto implement own serializiation format? [message #558829 is a reply to message #558825] Tue, 14 September 2010 14:52 Go to previous messageGo to next message
Michael Frey is currently offline Michael FreyFriend
Messages: 48
Registered: August 2010
Member
Hi,

Ed Merks wrote on Tue, 14 September 2010 10:29

That sounds more like a classpath issue. Is the util folder listed in
the bundle manifests's packages?
l


The util folder/package is exported in the manifest file.

Ed Merks wrote on Tue, 14 September 2010 10:29

Look at the XyzExample. java in the *.owl.tests project.
l


There is no such file.

Ed Merks wrote on Tue, 14 September 2010 10:29

The editor isn't stand alone though so no need for that.



I've removed it.

Ed Merks wrote on Tue, 14 September 2010 10:29

> but I'm not really sure that this is the right place.
No.



I've thought so.

Ed Merks wrote on Tue, 14 September 2010 10:29

> If I run the code as eclipse application I get an NullPointerException.
What's null?



Okay. I've fixed that. The problem was that I've added the wrong class to the getExtensionToFactoryMap, so the exception is still a NoClassDefFoundError Exception and it still seems that the class OwlResourceImpl is not found.

Ed Merks wrote on Tue, 14 September 2010 10:29

> Maybe somebody knows what I'm missing? Thanks in advance!
Be sure the util package is an exported package.in the manifest.



The package is exported. So the stacktrace states the exception is caused while I'm calling the constructor of OwlResourceImpl in the createResource method of the OwlResourceFactoryImpl class. Which confuses me most is the fact that both classes reside in the same package. Suggestions how to debug that? I've added a breakpoint to the constructor call but the next step is obviously the NoClassDefFoundError.

Regards,
Michael
Re: Howto implement own serializiation format? [message #558842 is a reply to message #556621] Tue, 14 September 2010 15:19 Go to previous messageGo to next message
Michael Frey is currently offline Michael FreyFriend
Messages: 48
Registered: August 2010
Member
Hi,

I've tracked the problem down. So far it seems to be a problem with the library I'm using in my OwlResourceFactoryImpl. I've would expected another exception. If I remove the corresponding code the methods for loading and saving are called.

I've added the lib directory (where the library resides) to the bundle classpath as well as to the binary build (bin.include in build.properties) and it's still not working.

*confused*
Michael

[Updated on: Tue, 14 September 2010 15:22]

Report message to a moderator

Re: Howto implement own serializiation format? [message #558855 is a reply to message #558842] Tue, 14 September 2010 15:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30546
Registered: July 2009
Senior Member
Michael,

Where does the library reside? Does it work in the runtime workbench?


Michael Frey wrote:
> Hi,
>
> I've tracked the problem down. So far it seems to be a problem with
> the library I'm using in my OwlResourceFactoryImpl. I've expected
> another exception but if I remove the corresponding code the methods
> for loading and saving are called.
> I've added the lib (where the library resides) to the bundle classpath
> as well as to the binary build (bin.include in build.properties) and
> it's still not working.
>
> Michael
Re: Howto implement own serializiation format? [message #558979 is a reply to message #558855] Wed, 15 September 2010 08:39 Go to previous messageGo to next message
Michael Frey is currently offline Michael FreyFriend
Messages: 48
Registered: August 2010
Member
Hi,

I've created a lib/ directory where I've put my library. The directory resides in my de.hs_rm.cs.vs.dsm.owl plugin. I've added the library to the build path (Project Properties -> Java Build Path) as well as to the bundle classpath (Manifest.mf) and to the bin.include section in the build.properties.

What exactley do you mean by runtime workbench? If I'm writing code in my plugin everything seems to work fine (packages and classes of the library are resolved by eclipse). If I run the plugins as eclipse application I get an NoClassesDefFoundError exception (and that's probably what you meant by runtime workbench). I've had a look on my run configuration and set the "Clear configuration area before launching" to true, but nothing changes.

I have no clue why it's not working.
Regards,
Michael
Re: Howto implement own serializiation format? [message #559213 is a reply to message #558979] Thu, 16 September 2010 02:28 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30546
Registered: July 2009
Senior Member
Michael,

Comments below.


Michael Frey wrote:
> Hi,
>
> I've created a lib/ directory where I've put my library. The directory
> resides in my de.hs_rm.cs.vs.dsm.owl plugin. I've added the library to
> the build path (Project Properties -> Java Build Path)
Don't ever do that. Edit only the MANIFEST.MF.
> as well as to the bundle classpath (Manifest.mf) and to the
> bin.include section in the build.properties.
That part sounds good, but if you made a mistake, the direct build path
update would mask it as compile time only for it to come back at runtime.
> What exactley do you mean by runtime workbench?
When you launch a second Eclipse in order to run or debug it.
> If I'm writing code in my plugin everything seems to work fine
> (packages and classes of the library are resolved by eclipse).
At build time...
> If I run the plugins as eclipse application I get an
> NoClassesDefFoundError exception (and that's probably what you meant
> by runtime workbench).
Yes.
> I've had a look on my run configuration and set the "Clear
> configuration area before launching" to true, but nothing changes.
> I have no clue why it's not working.
From the context menu for the project, use PDE Tools -> Update
Classpath to ensure that the build path reflects exactly what's in the
MANIFEST. If you have compile problems, fix them by editing the
MANIFEST.MF.

> Regards,
> Michael
Previous Topic:[CDO/Teneo] Mapping exception on Could not determine type for: org.eclipse.emf.teneo.hibernate.mappi
Next Topic:Re: [cdo] streaming large data?
Goto Forum:
  


Current Time: Wed Oct 16 09:14:16 GMT 2019

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

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

Back to the top