Package com.example

Examples of com.example.ReloadableService


        createImplementationClass("initial");

        Registry registry = createRegistry();

        ReloadableService reloadable = registry.getService(ReloadableService.class);

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "initial");

        fireUpdateCheck(registry);

        // Sleep long enough that the Java millisecond clock advances.

        Thread.currentThread().sleep(1500);

        createImplementationClass("updated");

        // Doesn't take effect until after the update check

        assertEquals(reloadable.getStatus(), "initial");

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "updated");

        registry.shutdown();
    }
View Full Code Here


    {
        createImplementationClass("before delete");

        Registry registry = createRegistry();

        ReloadableService reloadable = registry.getService(ReloadableService.class);

        assertEquals(reloadable.getStatus(), "before delete");

        File classFile = new File(classesDir, "com/example/ReloadableServiceImpl.class");

        assertTrue(classFile.exists(), "The class file must exist.");

        classFile.delete();

        fireUpdateCheck(registry);

        try
        {
            reloadable.getStatus();
            unreachable();
        }
        catch (RuntimeException ex)
        {
            assertMessageContains(ex, "Unable to reload", CLASS, "deleted");
View Full Code Here

        Registry registry = createRegistry();

        Class<ReloadableService> clazz = (Class<ReloadableService>) classLoader.loadClass(CLASS);

        ReloadableService reloadable = registry.proxy(ReloadableService.class, clazz);

        assertEquals(reloadable.getStatus(), "initial proxy");

        Thread.currentThread().sleep(1500);

        createImplementationClass("updated proxy");

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "updated proxy");

        registry.shutdown();
    }
View Full Code Here

    {
        createImplementationClass("initial");

        Registry registry = createRegistry();

        ReloadableService reloadable = registry.getService(ReloadableService.class);

        createInvalidImplentationClass();

        Thread.currentThread().sleep(1500);

        fireUpdateCheck(registry);

        try
        {
            reloadable.getStatus();

            unreachable();
        }
        catch (Exception ex)
        {
View Full Code Here

        createImplementationClass("initial");

        Registry registry = createRegistry();

        ReloadableService reloadable = registry.getService(ReloadableService.class);

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "initial");

        fireUpdateCheck(registry);

        touch(classFile);

        createImplementationClass("updated");

        // Doesn't take effect until after the update check

        assertEquals(reloadable.getStatus(), "initial");

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "updated");

        registry.shutdown();
    }
View Full Code Here

        ctClass.writeFile(classesDir.getAbsolutePath());

        Registry registry = createRegistry();

        ReloadableService reloadable = registry.getService(ReloadableService.class);

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "initial from base");

        touch(new File(classesDir, ClassFabUtils.getPathForClassNamed(BASE_CLASS)));

        createImplementationClass(BASE_CLASS, "updated from base");

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "updated from base");

        registry.shutdown();

    }
View Full Code Here

    {
        createImplementationClass("before delete");

        Registry registry = createRegistry();

        ReloadableService reloadable = registry.getService(ReloadableService.class);

        assertEquals(reloadable.getStatus(), "before delete");

        assertTrue(classFile.exists(), "The class file must exist.");

        classFile.delete();

        fireUpdateCheck(registry);

        try
        {
            reloadable.getStatus();
            unreachable();
        }
        catch (RuntimeException ex)
        {
            assertMessageContains(ex, "Unable to reload", CLASS);
View Full Code Here

        Registry registry = createRegistry();

        Class<ReloadableService> clazz = (Class<ReloadableService>) classLoader.loadClass(CLASS);

        ReloadableService reloadable = registry.proxy(ReloadableService.class, clazz);

        assertEquals(reloadable.getStatus(), "initial proxy");

        touch(classFile);

        createImplementationClass("updated proxy");

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "updated proxy");

        touch(classFile);

        createImplementationClass("re-updated proxy");

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "re-updated proxy");

        registry.shutdown();
    }
View Full Code Here

    {
        createImplementationClass("initial");

        Registry registry = createRegistry();

        ReloadableService reloadable = registry.getService(ReloadableService.class);

        touch(classFile);

        createInvalidImplentationClass();

        fireUpdateCheck(registry);

        try
        {
            reloadable.getStatus();

            unreachable();
        }
        catch (Exception ex)
        {
View Full Code Here

        createImplementationClass("initial");

        Registry registry = createRegistry();

        ReloadableService reloadable = registry.getService(ReloadableService.class);

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "initial");

        fireUpdateCheck(registry);

        touch(classFile);

        createImplementationClass("updated");

        // Doesn't take effect until after the update check

        assertEquals(reloadable.getStatus(), "initial");

        fireUpdateCheck(registry);

        assertEquals(reloadable.getStatus(), "updated");

        registry.shutdown();
    }
View Full Code Here

TOP

Related Classes of com.example.ReloadableService

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.