Package com.netflix.governator.lifecycle

Examples of com.netflix.governator.lifecycle.LifecycleManager$StateKey


    {
        // Always get the Guice injector from Governator
        Injector injector = LifecycleInjector.builder().createInjector();
        injector.getInstance(ExampleObjectA.class);

        LifecycleManager manager = injector.getInstance(LifecycleManager.class);

        // Always start the Lifecycle Manager
        manager.start();

        // by calling start() warm up begins. The console will show
        // something like this (the order may be slightly different):
        /*
            b.isWarm() false
            c.isWarm() false
            ExampleObjectB warm up start
            ExampleObjectC warm up start
            ExampleObjectB warm up end
            ExampleObjectC warm up end
            b.isWarm() true
            c.isWarm() true
            ExampleObjectA warm up start
            ExampleObjectA warm up end
         */

        // your app would execute here

        // Always close the Lifecycle Manager at app end
        manager.close();
    }
View Full Code Here


                        }
                    }
                )
            .createInjector();

        LifecycleManager manager = injector.getInstance(LifecycleManager.class);

        // Always start the Lifecycle Manager
        manager.start();

        System.out.println(injector.getInstance(ExampleObjectA.class).getValue());
        System.out.println(injector.getInstance(ExampleObjectB.class).getValue());
        System.out.println(injector.getInstance(ExampleObjectC.class).getValue());

        /*
            Console will output:
                ExampleObjectA should see this
                b
                c
         */

        // your app would execute here

        // Always close the Lifecycle Manager at app end
        manager.close();
    }
View Full Code Here

        Injector injector = LifecycleInjector.builder().createInjector();

        // This causes ExampleService and its dependency, ExampleResource, to get instantiated
        injector.getInstance(ExampleService.class);

        LifecycleManager manager = injector.getInstance(LifecycleManager.class);

        // Always start the Lifecycle Manager
        manager.start();

        // your app would execute here

        // Always close the Lifecycle Manager at app end
        manager.close();

        /*
            The console output should show:
                ExampleResource construction
                ExampleResource setup
View Full Code Here

                        }
                    }
                )
            .createInjector();

        LifecycleManager    manager = injector.getInstance(LifecycleManager.class);

        // Always start the Lifecycle Manager
        manager.start();

        // your app would execute here

        // Always close the Lifecycle Manager at app end
        manager.close();
    }
View Full Code Here

            )
            .createInjector();

        ExampleObject       obj = injector.getInstance(ExampleObject.class);

        LifecycleManager    manager = injector.getInstance(LifecycleManager.class);

        // Always start the Lifecycle Manager
        manager.start();

        System.out.println(obj.getAString());
        System.out.println(obj.getAnInt());
        System.out.println(obj.getADouble());

        // your app would execute here

        // Always close the Lifecycle Manager at app end
        manager.close();
    }
View Full Code Here

                    }
                }
            )
            .createInjector();

        LifecycleManager manager = injector.getInstance(LifecycleManager.class);

        // Always start the Lifecycle Manager
        manager.start();

        System.out.println(injector.getInstance(ExampleObjectA.class).getValue());
        System.out.println(injector.getInstance(ExampleObjectB.class).getValue());
        System.out.println(injector.getInstance(ExampleObjectC.class).getValue());

        /*
            Console will output:
                letter A - 1
                letter B - 2
                letter C - 3
         */

        // your app would execute here

        // Always close the Lifecycle Manager at app end
        manager.close();
    }
View Full Code Here

            .usingBasePackages("autobind"// specify a package for CLASSPATH scanning so that Governator finds the AutoBindSingleton
            .createInjector();

        // NOTE: ExampleService will be created at this point - you should see "ExampleService auto-bind construction" in the console

        LifecycleManager manager = injector.getInstance(LifecycleManager.class);

        // Always start the Lifecycle Manager
        manager.start();

        // your app would execute here

        // Always close the Lifecycle Manager at app end
        manager.close();
    }
View Full Code Here

    @Test(dataProvider = "builders")
    public void     testSimpleSingleton(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
    {
        Injector            injector = lifecycleInjectorBuilder.usingBasePackages(PACKAGES).createInjector();
        LifecycleManager    manager = injector.getInstance(LifecycleManager.class);
        manager.start();

        SimpleSingleton     instance = injector.getInstance(SimpleSingleton.class);

        Assert.assertEquals(instance.startCount.get(), 1);
        Assert.assertEquals(instance.finishCount.get(), 0);

        manager.close();

        Assert.assertEquals(instance.startCount.get(), 1);
        Assert.assertEquals(instance.finishCount.get(), 1);
    }
View Full Code Here

    @Test(dataProvider = "builders")
    public void     testInjectedIntoAnother(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
    {
        Injector            injector = lifecycleInjectorBuilder.usingBasePackages(PACKAGES).createInjector();
        LifecycleManager    manager = injector.getInstance(LifecycleManager.class);
        manager.start();

        SimpleContainer     instance = injector.getInstance(SimpleContainer.class);

        Assert.assertEquals(instance.simpleObject.startCount.get(), 1);
        Assert.assertEquals(instance.simpleObject.finishCount.get(), 0);

        manager.close();

        Assert.assertEquals(instance.simpleObject.startCount.get(), 1);
        Assert.assertEquals(instance.simpleObject.finishCount.get(), 1);
    }
View Full Code Here

public class LifecycleManagerStarter implements PostInjectorAction {
    private static final Logger log = LoggerFactory.getLogger(LifecycleManagerStarter.class);

    @Override
    public void call(Injector injector) {
        LifecycleManager manager = injector.getInstance(LifecycleManager.class);
        try {
            manager.start();
        } catch (Exception e) {
            log.error("Failed to start LifecycleManager", e);
        }
    }
View Full Code Here

TOP

Related Classes of com.netflix.governator.lifecycle.LifecycleManager$StateKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.