incubator-s4-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kishore g <g.kish...@gmail.com>
Subject Re: Guice instantiation
Date Thu, 03 Nov 2011 20:40:56 GMT
I see, then the Module/injector must be created only once in a jvm ?

When you say singleton are they enforced or responsibility of the developer
?, I created two apps from different modules and  both acquired different
tasks.

thanks,
Kishore G

On Thu, Nov 3, 2011 at 10:32 AM, Leo Neumeyer <leoneumeyer@gmail.com> wrote:

> They are Singletons.
>
> Check this snippet from Server. The Server singleton has the reference to
> the sender and receiver singletons. We pass the references via loadApp().
> Does this make sense?
>
> /* After some indirection we get the injector. */
>        injector = Guice.createInjector(module);
>
>        Sender sender = injector.getInstance(Sender.class);
>        Receiver receiver = injector.getInstance(Receiver.class);
>
>        // File[] s4rFiles = new File(appsDir).listFiles(new
> PatternFilenameFilter("\\w+\\.s4r"));
>        File[] s4rFiles = new File(appsDir).listFiles(new
> PatternFilenameFilter(".+.s4r"));
>        for (File s4rFile : s4rFiles) {
>            logger.info("Loading app: " + s4rFile.getPath());
>            loadApp(sender, receiver, s4rFile);
>        }
>
>        /* Now init + start apps. TODO: implement dynamic loading/unloading
> using ZK. */
>        for (App app : apps) {
>            logger.info("Starting app " + app.getClass().getName());
>            app.init();
>            app.start();
>        }
>
>
>
> Leo Neumeyer (@leoneu)
>
>
>
> On Nov 3, 2011, at 10:20 AM, kishore g wrote:
>
> > Hi,
> >
> > Will creation of every App create a new instance of sender/receiver which
> > creates Assignment and Topology ?. How to share these between Apps
> >
> > thanks,
> > Kishore G
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message