Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: Registering a resource factory on a file name
Re: Registering a resource factory on a file name [message #399092] Mon, 06 March 2006 23:09 Go to next message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 201
Registered: July 2009
Senior Member
I dredged this up from the depths (dated Tue, 13 Apr 2004):

> Stefan,
>
> We may consider adding support for this to Resource.Factory.Registry in the
> future. For now you can override ResourceFactoryRegistryImpl.getFactory() to
> detect this case.
>
>
> Stefan wrote:
>
> > Hi,
> >
> > I'd like to use my own resource / resource factory implementation for
> > ejb-jar.xml files. Of course I don't want to register the factory on the
> > ".xml" file extension, and I also don't want to invent my own URI protocol
> > for this, but use standard 'file:' URIs. Is it possible to register a
> > factory on a complete file name instead, i.e. "ejb-jar.xml" ? Which EMF
> > class would I need to subclass for accomplishing this?
> >
> > bye,
> > Stefan

I have the exact same question. I want to do this for my particular
foo.xml file, but I don't want to register the factory on the entire
".xml" extension. Is there now extended support for this?

- Paul
Re: Registering a resource factory on a file name [message #399096 is a reply to message #399092] Tue, 07 March 2006 12:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Paul,

You can register a factory for *.xml by extending the existing
XMLResourceFactoryImpl and overriding createResource to do something
special for certain special files and call super for the rest.


Paul Fullbright wrote:
> I dredged this up from the depths (dated Tue, 13 Apr 2004):
>
>> Stefan,
>>
>> We may consider adding support for this to Resource.Factory.Registry
>> in the
>> future. For now you can override
>> ResourceFactoryRegistryImpl.getFactory() to
>> detect this case.
>>
>>
>> Stefan wrote:
>>
>> > Hi,
>> >
>> > I'd like to use my own resource / resource factory implementation for
>> > ejb-jar.xml files. Of course I don't want to register the factory
>> on the
>> > ".xml" file extension, and I also don't want to invent my own URI
>> protocol
>> > for this, but use standard 'file:' URIs. Is it possible to register a
>> > factory on a complete file name instead, i.e. "ejb-jar.xml" ? Which
>> EMF
>> > class would I need to subclass for accomplishing this?
>> >
>> > bye,
>> > Stefan
>
> I have the exact same question. I want to do this for my particular
> foo.xml file, but I don't want to register the factory on the entire
> ".xml" extension. Is there now extended support for this?
>
> - Paul
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Registering a resource factory on a file name [message #399422 is a reply to message #399096] Thu, 16 March 2006 20:42 Go to previous messageGo to next message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 201
Registered: July 2009
Senior Member
Ed Merks wrote:

> Paul,

> You can register a factory for *.xml by extending the existing
> XMLResourceFactoryImpl and overriding createResource to do something
> special for certain special files and call super for the rest.

Hi Ed,

Isn't that a bit impolite? How about the others out there using the .xml
extension? Won't I potentially be replacing somebody else's use of an
extension of XMLResourceFactoryImpl?

For instance, if somebody is trying to do something similar for foo.xml,
and they implement FooXMLResourceFactoryImpl, which they then register to
the *.xml extension, which factory would be retrieved in the lookup for an
*.xml file? Theirs or mine?

- Paul
Re: Registering a resource factory on a file name [message #399423 is a reply to message #399422] Thu, 16 March 2006 20:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Paul,

You'd register it only local to your resource set where you have
complete control, not in the global registry that effects everyone,
which would be very rude indeed!


Paul Fullbright wrote:
> Ed Merks wrote:
>
>> Paul,
>
>> You can register a factory for *.xml by extending the existing
>> XMLResourceFactoryImpl and overriding createResource to do something
>> special for certain special files and call super for the rest.
>
> Hi Ed,
>
> Isn't that a bit impolite? How about the others out there using the
> .xml extension? Won't I potentially be replacing somebody else's use
> of an extension of XMLResourceFactoryImpl?
>
> For instance, if somebody is trying to do something similar for
> foo.xml, and they implement FooXMLResourceFactoryImpl, which they then
> register to the *.xml extension, which factory would be retrieved in
> the lookup for an *.xml file? Theirs or mine?
>
> - Paul
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Registering a resource factory on a file name [message #1069701 is a reply to message #399422] Tue, 16 July 2013 12:24 Go to previous messageGo to next message
Wladimir Safonov is currently offline Wladimir SafonovFriend
Messages: 7
Registered: July 2011
Junior Member
Hi Ed,

I ran now into the same situation where support of file name matching for resource factories lookup is needed. I cannot simply use my local resource set for registering "xml" extension factory, because we have several *.xml files containing models of different types, which all need to be loaded into the same resource set. So I am looking now at the possibility of implementing another extension point which would provide support for configuring resource factory using file name patterns and hook it into the ResourceFactoryRegistryImpl.getFactory() method.

Is there something similar planned in EMF for the future? Or is there meanwhile a better way to solve the problem? Of course, name patterns can still lead to overlapping, but this is a trade-off for giving more flexibility to the user. I can imagine that the resource factory registration based on name patterns can replace those based on file extensions and make the corresponding extension point obsolete after a while.

--
Vladimir
Re: Registering a resource factory on a file name [message #1069711 is a reply to message #1069701] Tue, 16 July 2013 12:43 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 16.07.2013 14:24, schrieb Wladimir Safonov:
> Hi Ed,
>
> I ran now into the same situation where support of file name matching for resource factories lookup is needed. I
> cannot simply use my local resource set for registering "xml" extension factory, because we have several *.xml files
> containing models of different types, which all need to be loaded into the same resource set. So I am looking now at
> the possibility of implementing another extension point which would provide support for configuring resource factory
> using file name patterns and hook it into the ResourceFactoryRegistryImpl.getFactory() method.
>
> Is there something similar planned in EMF for the future? Or is there meanwhile a better way to solve the problem? Of
> course, name patterns can still lead to overlapping, but this is a trade-off for giving more flexibility to the user.
> I can imagine that the resource factory registration based on name patterns can replace those based on file extensions
> and make the corresponding extension point obsolete after a while.
This thread might be interesting for you: http://www.eclipsezone.com/eclipse/forums/t107605.html

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Previous Topic:[EMF Compare] How to provide a ModelComparison for custom refactorings?
Next Topic:noNamespaceSchemaLocation URI resolution with catalog entry
Goto Forum:
  


Current Time: Thu Apr 25 16:37:26 GMT 2024

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

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

Back to the top