Re: Non-deterministic trouble with PrivateModules and Multibindings
Take a look at http://code.google.com/p/google-guice/wiki/Multibindings#Limitations: You cannot create collections whose elements span private modules. That might be your problem. W On 27/08/2010 00:29, Esko Luontola wrote: I'm facing non-deterministic trouble with PrivateModules and Multibindings. My architecture is that I have Controller-Service pairs which communicate using a MessageQueue. Each Service is running in its own thread and only the Controller which is paired with it can send messages to it. All Controllers are placed into a ControllerHub (which is also itself a Service running in its own thread), which broadcasts messages to all Controllers. To prevent anyone else from getting direct access to the Controllers and Services, I've implemented them as PrivateModules like this: Infrastructure: http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/modules/ServiceInstallerModule.java http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/services/ServiceModule.java Modules: http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/modules/CommonModules.java http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/modules/ControllerModule.java http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/modules/AuthenticatorModule.java http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/modules/NetworkModule.java The class which gets all the ServiceRegistrations and starts them in their own threads: http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/services/ServiceStarter.java http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/services/ServiceRunner.java My problem is that even though I bind the message queue interfaces inside the private modules (http://github.com/orfjackal/dimdwarf/blob/ ctrl-bug/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/services/ ServiceModule.java#L72-76), sometimes non-deterministically the controllers from two different modules both receive the same message queue instance. Here are the controllers. I've made them print in their constructors the MessageSender instance that is injected. It will print either MessageQueue(Network) or MessageQueue(Authenticator) depending on which module owns that message queue. http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/scala/net/orfjackal/dimdwarf/auth/AuthenticatorController.scala http://github.com/orfjackal/dimdwarf/blob/ctrl-bug/dimdwarf-core/src/main/scala/net/orfjackal/dimdwarf/net/NetworkController.scala Here is the output from a passing test run. Notice that now AuthenticatorController and NetworkController both got their own MessageQueue instances injected. They print AuthenticatorController: MessageQueue(Authenticator) and NetworkController: MessageQueue(Network) respectively. 00:57:42.592 [main] INFO net.orfjackal.dimdwarf.server.Main - Dimdwarf 0.1.0-SNAPSHOT starting up 00:57:43.103 [main] INFO net.orfjackal.dimdwarf.server.Main - Modules loaded 00:57:43.113 [main] INFO net.orfjackal.dimdwarf.server.Main - Bootstrapper created AuthenticatorModule.service: MessageQueue(Authenticator) 00:57:43.117 [Authenticator] DEBUG n.o.d.services.ServiceMessageLoop - START: class net.orfjackal.dimdwarf.auth.AuthenticatorService NetworkModule.service: MessageQueue(Network) 00:57:43.120 [Network] DEBUG n.o.d.services.ServiceMessageLoop - START: class net.orfjackal.dimdwarf.net.NetworkService AuthenticatorController: MessageQueue(Authenticator) 00:57:43.238 [Controller] INFO n.o.d.modules.ControllerModule - Registering controller Authenticator of type net.orfjackal.dimdwarf.auth.AuthenticatorController NetworkController: MessageQueue(Network) 00:57:43.239 [Controller] INFO n.o.d.modules.ControllerModule - Registering controller Network of type net.orfjackal.dimdwarf.net.NetworkController 00:57:43.239 [Controller] DEBUG n.o.d.services.ServiceMessageLoop - START: class net.orfjackal.dimdwarf.controller.ControllerHub 00:57:43.241 [Network] INFO n.o.dimdwarf.net.NetworkService - Begin listening on port 56536 00:57:43.247 [main] INFO net.orfjackal.dimdwarf.server.Main - Server started 00:57:43.339 [NioProcessor-1] INFO o.a.m.filter.logging.LoggingFilter - CREATED 00:57:43.339 [NioProcessor-1] INFO o.a.m.filter.logging.LoggingFilter - OPENED 00:57:43.386 [NioProcessor-1] INFO o.a.m.filter.logging.LoggingFilter - RECEIVED: HeapBuffer[pos=0 lim=26 cap=2048: 00 18 10 05 00 04 75 73 65 72 00 0E 77 72 6F 6E...] 00:57:43.386 [NioProcessor-1] DEBUG o.a.m.f.codec.ProtocolCodecFilter - Processing a MESSAGE_RECEIVED for session 1 00:57:43.395 [NioProcessor-1] DEBUG n.o.d.net.SimpleSgsProtocolIoHandler - RECEIVED: LoginRequest()
Re: Non-deterministic trouble with PrivateModules and Multibindings
I was able to find out what the problem was. One of the private modules had a constructor-injected dependency to a concrete class which was logically part of another private module. But since implicit bindings are created for concrete classes, the other class from the other private module became accidentally part of the this private module. Here a test to reproduce (also in http://pastebin.com/wt3YrkEx). The problem was that Foo had a direct dependency to Bar. The solution that I'll try is to create an interface for Bar, so that bindings are not created implicitly for it, and then expose Bar's interface from the other private module. import com.google.inject.*; import com.google.inject.name.Names; import org.junit.Test; import static org.junit.Assert.assertEquals; public class PrivateModuleBugTest { @Test public void private_modules_should_not_see_each_others_private_bindings() { Injector injector = Guice.createInjector(new FooModule(), new BarModule()); PrivateValue foo = injector.getInstance(Key.get(PrivateValue.class, Names.named(Foo))); Bar bar = ((Foo) foo).bar; assertEquals(Foo, foo.getClass().getSimpleName()); assertEquals(Foo-private, foo.getPrivateValue()); assertEquals(Bar, bar.getClass().getSimpleName()); assertEquals(Bar-private, bar.getPrivateValue()); // actually returns Foo-private } } class FooModule extends PrivateModule { protected void configure() { bind(String.class).toInstance(Foo-private); bind(PrivateValue.class).to(Foo.class); bind(PrivateValue.class).annotatedWith(Names.named(Foo)).to(Foo.class); expose(PrivateValue.class).annotatedWith(Names.named(Foo)); } } class BarModule extends PrivateModule { protected void configure() { bind(String.class).toInstance(Bar-private); bind(PrivateValue.class).to(Bar.class); bind(PrivateValue.class).annotatedWith(Names.named(Bar)).to(Bar.class); expose(PrivateValue.class).annotatedWith(Names.named(Bar)); } } class Foo implements PrivateValue { private final String privateValue; public final Bar bar; @Inject public Foo(String privateValue, Bar bar) { // there is no warning about this dependency to Bar this.privateValue = privateValue; this.bar = bar; } public String getPrivateValue() { return privateValue; } } class Bar implements PrivateValue { private final String privateValue; @Inject public Bar(String privateValue) { this.privateValue = privateValue; } public String getPrivateValue() { return privateValue; } } interface PrivateValue { String getPrivateValue(); } -- You received this message because you are subscribed to the Google Groups google-guice group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
Re: Non-deterministic trouble with PrivateModules and Multibindings
On Aug 27, 12:07 pm, Esko Luontola esko.luont...@gmail.com wrote: Here a test to reproduce (also inhttp://pastebin.com/wt3YrkEx). The problem was that Foo had a direct dependency to Bar. The solution that I'll try is to create an interface for Bar, so that bindings are not created implicitly for it, and then expose Bar's interface from the other private module. Another, maybe even better solution (it's more reliable), is to expose Bar.class in the BarModule. That way the dependency from Foo to Bar can be declared, but at the same time Bar will get its own instance of the String. class BarModule extends PrivateModule { protected void configure() { bind(String.class).toInstance(Bar-private); bind(PrivateValue.class).to(Bar.class); bind(Bar.class); expose(Bar.class); bind(PrivateValue.class).annotatedWith(Names.named(Bar)).to(Bar.class); expose(PrivateValue.class).annotatedWith(Names.named(Bar)); } } -- You received this message because you are subscribed to the Google Groups google-guice group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
Nice javadoc
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi guys, I have seen that the javadocs have improved much. I really like it. Any information about how to achieve that? Might be interesting for some other projects too... Thanks, Johannes - -- Johannes Schneider - blog.cedarsoft.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJMd4r2AAoJEAytD9R7Qv6dLBEH/jSi2rXRThCXGcNX1rr7SsDk tKRMj4ozwfOjLQua5bXlVqYpbRRwCTG6rkk+HX806nPR0aicboh74PrvPSW7FqY+ 8e/bIFPdqdDYYXl9bpENrt+m6yCBSezjT5h5hbUIGTYbW+pF9ryaPao0Mz0rKenP gbyN0y8xwu/vCzgzndM5LAVR4W1Jq/HF9CPngF0moiMhkLHloWVHpYYL2koAdwRw iLUasAREh0xEB2XeA22M0asC5eU2yVpqMWcVsIsdSoXgVjPkynF9Fuf9906AquUG /mjNML9jTB7VQwaq7m1DdIYBuXYELEPjlqPfO0QDCz5FBcGpxSFAEehyhvq+pAo= =x5W0 -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups google-guice group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
Re: Nice javadoc
Hi, I also find it much nicer. But I'm concerned about the missing annotations in the left column. We can access them if they are documented somewhere else, but not by the usual browsing (for instance in order to see @Assisted, I need to get on FactoryProvider then click on any @Assisted). Can this be fixed? Thanks and regards, Olivier 2010/8/27 Johannes Schneider maili...@cedarsoft.com -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi guys, I have seen that the javadocs have improved much. I really like it. Any information about how to achieve that? Might be interesting for some other projects too... Thanks, Johannes - -- Johannes Schneider - blog.cedarsoft.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJMd4r2AAoJEAytD9R7Qv6dLBEH/jSi2rXRThCXGcNX1rr7SsDk tKRMj4ozwfOjLQua5bXlVqYpbRRwCTG6rkk+HX806nPR0aicboh74PrvPSW7FqY+ 8e/bIFPdqdDYYXl9bpENrt+m6yCBSezjT5h5hbUIGTYbW+pF9ryaPao0Mz0rKenP gbyN0y8xwu/vCzgzndM5LAVR4W1Jq/HF9CPngF0moiMhkLHloWVHpYYL2koAdwRw iLUasAREh0xEB2XeA22M0asC5eU2yVpqMWcVsIsdSoXgVjPkynF9Fuf9906AquUG /mjNML9jTB7VQwaq7m1DdIYBuXYELEPjlqPfO0QDCz5FBcGpxSFAEehyhvq+pAo= =x5W0 -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups google-guice group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.comgoogle-guice%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-guice?hl=en. -- You received this message because you are subscribed to the Google Groups google-guice group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
Re: Nice javadoc
On Fri, Aug 27, 2010 at 11:52 AM, Johannes Schneider maili...@cedarsoft.com wrote: Might be interesting for some other projects too... It's the same JavaDoc style as Android's, so I maybe there's hope for the tool that generates it to be released one day? Moandji -- You received this message because you are subscribed to the Google Groups google-guice group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
Re: Nice javadoc
On Aug 27, 3:39 am, Olivier Grégoire ogrego...@gmail.com wrote: I also find it much nicer. But I'm concerned about the missing annotations in the left column. We can access them if they are documented somewhere else, but not by the usual browsing (for instance in order to see @Assisted, I need to get on FactoryProvider then click on any @Assisted). Yikes! What an awful bug. I'll get that fixed immediately! The tool is here: http://code.google.com/p/doclava/ As you can see from the missing annotations, we're still working out some bugs! Once that's worked out, I hope the tool will gain traction without our community. Cheers, Jesse -- You received this message because you are subscribed to the Google Groups google-guice group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
Issue 534 in google-guice: Add public api: Named.getValue()
Status: New Owner: New issue 534 by ma.qianfan: Add public api: Named.getValue() http://code.google.com/p/google-guice/issues/detail?id=534 In my properties file, I need to specify a sorting order, such as sort_10=abc sort_20=def sort_30=html I would like to figure out the order by doing: get properties name starting with sort_, use the following integer as index for ordering. I found it is hard to do it from Injector because it missed the api proposed. I could do my algorithm in multiple ways. but adding this api seems helpful. -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To post to this group, send email to google-guice-...@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en.
Re: Issue 534 in google-guice: Add public api: Named.getValue()
Comment #1 on issue 534 by mcculls: Add public api: Named.getValue() http://code.google.com/p/google-guice/issues/detail?id=534 @Named already has a method to get the value at runtime: Named.value() [this doesn't show up in the latest javadoc, but that's a bug in the new javadoc renderer] -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To post to this group, send email to google-guice-...@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en.
Re: Issue 534 in google-guice: Add public api: Named.getValue()
Yikes, another Doclava bug. I'll fix this right away! http://code.google.com/p/doclava/issues/detail?id=9 -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To post to this group, send email to google-guice-...@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en.