bineanzhou / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Bindings to Singleton fails depending on the order of bindings #181

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I attached a runnable code sample.

I make use of (dedicated) modules that make (dedicated) bindings to 
Singleton. Unfortunately the order of those bindings can not be arbitrary.
I.e., binding a class in Singleton having a parameter which is bound 
later - but before contruction - will fail.

Workaround is to make those singleton bindings the very last. But this 
breaks the ease of using my modules...

Thank you for this awesome framework.

Original issue reported on code.google.com by oliver.b...@googlemail.com on 16 Feb 2008 at 11:25

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ooops. Duplicate of 166. 

Original comment by oliver.b...@googlemail.com on 18 Feb 2008 at 9:15

GoogleCodeExporter commented 9 years ago
This can be solved by using the command-extension. 
Added util class that orders modules before creation. 
Could be improved by a more sophisticated Comparator.

Bye, Oli.

PS: WorksForMe

Original comment by oliver.b...@googlemail.com on 28 Feb 2008 at 4:15

Attachments:

GoogleCodeExporter commented 9 years ago
Dude, this is fantastic! I'm thrilled to see that the commands/ package is 
being put to good use.

I reviewed your code and I have some suggestions:
 - Consider using the CommandVisitor in order to assign ranks to commands. The visitor takes some getting 
used to, but it should provide a more elegant mapping.
 - It's necessary to call setInjector on the FutureInjector. This is necessary for the getProvider() command 
work.
 - Use an ArrayList rather than a LinkedList to sort the commands; the LinkedList needs to be copied into a 
temporary array to be sorted

Again, nice work.

Original comment by limpbizkit on 28 Feb 2008 at 8:36

GoogleCodeExporter commented 9 years ago
Closing as duplicate of 166.

Original comment by limpbizkit on 13 May 2008 at 8:45