Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EPackage.Registry
EPackage.Registry [message #429922] Wed, 06 May 2009 18:37 Go to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Ed,

One of the recent changes to the registry is that after calling
XXXEPackage.eINSTANCE the registry still contains an instance of
descriptor and not an instance of EPackage as GMF MetaModelManager
assumes. I wonder how do we adopt this now in GMF... Is there anyway to
find out whether the descriptor has been resolved or not (aside checking
if class has been loaded i guess)? So we don't load unnecessary plugins by
resolving all packages in the registry...
Any help is appreciated.
Thanks in advance.

Cheers,
Alex
Re: EPackage.Registry [message #429924 is a reply to message #429922] Wed, 06 May 2009 18:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Alex,

Comments below.

Alex Boyko wrote:
> Hi Ed,
>
> One of the recent changes to the registry is that after calling
> XXXEPackage.eINSTANCE the registry still contains an instance of
> descriptor and not an instance of EPackage as GMF MetaModelManager
> assumes.
How does this assumption manifest itself?
> I wonder how do we adopt this now in GMF...
Given the lack of detail, I'll only have to wonder as well.
> Is there anyway to find out whether the descriptor has been resolved
> or not (aside checking if class has been loaded i guess)?
Call getEPackage and it will be resolved.
> So we don't load unnecessary plugins by resolving all packages in the
> registry...
Call get and check if it's an instance of a descriptor.
> Any help is appreciated.
I'm just not sure what the problem is...
> Thanks in advance.
>
> Cheers,
> Alex
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EPackage.Registry [message #429926 is a reply to message #429924] Wed, 06 May 2009 18:53 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Ed,

It just checks whether the value in the registry is an instance of
EPackage and not Descriptor. If it's EPackage that meant that it was
resolved
The chunk of the code below is what's broken.

for (Iterator iter = EPackage.Registry.INSTANCE.values().iterator();
iter.hasNext();)
{
Object next = iter.next();

if (next instanceof EPackage) {
// skip descriptors because if the EPackage hasn't been
// instantiated then it cannot be in use by the client
EPackage pkg = (EPackage) next;

if (pkgName.equals(pkg.getName()))
{
result = findElement(pkg, id);
if (result != null) {
// register the package for subsequent look-ups
register(pkg, null);
break;
}
}
}

Thanks.

Cheers,
Alex
Re: EPackage.Registry [message #429927 is a reply to message #429926] Wed, 06 May 2009 18:57 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Alex Boyko schrieb:
> Ed,
>
> It just checks whether the value in the registry is an instance of
> EPackage and not Descriptor. If it's EPackage that meant that it was
> resolved
> The chunk of the code below is what's broken.
>
> for (Iterator iter = EPackage.Registry.INSTANCE.values().iterator();
> iter.hasNext();)
> {
> Object next = iter.next();
>
> if (next instanceof EPackage) {
> // skip descriptors because if the EPackage hasn't been
> // instantiated then it cannot be in use by the client
> EPackage pkg = (EPackage) next;
>
> if (pkgName.equals(pkg.getName()))
Are you aware that the package name is not required to be unique in a
registry?

Cheers
/Eike

----
http://thegordian.blogspot.com


> {
> result = findElement(pkg, id);
> if (result != null) {
> // register the package for subsequent look-ups
> register(pkg, null);
> break;
> }
> }
> }
>
> Thanks.
>
> Cheers,
> Alex
>
>


Re: EPackage.Registry [message #429928 is a reply to message #429926] Wed, 06 May 2009 19:01 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
I think it's broken because when EPAckage is created we put a "resolved"
descriptor instead of the EPackage itself in the registry see the
constructor EPackageImpl(String, EFactory)

Perhaps I could check if the EFactory is there?

Cheers,
Alex
Re: EPackage.Registry [message #429929 is a reply to message #429927] Wed, 06 May 2009 19:05 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Yes, that's another issue... I could try reworking those ids such that
they are based on nsuri, but not for GMF M7 i guess.
The problem here is that I cannot tell reolved EPackage from the
unresolved one

Cheers,
Alex
Re: EPackage.Registry [message #429931 is a reply to message #429928] Wed, 06 May 2009 19:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Alex,

Yes, exactly, and that's needed because otherwise any thread could get
access to a partially initialized package, which is the problem that was
fixed. I suppose at the end of the init method we could put the
package into the registry...


Alex Boyko wrote:
> I think it's broken because when EPAckage is created we put a
> "resolved" descriptor instead of the EPackage itself in the registry
> see the constructor EPackageImpl(String, EFactory)
>
> Perhaps I could check if the EFactory is there?
>
> Cheers,
> Alex
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EPackage.Registry [message #429932 is a reply to message #429931] Wed, 06 May 2009 19:34 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Ed,

You mean at the end of XXXPackageImpl init method is ok to add the package
to the registry?
Thanks.

Cheers,
Alex
Re: EPackage.Registry [message #429934 is a reply to message #429932] Wed, 06 May 2009 19:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Alex,

Yes, once the package is fully initialized at the end of the init, we
could add it to the registry to replace the "temporary descriptor" which
is there to ensure that other threads block and the initiating thread
doesn't reentrantly initialize the class (which unblocks other threads).


Alex Boyko wrote:
> Ed,
>
> You mean at the end of XXXPackageImpl init method is ok to add the
> package to the registry? Thanks.
>
> Cheers,
> Alex
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EPackage.Registry [message #429935 is a reply to message #429934] Wed, 06 May 2009 20:02 Go to previous message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Sounds good, Ed.
Thanks for the help!

Cheers,
Alex
Previous Topic:Proxies of abstract classes?
Next Topic:[CDO] New Documentation for Custom Store Developers
Goto Forum:
  


Current Time: Fri Apr 26 11:34:41 GMT 2024

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

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

Back to the top