incubator-s4-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leo Neumeyer <leoneume...@gmail.com>
Subject Re: Guice instantiation
Date Thu, 03 Nov 2011 17:32:36 GMT
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