Home » Modeling » TMF (Xtext) » Xtext runtime tries to access internet at application startup(Xtext runtime tries to access internet at application startup)
| | | |
Re: Xtext runtime tries to access internet at application startup [message #1064503 is a reply to message #1064431] |
Wed, 19 June 2013 14:16 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
That's the registration of the ResourceFactory, but I mean the
registration of the EcorePackage. It should happen automatically as soon
as you access the EcorePackage.eINSTANCE, but you can of course do it
explicitly:
org.eclipse.emf.ecore.impl.EcorePackageImpl.init()
Am 19.06.13 10:52, schrieb FJ Stöver:
> Good morning Jan,
>
> Thank you for your prompt reply.
>
>> That should not be the case, when the EcorePackage is correctly
> registered.
>
> For registration we use the generated code in
> BaseStandaloneSetupGenerated.java:
>
> ...
> if
> (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
> "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
> ...
>
>
> That seemed to be ok, and we tried to replace in the grammar
>
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>
> by
>
> import "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
>
> which gave the warning "Fix the bogus package import; import
> 'http://www.eclipse.org/emf/2002/Ecore'".
>
> When compiling the grammar however it gave the error "Couldn't resolve
> reference to EPackage
> 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore' ..."
>
> Any idea how to go the 'import from platform' approach ?
>
> Whatever: If the 'import from platform' approach is not successful, or
> the problem persists, then the next well probably be to produce a repro.
>
> kind regards Franz-Josef
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
| |
Re: Xtext runtime tries to access internet at application startup [message #1064584 is a reply to message #1064503] |
Thu, 20 June 2013 06:30 |
Ed Merks Messages: 33136 Registered: July 2009 |
Senior Member |
|
|
Jan,
A better idiom for forcing package initialization is
XyzPackage.eINSTANCE.eClass(); it's better to write code that assumes
the generated Impls are private.
On 19/06/2013 4:16 PM, Jan Koehnlein wrote:
> That's the registration of the ResourceFactory, but I mean the
> registration of the EcorePackage. It should happen automatically as
> soon as you access the EcorePackage.eINSTANCE, but you can of course
> do it explicitly:
>
> org.eclipse.emf.ecore.impl.EcorePackageImpl.init()
>
> Am 19.06.13 10:52, schrieb FJ Stöver:
>> Good morning Jan,
>>
>> Thank you for your prompt reply.
>>
>>> That should not be the case, when the EcorePackage is correctly
>> registered.
>>
>> For registration we use the generated code in
>> BaseStandaloneSetupGenerated.java:
>>
>> ...
>> if
>> (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
>>
>>
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
>> "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
>> ...
>>
>>
>> That seemed to be ok, and we tried to replace in the grammar
>>
>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>
>> by
>>
>> import "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
>>
>> which gave the warning "Fix the bogus package import; import
>> 'http://www.eclipse.org/emf/2002/Ecore'".
>>
>> When compiling the grammar however it gave the error "Couldn't resolve
>> reference to EPackage
>> 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore' ..."
>>
>> Any idea how to go the 'import from platform' approach ?
>>
>> Whatever: If the 'import from platform' approach is not successful, or
>> the problem persists, then the next well probably be to produce a repro.
>>
>> kind regards Franz-Josef
>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Xtext runtime tries to access internet at application startup [message #1064619 is a reply to message #1064584] |
Thu, 20 June 2013 09:14 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
In terms of readability, my solution feels a bit more explicit. Yours
would definitively need a comment that you are just doing it for a
magical side-effect in order not to be removed in the next refactoring.
I'd prefer an even more explicit statement (involving the
EPackage.Registry), but then we are likely introducing some obsolete
action.
Am 20.06.13 08:30, schrieb Ed Merks:
> Jan,
>
> A better idiom for forcing package initialization is
> XyzPackage.eINSTANCE.eClass(); it's better to write code that assumes
> the generated Impls are private.
>
> On 19/06/2013 4:16 PM, Jan Koehnlein wrote:
>> That's the registration of the ResourceFactory, but I mean the
>> registration of the EcorePackage. It should happen automatically as
>> soon as you access the EcorePackage.eINSTANCE, but you can of course
>> do it explicitly:
>>
>> org.eclipse.emf.ecore.impl.EcorePackageImpl.init()
>>
>> Am 19.06.13 10:52, schrieb FJ Stöver:
>>> Good morning Jan,
>>>
>>> Thank you for your prompt reply.
>>>
>>>> That should not be the case, when the EcorePackage is correctly
>>> registered.
>>>
>>> For registration we use the generated code in
>>> BaseStandaloneSetupGenerated.java:
>>>
>>> ...
>>> if
>>> (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
>>>
>>>
>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
>>> "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
>>> ...
>>>
>>>
>>> That seemed to be ok, and we tried to replace in the grammar
>>>
>>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>>
>>> by
>>>
>>> import "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
>>>
>>> which gave the warning "Fix the bogus package import; import
>>> 'http://www.eclipse.org/emf/2002/Ecore'".
>>>
>>> When compiling the grammar however it gave the error "Couldn't resolve
>>> reference to EPackage
>>> 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore' ..."
>>>
>>> Any idea how to go the 'import from platform' approach ?
>>>
>>> Whatever: If the 'import from platform' approach is not successful, or
>>> the problem persists, then the next well probably be to produce a repro.
>>>
>>> kind regards Franz-Josef
>>>
>>
>>
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
| |
Re: Xtext runtime tries to access internet at application startup [message #1064633 is a reply to message #1064619] |
Thu, 20 June 2013 10:41 |
Ed Merks Messages: 33136 Registered: July 2009 |
Senior Member |
|
|
Jan,
EPackage.Registry.INSTANCE.getEPackage(XyzPackage.eNS_URI) works too.
Accessing model implementation classes shouldn't be encouraged...
On 20/06/2013 11:14 AM, Jan Koehnlein wrote:
> In terms of readability, my solution feels a bit more explicit. Yours
> would definitively need a comment that you are just doing it for a
> magical side-effect in order not to be removed in the next
> refactoring. I'd prefer an even more explicit statement (involving the
> EPackage.Registry), but then we are likely introducing some obsolete
> action.
>
> Am 20.06.13 08:30, schrieb Ed Merks:
>> Jan,
>>
>> A better idiom for forcing package initialization is
>> XyzPackage.eINSTANCE.eClass(); it's better to write code that assumes
>> the generated Impls are private.
>>
>> On 19/06/2013 4:16 PM, Jan Koehnlein wrote:
>>> That's the registration of the ResourceFactory, but I mean the
>>> registration of the EcorePackage. It should happen automatically as
>>> soon as you access the EcorePackage.eINSTANCE, but you can of course
>>> do it explicitly:
>>>
>>> org.eclipse.emf.ecore.impl.EcorePackageImpl.init()
>>>
>>> Am 19.06.13 10:52, schrieb FJ Stöver:
>>>> Good morning Jan,
>>>>
>>>> Thank you for your prompt reply.
>>>>
>>>>> That should not be the case, when the EcorePackage is correctly
>>>> registered.
>>>>
>>>> For registration we use the generated code in
>>>> BaseStandaloneSetupGenerated.java:
>>>>
>>>> ...
>>>> if
>>>> (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
>>>>
>>>>
>>>>
>>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
>>>> "ecore", new
>>>> org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
>>>> ...
>>>>
>>>>
>>>> That seemed to be ok, and we tried to replace in the grammar
>>>>
>>>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>>>
>>>> by
>>>>
>>>> import "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
>>>>
>>>> which gave the warning "Fix the bogus package import; import
>>>> 'http://www.eclipse.org/emf/2002/Ecore'".
>>>>
>>>> When compiling the grammar however it gave the error "Couldn't resolve
>>>> reference to EPackage
>>>> 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore' ..."
>>>>
>>>> Any idea how to go the 'import from platform' approach ?
>>>>
>>>> Whatever: If the 'import from platform' approach is not successful, or
>>>> the problem persists, then the next well probably be to produce a
>>>> repro.
>>>>
>>>> kind regards Franz-Josef
>>>>
>>>
>>>
>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Xtext runtime tries to access internet at application startup [message #1064635 is a reply to message #1064632] |
Thu, 20 June 2013 10:56 |
Ed Merks Messages: 33136 Registered: July 2009 |
Senior Member |
|
|
Maybe a breakpoint in
org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URI, Map<?,
?>) would help track it down.
On 20/06/2013 12:43 PM, FJ Stöver wrote:
> Dear colleagues !
>
> Thank you for the valuable comments; I'll do my best to integrate it
> into our software.
>
> Meanwhile we have found out more:
>
> * If we have one Xtext parser instance everything works fine, and we
> observe no internet traffic. So I assume that package registration
> seems to be ok - though I'll look into your suggestions to improve the
> software.
>
> * If we have two Xtext parser instances then we observe Internet
> traffic ! Seems like they influence each other. We looked for static
> fields in our source, and in the Xtext generated sources, but didn't
> find anything.
>
> Any ideas ?
>
> kind regards
>
> Franz-Josef
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Fri Apr 19 02:21:36 GMT 2024
Powered by FUDForum. Page generated in 0.02448 seconds
|