[OSGi] NoClassDefFoundError: com/google/inject/internal/util/$StackTraceElements
Hi guys, I am trying to use Guice within an OSGi context (Equinox). Unfortunately, I get a NoClassDefFoundError. I am using Guice 3.0-rc2 from Maven central. Any idea what the problem might be - or how I should/could solve it? Of course I could catch the exception within my bundle... Thanks, Johannes java.lang.NoClassDefFoundError: com/google/inject/internal/util/$StackTraceElements at com.google.inject.internal.Errors.formatInjectionPoint(Errors.java:697) at com.google.inject.internal.Errors.formatSource(Errors.java:659) at com.google.inject.internal.Errors.format(Errors.java:536) at com.google.inject.CreationException.getMessage(CreationException.java:48) at java.lang.Throwable.getLocalizedMessage(Throwable.java:267) at java.lang.Throwable.toString(Throwable.java:343) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:536) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTrace(Throwable.java:516) at org.eclipse.core.runtime.adaptor.EclipseLog.getStackTrace(EclipseLog.java:446) at org.eclipse.core.runtime.adaptor.EclipseLog.writeStack(EclipseLog.java:537) at org.eclipse.core.runtime.adaptor.EclipseLog.writeLog(EclipseLog.java:480) at org.eclipse.core.runtime.adaptor.EclipseLog.log(EclipseLog.java:306) at org.eclipse.core.internal.runtime.PlatformLogWriter.logging(PlatformLogWriter.java:35) at org.eclipse.core.internal.runtime.RuntimeLog.log(RuntimeLog.java:95) at org.eclipse.core.internal.runtime.InternalPlatform.log(InternalPlatform.java:711) at org.eclipse.core.internal.runtime.Log.log(Log.java:56) at org.eclipse.ui.statushandlers.WorkbenchErrorHandler.handle(WorkbenchErrorHandler.java:80) at org.eclipse.ui.internal.WorkbenchErrorHandlerProxy.handle(WorkbenchErrorHandlerProxy.java:36) at org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:189) at org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:231) at org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:242) at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:248) at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595) at org.eclipse.ui.internal.WorkbenchPage$ActivationList.setActive(WorkbenchPage.java:4218) at org.eclipse.ui.internal.WorkbenchPage$18.runWithException(WorkbenchPage.java:3277) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660) at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803) at org.eclipse.ui.internal.Workbench$31.runWithException(Workbench.java:1566) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2537) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at de.avat.service.platform.application.Application.start(Application.java:29) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Re: Guice RC2 Available
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thanks a lot mate. This has been the missing motivation for me to try Guice 3.0 RC2. On 01/10/2011 05:38 AM, Stuart McCulloch wrote: On 10 January 2011 02:02, Sam Berlin sber...@gmail.com mailto:sber...@gmail.com wrote: All, Guice 3.0 RC2 is now available. Please see http://code.google.com/p/google-guice/wiki/Guice30 http://code.google.com/p/google-guice/wiki/Guice30 for links and details of what changed since Guice 2.0 (and since the last Guice 3.0 snapshot). That page also contains a broad overview of new features since the 2.0 release. The bottom of the page has some notes about compatibility issues if upgrading from Guice 2.0. I am very confident that this will be the last release candidate and we'll roll smoothly into an official release very soon now. A maven build should appear soon, too. (Sorry that it wasn't released for rc1.. there were some differences between the ant maven build that we wanted to fix.) Hi everyone, Just to follow up - the maven artifacts have now been sync'd to central, including both standard and no_aop builds with source and javadoc: http://repo1.maven.org/maven2/com/google/inject/guice/3.0-rc2 as well as the various extensions: http://repo1.maven.org/maven2/com/google/inject/extensions Please report back to this list with your experiences using the release candidate. It will greatly help speedup and stabilize the release process. Please also report if you find any issues with the Maven artifacts or poms (especially wrt. dependencies) Happy New Year! -- Cheers, Stuart Thanks! sam -- 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-dev@googlegroups.com mailto:google-guice-dev@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com mailto:google-guice-dev%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en. -- 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-dev@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. - -- Johannes Schneider - blog.cedarsoft.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJNOuP+AAoJEAytD9R7Qv6d0acH/0F6kBXnCHeTK4VgOQZ18nU4 2HVa57FuSIr3rrhnOoQeVAo0tnfVOIxA5exVMf2QCk6t2Og+f5Kr//eSKAchkPgB tpas87jN92mmZv5rqGNuysSaVK8Fwed4/gkiEtT8C8kg6o+VXYhAXXi5JwhoQ5I6 LR0N5WnFXy6tVb2i4y2Zpl3hIylqFLZGEz973A3A9V4Unns5/iWrgTrDamkdfj7S 5iX6O+l2GeoKb0aP0r9B21Sd6axKaJ35MiuyYLUZhJiLU6KzNrJzMDTohR0R5mJ+ 33Q+Vj+xI+c89gtmsCXcJOCL9LAS8kjl9uwZGtuFmmIG/bdBrmu9vOq6DBsNy54= =Tg4f -END PGP SIGNATURE- -- 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-dev@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: Generics and binded interface inside another binded interface
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Use methods annotated with @Provided. In my opinion those methods are really good. A little bit verbose - but that is a good thing when using Generics... At least I am still able to read and understand those bindings after some time... On 09/23/2010 04:35 PM, Christian Goudreau wrote: Anyone else ? On Wed, Sep 22, 2010 at 11:34 AM, Christian Goudreau goudreau.christ...@gmail.com mailto:goudreau.christ...@gmail.com wrote: bind(MemberView.MyUiHandlers.class).to(MemberPresenter.class); bind(UiHandlersStrategy.class).annotatedWith(ProviderUiHandler.class).to(ProviderUiHandlersStrategyImpl.class); bind(UiHandlersStrategy.class).annotatedWith(SetterUiHandler.class).to(SetterUiHandlersStrategyImpl.class); public interface UiHandlersStrategyH extends UiHandlers { void setUiHandlers(H uiHandlers); H getUiHandlers(); } public class ProviderUiHandlersStrategyImplH extends UiHandlers implements UiHandlersStrategyH { private final ProviderH uiHandlersProvider; Here's more informations. What I don't get is that MyUiHandlers is declared... but my guest is that it is AFTER the other one... Cheers, On Wed, Sep 22, 2010 at 11:16 AM, Fred Faber ffa...@faiser.com mailto:ffa...@faiser.com wrote: Can you post your binding? You should be able to do this with something to the effect of: bind(new TypeLiteralUiHandlersStrategyMyUiHandlers(){}) .to(...your impl); -Fred On Mon, Sep 20, 2010 at 5:10 PM, Christian Goudreau goudreau.christ...@gmail.com mailto:goudreau.christ...@gmail.com wrote: Humm I think my subject is weird... anyway :D Here's what I want to do: @Inject public MemberView(@ProviderUiHandler final UiHandlersStrategyMyUiHandlers providerUiHandlersStrategyImpl) { My error: 17:02:42.928 [ERROR] [apapul] No implementation bound for key Key[type=ca.ulaval.apapul.client.mvp.strategies.uihandlers.UiHandlersStrategyca.ulaval.apapul.client.core.member.MemberView$MyUiHandlers, annotati...@ca.ulaval.apapul.client.mvp.gin.provideruihandler] MyUiHandlers is also an interface binded by Gin/Guice. Using the implementation class instead the interface work, but I wanted to use the interface with an annotation. Btw, is this worth the pain ? That seem to be almost as if I was using the implementation class anyway... Thanks and cheers, -- Christian Goudreau www.arcbees.com http://www.arcbees.com -- 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 mailto:google-guice@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com mailto:google-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-guice@googlegroups.com mailto:google-guice@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com mailto:google-guice%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en. -- Christian Goudreau www.arcbees.com http://www.arcbees.com -- Christian Goudreau www.arcbees.com http://www.arcbees.com -- 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. - -- Johannes Schneider - blog.cedarsoft.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJMnGREAAoJEAytD9R7Qv6dOksIAMinVSjEBjU2omN7AFci9qnW pxSdZTDOVT8N0vPbCk7ZYb//h5SjkyGqCP5OJhw6UHEW7Ob04bcw7bJppJpaWN6X zRfatns0r7wUzGMBnF/HtqF91wW80DbMbkQf6UIAR5KXvWaBRdRUIj5p5ly4qfPC xUqvKz1wRWcUIBu8bsY5KqVNQSMHIiLj/uS01KeDNNZ6ML+Hlk2E0BUlpXA113nJ FlvOv5sUHpBmpwDFiaefIL3BQ66QRf2NEnMlMk/AVWzqecwIxuf9YjHvHHatzj+J 8ZoLHUxzFsDRpIppZF5sEI5VkUmff5B8nNT4V/iYG270MrCCi
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: Ping? Could a Guice maintainer comment? (Re: Move internal utility code to separate package?)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/10/2010 09:08 PM, Dhanji R. Prasanna wrote: We should just obfuscate Immutable* so it doesn't bother IDE importers. Wonder if Jarjar can do that. IDE code completion problems are just one symptom. The problem (potentially a lot of duplicate code) isn't solved through obfuscation/renamings/whatever... Johannes Dhanji. On Thu, Jun 10, 2010 at 11:37 AM, Johannes Schneider maili...@cedarsoft.com mailto:maili...@cedarsoft.com wrote: On 06/10/2010 08:20 PM, Eric Burke wrote: -1 to new external dependencies. I'd rather Guice be free to innovate rather than tie itself to a particular version of an external library. Not to mention the added headaches when my app already uses one version of an external library but now Guice thinks I should have a different version of the library, and they have conflicts. Yeah, I see that point. But if everybody uses the solution you propose, we will end up with several **.internal.ImmutableList classes for larger projects. This doesn't scale either... So adding every lib as internal will lead into the wrong direction. And that just because it *might* be possible for some projects that there is an incompatible version clash. So what can we do to about that? Maybe two different versions? Adds a lot of complexity to the build process... In Maven land that could be useful: http://mojo.codehaus.org/minijar-maven-plugin Never tried it myself... -- Default case for normal projects: External dependency to Guava -- Special case for Android/avoiding-dep-problems users Regards, Johannes Furthermore, Guice works well on Android now. Adding external library dependencies may make this more complicated. On Thu, Jun 10, 2010 at 11:11 AM, Christian Edward Gruber cgru...@google.com mailto:cgru...@google.com mailto:cgru...@google.com mailto:cgru...@google.com wrote: +1. On Jun 10, 2010, at 7:04 AM, Johannes Schneider wrote: On 06/03/2010 04:31 PM, je...@swank.ca mailto:je...@swank.ca mailto:je...@swank.ca mailto:je...@swank.ca wrote: Moving these classes is a fine idea, but it will cause pain for any developer who has mistakenly imported Guice's ImmutableSet (etc.) rather than that from Guava. Maybe it is a good idea to remove that interal classes completly and instead create a dependency to Guava? In nearly every project, I have many duplicates... -- 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-dev@googlegroups.com mailto:google-guice-dev@googlegroups.com mailto:google-guice-dev@googlegroups.com mailto:google-guice-dev@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com mailto:google-guice-dev%2bunsubscr...@googlegroups.com mailto:google-guice-dev%2bunsubscr...@googlegroups.com mailto:google-guice-dev%252bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en. -- Eric M. Burke http://www.linkedin.com/in/ericburke 314-494-3185 (mobile) 636-294-0191 (home) -- 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-dev@googlegroups.com mailto:google-guice-dev@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com mailto:google-guice-dev%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en. - -- 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-dev@googlegroups.com mailto:google-guice-dev@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com mailto:google-guice-dev%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en. -- 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. - -- Johannes Schneider - blog.cedarsoft.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJMEiw2AAoJEAytD9R7Qv6dQjEH+wdk1EUg29aMuDrpEGbw3JfR BcbhGMXG3VaU68ddLieVYbahsP1lLqclrcDMh02ppg8axbwvJ8coc64Pl/cmbXnH CYIzSIJeql5zZjlBYJ23/b1tadyxaR5qF3JyVDz7AG2KWU9V1q1BEimPJ5uBSb11 SXmmvz5S/2vz7jImWXWxJNludbIjqlmeT5ZK8GSLHQU/3Cl1CmCsZnFkYfPBAjQ8 1XFcJpcm+KTWMC08Q
Re: Ping? Could a Guice maintainer comment? (Re: Move internal utility code to separate package?)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/03/2010 04:31 PM, je...@swank.ca wrote: Moving these classes is a fine idea, but it will cause pain for any developer who has mistakenly imported Guice's ImmutableSet (etc.) rather than that from Guava. Maybe it is a good idea to remove that interal classes completly and instead create a dependency to Guava? In nearly every project, I have many duplicates... Unfortunately IDEs have a habit of importing the wrong package on a user's behalf, which makes this mistake somewhat common. Yes, I think the vendors know exactly what type I want to import. And then they put that one to the bottom. I think one should create a Plugin that simply inverts the List of possible imports. Would safe me several key strokes every day Probably there is some sort of unholy alliance between the IDE vendors and keyboard manufacturers Fortunately it is possible to exclude packages from being imported in IntelliiJ Idea. Johannes This doesn't rule out the change completely, but it does make it significantly less compelling. - -- Johannes Schneider - blog.cedarsoft.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJMEMayAAoJEAytD9R7Qv6dogIH/30YQm2ySVb/836HhBar00w0 Ti6W/5xksvmvho8buo8fe1Q6Tiebt3yceBFUcA2ZLVmCIMSy9a/Kms3Qb0KgzvLE ZN9kbDlMdVYNb91YLq2ozIIh7dQbi525R0M/Po3q50jeWsYPsj6iwPbCaI5SRQWS 9XZZbaFk9rOVQScdO9raJlelGdIlXvc37rI1iGF2PvKl+q/jJfZuP5nzzuZdV4Us Urnpm+LsWwjvzzh0ISEkz1IGU0ZFGiWYZPKo5OK1GVSBISHZeLAMZMpbMCnUFuhq +fUK4+FUYdrO686u5VITh+YCgZkK4rigx083073DmYLcGU+/fiuuPZGly216iMU= =+x2O -END PGP SIGNATURE- -- 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.
Multibinding + Collection types
Hi, I recently started to use the Multibinder - thanks for that work. But now I find me writing that code several times: MultibinderImageSelectionStrategy strategyMultibinder = Multibinder.newSetBinder( binder(), ImageSelectionStrategy.class ); strategyMultibinder.addBinding().to( Impl1.class ); strategyMultibinder.addBinding().to( Impl2.class ); bind( new TypeLiteralCollection? extends ImageSelectionStrategy() { } ).to( new TypeLiteralSetImageSelectionStrategy() { } ); This is necessary because I inject the strategies using a parameter of type Collection? extends ImageSelectionStrategy. Could that not-so-readable part with the type literals be skipped somehow? I think that is quite a common use case and maybe should be added to the multibinder? Sincerly, Johannes --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Multibinding + Collection types
Hmm, I think that Key should always be cast - of course. So binder.bind( ( ( KeyCollection? extends Integer ) Key.get( Types.newParameterizedType( Collection.class, Types.subtypeOf( Integer.class ) ) ) ) ).to( ( Key? extends Collection? extends Integer ) Key.get( Types.setOf( Integer.class ) ) ); compiles... Thanks Johannes Schneider wrote: Thanks for pointing at that class. Have missed it completely. But now I have a generics related problem with the compiler. I can fix it using casts but I'd like to understand my error: Could anyone give me a hint why this code does not compile? binder.bind( Key.get( Types.newParameterizedType( Collection.class, Types.subtypeOf( Integer.class ) ) ) ).to( Key.get( Types.setOf( Integer.class ) ) ); Sincerly, Johannes je...@swank.ca wrote: On Oct 15, 6:42 am, Johannes Schneider maili...@cedarsoft.com wrote: This is necessary because I inject the strategies using a parameter of type Collection? extends ImageSelectionStrategy. Could that not-so-readable part with the type literals be skipped somehow? I think that is quite a common use case and maybe should be added to the multibinder? I think a your one-statement is the right fix here. If you write this too often, you can encapsulate it by using the Types utility class to compose the appropriate type objects: bindWildcardCollectionForSet(binder(), ImageSelectionStrategy.class); http://google-guice.googlecode.com/svn/tags/2.0/javadoc/com/google/inject/util/Types.html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Wildcards...
Thanks for your suggestion - I have discovered the provides methods (annotated with @Provides) that do the same thing. So for all you out there - just use that annotation - will save a lot of work and the code gets a lot clearer. Btw: Guice is great Btw2: Plz upload to maven central Regards, Johannes je...@swank.ca wrote: On Jun 6, 8:48 am, Johannes Schneider maili...@cedarsoft.com wrote: bind( ( TypeLiteralList? extends B ) TypeLiteral.get( Types.listOf( Types.subtypeOf( new TypeLiteralB?() { }.getType() ) ) ) ).toProvider( BProvider.class ); Not much I can really say - creating models for complex types code- intensive. TypeLiteral works for some wildcards, and for the ones it doesn't you can either use the Types factory class, or you can do something reflective. private final List? extends B? unused = null; private final TypeLiteralList? extends B? type = fieldToType (MyClass.class, unused); private static Type fieldToType(Class? definedIn, String name) { return definedIn.getDeclaredField(name).getGenericType(); } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Wildcards...
Hi, I think someone at Google really understands Generics ;-). At the moment I try to understand how Guice manges those things. Therefore I have created a small sample that works. But I would like to have any feedback how that should/could be solved better: Regards, Johannes public class GuiceListWildcardTest { @Test public void testIt() { Injector injector = Guice.createInjector( new AbstractModule() { @Override protected void configure() { bind( ( TypeLiteralList? extends B ) TypeLiteral.get( Types.listOf( Types.subtypeOf( new TypeLiteralB?() { }.getType() ) ) ) ).toProvider( BProvider.class ); } } ); A a = injector.getInstance( A.class ); assertEquals( a.bs.size(), 2 ); } public static class A { private final List? extends B? bs; @Inject public A( @NotNull List? extends B? bs ) { this.bs = bs; } } public static class BT { } public static class BProvider implements ProviderList? extends B { @Override public List? extends B get() { return Arrays.asList( new B(), new B() ); } } } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Wildcards...
one more time: public class GuiceListWildcardTest { @Test public void testIt() { Injector injector = Guice.createInjector( new AbstractModule() { @Override protected void configure() { bind( ( TypeLiteralList? extends B? ) TypeLiteral.get( Types.listOf( Types.subtypeOf( new TypeLiteralB?() { }.getType() ) ) ) ).toProvider( BProvider.class ); } } ); A a = injector.getInstance( A.class ); assertEquals( a.bs.size(), 2 ); } public static class A { private final List? extends B? bs; @Inject public A( @NotNull List? extends B? bs ) { this.bs = bs; } } public static class BT { } public static class BProvider implements ProviderList? extends B? { @Override public List? extends B? get() { return Arrays.B?asList( new B(), new B() ); } } } Johannes Schneider wrote: Improved a little (forgot wildcard at provider): public class GuiceListWildcardTest { @Test public void testIt() { Injector injector = Guice.createInjector( new AbstractModule() { @Override protected void configure() { bind( ( TypeLiteralList? extends B ) TypeLiteral.get( Types.listOf( Types.subtypeOf( new TypeLiteralB?() { }.getType() ) ) ) ).toProvider( BProvider.class ); } } ); A a = injector.getInstance( A.class ); assertEquals( a.bs.size(), 2 ); } public static class A { private final List? extends B? bs; @Inject public A( @NotNull List? extends B? bs ) { this.bs = bs; } } public static class BT { } public static class BProvider implements ProviderList? extends B? { @Override public List? extends B? get() { return Arrays.B?asList( new B(), new B() ); } } } Johannes Schneider wrote: Hi, I think someone at Google really understands Generics ;-). At the moment I try to understand how Guice manges those things. Therefore I have created a small sample that works. But I would like to have any feedback how that should/could be solved better: Regards, Johannes public class GuiceListWildcardTest { @Test public void testIt() { Injector injector = Guice.createInjector( new AbstractModule() { @Override protected void configure() { bind( ( TypeLiteralList? extends B ) TypeLiteral.get( Types.listOf( Types.subtypeOf( new TypeLiteralB?() { }.getType() ) ) ) ).toProvider( BProvider.class ); } } ); A a = injector.getInstance( A.class ); assertEquals( a.bs.size(), 2 ); } public static class A { private final List? extends B? bs; @Inject public A( @NotNull List? extends B? bs ) { this.bs = bs; } } public static class BT { } public static class BProvider implements ProviderList? extends B { @Override public List? extends B get() { return Arrays.asList( new B(), new B() ); } } } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: maven [was: Guice 2.0]
still waiting... any news? On 05/29/2009 09:47 AM, Jelle Herold wrote: On May 29, 2009, at 08:05, Adam Ruggles wrote: I've been using this repository patiently awaiting the official guice maven release. http://guice-maven.googlecode.com/svn/trunk Also waiting for an official maven release... We are using repository idkamalook/id nameKamalook, provides google-guice 2.0/name urlhttp://maven.kamalook.de//url /repository dependency groupIdcom.google.inject/groupId artifactIdguice/artifactId version2.0-SNAPSHOT/version /dependency --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Guice 2 prerelease snapshot 20090205
I have downloaded the file. Thanks for your work. Just one question: What about an extra jar for the annotations? http://code.google.com/p/google-guice/issues/detail?id=106 Thanks, Johannes On Sun, 2009-02-08 at 12:37 -0800, je...@swank.ca wrote: I've tagged a new snapshot and uploaded new binaries for a new prerelease. This is a preview of Guice 2. Since the previous 20081123 snapshot, we've improved servlets, private modules, assisted inject and performance. This .zip includes the guice jar, extension jars, and javadoc: http://google-guice.googlecode.com/files/guice-snapshot20090205.zip -- browse source: http://code.google.com/p/google-guice/source/browse/tags/snapshot20090205/ download source: http://google-guice.googlecode.com/files/guice-snapshot20090205-src.zip v2 overview: http://code.google.com/p/google-guice/wiki/Changes20 v2 bugs: http://code.google.com/p/google-guice/issues/list?q=label:Milestone-Release2.0 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---