Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Mapping a file to my own protocol resource
Mapping a file to my own protocol resource [message #491264] Tue, 13 October 2009 20:43 Go to next message
Sandro Boehme is currently offline Sandro BoehmeFriend
Messages: 95
Registered: July 2009
Member
Hello,

the usecase I'm working on is that a file should be loaded using my
org.eclipse.emf.ecore.resource.Resource.Factory implementation.
I was assuming that I can simply use the following extension points for
that:

<extension
point="org.eclipse.emf.ecore.uri_mapping">
<mapping
source="platform:/resource/JCRMDemo/my.mydomainmodel"
target="jcrm:/test/my.jcr">
</mapping>
</extension>
<extension
point="org.eclipse.emf.ecore.protocol_parser">
<parser

class="org.eclipse.emf.jcrm.repoconn.RepoconnResourceFactoryImpl "
protocolName="jcrm">
</parser>
</extension>

The first one would map the file to my protocol and the second one would
specify my resource factory for the protocol. But the resource or
ExtensibleURIConverterImpl.normalize(URI uri) or
ResourceFactoryRegistryImpl.getFactory(URI...) are never called and if I
open the file its just opened like a simple text file. Is there
something wrong with my mapping definition?
Or can somebody please tell me how to specify a mapping from an
arbitrary file to my resource using an own protocol?
I'm looking forward to your feedback!

Best,

Sandro
Re: Mapping a file to my own protocol resource [message #491304 is a reply to message #491264] Wed, 14 October 2009 05:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000607060209010104070507
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Sandro,

Comments below.


Sandro B


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Mapping a file to my own protocol resource [message #491319 is a reply to message #491304] Wed, 14 October 2009 07:04 Go to previous messageGo to next message
Sandro Boehme is currently offline Sandro BoehmeFriend
Messages: 95
Registered: July 2009
Member
Hi Ed,

thanks for your feedback.
My comments are inline.

Ed Merks schrieb:
> Sandro,
>
> Comments below.
>
>
> Sandro Böhme wrote:
>> Hello,
>>
>> the usecase I'm working on is that a file should be loaded using my
>> org.eclipse.emf.ecore.resource.Resource.Factory implementation.
>> I was assuming that I can simply use the following extension points
>> for that:
>>
>> <extension
>> point="org.eclipse.emf.ecore.uri_mapping">
>> <mapping
>> source="platform:/resource/JCRMDemo/my.mydomainmodel"
>> target="jcrm:/test/my.jcr">
>> </mapping>
>> </extension>
> It seems odd though to have a registered mapping for something in a
> workspace...
>> <extension
>> point="org.eclipse.emf.ecore.protocol_parser">
>> <parser
>>
>> class="org.eclipse.emf.jcrm.repoconn.RepoconnResourceFactoryImpl "
>> protocolName="jcrm">
>> </parser>
>> </extension>
>>
>> The first one would map the file to my protocol and the second one
>> would specify my resource factory for the protocol. But the resource
>> or ExtensibleURIConverterImpl.normalize(URI uri) or
>> ResourceFactoryRegistryImpl.getFactory(URI...) are never called and if
>> I open the file its just opened like a simple text file.
> The editor does this:
>
> public void createModel()
> {
> URI resourceURI = EditUIUtil.getURI(getEditorInput());
> Exception exception = null;
> Resource resource = null;
> try
> {
> // Load the resource through the editing domain.
> //
> resource =
> editingDomain.getResourceSet().*getResource*(resourceURI, true);
>
> and the resource set does this
>
> public Resource getResource(URI uri, boolean loadOnDemand)
> {
> Map<URI, Resource> map = getURIResourceMap();
> if (map != null)
> {
> Resource resource = map.get(uri);
> if (resource != null)
> {
> if (loadOnDemand && !resource.isLoaded())
> {
> demandLoadHelper(resource);
> }
> return resource;
> }
> }
>
> URIConverter theURIConverter = getURIConverter();
> URI normalizedURI = theURIConverter.*normalize*(uri);
>
> so normalize must be getting called.
I will have a look in the ResourceSetImpl to see why my factory isn't
called.

>> Is there something wrong with my mapping definition?
> Hard coding one specific resource in the workspace doesn't seem right.
I'm working on a repository connection configuration editor that can be
used to open a repository. But most modeling tools do rely on workspace
resources for models as you know. This is why I'm working on a way that
a user can define a mapping from his file to a repository connection
configuration (an URI). This way the tools can work on the files while
behind the scenes they working on a repository.

>> Or can somebody please tell me how to specify a mapping from an
>> arbitrary file to my resource using an own protocol?
> I think you'd be better to do that in your editor's createModel method.
> Another trick people have used is to write repository into the workspace
I'm not sure what you mean with writing repository into the workspace.
You mean something like writing the repository configuration into file,
registering the file extention to a resource and opening the repo with
the configuration in the file?

> resource so that the workspace resource works more like a link. After
> all, if you have a workspace in the resource, what's actually there?
Nothing ;-)

>> I'm looking forward to your feedback!
>>
>> Best,
>>
>> Sandro

Best,

Sandro
Re: Mapping a file to my own protocol resource [message #491329 is a reply to message #491319] Wed, 14 October 2009 07:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Sandro,

Comments below.

Sandro Böhme wrote:
> Hi Ed,
>
> thanks for your feedback.
> My comments are inline.
>
> Ed Merks schrieb:
>> Sandro,
>>
>> Comments below.
>>
>>
>> Sandro Böhme wrote:
>>> Hello,
>>>
>>> the usecase I'm working on is that a file should be loaded using my
>>> org.eclipse.emf.ecore.resource.Resource.Factory implementation.
>>> I was assuming that I can simply use the following extension points
>>> for that:
>>>
>>> <extension
>>> point="org.eclipse.emf.ecore.uri_mapping">
>>> <mapping
>>> source="platform:/resource/JCRMDemo/my.mydomainmodel"
>>> target="jcrm:/test/my.jcr">
>>> </mapping>
>>> </extension>
>> It seems odd though to have a registered mapping for something in a
>> workspace...
>>> <extension
>>> point="org.eclipse.emf.ecore.protocol_parser">
>>> <parser
>>>
>>> class="org.eclipse.emf.jcrm.repoconn.RepoconnResourceFactoryImpl "
>>> protocolName="jcrm">
>>> </parser>
>>> </extension>
>>>
>>> The first one would map the file to my protocol and the second one
>>> would specify my resource factory for the protocol. But the resource
>>> or ExtensibleURIConverterImpl.normalize(URI uri) or
>>> ResourceFactoryRegistryImpl.getFactory(URI...) are never called and
>>> if I open the file its just opened like a simple text file.
>> The editor does this:
>>
>> public void createModel()
>> {
>> URI resourceURI = EditUIUtil.getURI(getEditorInput());
>> Exception exception = null;
>> Resource resource = null;
>> try
>> {
>> // Load the resource through the editing domain.
>> //
>> resource =
>> editingDomain.getResourceSet().*getResource*(resourceURI, true);
>>
>> and the resource set does this
>>
>> public Resource getResource(URI uri, boolean loadOnDemand)
>> {
>> Map<URI, Resource> map = getURIResourceMap();
>> if (map != null)
>> {
>> Resource resource = map.get(uri);
>> if (resource != null)
>> {
>> if (loadOnDemand && !resource.isLoaded())
>> {
>> demandLoadHelper(resource);
>> }
>> return resource;
>> }
>> }
>>
>> URIConverter theURIConverter = getURIConverter();
>> URI normalizedURI = theURIConverter.*normalize*(uri);
>>
>> so normalize must be getting called.
> I will have a look in the ResourceSetImpl to see why my factory isn't
> called.
The debugger generally answers questions faster than me. :-P
>
>>> Is there something wrong with my mapping definition?
>> Hard coding one specific resource in the workspace doesn't seem right.
> I'm working on a repository connection configuration editor that can
> be used to open a repository. But most modeling tools do rely on
> workspace resources for models as you know. This is why I'm working on
> a way that a user can define a mapping from his file to a repository
> connection configuration (an URI). This way the tools can work on the
> files while behind the scenes they working on a repository.
It seems better to try to open such editors with your own URI rather
than try to divert them from opening the expected resource.
EditUIUtil.getURI is called for EMF generated editors so it's possible
to pass in a URIEditorInput.; I'm not sure if GMF editors support other
forms for IEditorInput...
>
>>> Or can somebody please tell me how to specify a mapping from an
>>> arbitrary file to my resource using an own protocol?
>> I think you'd be better to do that in your editor's createModel
>> method. Another trick people have used is to write repository into
>> the workspace
> I'm not sure what you mean with writing repository into the workspace.
> You mean something like writing the repository configuration into
> file, registering the file extention to a resource and opening the
> repo with the configuration in the file?
Yes.
>
>> resource so that the workspace resource works more like a link.
>> After all, if you have a workspace in the resource, what's actually
>> there?
> Nothing ;-)
That seems problematic. After all, the wizard create the resource so
how will redirecting to a repository still provide access to what's
initially in the resource?
>
>>> I'm looking forward to your feedback!
>>>
>>> Best,
>>>
>>> Sandro
>
> Best,
>
> Sandro


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Mapping a file to my own protocol resource [message #491367 is a reply to message #491329] Wed, 14 October 2009 11:02 Go to previous messageGo to next message
Sandro Boehme is currently offline Sandro BoehmeFriend
Messages: 95
Registered: July 2009
Member
Ed Merks schrieb:
> Sandro,
>
> Comments below.
>
> Sandro Böhme wrote:
>> Hi Ed,
>>
>> thanks for your feedback.
>> My comments are inline.
>>
>> Ed Merks schrieb:
>>> Sandro,
>>>
>>> Comments below.
>>>
>>>
>>> Sandro Böhme wrote:
>>>> Hello,
>>>>
>>>> the usecase I'm working on is that a file should be loaded using my
>>>> org.eclipse.emf.ecore.resource.Resource.Factory implementation.
>>>> I was assuming that I can simply use the following extension points
>>>> for that:
>>>>
>>>> <extension
>>>> point="org.eclipse.emf.ecore.uri_mapping">
>>>> <mapping
>>>> source="platform:/resource/JCRMDemo/my.mydomainmodel"
>>>> target="jcrm:/test/my.jcr">
>>>> </mapping>
>>>> </extension>
>>> It seems odd though to have a registered mapping for something in a
>>> workspace...
>>>> <extension
>>>> point="org.eclipse.emf.ecore.protocol_parser">
>>>> <parser
>>>>
>>>> class="org.eclipse.emf.jcrm.repoconn.RepoconnResourceFactoryImpl "
>>>> protocolName="jcrm">
>>>> </parser>
>>>> </extension>
>>>>
>>>> The first one would map the file to my protocol and the second one
>>>> would specify my resource factory for the protocol. But the resource
>>>> or ExtensibleURIConverterImpl.normalize(URI uri) or
>>>> ResourceFactoryRegistryImpl.getFactory(URI...) are never called and
>>>> if I open the file its just opened like a simple text file.
>>> The editor does this:
>>>
>>> public void createModel()
>>> {
>>> URI resourceURI = EditUIUtil.getURI(getEditorInput());
>>> Exception exception = null;
>>> Resource resource = null;
>>> try
>>> {
>>> // Load the resource through the editing domain.
>>> //
>>> resource =
>>> editingDomain.getResourceSet().*getResource*(resourceURI, true);
>>>
>>> and the resource set does this
>>>
>>> public Resource getResource(URI uri, boolean loadOnDemand)
>>> {
>>> Map<URI, Resource> map = getURIResourceMap();
>>> if (map != null)
>>> {
>>> Resource resource = map.get(uri);
>>> if (resource != null)
>>> {
>>> if (loadOnDemand && !resource.isLoaded())
>>> {
>>> demandLoadHelper(resource);
>>> }
>>> return resource;
>>> }
>>> }
>>>
>>> URIConverter theURIConverter = getURIConverter();
>>> URI normalizedURI = theURIConverter.*normalize*(uri);
>>>
>>> so normalize must be getting called.
>> I will have a look in the ResourceSetImpl to see why my factory isn't
>> called.
> The debugger generally answers questions faster than me. :-P
I wouldn't bet on it ;-)
I didn't expect an answer. Right now I have a break at work and will
dive into it after work. (as always)

>>
>>>> Is there something wrong with my mapping definition?
>>> Hard coding one specific resource in the workspace doesn't seem right.
>> I'm working on a repository connection configuration editor that can
>> be used to open a repository. But most modeling tools do rely on
>> workspace resources for models as you know. This is why I'm working on
>> a way that a user can define a mapping from his file to a repository
>> connection configuration (an URI). This way the tools can work on the
>> files while behind the scenes they working on a repository.
> It seems better to try to open such editors with your own URI rather
> than try to divert them from opening the expected resource.
> EditUIUtil.getURI is called for EMF generated editors so it's possible
> to pass in a URIEditorInput.; I'm not sure if GMF editors support other
> forms for IEditorInput...
The editor of the connection configuration (concon) model already uses
the URIEditorInput to pass on the connection configuration URI (concon
URI) to the repo-editor to be opened. This way the user can open a
repo-editor without depending on a file that redirects to the repo.

I have seen for example an Eclipse model to model transformation tool
where you can choose a file as a source and as a target. It should be
able with JCRM to create a source and a target file of your choice and
map it to a repository. This way the model to model transformation tool
and other tools can work on those files while they are actually
redirected to a java content repository.

>>
>>>> Or can somebody please tell me how to specify a mapping from an
>>>> arbitrary file to my resource using an own protocol?
>>> I think you'd be better to do that in your editor's createModel
>>> method. Another trick people have used is to write repository into
>>> the workspace
>> I'm not sure what you mean with writing repository into the workspace.
>> You mean something like writing the repository configuration into
>> file, registering the file extention to a resource and opening the
>> repo with the configuration in the file?
> Yes.
>>
>>> resource so that the workspace resource works more like a link.
>>> After all, if you have a workspace in the resource, what's actually
>>> there?
>> Nothing ;-)
> That seems problematic. After all, the wizard create the resource so
> how will redirecting to a repository still provide access to what's
> initially in the resource?
It depends on what the user want. If he first wants to save an instance
of the model in the file he can set the redirect to the repo later on.
In case he immediately wants to work on the repo he can first define the
mapping with the file name he plans to use. If the user decides to
switch back from the repo to the real file content he can remove the
mapping (assuming I get the mapping to work ;-) ).

BTW: The whole JCRM resource framework including the tools is not yet
checked in. I'm working hard on getting it presentable in a blog entry
until the Eclipse Summit.

Best,

Sandro
Re: Mapping a file to my own protocol resource [message #491372 is a reply to message #491367] Wed, 14 October 2009 11:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090105020509080701020209
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Sandro,

Perhaps you'd like to have a slot at the symposium to present your progress?
<http://wp.kolbware.de/2009/10/modeling-symposium-cfp/>

http://wp.kolbware.de/2009/10/modeling-symposium-cfp/



Sandro B


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Mapping a file to my own protocol resource [message #491397 is a reply to message #491372] Wed, 14 October 2009 12:18 Go to previous message
Sandro Boehme is currently offline Sandro BoehmeFriend
Messages: 95
Registered: July 2009
Member
Hi Ed,


Ed Merks schrieb:
> Sandro,
>
> Perhaps you'd like to have a slot at the symposium to present your progress?
> <http://wp.kolbware.de/2009/10/modeling-symposium-cfp/>
>
> http://wp.kolbware.de/2009/10/modeling-symposium-cfp/
puh. At the one hand I avoided presenting something at the Eclipse
Summit this year in favor of coding the resource framework and tools for
JCRM and showing it in my blog. We also have a tight deadline at work
for the 30'th of october and I'm not even sure, if I can attend the
Eclipse Summit. Preparing my progress would mean even more work.

At the other hand I think this is an interesting issue whose solutions
and workarounds are probably relevant to other Eclipse modeling people.
And it would be interesting to discuss that.

I haven't seen a deadline in the cfp. If there isn't one, I will try to
get something ready. But I cannot promise to have it ready for a certain
deadline. I will do my best and there are two weekends in between. My
wife will beat me, but we all have to make our sacrifices right? ;-)

BTW: Do you personally think it makes sense to have a redirection of
files for compatibility? Or do I miss an other way of implementing that
use case?

Best,

Sandro

>
>
>
> Sandro Böhme wrote:
>> Ed Merks schrieb:
>>> Sandro,
>>>
>>> Comments below.
>>>
>>> Sandro Böhme wrote:
>>>> Hi Ed,
>>>>
>>>> thanks for your feedback.
>>>> My comments are inline.
>>>>
>>>> Ed Merks schrieb:
>>>>> Sandro,
>>>>>
>>>>> Comments below.
>>>>>
>>>>>
>>>>> Sandro Böhme wrote:
>>>>>> Hello,
>>>>>>
>>>>>> the usecase I'm working on is that a file should be loaded using
>>>>>> my org.eclipse.emf.ecore.resource.Resource.Factory implementation.
>>>>>> I was assuming that I can simply use the following extension
>>>>>> points for that:
>>>>>>
>>>>>> <extension
>>>>>> point="org.eclipse.emf.ecore.uri_mapping">
>>>>>> <mapping
>>>>>> source="platform:/resource/JCRMDemo/my.mydomainmodel"
>>>>>> target="jcrm:/test/my.jcr">
>>>>>> </mapping>
>>>>>> </extension>
>>>>> It seems odd though to have a registered mapping for something in a
>>>>> workspace...
>>>>>> <extension
>>>>>> point="org.eclipse.emf.ecore.protocol_parser">
>>>>>> <parser
>>>>>>
>>>>>> class="org.eclipse.emf.jcrm.repoconn.RepoconnResourceFactoryImpl "
>>>>>> protocolName="jcrm">
>>>>>> </parser>
>>>>>> </extension>
>>>>>>
>>>>>> The first one would map the file to my protocol and the second one
>>>>>> would specify my resource factory for the protocol. But the
>>>>>> resource or ExtensibleURIConverterImpl.normalize(URI uri) or
>>>>>> ResourceFactoryRegistryImpl.getFactory(URI...) are never called
>>>>>> and if I open the file its just opened like a simple text file.
>>>>> The editor does this:
>>>>>
>>>>> public void createModel()
>>>>> {
>>>>> URI resourceURI = EditUIUtil.getURI(getEditorInput());
>>>>> Exception exception = null;
>>>>> Resource resource = null;
>>>>> try
>>>>> {
>>>>> // Load the resource through the editing domain.
>>>>> //
>>>>> resource =
>>>>> editingDomain.getResourceSet().*getResource*(resourceURI, true);
>>>>>
>>>>> and the resource set does this
>>>>>
>>>>> public Resource getResource(URI uri, boolean loadOnDemand)
>>>>> {
>>>>> Map<URI, Resource> map = getURIResourceMap();
>>>>> if (map != null)
>>>>> {
>>>>> Resource resource = map.get(uri);
>>>>> if (resource != null)
>>>>> {
>>>>> if (loadOnDemand && !resource.isLoaded())
>>>>> {
>>>>> demandLoadHelper(resource);
>>>>> }
>>>>> return resource;
>>>>> }
>>>>> }
>>>>>
>>>>> URIConverter theURIConverter = getURIConverter();
>>>>> URI normalizedURI = theURIConverter.*normalize*(uri);
>>>>>
>>>>> so normalize must be getting called.
>>>> I will have a look in the ResourceSetImpl to see why my factory
>>>> isn't called.
>>> The debugger generally answers questions faster than me. :-P
>> I wouldn't bet on it ;-)
>> I didn't expect an answer. Right now I have a break at work and will
>> dive into it after work. (as always)
>>
>>>>
>>>>>> Is there something wrong with my mapping definition?
>>>>> Hard coding one specific resource in the workspace doesn't seem right.
>>>> I'm working on a repository connection configuration editor that can
>>>> be used to open a repository. But most modeling tools do rely on
>>>> workspace resources for models as you know. This is why I'm working
>>>> on a way that a user can define a mapping from his file to a
>>>> repository connection configuration (an URI). This way the tools can
>>>> work on the files while behind the scenes they working on a repository.
>>> It seems better to try to open such editors with your own URI rather
>>> than try to divert them from opening the expected resource.
>>> EditUIUtil.getURI is called for EMF generated editors so it's
>>> possible to pass in a URIEditorInput.; I'm not sure if GMF editors
>>> support other forms for IEditorInput...
>> The editor of the connection configuration (concon) model already uses
>> the URIEditorInput to pass on the connection configuration URI (concon
>> URI) to the repo-editor to be opened. This way the user can open a
>> repo-editor without depending on a file that redirects to the repo.
>>
>> I have seen for example an Eclipse model to model transformation tool
>> where you can choose a file as a source and as a target. It should be
>> able with JCRM to create a source and a target file of your choice and
>> map it to a repository. This way the model to model transformation
>> tool and other tools can work on those files while they are actually
>> redirected to a java content repository.
>>
>>>>
>>>>>> Or can somebody please tell me how to specify a mapping from an
>>>>>> arbitrary file to my resource using an own protocol?
>>>>> I think you'd be better to do that in your editor's createModel
>>>>> method. Another trick people have used is to write repository into
>>>>> the workspace
>>>> I'm not sure what you mean with writing repository into the
>>>> workspace. You mean something like writing the repository
>>>> configuration into file, registering the file extention to a
>>>> resource and opening the repo with the configuration in the file?
>>> Yes.
>>>>
>>>>> resource so that the workspace resource works more like a link.
>>>>> After all, if you have a workspace in the resource, what's actually
>>>>> there?
>>>> Nothing ;-)
>>> That seems problematic. After all, the wizard create the resource so
>>> how will redirecting to a repository still provide access to what's
>>> initially in the resource?
>> It depends on what the user want. If he first wants to save an
>> instance of the model in the file he can set the redirect to the repo
>> later on. In case he immediately wants to work on the repo he can
>> first define the mapping with the file name he plans to use. If the
>> user decides to switch back from the repo to the real file content he
>> can remove the mapping (assuming I get the mapping to work ;-) ).
>>
>> BTW: The whole JCRM resource framework including the tools is not yet
>> checked in. I'm working hard on getting it presentable in a blog entry
>> until the Eclipse Summit.
>>
>> Best,
>>
>> Sandro
Previous Topic:[Teneo] CurrentSession problem with spring managed transactions
Next Topic:XMLTypeFactoryImpl fails to recreate QNames properly while "undoing change"
Goto Forum:
  


Current Time: Tue Apr 16 09:19:37 GMT 2024

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

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

Back to the top