Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Sirius integration with EMFStore
Sirius integration with EMFStore [message #1389379] Fri, 27 June 2014 18:20 Go to next message
Olivier Labrosse is currently offline Olivier LabrosseFriend
Messages: 49
Registered: November 2011
Member
Hi,

We're trying to convert our XMI file-based app into an ECP/EMFStore app, but I'm getting Sirius issues (pardon the pun) with regards to the emfstore URI that the semantic resource now has.

At first I tried getting the SessionManager to create the Session in the EMFStore, but it failed due to the TransactionalEditingDomain's ResourceSet not having a URIConverter that supports emfstore URIs. I resorted to keeping the .aird file saved in the workspace for now; the Session gets created fine.

Then comes the time to add the semantic resource to the Session. Again the emfstore URI causes issues. Even if I "hack" the Session's URIConverter (basically set it to that of the semantic resource), createInputStream() fails due to a lack of URLStreamHandler handling the emfstore protocol. Here's the stack trace:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.net.MalformedURLException: unknown protocol: emfstore
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
	at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.addSemanticResource(DAnalysisSessionImpl.java:731)
	at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.addSemanticResource(DAnalysisSessionImpl.java:744)
	at com.castortech.ba.sirius.BaSiriusUtils$1.run(BaSiriusUtils.java:73)
	at com.castortech.ba.sirius.BaSiriusUtils.runInTransaction(BaSiriusUtils.java:123)
	at com.castortech.ba.sirius.BaSiriusUtils.getSession(BaSiriusUtils.java:69)
	...
Caused by: java.net.MalformedURLException: unknown protocol: emfstore
	at java.net.URL.<init>(URL.java:592)
	at java.net.URL.<init>(URL.java:482)
	at java.net.URL.<init>(URL.java:431)
	at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URIHandlerImpl.java:199)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1269)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	... 56 more


I need a little hand understanding what can be done to make it all work nicely. Any help will be much appreciated.

Best regards,

-Olivier
Re: Sirius integration with EMFStore [message #1391097 is a reply to message #1389379] Mon, 30 June 2014 12:41 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 270
Registered: August 2010
Senior Member
Hi Olivier,

Having taken a look at EMFStore project, it seems that it provides its
own URIConverter
(org.eclipse.emf.emfstore.internal.client.provider.XMIClientURIConverter) when
creating its Resourceset. The emfstore protocol seems to be handled by
this URIConverter. In the Sirius context, the session uses its own
resourceset with a specific URIConverter so the EMFStore URIConverter is
never installed.

You could provides your own
org.eclipse.sirius.common.tools.api.resource.ResourceSetFactory and
install a specific URIConverter for emfstore URIs. That has already been
done before, to integrate XText with Sirius. You should take a look on
org.eclipse.sirius.common.xtext.internal.XtextResourceSetFactory which
is registered in org.eclipse.sirius.common.xtext:
<extension
point="org.eclipse.sirius.common.resourceSetFactory">
<factory

class="org.eclipse.sirius.common.xtext.internal.XTextResourceSetFactory">
</factory>
</extension>

An other solution could be providing your own protocol parser as it is
done with org.eclipse.sirius.tools.internal.uri.ViewpointProtocolParser.
See org.eclipse.emf.ecore.protocol_parser extension point for more details.

Regards,

Florian

On 06/27/2014 08:20 PM, Olivier Labrosse wrote:
> Hi,
>
> We're trying to convert our XMI file-based app into an ECP/EMFStore app,
> but I'm getting Sirius issues (pardon the pun) with regards to the
> emfstore URI that the semantic resource now has.
>
> At first I tried getting the SessionManager to create the Session in the
> EMFStore, but it failed due to the TransactionalEditingDomain's
> ResourceSet not having a URIConverter that supports emfstore URIs. I
> resorted to keeping the .aird file saved in the workspace for now; the
> Session gets created fine.
>
> Then comes the time to add the semantic resource to the Session. Again
> the emfstore URI causes issues. Even if I "hack" the Session's
> URIConverter (basically set it to that of the semantic resource),
> createInputStream() fails due to a lack of URLStreamHandler handling the
> emfstore protocol. Here's the stack trace:
>
>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException:
> java.net.MalformedURLException: unknown protocol: emfstore
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
>
> at
> org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.addSemanticResource(DAnalysisSessionImpl.java:731)
>
> at
> org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.addSemanticResource(DAnalysisSessionImpl.java:744)
>
> at com.castortech.ba.sirius.BaSiriusUtils$1.run(BaSiriusUtils.java:73)
> at
> com.castortech.ba.sirius.BaSiriusUtils.runInTransaction(BaSiriusUtils.java:123)
>
> at
> com.castortech.ba.sirius.BaSiriusUtils.getSession(BaSiriusUtils.java:69)
> ...
> Caused by: java.net.MalformedURLException: unknown protocol: emfstore
> at java.net.URL.<init>(URL.java:592)
> at java.net.URL.<init>(URL.java:482)
> at java.net.URL.<init>(URL.java:431)
> at
> org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URIHandlerImpl.java:199)
>
> at
> org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1269)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
>
> ... 56 more
>
>
> I need a little hand understanding what can be done to make it all work
> nicely. Any help will be much appreciated.
>
> Best regards,
>
> -Olivier

