Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » Add New Resource Storage Mechanism
Add New Resource Storage Mechanism [message #382209] Mon, 26 May 2008 19:46 Go to next message
Martin Geisse is currently offline Martin Geisse
Messages: 24
Registered: July 2009
Junior Member
Hello,

I am currently writing a plug-in that adds a new mechanism for ecore
resource storage. Basically, I want to have EMF recognize a distinct
kind of URIs and redirect them to my plug-in. I do not require special
behaviour of the Resource instances, only custom input/output streams.
In fact, I want to re-use the behaviour of existing resource
implementations (and corresponding resource factories) such that they
impose "their" file format on the input/output streams that I provide.

To me it seems that the proper solution is a custom implementation of
either URIConverter or URIHandler.

However, I want the new kind of URI to be available for any entity that
resolves resources using URIs, without specific knowledge about my
plug-in. For instance, I want the example editors which are generated
from ecore models to be able to load resources using "my" URIs and point
ERereference variables to objects contained in them. This indicates that
my custom URI handling code must be registered globally in some way, but
I am unsure where the best place is for this.

I have found URIConverter.INSTANCE, but the documentation says that
"It's generally not a good idea to modify any aspect of this instance",
which rules it out for my purpose because adding a custom URI handler to
it is clearly modifying the instance.

I have found URIHandler.DEFAULT_HANDLER, but again the documentation
says that it is read-only.

I have found the "org.eclipse.emf.ecore.protocol_parser" extension
point, but this allows me to register a resource factory, not an URI
handler / converter, which is not what I want. Specifically, by using a
custom resource factory I would bypass the existing resource factories
that implement specific file formats for the various models, when in
reality I want to use those existing factories, only with custom code
for creating the raw data streams.

Can anyone point me to the right direction?
Thanks in advance,
Martin Geisse
Re: Add New Resource Storage Mechanism [message #382210 is a reply to message #382209] Mon, 26 May 2008 20:50 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26137
Registered: July 2009
Senior Member
Martin,

Please use the EMF newsgroup for EMF questions in the future. I've
added it to the "to" list of the reply.


Martin Geisse wrote:
> Hello,
>
> I am currently writing a plug-in that adds a new mechanism for ecore
> resource storage. Basically, I want to have EMF recognize a distinct
> kind of URIs and redirect them to my plug-in. I do not require special
> behaviour of the Resource instances, only custom input/output streams.
> In fact, I want to re-use the behaviour of existing resource
> implementations (and corresponding resource factories) such that they
> impose "their" file format on the input/output streams that I provide.
>
> To me it seems that the proper solution is a custom implementation of
> either URIConverter or URIHandler.
Yes, a URIHandler should suffice.
>
> However, I want the new kind of URI to be available for any entity
> that resolves resources using URIs, without specific knowledge about
> my plug-in.
Hmmm. I didn't make the handlers a pluggable thing because each handler
adds a bit of overhead and I was concerned that not all clients will
want such handlers injected into their environment...
> For instance, I want the example editors which are generated from
> ecore models to be able to load resources using "my" URIs and point
> ERereference variables to objects contained in them. This indicates
> that my custom URI handling code must be registered globally in some
> way, but I am unsure where the best place is for this.
I suppose you could also take the approach of defining an actual URL
handler. You could look at org.eclipse.emf.common.archive.Handler as an
example of how you could register a URL handler that would work
universally throughout the JRE.
>
> I have found URIConverter.INSTANCE, but the documentation says that
> "It's generally not a good idea to modify any aspect of this
> instance", which rules it out for my purpose because adding a custom
> URI handler to it is clearly modifying the instance.
And besides, resource set's have local URI converter and only the
handlers on that instance are used within the resource set.
>
> I have found URIHandler.DEFAULT_HANDLER, but again the documentation
> says that it is read-only.
Yes, I'm concerned that 100 different plugins might inject behavior for
all applications, that they might compete for priority (being ahead on
the list) and might usurp control...
>
> I have found the "org.eclipse.emf.ecore.protocol_parser" extension
> point, but this allows me to register a resource factory, not an URI
> handler / converter, which is not what I want. Specifically, by using
> a custom resource factory I would bypass the existing resource
> factories that implement specific file formats for the various models,
> when in reality I want to use those existing factories, only with
> custom code for creating the raw data streams.
Another approach would be to make use of the Eclipse File System, EFS.
An interesting aspect of that is you could even use this to surface your
scheme as real IFiles in the workspace. The existing URI handlers
include ones that will delegate to EFS for any scheme supported by EFS.
A bit of googling should find you some nice documentation about this.
We're able to open resources in a CVS repository because of EFS support
for that...
>
> Can anyone point me to the right direction?
> Thanks in advance,
> Martin Geisse
Re: Add New Resource Storage Mechanism [message #607534 is a reply to message #382209] Mon, 26 May 2008 20:50 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26137
Registered: July 2009
Senior Member
Martin,

Please use the EMF newsgroup for EMF questions in the future. I've
added it to the "to" list of the reply.


Martin Geisse wrote:
> Hello,
>
> I am currently writing a plug-in that adds a new mechanism for ecore
> resource storage. Basically, I want to have EMF recognize a distinct
> kind of URIs and redirect them to my plug-in. I do not require special
> behaviour of the Resource instances, only custom input/output streams.
> In fact, I want to re-use the behaviour of existing resource
> implementations (and corresponding resource factories) such that they
> impose "their" file format on the input/output streams that I provide.
>
> To me it seems that the proper solution is a custom implementation of
> either URIConverter or URIHandler.
Yes, a URIHandler should suffice.
>
> However, I want the new kind of URI to be available for any entity
> that resolves resources using URIs, without specific knowledge about
> my plug-in.
Hmmm. I didn't make the handlers a pluggable thing because each handler
adds a bit of overhead and I was concerned that not all clients will
want such handlers injected into their environment...
> For instance, I want the example editors which are generated from
> ecore models to be able to load resources using "my" URIs and point
> ERereference variables to objects contained in them. This indicates
> that my custom URI handling code must be registered globally in some
> way, but I am unsure where the best place is for this.
I suppose you could also take the approach of defining an actual URL
handler. You could look at org.eclipse.emf.common.archive.Handler as an
example of how you could register a URL handler that would work
universally throughout the JRE.
>
> I have found URIConverter.INSTANCE, but the documentation says that
> "It's generally not a good idea to modify any aspect of this
> instance", which rules it out for my purpose because adding a custom
> URI handler to it is clearly modifying the instance.
And besides, resource set's have local URI converter and only the
handlers on that instance are used within the resource set.
>
> I have found URIHandler.DEFAULT_HANDLER, but again the documentation
> says that it is read-only.
Yes, I'm concerned that 100 different plugins might inject behavior for
all applications, that they might compete for priority (being ahead on
the list) and might usurp control...
>
> I have found the "org.eclipse.emf.ecore.protocol_parser" extension
> point, but this allows me to register a resource factory, not an URI
> handler / converter, which is not what I want. Specifically, by using
> a custom resource factory I would bypass the existing resource
> factories that implement specific file formats for the various models,
> when in reality I want to use those existing factories, only with
> custom code for creating the raw data streams.
Another approach would be to make use of the Eclipse File System, EFS.
An interesting aspect of that is you could even use this to surface your
scheme as real IFiles in the workspace. The existing URI handlers
include ones that will delegate to EFS for any scheme supported by EFS.
A bit of googling should find you some nice documentation about this.
We're able to open resources in a CVS repository because of EFS support
for that...
>
> Can anyone point me to the right direction?
> Thanks in advance,
> Martin Geisse
Previous Topic:Add New Resource Storage Mechanism
Next Topic:Amalgamate Models
Goto Forum:
  


Current Time: Thu Oct 23 18:04:13 GMT 2014

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

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