What is the correct stage to use for Google Guice in production in an application server?
- by Yishai
It seems like a strange question (the obvious answer would Production, duh), but if you read the java docs:
/**
* We want fast startup times at the expense of runtime performance and some up front error
* checking.
*/
DEVELOPMENT,
/**
* We want to catch errors as early as possible and take performance hits up front.
*/
PRODUCTION
Assuming a scenario where you have a stateless call to an application server, the initial receiving method (or there abouts) creates the injector new every call. If there all of the module bindings are not needed in a given call, then it would seem to have been better to use the Development stage (which is the default) and not take the performance hit upfront, because you may never take it at all, and here the distinction between "upfront" and "runtime performance" is kind of moot, as it is one call.
Of course the downside of this would appear to be that you would lose the error checking, causing potential code paths to cause a problem by surprise.
So the question boils down to are the assumptions in the above correct? Will you save performance on a large set of modules when the given lifetime of an injector is one call?