Package org.impalaframework.module

Examples of org.impalaframework.module.ModuleDefinition


        super.setUp();
        reader = new ApplicationModuleTypeReader();
    }

    public void testReadModuleDefinition() {
        ModuleDefinition definition = reader.readModuleDefinition(null, "mymodule", new Properties());
        SimpleModuleDefinition moduleDefinition = (SimpleModuleDefinition) definition;
        assertEquals("mymodule", moduleDefinition.getName());
        assertEquals(ModuleTypes.APPLICATION, moduleDefinition.getType());
        assertEquals("spring", moduleDefinition.getRuntimeFramework());
    }
View Full Code Here


        properties.put(ModuleElementNames.RELOADABLE_ELEMENT, "false");
        properties.put("prop1", "value1");
        properties.put("prop2", "value2");
        properties.put("runtime", "myruntime");
       
        ModuleDefinition definition = reader.readModuleDefinition(null, "mymodule", properties);
        SimpleModuleDefinition moduleDefinition = (SimpleModuleDefinition) definition;
        assertEquals("mymodule", moduleDefinition.getName());
        assertEquals(ModuleTypes.APPLICATION, moduleDefinition.getType());
        assertEquals(Arrays.asList(new String[]{ "loc1", "loc2", "loc3"}), moduleDefinition.getConfigLocations());
        assertEquals(Arrays.asList(new String[]{ "module1", "module2", "module3", "module4", "module5"}), moduleDefinition.getDependentModuleNames(false));
View Full Code Here

    //same as 3, but adds d, and adds adds g, which depends on d
    private SimpleRootModuleDefinition definitionSet3() {
        List<ModuleDefinition> definitions = new ArrayList<ModuleDefinition>();

        //a has no parent or dependencies
        ModuleDefinition a = newDefinition(definitions, null, "a", null);

        //c has no parent or dependencies
        ModuleDefinition c = newDefinition(definitions, null, "c", null);
       
        ModuleDefinition d = newDefinition(definitions, null, "d", null);
       
        //root has siblings a and c, and depends on a
        SimpleRootModuleDefinition root = new SimpleRootModuleDefinition("root",
                new String[] {"root.xml"},
                new String[] {"a"},
                null,
                new ModuleDefinition[] {a, c, d}, null, null, true);
       
        //e has parent root, and depends on a and c
        ModuleDefinition e = newDefinition(definitions, root, "e", "a,c");
       
        //f has parent e, but no other dependencies
        newDefinition(definitions, e, "f", null);

        //has parent e, depends on d
View Full Code Here

        reader.readModuleDefinitionProperties(properties, "mymodule", root);
        System.out.println(properties);
        assertEquals("location1,location2", properties.get("config-locations"));
        assertEquals("module1,module2,module3,module4,module5", properties.get("depends-on"));
       
        ModuleDefinition moduleDefinition = reader.readModuleDefinition(new SimpleModuleDefinition("parent"), "mymodule", root);
        assertFalse(moduleDefinition.isReloadable());
        assertEquals(Arrays.asList(new String[]{ "location1", "location2"}), moduleDefinition.getConfigLocations());
        assertEquals(Arrays.asList(new String[]{ "parent", "module1", "module2", "module3", "module4", "module5"}), moduleDefinition.getDependentModuleNames(false));
       
       
        Map<String,String> expectedAttributes = new HashMap<String,String>();
        expectedAttributes.put("prop1", "value1");
        expectedAttributes.put("prop2", "value2");
        assertEquals(expectedAttributes, moduleDefinition.getAttributes());
        assertEquals("myruntime", moduleDefinition.getRuntimeFramework());
       
        assertEquals("persistence,clustering", StringUtils.collectionToCommaDelimitedString(moduleDefinition.getCapabilities()));
    }
