Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sisu-users] Sisu documentation

Hi Stuart,

Many thanks for your extensive answer. 

My use case is rather simple I believe, and as far as I understand, fits
quite well with the current capabilities of Sisu.

I've a quite large RCP application, and despite the use of OSGi, the
bundles are quite statically wired, a lot of "Required Bundle" rather
than "import". Bundles are logically grouped in components by namespace
and dependency. Within such multi-bundle components, I'd like to use a
very light-weighed DI approach for wiring a lot of classes together.

The "components" currently expose declarative services to be linked
together. My second (and secondary) use case would be to also replace
this with annotation based DI.

Wrt. bootstrapping. Given an RCP application, the "start" method of the
IApplication would be the right place to have a
"SisuGuice.inject(MyClass.class)" ?

Cheers,

Gernot

On Thu, 2012-09-27 at 17:32 +0100, Stuart McCulloch wrote:
> Hi Gernot,
> 
> Documentation is on our roadmap (http://wiki.eclipse.org/Sisu/Roadmap) and I'll be working on it over the next months.
> Note that the API/SPI cleanup is still in progress, so any classes under org.eclipse.sisu.* may change in the near future.
> 
> However, you can use Sisu in OSGi by only depending on JSR330 (ie. @Inject, @Named, etc.) in your components.
> 
> When deployed in OSGi Sisu will:
> 
>    * Scan bundles that use JSR330 for classes tagged with @Named
>    * Bind missing @Inject dependencies to the dynamic Sisu locator
>    * Create an injector (per-bundle) with bindings for those components
>    * Register the bundle injectors with the OSGi service registry
>    * Lookup components dynamically across all registered injectors
> 
>    ( Note that fine-grained service imports/exports, like in peaberry, to interact with other frameworks like
>      Declarative Services is in the plan - but at the moment Sisu shares whole injectors between bundles )
> 
> So, for example you could have a bundle with:
> 
>    @Named
>    public class MyFoo implements Foo {
>       // etc...
>    }
> 
> and in another bundle you could have:
> 
>    @Named
>    public class Test {
>       @Inject
>       public Test( Foo foo ) {
>          // can also use field/setter injection
>       }
>    }
> 
> and it will inject MyFoo into test - specifically it will inject the highest-ranked Foo (default ranking is to put 'Default' implementations before others).
> 
> You could also @Inject List<Foo>, or @Inject Map<Named, Foo>, or even @Inject Map<String, Foo> if you wanted to see all Foo implementations.
> These injected collections are fully dynamic and thread-safe, so as you start/stop bundles the contents could change as components come and go.
> 
> Wrt. bootstrapping, at the moment you'd either use the SisuGuice static utility to lookup the root component, or tag it with @EagerSingleton.
> 
> There is an old example over at:
> 
>    https://github.com/sonatype/sisu/tree/master/sisu-examples/guice-swing
> 
> which demos some of the dynamics.
> 
> Use "mvn clean install" to build, and "java -jar guice-swing-main/target/main.jar osgi" to start the framework (try starting/stopping the checkbox bundle).
> 
> Anyway, watch out for some simpler examples over the coming weeks - is there any specific feature or example you'd be interested in?
> 
> --
> Cheers, Stuart
> 
> On 26 Sep 2012, at 23:01, Gernot Kvas wrote:
> 
> > Hi,
> > 
> > I'd like to give Sisu a try, but I'm desperate to find some
> > documentation. As I understand, the project is still somewhat in the
> > transition from sonatype to eclipse. I've found some traces
> > (http://sisu.sonatype.org/quick-guide.html), but this is just a redirect
> > to the new Eclipse project page. Any chance to get some pointers about
> > deployment, usage, maybe a small, intuitive example ;-)?
> > 
> > Thanks in advance,
> > 
> > Gernot
> > 
> > _______________________________________________
> > sisu-users mailing list
> > sisu-users@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/sisu-users
> 
> _______________________________________________
> sisu-users mailing list
> sisu-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/sisu-users




Back to the top