Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Dependency injection in objects instantiated in custom code
Dependency injection in objects instantiated in custom code [message #1060866] Tue, 28 May 2013 14:28 Go to next message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
My question is mostly related to Google Guice. In my GlobalScopeProvider, I need to instantiate an XtextResource.

myResource = new XtextResource(myUri);


Is there a way I can take advantage of all bindings defined in my DSL module in order to populate XtextResource fields?
Re: Dependency injection in objects instantiated in custom code [message #1060871 is a reply to message #1060866] Tue, 28 May 2013 15:02 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1151
Registered: July 2009
Senior Member
Hi,

the whole point of dependency injection is not to use constructors... How about injecting IResourceFactory (bound in DefaultRuntimeModule)? Going back one step, I'd ask, why do you need a new XtextResource in the GlobalScopeProvider - what do you want to achieve?


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Dependency injection in objects instantiated in custom code [message #1060874 is a reply to message #1060871] Tue, 28 May 2013 15:15 Go to previous message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
I'm new to dependency injection, still getting the hang of it. I will try that.

Actually, I'm trying to treat imports for files outside the current project or even the workspace. It seems to me that creating a Resource objects for these files might help.
Previous Topic:xtext project creation programmatically
Next Topic:Add my var in Quick Reference
Goto Forum:
  


Current Time: Wed Aug 20 10:49:31 EDT 2014

Powered by FUDForum. Page generated in 0.01844 seconds