A couple of things: 1) MyInterface.class could actually be MyAbstractClass.class 2) The instance returned by GWT.create is not necessarily stateless. So, even though both objects are equal upon creation, you can manipulate them afterward. As a result, you don't want both calls to GWT.create to return the same instance (unless its meant to be a Singleton). 3) Nothing guarantees that the objects are actually equal upon creation: static information could be used to initialize them (i.e. random)
Cheers, Philippe On Thu, Jan 27, 2011 at 10:30 AM, Eric <erjab...@gmail.com> wrote: > > > On Jan 27, 1:43 am, PhilBeaudoin <philippe.beaud...@gmail.com> wrote: >> Hi all, >> >> Gin has a great feature where it will GWT.create() an interface if it >> is not explicitly bound. However, if you want the GWT.create() call to >> occur just once then you need to bind the interface as a singleton. >> Often it would be much simpler and cleaner to annotate the interface >> with @Singleton instead. This would be relatively easy to support in >> gin I believe, but unfortunately such scope annotations are not >> permitted by Guice. > > is there any reason to force the GWT-generated class to be a > singleton? > Since you're starting with an interface, GWT.create(MyInterface.class) > cannot have any instance-specific customization. There's no way to > apply any. So, two calls to GWT.create(MyInterface.class) would have > to create equivalent instances. I would not be surprised if GWT.create > just creates one global JavaScript instance for both. There's no > reason > for anything else. > > Respectfully, > Eric Jablow > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to google-guice@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. > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to google-guice@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.