View Full Code Here

    //same as 4, but g does not depend on d
    private SimpleRootModuleDefinition definitionSet4() {
        List<ModuleDefinition> definitions = new ArrayList<ModuleDefinition>();

        //a has no parent or dependencies
        ModuleDefinition a = newDefinition(definitions, null, "a", null);

        //c has no parent or dependencies
        ModuleDefinition c = newDefinition(definitions, null, "c", null);
       
        ModuleDefinition d = newDefinition(definitions, null, "d", null);
       
        //root has siblings a and c, and depends on a
        SimpleRootModuleDefinition root = new SimpleRootModuleDefinition("root",
                new String[] {"root.xml"},
                new String[] {"a"},
                null,
                new ModuleDefinition[] {a, c, d}, null, null, true);
       
        //e has parent root, and depends on a and c
        ModuleDefinition e = newDefinition(definitions, root, "e", "a,c");
       
        //f has parent e, but no other dependencies
        newDefinition(definitions, e, "f", null);

        //has parent e, depends on d
View Full Code Here

   
    private SimpleRootModuleDefinition definitionSet1() {
        List<ModuleDefinition> definitions = new ArrayList<ModuleDefinition>();
       
        //a has no parent or dependencies
        ModuleDefinition a = newDefinition(definitions, null, "a", null);
       
        //b depends on d but has no parent
        ModuleDefinition b = newDefinition(definitions, null, "b", "d");
       
        //c has no parent or dependencies
        ModuleDefinition c = newDefinition(definitions, null, "c", null);
       
        //d has no parent or dependencies
        ModuleDefinition d = newDefinition(definitions, null, "d", null);
       
        //root has siblings a to d, and depends on a
        SimpleRootModuleDefinition root = new SimpleRootModuleDefinition("root",
                new String[] {"root.xml"},
                new String[] {"a"},
                null,
                new ModuleDefinition[] {a, b, c, d}, null, null, true);
        //e has parent root, and depends on b an d
        ModuleDefinition e = newDefinition(definitions, root, "e", "c");
       
        //has parent e, and depends on c
        newDefinition(definitions, e, "f", "c");

        //has parent e, depends on f
View Full Code Here

        moduleStateHolder = (DefaultModuleStateHolder) application.getModuleStateHolder();
    }

    public void testResourceBasedValue() {
        ModuleDefinitionSource source = new SimpleModuleDefinitionSource(rootProjectName, new String[] { "parentTestContext.xml" }, new String[] { plugin1, plugin2 });
        ModuleDefinition p2 = source.getModuleDefinition().getChildModuleDefinition(plugin2);
        new SimpleModuleDefinition(p2, plugin3);
        addModule(source);

        ClassLoader originalClassLoader = this.getClass().getClassLoader();
       
View Full Code Here

    public void testLoadUnloadModules() {

        ModuleDefinitionSource source = new SimpleModuleDefinitionSource(rootProjectName, new String[] { "parentTestContext.xml" }, new String[] { plugin1, plugin2 });

        addModule(source);
        ModuleDefinition root = source.getModuleDefinition();

        ConfigurableApplicationContext parent = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
        assertNotNull(parent);
        assertEquals(3, moduleStateHolder.getRuntimeModules().size());

        FileMonitor bean1 = (FileMonitor) parent.getBean("bean1");
        assertEquals(999L, bean1.lastModified((File) null));

        FileMonitor bean2 = (FileMonitor) parent.getBean("bean2");
        assertEquals(100L, bean2.lastModified((File) null));

        // shutdown module and check behaviour has gone
        removeModule(plugin2);

        try {
            bean2.lastModified((File) null);
            fail();
        }
        catch (NoServiceException e) {
        }

        // bean 2 still works
        assertEquals(999L, bean1.lastModified((File) null));

        removeModule(plugin1);

        try {
            bean1.lastModified((File) null);
            fail();
        }
        catch (NoServiceException e) {
        }

        // now reload the module, and see that behaviour returns
       
        addModule(new SimpleModuleDefinition(plugin2));
        bean2 = (FileMonitor) parent.getBean("bean2");
        assertEquals(100L, bean2.lastModified((File) null));

        addModule(new SimpleModuleDefinition(plugin1));
        bean1 = (FileMonitor) parent.getBean("bean1");
        assertEquals(999L, bean1.lastModified((File) null));

        FileMonitor bean3 = (FileMonitor) parent.getBean("bean3");
        try {
            bean3.lastModified((File) null);
            fail();
        }
        catch (NoServiceException e) {
        }

        ModuleDefinition p2 = root.getChildModuleDefinition(plugin2);
        addModule(new SimpleModuleDefinition(p2, plugin3));
        assertEquals(333L, bean3.lastModified((File) null));

        final ConfigurableApplicationContext applicationPlugin3 = SpringModuleUtils.getModuleSpringContext(moduleStateHolder, plugin3);
        applicationPlugin3.close();
View Full Code Here

    }

    public void testLoadAll() {

        ModuleDefinitionSource source = new SimpleModuleDefinitionSource(rootProjectName, new String[] { "parentTestContext.xml" }, new String[] { plugin1, plugin2 });
        final ModuleDefinition p2 = source.getModuleDefinition().getChildModuleDefinition(plugin2);
        new SimpleModuleDefinition(p2, plugin3);

        addModule(source);

        ConfigurableApplicationContext parent = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
View Full Code Here

        ApplicationModuleLoader rootModuleLoader = new ApplicationModuleLoader();
        moduleLoaderRegistry.addItem(ModuleTypes.ROOT, rootModuleLoader);
        ApplicationModuleLoader applicationModuleLoader = new ApplicationModuleLoader();
        moduleLoaderRegistry.addItem(ModuleTypes.APPLICATION, applicationModuleLoader);

        ModuleDefinition p = new SimpleRootModuleDefinition(rootModuleName, new String[] { "parent-context.xml" });
        assertTrue(moduleLoaderRegistry.getModuleLoader(p.getType()) instanceof ApplicationModuleLoader);

        DelegatingContextLoader delegatingLoader = new DelegatingContextLoader() {
            public ConfigurableApplicationContext loadApplicationContext(ApplicationContext parent,
                    ModuleDefinition definition) {
                return null;
View Full Code Here

TOP

Related Classes of org.impalaframework.module.ModuleDefinition

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.