|Re: Creating an Action to Open the Xtext Project Wizard [message #697760 is a reply to message #697756]
||Mon, 18 July 2011 00:46
| Mirko Raner
Registered: July 2009
Location: New York City, NY
Welcome to the wonderful world of Guice dependency injection |
As you may know, Xtext relies heavily on the Guice dependency injection framework. This means that most collaborators of a class will be procured via an @Inject annotation, which means that you cannot simply instantiate a class using a "new". In this case, you are missing the Provider for the PluginProjectFactory.
Now, in some cases you can try supplying the missing dependencies manually, but usually the dependencies themselves have other (Guice-injected) dependencies, and so you will end up with a large and unmanageable dependency tree.
A better strategy is to get the Guice Injector from your UI plug-in's activator and use getInstance(...) to create the object you need.
But the very best solution is to have the objects you need injected into your own code, for example, by providing the appropriate fields with an @Inject annotation. However, this will only work if your class itself is instantiated via Guice.
Powered by FUDForum
. Page generated in 0.02274 seconds