Home » Modeling » EMF » retrieving the EFactory programmatically/dynamically
| | |
Re: retrieving the EFactory programmatically/dynamically [message #761011 is a reply to message #760969] |
Mon, 05 December 2011 19:13 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi Ed
Yes, but all auto-generated EObjects have a no argument constructor, so
he can just create an instance from the class.
Regards
Ed
On 05/12/2011 18:15, Ed Merks wrote:
> Ed,
>
> He'd need an instance to do that, but it sounds like he only has the
> java.lang.Class for the generated interface...
>
> Lorenzo,
>
> There's no direct mapping from java.lang.Class back to the package or
> factory. You'd need to use some type of indexing approach to have
> that type of information... Brute force searching of the package
> registry would be one way, unless you need to find it in the workspace
> not installed in the IDE...
>
>
> On 05/12/2011 9:26 AM, Ed Willink wrote:
>> Hi
>>
>> myObject.eClass().getEPackage().getEFactoryInstance()
>>
>> Regards
>>
>> Ed Willink
>>
>> On 05/12/2011 17:09, Lorenzo Bettini wrote:
>>> Hi
>>>
>>> say that I have the fully qualified name of a class implementing
>>> EObject; is there a way to retrieve the corresponding EFactory?
>>>
>>> My context is a DSL where I have something like
>>>
>>> new org.my.emf.model.MyObject()
>>>
>>> and during the generation I have to retrieve the EFactory
>>> corresponding to org.my.emf.model.MyObject
>>>
>>> I don't think there's a kind of registry holding this information,
>>> but it's worth trying and ask :)
>>>
>>> thanks in advance
>>> Lorenzo
>>>
>>
|
|
|
Re: retrieving the EFactory programmatically/dynamically [message #761066 is a reply to message #761011] |
Mon, 05 December 2011 20:50 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
It sounded more like he had the interface for it and the constructor for
the generated class is protected by default...
On 05/12/2011 11:13 AM, Ed Willink wrote:
> Hi Ed
>
> Yes, but all auto-generated EObjects have a no argument constructor,
> so he can just create an instance from the class.
>
> Regards
>
> Ed
>
> On 05/12/2011 18:15, Ed Merks wrote:
>> Ed,
>>
>> He'd need an instance to do that, but it sounds like he only has the
>> java.lang.Class for the generated interface...
>>
>> Lorenzo,
>>
>> There's no direct mapping from java.lang.Class back to the package or
>> factory. You'd need to use some type of indexing approach to have
>> that type of information... Brute force searching of the package
>> registry would be one way, unless you need to find it in the
>> workspace not installed in the IDE...
>>
>>
>> On 05/12/2011 9:26 AM, Ed Willink wrote:
>>> Hi
>>>
>>> myObject.eClass().getEPackage().getEFactoryInstance()
>>>
>>> Regards
>>>
>>> Ed Willink
>>>
>>> On 05/12/2011 17:09, Lorenzo Bettini wrote:
>>>> Hi
>>>>
>>>> say that I have the fully qualified name of a class implementing
>>>> EObject; is there a way to retrieve the corresponding EFactory?
>>>>
>>>> My context is a DSL where I have something like
>>>>
>>>> new org.my.emf.model.MyObject()
>>>>
>>>> and during the generation I have to retrieve the EFactory
>>>> corresponding to org.my.emf.model.MyObject
>>>>
>>>> I don't think there's a kind of registry holding this information,
>>>> but it's worth trying and ask :)
>>>>
>>>> thanks in advance
>>>> Lorenzo
>>>>
>>>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: retrieving the EFactory programmatically/dynamically [message #761471 is a reply to message #760969] |
Tue, 06 December 2011 14:14 |
|
On 12/05/2011 07:15 PM, Ed Merks wrote:
> Ed,
>
> He'd need an instance to do that, but it sounds like he only has the
> java.lang.Class for the generated interface...
>
> Lorenzo,
>
> There's no direct mapping from java.lang.Class back to the package or
> factory. You'd need to use some type of indexing approach to have that
> type of information... Brute force searching of the package registry
> would be one way, unless you need to find it in the workspace not
> installed in the IDE...
>
Hi Ed(s) :)
yes, I only have the java.lang.Class, and I'd need a solution who would
work also in 'standalone' mode... for the moment, I'll do without
thanks
Lorenzo
>
> On 05/12/2011 9:26 AM, Ed Willink wrote:
>> Hi
>>
>> myObject.eClass().getEPackage().getEFactoryInstance()
>>
>> Regards
>>
>> Ed Willink
>>
>> On 05/12/2011 17:09, Lorenzo Bettini wrote:
>>> Hi
>>>
>>> say that I have the fully qualified name of a class implementing
>>> EObject; is there a way to retrieve the corresponding EFactory?
>>>
>>> My context is a DSL where I have something like
>>>
>>> new org.my.emf.model.MyObject()
>>>
>>> and during the generation I have to retrieve the EFactory
>>> corresponding to org.my.emf.model.MyObject
>>>
>>> I don't think there's a kind of registry holding this information,
>>> but it's worth trying and ask :)
>>>
>>> thanks in advance
>>> Lorenzo
>>>
>>
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: retrieving the EFactory programmatically/dynamically [message #761472 is a reply to message #761066] |
Tue, 06 December 2011 14:14 |
|
Exactly as you said.
You can imagine that the underlying context is Xtext :)
cheers
Lorenzo
On 12/05/2011 09:50 PM, Ed Merks wrote:
> It sounded more like he had the interface for it and the constructor for
> the generated class is protected by default...
>
> On 05/12/2011 11:13 AM, Ed Willink wrote:
>> Hi Ed
>>
>> Yes, but all auto-generated EObjects have a no argument constructor,
>> so he can just create an instance from the class.
>>
>> Regards
>>
>> Ed
>>
>> On 05/12/2011 18:15, Ed Merks wrote:
>>> Ed,
>>>
>>> He'd need an instance to do that, but it sounds like he only has the
>>> java.lang.Class for the generated interface...
>>>
>>> Lorenzo,
>>>
>>> There's no direct mapping from java.lang.Class back to the package or
>>> factory. You'd need to use some type of indexing approach to have
>>> that type of information... Brute force searching of the package
>>> registry would be one way, unless you need to find it in the
>>> workspace not installed in the IDE...
>>>
>>>
>>> On 05/12/2011 9:26 AM, Ed Willink wrote:
>>>> Hi
>>>>
>>>> myObject.eClass().getEPackage().getEFactoryInstance()
>>>>
>>>> Regards
>>>>
>>>> Ed Willink
>>>>
>>>> On 05/12/2011 17:09, Lorenzo Bettini wrote:
>>>>> Hi
>>>>>
>>>>> say that I have the fully qualified name of a class implementing
>>>>> EObject; is there a way to retrieve the corresponding EFactory?
>>>>>
>>>>> My context is a DSL where I have something like
>>>>>
>>>>> new org.my.emf.model.MyObject()
>>>>>
>>>>> and during the generation I have to retrieve the EFactory
>>>>> corresponding to org.my.emf.model.MyObject
>>>>>
>>>>> I don't think there's a kind of registry holding this information,
>>>>> but it's worth trying and ask :)
>>>>>
>>>>> thanks in advance
>>>>> Lorenzo
>>>>>
>>>>
>>
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: retrieving the EFactory programmatically/dynamically [message #761496 is a reply to message #761472] |
Tue, 06 December 2011 14:47 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Lorenzo,
With the Xcore work, we have indexing support for *.genmodel/*.ecore as
well as for *.xcore so I imagine you'll be able to reuse that at some
point soon: https://github.com/merks/Xcore
On 06/12/2011 6:14 AM, Lorenzo Bettini wrote:
> Exactly as you said.
>
> You can imagine that the underlying context is Xtext :)
>
> cheers
> Lorenzo
>
> On 12/05/2011 09:50 PM, Ed Merks wrote:
>> It sounded more like he had the interface for it and the constructor for
>> the generated class is protected by default...
>>
>> On 05/12/2011 11:13 AM, Ed Willink wrote:
>>> Hi Ed
>>>
>>> Yes, but all auto-generated EObjects have a no argument constructor,
>>> so he can just create an instance from the class.
>>>
>>> Regards
>>>
>>> Ed
>>>
>>> On 05/12/2011 18:15, Ed Merks wrote:
>>>> Ed,
>>>>
>>>> He'd need an instance to do that, but it sounds like he only has the
>>>> java.lang.Class for the generated interface...
>>>>
>>>> Lorenzo,
>>>>
>>>> There's no direct mapping from java.lang.Class back to the package or
>>>> factory. You'd need to use some type of indexing approach to have
>>>> that type of information... Brute force searching of the package
>>>> registry would be one way, unless you need to find it in the
>>>> workspace not installed in the IDE...
>>>>
>>>>
>>>> On 05/12/2011 9:26 AM, Ed Willink wrote:
>>>>> Hi
>>>>>
>>>>> myObject.eClass().getEPackage().getEFactoryInstance()
>>>>>
>>>>> Regards
>>>>>
>>>>> Ed Willink
>>>>>
>>>>> On 05/12/2011 17:09, Lorenzo Bettini wrote:
>>>>>> Hi
>>>>>>
>>>>>> say that I have the fully qualified name of a class implementing
>>>>>> EObject; is there a way to retrieve the corresponding EFactory?
>>>>>>
>>>>>> My context is a DSL where I have something like
>>>>>>
>>>>>> new org.my.emf.model.MyObject()
>>>>>>
>>>>>> and during the generation I have to retrieve the EFactory
>>>>>> corresponding to org.my.emf.model.MyObject
>>>>>>
>>>>>> I don't think there's a kind of registry holding this information,
>>>>>> but it's worth trying and ask :)
>>>>>>
>>>>>> thanks in advance
>>>>>> Lorenzo
>>>>>>
>>>>>
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: retrieving the EFactory programmatically/dynamically [message #766288 is a reply to message #761496] |
Thu, 15 December 2011 14:01 |
|
On 12/06/2011 03:47 PM, Ed Merks wrote:
> Lorenzo,
>
> With the Xcore work, we have indexing support for *.genmodel/*.ecore as
> well as for *.xcore so I imagine you'll be able to reuse that at some
> point soon: https://github.com/merks/Xcore
Uh! That's great!
I'm looking forward to reusing it.
thanks Ed
cheers
Lorenzo
>
> On 06/12/2011 6:14 AM, Lorenzo Bettini wrote:
>> Exactly as you said.
>>
>> You can imagine that the underlying context is Xtext :)
>>
>> cheers
>> Lorenzo
>>
>> On 12/05/2011 09:50 PM, Ed Merks wrote:
>>> It sounded more like he had the interface for it and the constructor for
>>> the generated class is protected by default...
>>>
>>> On 05/12/2011 11:13 AM, Ed Willink wrote:
>>>> Hi Ed
>>>>
>>>> Yes, but all auto-generated EObjects have a no argument constructor,
>>>> so he can just create an instance from the class.
>>>>
>>>> Regards
>>>>
>>>> Ed
>>>>
>>>> On 05/12/2011 18:15, Ed Merks wrote:
>>>>> Ed,
>>>>>
>>>>> He'd need an instance to do that, but it sounds like he only has the
>>>>> java.lang.Class for the generated interface...
>>>>>
>>>>> Lorenzo,
>>>>>
>>>>> There's no direct mapping from java.lang.Class back to the package or
>>>>> factory. You'd need to use some type of indexing approach to have
>>>>> that type of information... Brute force searching of the package
>>>>> registry would be one way, unless you need to find it in the
>>>>> workspace not installed in the IDE...
>>>>>
>>>>>
>>>>> On 05/12/2011 9:26 AM, Ed Willink wrote:
>>>>>> Hi
>>>>>>
>>>>>> myObject.eClass().getEPackage().getEFactoryInstance()
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>> Ed Willink
>>>>>>
>>>>>> On 05/12/2011 17:09, Lorenzo Bettini wrote:
>>>>>>> Hi
>>>>>>>
>>>>>>> say that I have the fully qualified name of a class implementing
>>>>>>> EObject; is there a way to retrieve the corresponding EFactory?
>>>>>>>
>>>>>>> My context is a DSL where I have something like
>>>>>>>
>>>>>>> new org.my.emf.model.MyObject()
>>>>>>>
>>>>>>> and during the generation I have to retrieve the EFactory
>>>>>>> corresponding to org.my.emf.model.MyObject
>>>>>>>
>>>>>>> I don't think there's a kind of registry holding this information,
>>>>>>> but it's worth trying and ask :)
>>>>>>>
>>>>>>> thanks in advance
>>>>>>> Lorenzo
>>>>>>>
>>>>>>
>>>>
>>
>>
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Goto Forum:
Current Time: Fri Apr 26 19:58:09 GMT 2024
Powered by FUDForum. Page generated in 0.04018 seconds
|