Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » BasicExtendedMetaData.demandRegistry delegation
BasicExtendedMetaData.demandRegistry delegation [message #1032720] Wed, 03 April 2013 10:41 Go to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi Ed

While trying to debug a UML profile issue I started watching
BasicExtendedMetaData.demandPackage and was surprised to see a demand
package being created for http://www.eclipse.org/2008/Xtext. This occurs
when opening an Xtext editor loads its grammar file. The demand package
is needed because the demand package registry does not delegate to the
global registry. Is this intentional or an oversight?

Regards

Ed Willink
Re: BasicExtendedMetaData.demandRegistry delegation [message #1032756 is a reply to message #1032720] Wed, 03 April 2013 11:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26138
Registered: July 2009
Senior Member
Ed,

The API is documented like this:

/**
* Returns a package from the demand package registry, creating it
(with a document root class) if necessary.
*/
EPackage demandPackage(String namespace);

So yes, it should demand create a new package or reuse a previously
demand created package. It should not consult any other registry.

If you look at the callers, it's generally is things like
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleMissingPackage(String)
where the resource set's registry or global registry have already been
consulted or like this in the QName support in XMLHelper:

ePackage = extendedMetaData.getPackage(namespace);
if (ePackage == null)
{
ePackage = extendedMetaData.demandPackage(namespace);
}


On 03/04/2013 12:41 PM, Ed Willink wrote:
> Hi Ed
>
> While trying to debug a UML profile issue I started watching
> BasicExtendedMetaData.demandPackage and was surprised to see a demand
> package being created for http://www.eclipse.org/2008/Xtext. This
> occurs when opening an Xtext editor loads its grammar file. The demand
> package is needed because the demand package registry does not
> delegate to the global registry. Is this intentional or an oversight?
>
> Regards
>
> Ed Willink
Re: BasicExtendedMetaData.demandRegistry delegation [message #1032805 is a reply to message #1032756] Wed, 03 April 2013 13:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi Ed

Yes, you're right, there is a preceding getPackage() guarding the
delegateRegistry usage..

The failure to use the already initialized XtextPackageImpl is because
BasicExtendedMetaData.registry doesn't delegate.

XMLContentHandlerImpl initializes it as

ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(new
EPackageRegistryImpl());

Is this intentional or an oversight?

Regards

Ed Willink

On 03/04/2013 12:56, Ed Merks wrote:
> Ed,
>
> The API is documented like this:
>
> /**
> * Returns a package from the demand package registry, creating it
> (with a document root class) if necessary.
> */
> EPackage demandPackage(String namespace);
>
> So yes, it should demand create a new package or reuse a previously
> demand created package. It should not consult any other registry.
>
> If you look at the callers, it's generally is things like
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleMissingPackage(String)
> where the resource set's registry or global registry have already been
> consulted or like this in the QName support in XMLHelper:
>
> ePackage = extendedMetaData.getPackage(namespace);
> if (ePackage == null)
> {
> ePackage = extendedMetaData.demandPackage(namespace);
> }
>
>
> On 03/04/2013 12:41 PM, Ed Willink wrote:
>> Hi Ed
>>
>> While trying to debug a UML profile issue I started watching
>> BasicExtendedMetaData.demandPackage and was surprised to see a demand
>> package being created for http://www.eclipse.org/2008/Xtext. This
>> occurs when opening an Xtext editor loads its grammar file. The
>> demand package is needed because the demand package registry does not
>> delegate to the global registry. Is this intentional or an oversight?
>>
>> Regards
>>
>> Ed Willink
>
Re: BasicExtendedMetaData.demandRegistry delegation [message #1032818 is a reply to message #1032805] Wed, 03 April 2013 13:19 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26138
Registered: July 2009
Senior Member
Ed,

Comments below.

On 03/04/2013 3:01 PM, Ed Willink wrote:
> Hi Ed
>
> Yes, you're right, there is a preceding getPackage() guarding the
> delegateRegistry usage..
>
> The failure to use the already initialized XtextPackageImpl is because
> BasicExtendedMetaData.registry doesn't delegate.
>
> XMLContentHandlerImpl initializes it as
>
> ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(new
> EPackageRegistryImpl());
>
> Is this intentional or an oversight?
Yes, the content handlers just want to do simple XML processing to
determine things like the namespace of the root element in the
document. They don't want to do any "real" processing of the document
and don't want to create any real instances of any models.

>
> Regards
>
> Ed Willink
>
> On 03/04/2013 12:56, Ed Merks wrote:
>> Ed,
>>
>> The API is documented like this:
>>
>> /**
>> * Returns a package from the demand package registry, creating it
>> (with a document root class) if necessary.
>> */
>> EPackage demandPackage(String namespace);
>>
>> So yes, it should demand create a new package or reuse a previously
>> demand created package. It should not consult any other registry.
>>
>> If you look at the callers, it's generally is things like
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleMissingPackage(String) where
>> the resource set's registry or global registry have already been
>> consulted or like this in the QName support in XMLHelper:
>>
>> ePackage = extendedMetaData.getPackage(namespace);
>> if (ePackage == null)
>> {
>> ePackage = extendedMetaData.demandPackage(namespace);
>> }
>>
>>
>> On 03/04/2013 12:41 PM, Ed Willink wrote:
>>> Hi Ed
>>>
>>> While trying to debug a UML profile issue I started watching
>>> BasicExtendedMetaData.demandPackage and was surprised to see a
>>> demand package being created for http://www.eclipse.org/2008/Xtext.
>>> This occurs when opening an Xtext editor loads its grammar file. The
>>> demand package is needed because the demand package registry does
>>> not delegate to the global registry. Is this intentional or an
>>> oversight?
>>>
>>> Regards
>>>
>>> Ed Willink
>>
>
Previous Topic:Flow Diagram
Next Topic:How to parse an XMI file to SQL
Goto Forum:
  


Current Time: Fri Oct 24 12:17:59 GMT 2014

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

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