[Updated on: Mon, 30 June 2014 13:46]

Report message to a moderator

Re: Sirius integration with EMFStore [message #1407891 is a reply to message #1391097] Wed, 13 August 2014 18:15 Go to previous messageGo to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 266
Registered: July 2009
Senior Member
Bonjour Florian,

Thanks for your very informative and accurate pointers, which I used to implement a solution.

But I encountered 2 small issues in the Sirius codebase that needs to be fixed in order to make this work. I am attaching a patch created against the latest nightly.

The 1st issue is that a ResourceSet was created without using the factory, which didn't return the right one, and the next is that you are adding some monitored URI handler but then changing the URI converter instead of just being satisfied of having added new URI handlers at the head of the list.

One last thing, when you are adding those 2 monitored URI handler, you are setting the monitor on only one of them. Not sure if that is the intended behavior.

Cheers,
Alain

Re: Sirius integration with EMFStore [message #1408093 is a reply to message #1407891] Thu, 14 August 2014 07:55 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi Alain,

In SessionFactory we use a simple ResourceSetImpl to create the aird
resource because by default it is a XMIResource and this last has its
factory, XMIResourceFactoryImpl registered by the
org.eclipse.emf.ecore.protocol_parser extension point. For other type of
resource you should have a factory registrered through the same
extension point. See the other example,
org.eclipse.sirius.tools.internal.resource.InMemoryResourceFactoryImpl.

Why do you have not a specific Resource type for your URI?
Can you give an example of URI you use?
About the ResourceSetUtil you are right, we set the monitor only on the
last handler and we should not reset the ResourceSet's URIConverter but
should test if the existing one is a ExtensibleURIConverterImpl to
update its URIHandlers.
Could you raise a bugzilla about these 2 issues with a scenario?

Best Regards.

Le 13/08/2014 20:15, Alain Picard a écrit :
> Bonjour Florian,
>
> Thanks for your very informative and accurate pointers, which I used to implement a solution.
>
> But I encountered 2 small issues in the Sirius codebase that needs to be fixed in order to make this work. I am attaching a patch created against the latest nightly.
>
> The 1st issue is that a ResourceSet was created without using the factory, which didn't return the right one, and the next is that you are adding some monitored URI handler but then changing the URI converter instead of just being satisfied of having added new URI handlers at the head of the list.
>
> One last thing, when you are adding those 2 monitored URI handler, you are setting the monitor on only one of them. Not sure if that is the intended behavior.
>
> Cheers,
> Alain
>
>


--
Esteban Dugueperoux - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Sirius integration with EMFStore [message #1409234 is a reply to message #1408093] Sun, 17 August 2014 14:02 Go to previous messageGo to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 266
Registered: July 2009
Senior Member
Hi Esteban,

It appears that my last posting wasn't posted correctly, so let me try again.

First, the context is the one reported by Olivier (we work together) in this thread, namely the use of EMFStore.

As both you and Florian suggested we do have the protocol_parser extension point, but this is on the resource factory.

The problem that we are facing here, to the best of my understanding, is that EMFStore uses a specific URI converter a the URI Converter is tied to the ResourceSet and not the resource. So in order for a resource to be created correctly, it has to be handled by the correct resource set.

So if you use the resource set factory with the URI to create the factory, you will get the correct resource set with the appropriate URI converter and the resource emanating from it will behave correctly.

But let's ask the question differently. What would you want to keep making assumption about dealing with XMIResource and not apply the best practice of getting your resource set through the factory et voila, everything works in a broader context ?

Cheers,
Alain

Re: Sirius integration with EMFStore [message #1409462 is a reply to message #1409234] Mon, 18 August 2014 07:03 Go to previous message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Indeed we don't manage ResourceSet's URIConverter case, could you raise
a bugzilla?

Thanks.

Le 17/08/2014 16:02, Alain Picard a écrit :
> Hi Esteban,
>
> It appears that my last posting wasn't posted correctly, so let me try
> again.
>
> First, the context is the one reported by Olivier (we work together) in
> this thread, namely the use of EMFStore.
>
> As both you and Florian suggested we do have the protocol_parser
> extension point, but this is on the resource factory.
>
> The problem that we are facing here, to the best of my understanding, is
> that EMFStore uses a specific URI converter a the URI Converter is tied
> to the ResourceSet and not the resource. So in order for a resource to
> be created correctly, it has to be handled by the correct resource set.
>
> So if you use the resource set factory with the URI to create the
> factory, you will get the correct resource set with the appropriate URI
> converter and the resource emanating from it will behave correctly.
>
> But let's ask the question differently. What would you want to keep
> making assumption about dealing with XMIResource and not apply the best
> practice of getting your resource set through the factory et voila,
> everything works in a broader context ?
>
> Cheers,
> Alain
>
>


--
Esteban Dugueperoux - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Container - Sub Container Creation
Next Topic:Open Model in Editor programmatically
Goto Forum:
  


Current Time: Tue Mar 19 06:25:29 GMT 2024

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

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

Back to the top