Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Delegating content types to the global URIConverter
Delegating content types to the global URIConverter [message #781179] Fri, 20 January 2012 14:47 Go to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7658
Registered: July 2009
Senior Member
Hi Ed

Is it possible when running standalone to use content handlers defined
for the global URIConverter?

The normal ResourceFactory delegation in
ResourceSetImpl.getResourceFactoryRegistry using
convert(getFactory(...)) carefully uses the global
Protocol/Extension/ContentType FactoryMaps but does not pass the global
URIConverter so when delegated content types are resolved, the content
handlers registered on the local URIConverter rather than those on the
global URIConverter are used.

Regards

Ed Willink
Re: Delegating content types to the global URIConverter [message #781180 is a reply to message #781179] Fri, 20 January 2012 15:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33147
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Ed,<br>
<br>
No, as the Java doc suggests, it's not good to modify it.<br>
<blockquote>&nbsp; /**<br>
&nbsp;&nbsp; * The global static URI converter instance.<br>
&nbsp;&nbsp; * It's generally not a good idea to modify any aspect of this
instance.<br>
&nbsp;&nbsp; * Instead, use a resource set's {@link
ResourceSet#getURIConverter() local} instance.<br>
&nbsp;&nbsp; * @since 2.4<br>
&nbsp;&nbsp; */<br>
</blockquote>
Content handling is an expensive thing and we've gone to lengths to
avoid it being expensive when it's not being use and to avoid
forcing everyone to pay an expense that any one contributor decides
is worth it from their point of view.<br>
<br>
<br>
<br>
On 20/01/2012 3:47 PM, Ed Willink wrote:
<blockquote cite="mid:jfbupp$kc4$1@news.eclipse.org" type="cite">Hi
Ed
<br>
<br>
Is it possible when running standalone to use content handlers
defined for the global URIConverter?
<br>
<br>
The normal ResourceFactory delegation in
ResourceSetImpl.getResourceFactoryRegistry using
convert(getFactory(...)) carefully uses the global
Protocol/Extension/ContentType FactoryMaps but does not pass the
global URIConverter so when delegated content types are resolved,
the content handlers registered on the local URIConverter rather
than those on the global URIConverter are used.
<br>
<br>
&nbsp;&nbsp;&nbsp; Regards
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ed Willink
<br>
<br>
<br>
</blockquote>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delegating content types to the global URIConverter [message #781446 is a reply to message #781180] Sat, 21 January 2012 08:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7658
Registered: July 2009
Senior Member
Hi Ed

UML is hardly just 'any one contributor'. The proliferation of UML
namespace URIs now that MDT/UML2 has got unstuck from UML 2.2 makes
working content types mandatory. There is some major pain in store for
UML users post-Juno unless we get content types working effectively. In
making OCL work for and use the enhanced UML, I am variously debugging
the changes and identifying useability challenges.

The problem I'm seeing is not efficiency related; the content types and
handlers are there, so they're already costing; they just aren't useable.

I would like to see the delegation transition from
- use my URIConverter and ResourceRegistryFactories
to
- use globals

also switch to using the global URIConverter, so that globally
registered content handlers are useable, otherwise we will need to
ensure that everyone's local ResourceSet acquires correct local UML
content handlers. Since many/most modeling applications have enhanced
ResourceSets this could cause major headaches.

Regards

Ed Willink




On 20/01/2012 15:01, Ed Merks wrote:
> Ed,
>
> No, as the Java doc suggests, it's not good to modify it.
>
> /**
> * The global static URI converter instance.
> * It's generally not a good idea to modify any aspect of this
> instance.
> * Instead, use a resource set's {@link
> ResourceSet#getURIConverter() local} instance.
> * @since 2.4
> */
>
> Content handling is an expensive thing and we've gone to lengths to
> avoid it being expensive when it's not being use and to avoid forcing
> everyone to pay an expense that any one contributor decides is worth
> it from their point of view.
>
>
>
> On 20/01/2012 3:47 PM, Ed Willink wrote:
>> Hi Ed
>>
>> Is it possible when running standalone to use content handlers
>> defined for the global URIConverter?
>>
>> The normal ResourceFactory delegation in
>> ResourceSetImpl.getResourceFactoryRegistry using
>> convert(getFactory(...)) carefully uses the global
>> Protocol/Extension/ContentType FactoryMaps but does not pass the
>> global URIConverter so when delegated content types are resolved, the
>> content handlers registered on the local URIConverter rather than
>> those on the global URIConverter are used.
>>
>> Regards
>>
>> Ed Willink
>>
>>
Re: Delegating content types to the global URIConverter [message #781454 is a reply to message #781446] Sat, 21 January 2012 09:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33147
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Ed,<br>
<br>
Comments below.<br>
<br>
On 21/01/2012 9:49 AM, Ed Willink wrote:
<blockquote cite="mid:jfdu73$s9u$1@news.eclipse.org" type="cite">Hi
Ed
<br>
<br>
UML is hardly just 'any one contributor'.</blockquote>
That's exactly the concern: in my experiences almost every
contributor has exactly this thinking., i.e., they're so important
that their impact on others is totally justified.&nbsp; Remember, I
worked at IBM for a long time.<br>
<blockquote cite="mid:jfdu73$s9u$1@news.eclipse.org" type="cite">
The proliferation of UML namespace URIs now that MDT/UML2 has got
unstuck from UML 2.2 makes working content types mandatory. There
is some major pain in store for UML users post-Juno unless we get
content types working effectively. In making OCL work for and use
the enhanced UML, I am variously debugging the changes and
identifying useability challenges.
<br>
<br>
The problem I'm seeing is not efficiency related; the content
types and handlers are there, so they're already costing; they
just aren't useable.
<br>
</blockquote>
The URI converter implementation is created like this:<br>
<blockquote><small>&nbsp; public ExtensibleURIConverterImpl()</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; this(URIHandler.DEFAULT_HANDLERS,
ContentHandler.Registry.INSTANCE.contentHandlers());</small><br>
<small>&nbsp; }</small><br>
</blockquote>
So all the registered content handlers are available.&nbsp;&nbsp; You seem to
be suggesting that a resource set's content handler list is empty...<br>
<blockquote cite="mid:jfdu73$s9u$1@news.eclipse.org" type="cite">
<br>
I would like to see the delegation transition from
<br>
- use my URIConverter and ResourceRegistryFactories
<br>
to
<br>
- use globals
<br>
</blockquote>
What's missing?<br>
<blockquote cite="mid:jfdu73$s9u$1@news.eclipse.org" type="cite">
<br>
also switch to using the global URIConverter, so that globally
registered content handlers are useable, otherwise we will need to
ensure that everyone's local ResourceSet acquires correct local
UML content handlers. </blockquote>
As I suggested above, that should be the case.&nbsp; They should be
populated with the globally registered content handlers.&nbsp; <br>
<blockquote cite="mid:jfdu73$s9u$1@news.eclipse.org" type="cite">Since
many/most modeling applications have enhanced ResourceSets this
could cause major headaches.
<br>
</blockquote>
Too bad things like dependency injection weren't well-understood 10
years ago.<br>
<blockquote cite="mid:jfdu73$s9u$1@news.eclipse.org" type="cite">
<br>
&nbsp;&nbsp;&nbsp; Regards
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ed Willink
<br>
<br>
<br>
<br>
<br>
On 20/01/2012 15:01, Ed Merks wrote:
<br>
<blockquote type="cite">Ed,
<br>
<br>
No, as the Java doc suggests, it's not good to modify it.
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /**
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * The global static URI converter instance.
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * It's generally not a good idea to modify any aspect of
this
<br>
&nbsp;&nbsp;&nbsp; instance.
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Instead, use a resource set's {@link
<br>
&nbsp;&nbsp;&nbsp; ResourceSet#getURIConverter() local} instance.
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * @since 2.4
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */
<br>
<br>
Content handling is an expensive thing and we've gone to lengths
to avoid it being expensive when it's not being use and to avoid
forcing everyone to pay an expense that any one contributor
decides is worth it from their point of view.
<br>
<br>
<br>
<br>
On 20/01/2012 3:47 PM, Ed Willink wrote:
<br>
<blockquote type="cite">Hi Ed
<br>
<br>
Is it possible when running standalone to use content handlers
defined for the global URIConverter?
<br>
<br>
The normal ResourceFactory delegation in
ResourceSetImpl.getResourceFactoryRegistry using
convert(getFactory(...)) carefully uses the global
Protocol/Extension/ContentType FactoryMaps but does not pass
the global URIConverter so when delegated content types are
resolved, the content handlers registered on the local
URIConverter rather than those on the global URIConverter are
used.
<br>
<br>
&nbsp;&nbsp;&nbsp; Regards
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ed Willink
<br>
<br>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delegating content types to the global URIConverter [message #781467 is a reply to message #781454] Sat, 21 January 2012 10:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7658
Registered: July 2009
Senior Member
Hi Ed
>> The problem I'm seeing is not efficiency related; the content types
>> and handlers are there, so they're already costing; they just aren't
>> useable.
> The URI converter implementation is created like this:
>
> public ExtensibleURIConverterImpl()
> {
> this(URIHandler.DEFAULT_HANDLERS,
> ContentHandler.Registry.INSTANCE.contentHandlers());
> }
>
> So all the registered content handlers are available. You seem to be
> suggesting that a resource set's content handler list is empty...
There's no problem with URIConverter. It;'s...
>>
>> I would like to see the delegation transition from
>> - use my URIConverter and ResourceRegistryFactories
>> to
>> - use globals
> What's missing?
In

return
convert
(getFactory
(uri,

Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap(),

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(),

Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap(),
contentTypeIdentifier,
false));

where the delegation to global occurs, either

URIConverter.INSTANCE could be an additional argument, or
delegate = false could bypass the invocation of getURIConverter to use
the global one.

[Obviously any change now has an established practice corrolary.]
>
>> Since many/most modeling applications have enhanced ResourceSets this
>> could cause major headaches.
> Too bad things like dependency injection weren't well-understood 10
> years ago.
5 years ago, I had my own 'better' ResourceSet to create 'better'
resources. It was a pain and hazardous imposing this on users.

I subsequently discovered that ResourceSetImpl does so much by
delegation and registries that problems seem soluble anyway.
ResourceSet.eAdapters() can solve almost anything.

Almost every derived ResourceSet that I have seen seems to have an
associated misunderstanding of EMF.

Regards

Ed Willink
Re: Delegating content types to the global URIConverter [message #781476 is a reply to message #781467] Sat, 21 January 2012 10:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33147
Registered: July 2009
Senior Member
Ed,

Comments below.


On 21/01/2012 11:11 AM, Ed Willink wrote:
> Hi Ed
>>> The problem I'm seeing is not efficiency related; the content types
>>> and handlers are there, so they're already costing; they just aren't
>>> useable.
>> The URI converter implementation is created like this:
>>
>> public ExtensibleURIConverterImpl()
>> {
>> this(URIHandler.DEFAULT_HANDLERS,
>> ContentHandler.Registry.INSTANCE.contentHandlers());
>> }
>>
>> So all the registered content handlers are available. You seem to
>> be suggesting that a resource set's content handler list is empty...
> There's no problem with URIConverter. It;'s...
I'm not sure what all the discussion about missing content handlers was
about then?
>>>
>>> I would like to see the delegation transition from
>>> - use my URIConverter and ResourceRegistryFactories
>>> to
>>> - use globals
>> What's missing?
> In
>
> return
> convert
> (getFactory
> (uri,
>
> Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap(),
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(),
>
> Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap(),
> contentTypeIdentifier,
> false));
>
> where the delegation to global occurs, either
>
> URIConverter.INSTANCE could be an additional argument, or
> delegate = false could bypass the invocation of getURIConverter to use
> the global one.
Why? What's so special about the global URI converter?

Note that this was added merely as a convenience to avoid all the places
in the code where we did new ExtensibleURIConverterImpl(), used it once,
and then threw it away. It was not intended to be a centralized place
for people to dump things that would then be generally reused by all
clients. It's clear you're asking for that, and you're even starting to
explain how to implement it, but until you step back and explain why you
need it, I will keep asking why and will ignore the rest as a distraction.
>
> [Obviously any change now has an established practice corrolary.]
>>
>>> Since many/most modeling applications have enhanced ResourceSets
>>> this could cause major headaches.
>> Too bad things like dependency injection weren't well-understood 10
>> years ago.
> 5 years ago, I had my own 'better' ResourceSet to create 'better'
> resources. It was a pain and hazardous imposing this on users.
>
> I subsequently discovered that ResourceSetImpl does so much by
> delegation and registries that problems seem soluble anyway.
> ResourceSet.eAdapters() can solve almost anything.
>
> Almost every derived ResourceSet that I have seen seems to have an
> associated misunderstanding of EMF.
>
> Regards
>
> Ed Willink


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delegating content types to the global URIConverter [message #781538 is a reply to message #781476] Sat, 21 January 2012 15:27 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7658
Registered: July 2009
Senior Member
Hi Ed

I was getting confused about the two globals again. I was initialising
URIConverter.INSTANCE.getContentHandlers() rather than
ContentHandler.Registry.INSTANCE.

In the case of ContentHandlers, they are copied into the extended
ResourceSet on construction rather than delegated on use; seems to
create needless lists given that no local content handlers is a rather
common use case.

Regards

Ed Willink
Re: Delegating content types to the global URIConverter [message #781562 is a reply to message #781538] Sat, 21 January 2012 17:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33147
Registered: July 2009
Senior Member
Ed,

Aren't you populating those things via plugin.xml registrations?

The issues with the lists is that they're used like this:

for (ContentHandler contentHandler :
uriConverter.getContentHandlers())
{
if (contentHandler.canHandle(uri))
{

So the clients iterate over the list and the list is processed in
order. The list is also editable. It's hard to imagine inserting
delegation to some other global list transparently under the covers of
such a thing...



On 21/01/2012 4:27 PM, Ed Willink wrote:
> Hi Ed
>
> I was getting confused about the two globals again. I was initialising
> URIConverter.INSTANCE.getContentHandlers() rather than
> ContentHandler.Registry.INSTANCE.
>
> In the case of ContentHandlers, they are copied into the extended
> ResourceSet on construction rather than delegated on use; seems to
> create needless lists given that no local content handlers is a rather
> common use case.
>
> Regards
>
> Ed Willink
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delegating content types to the global URIConverter [message #781568 is a reply to message #781562] Sat, 21 January 2012 17:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7658
Registered: July 2009
Senior Member
Hi

On 21/01/2012 17:03, Ed Merks wrote:
> Aren't you populating those things via plugin.xml registrations?

Yes, when using plugins.
No, when running standalone, e.g. for me when MWE2 build scripts that
activate Acceleo/QVTo/Xtext/genmodel/custom auto-generation code.

Unfortunately MDT/UML2 has never provided a standalone initialization
routine. It's now pretty mandatory:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=364419.

[I can't see any evidence that ContentHandler priority is honoured when
populating a URIConverter, but not my problem at present.]

Regards

Ed
>
> The issues with the lists is that they're used like this:
>
> for (ContentHandler contentHandler :
> uriConverter.getContentHandlers())
> {
> if (contentHandler.canHandle(uri))
> {
>
> So the clients iterate over the list and the list is processed in
> order. The list is also editable. It's hard to imagine inserting
> delegation to some other global list transparently under the covers of
> such a thing...
>
>
>
> On 21/01/2012 4:27 PM, Ed Willink wrote:
>> Hi Ed
>>
>> I was getting confused about the two globals again. I was
>> initialising URIConverter.INSTANCE.getContentHandlers() rather than
>> ContentHandler.Registry.INSTANCE.
>>
>> In the case of ContentHandlers, they are copied into the extended
>> ResourceSet on construction rather than delegated on use; seems to
>> create needless lists given that no local content handlers is a
>> rather common use case.
>>
>> Regards
>>
>> Ed Willink
>>
Re: Delegating content types to the global URIConverter [message #781575 is a reply to message #781568] Sat, 21 January 2012 17:34 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33147
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Ed,<br>
<br>
The parser reads the priority and this implementation ensures&nbsp; that
the list of handlers is ordered by priority.<br>
<blockquote>public class ContentHandlerRegistryImpl extends
TreeMap&lt;Integer, List&lt;ContentHandler&gt;&gt; implements
ContentHandler.Registry<br>
{<br>
&nbsp; private static final long serialVersionUID = 1L;<br>
<br>
&nbsp; public void put(int priority, ContentHandler contentHandler)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; Integer integerPriority = priority;<br>
&nbsp;&nbsp;&nbsp; List&lt;ContentHandler&gt; contentHandlers =
get(integerPriority);<br>
&nbsp;&nbsp;&nbsp; if (contentHandlers == null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; put(integerPriority, contentHandlers = new
ArrayList&lt;ContentHandler&gt;());<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; contentHandlers.add(contentHandler);<br>
&nbsp; }<br>
&nbsp; <br>
&nbsp; public List&lt;ContentHandler&gt; contentHandlers()<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; ArrayList&lt;ContentHandler&gt; result = new
ArrayList&lt;ContentHandler&gt;();<br>
&nbsp;&nbsp;&nbsp; for (List&lt;ContentHandler&gt; contentHandlers : values())<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result.addAll(contentHandlers);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return result;<br>
&nbsp; }<br>
}<br>
</blockquote>
There's a fairly complete patch for supporting registry reading
stand alone.&nbsp; Perhaps that would be useful?<br>
<br>
<br>
On 21/01/2012 6:22 PM, Ed Willink wrote:
<blockquote cite="mid:jfes8h$l8k$1@news.eclipse.org" type="cite">Hi
<br>
<br>
On 21/01/2012 17:03, Ed Merks wrote:
<br>
<blockquote type="cite">Aren't you populating those things via
plugin.xml registrations?
<br>
</blockquote>
<br>
Yes, when using plugins.
<br>
No, when running standalone, e.g. for me when MWE2 build scripts
that activate Acceleo/QVTo/Xtext/genmodel/custom auto-generation
code.
<br>
<br>
Unfortunately MDT/UML2 has never provided a standalone
initialization routine. It's now pretty mandatory:
<a class="moz-txt-link-freetext" href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=364419">https://bugs.eclipse.org/bugs/show_bug.cgi?id=364419</a>.
<br>
<br>
[I can't see any evidence that ContentHandler priority is honoured
when populating a URIConverter, but not my problem at present.]
<br>
<br>
&nbsp;&nbsp;&nbsp; Regards
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ed
<br>
<blockquote type="cite">
<br>
The issues with the lists is that they're used like this:
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (ContentHandler contentHandler :
uriConverter.getContentHandlers())
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (contentHandler.canHandle(uri))
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br>
<br>
So the clients iterate over the list and the list is processed
in order.&nbsp; The list is also editable.&nbsp; It's hard to imagine
inserting delegation to some other global list transparently
under the covers of such a thing...
<br>
<br>
<br>
<br>
On 21/01/2012 4:27 PM, Ed Willink wrote:
<br>
<blockquote type="cite">Hi Ed
<br>
<br>
I was getting confused about the two globals again. I was
initialising URIConverter.INSTANCE.getContentHandlers() rather
than ContentHandler.Registry.INSTANCE.
<br>
<br>
In the case of ContentHandlers, they are copied into the
extended ResourceSet on construction rather than delegated on
use; seems to create needless lists given that no local
content handlers is a rather common use case.
<br>
<br>
&nbsp;&nbsp;&nbsp; Regards
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ed Willink
<br>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EMF Editor Context menu and hierarchical Ecores
Next Topic:Dawn Codegen
Goto Forum:
  


Current Time: Sun May 12 08:10:50 GMT 2024

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

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

Back to the top