Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EPackage.Registry.INSTANCE.getEFactory
EPackage.Registry.INSTANCE.getEFactory [message #405328] Wed, 15 November 2006 15:10 Go to next message
Eclipse UserFriend
Originally posted by: kellypu.ie.ibm.com

Hi all,

I have the following snippet of code

String ePackageName = configElement.getAttribute("nsURI");
EFactory factory = EPackage.Registry.INSTANCE.getEFactory(ePackageName);
if (factory instanceof IAdapterEFactory) {
allAdapterFactories.add(factory);
}


What I want to do is if the factory is not loaded (i.e. factory = null
above). I want to load the factory. I was wondering how I force this
load. Do I use the EPackage.Descriptor object to achieve this?
Also, The ePackageName a valid package nsURI.

Cheers,

Paul
Re: EPackage.Registry.INSTANCE.getEFactory [message #405329 is a reply to message #405328] Wed, 15 November 2006 15:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26287
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090405010500020603070402
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Paul,

It's better to fetch the EPackage and ask it for the factory. I.e.,
this will always return the factory if there is a registration for the
given nsURI.

EPackage.Registry.INSTANCE.getEPackage(ePackageNsURI).getEFa ctoryInstance()

The registry's getEFactory method is really just designed to support the
factory_override extension point. If there is no override and the
package hasn't been instantiated yet, it will return null so I don't
expect it to be used outside of the package initialization code.


Paul Kelly wrote:
> Hi all,
>
> I have the following snippet of code
>
> String ePackageName = configElement.getAttribute("nsURI");
> EFactory factory = EPackage.Registry.INSTANCE.getEFactory(ePackageName);
> if (factory instanceof IAdapterEFactory) {
> allAdapterFactories.add(factory);
> }
>
>
> What I want to do is if the factory is not loaded (i.e. factory = null
> above). I want to load the factory. I was wondering how I force this
> load. Do I use the EPackage.Descriptor object to achieve this?
> Also, The ePackageName a valid package nsURI.
>
> Cheers,
>
> Paul


--------------090405010500020603070402
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Paul,<br>
<br>
It's better to fetch the EPackage and ask it for the factory.&nbsp; I.e.,
this will always return the factory if there is a registration for the
given nsURI.<br>
<blockquote> EPackage.Registry.INSTANCE.getEPackage(ePackageNsURI).getEFa ctoryInstance() <br>
</blockquote>
The registry's getEFactory method is really just designed to support
the factory_override extension point.&nbsp; If there is no override and the
package hasn't been instantiated yet, it will return null so I don't
expect it to be used outside of the package initialization code.<br>
<br>
<br>
Paul Kelly wrote:
<blockquote cite="midejfals$mru$1@utils.eclipse.org" type="cite">Hi
all,
<br>
<br>
I have the following snippet of code
<br>
<br>
String ePackageName = configElement.getAttribute("nsURI");
<br>
EFactory factory =
EPackage.Registry.INSTANCE.getEFactory(ePackageName);
<br>
if (factory instanceof IAdapterEFactory) {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;allAdapterFactories. add(factory);
<br>
}
<br>
<br>
<br>
What I want to do is if the factory is not loaded (i.e. factory = null
above). I want to load the factory.&nbsp; I was wondering how I force this
load. Do I use the EPackage.Descriptor object to achieve this?
<br>
Also, The ePackageName a valid package nsURI.
<br>
<br>
Cheers,
<br>
<br>
Paul
<br>
</blockquote>
<br>
</body>
</html>

--------------090405010500020603070402--
Re: EPackage.Registry.INSTANCE.getEFactory [message #405330 is a reply to message #405329] Wed, 15 November 2006 16:01 Go to previous message
Eclipse UserFriend
Originally posted by: kellypu.ie.ibm.com

That sorted it.

Thanks (again!) Ed.

Paul

Ed Merks wrote:
> Paul,
>
> It's better to fetch the EPackage and ask it for the factory. I.e.,
> this will always return the factory if there is a registration for the
> given nsURI.
>
> EPackage.Registry.INSTANCE.getEPackage(ePackageNsURI).getEFa ctoryInstance()
>
> The registry's getEFactory method is really just designed to support the
> factory_override extension point. If there is no override and the
> package hasn't been instantiated yet, it will return null so I don't
> expect it to be used outside of the package initialization code.
>
>
> Paul Kelly wrote:
>> Hi all,
>>
>> I have the following snippet of code
>>
>> String ePackageName = configElement.getAttribute("nsURI");
>> EFactory factory = EPackage.Registry.INSTANCE.getEFactory(ePackageName);
>> if (factory instanceof IAdapterEFactory) {
>> allAdapterFactories.add(factory);
>> }
>>
>>
>> What I want to do is if the factory is not loaded (i.e. factory = null
>> above). I want to load the factory. I was wondering how I force this
>> load. Do I use the EPackage.Descriptor object to achieve this?
>> Also, The ePackageName a valid package nsURI.
>>
>> Cheers,
>>
>> Paul
>
Previous Topic:JMerge problem
Next Topic:XSD editor NullPointerException
Goto Forum:
  


Current Time: Sun Dec 21 18:05:04 GMT 2014

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

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