Package org.mule.module.launcher.descriptor

Examples of org.mule.module.launcher.descriptor.ApplicationDescriptor


    }

    public Application createApp(String appName) throws IOException
    {
        AppBloodhound bh = new DefaultAppBloodhound();
        final ApplicationDescriptor descriptor = bh.fetch(appName);
        if (descriptor.isPrivileged())
        {
            final PriviledgedMuleApplication delegate = new PriviledgedMuleApplication(descriptor);
            delegate.setDeploymentService(deploymentService);
            delegate.setCoreExtensions(coreExtensions);
            return new ApplicationWrapper(delegate);
View Full Code Here


        pluginDir.mkdirs();
        final InputStream sourcePlugin = IOUtils.getResourceAsStream("plugins/groovy-plugin.zip", getClass());
        IOUtils.copy(sourcePlugin, new FileOutputStream(new File(pluginDir, "groovy-plugin.zip")));

        AppBloodhound hound = new DefaultAppBloodhound();
        ApplicationDescriptor desc = hound.fetch(appName);
        assertNotNull(desc);
        Set<PluginDescriptor> plugins = desc.getPlugins();
        assertNotNull(plugins);
        assertEquals(1, plugins.size());

        final PluginDescriptor plugin = plugins.iterator().next();
        assertEquals("groovy-plugin", plugin.getName());
View Full Code Here

            throw new MuleRuntimeException(
                    MessageFactory.createStaticMessage(
                            String.format("More than one mule-deploy descriptors found in application '%s'", appName)));
        }

        ApplicationDescriptor desc;

        // none found, return defaults
        if (deployFiles.isEmpty())
        {
            desc = new EmptyApplicationDescriptor(appName);
        }
        else
        {
            // lookup the implementation by extension
            final File descriptorFile = deployFiles.iterator().next();
            final String ext = FilenameUtils.getExtension(descriptorFile.getName());
            final DescriptorParser descriptorParser = parserRegistry.get(ext);

            if (descriptorParser == null)
            {
                // TODO need some kind of an InvalidAppFormatException
                throw new MuleRuntimeException(
                        MessageFactory.createStaticMessage(
                                String.format("Unsupported deployment descriptor format for app '%s': %s", appName, ext)));
            }

            desc = descriptorParser.parse(descriptorFile);
            // app name is external to the deployment descriptor
            desc.setAppName(appName);
        }

        // get a ref to an optional app props file (right next to the descriptor)
        final File appPropsFile = new File(appDir, ApplicationDescriptor.DEFAULT_APP_PROPERTIES_RESOURCE);
        if (appPropsFile.exists() && appPropsFile.canRead())
        {
            final Properties props = PropertiesUtils.loadProperties(appPropsFile.toURI().toURL());
            // ugh, no straightforward way to convert to a map
            Map<String, String> m = new HashMap<String, String>(props.size());
            for (Object key : props.keySet())
            {
                m.put(key.toString(), props.getProperty(key.toString()));
            }
            desc.setAppProperties(m);
        }

        final Set<PluginDescriptor> plugins = new PluginDescriptorParser(desc, appDir).parse();
        desc.setPlugins(plugins);

        return desc;

    }
View Full Code Here

        pluginDir.mkdirs();
        final InputStream sourcePlugin = IOUtils.getResourceAsStream("plugins/groovy-plugin.zip", getClass());
        IOUtils.copy(sourcePlugin, new FileOutputStream(new File(pluginDir, "groovy-plugin.zip")));

        AppBloodhound hound = new DefaultAppBloodhound();
        ApplicationDescriptor desc = hound.fetch(appName);
        assertNotNull(desc);
        Set<PluginDescriptor> plugins = desc.getPlugins();
        assertNotNull(plugins);
        assertEquals(1, plugins.size());

        final PluginDescriptor plugin = plugins.iterator().next();
        assertEquals("groovy-plugin", plugin.getName());
View Full Code Here

        InputStream input = getClass().getClassLoader().getResourceAsStream("overridden.properties");
        FileOutputStream output = new FileOutputStream(tempProps);
        IOUtils.copy(input, output);
        input.close();
        output.close();
        ApplicationDescriptor descriptor = new ApplicationDescriptor();
        DefaultAppBloodhound dab = new DefaultAppBloodhound();
        dab.setApplicationProperties(descriptor, tempProps);
        Map<String, String>appProps = descriptor.getAppProperties();
        assertEquals("state", appProps.get("texas"));
        assertEquals("country", appProps.get("peru"));
        assertEquals("austin", appProps.get("texas.capital"));
        assertEquals("4", appProps.get("peru.capital.numberOfletters"));
        assertEquals("esb", appProps.get("mule"));
        assertEquals("ipaas", appProps.get("mule.ion"));

        try
        {
            setSystemProperties();
            descriptor = new ApplicationDescriptor();
            dab.setApplicationProperties(descriptor, tempProps);
            appProps = descriptor.getAppProperties();
            assertEquals("state", appProps.get("texas"));
            assertEquals("nation", appProps.get("peru"));
            assertEquals("austin", appProps.get("texas.capital"));
            assertEquals("4", appProps.get("peru.capital.numberOfletters"));
            assertEquals("wayCool", appProps.get("mule"));
            assertEquals("ipaas", appProps.get("mule.ion"));
            assertEquals("evenCooler", appProps.get("mule.mmc"));

            descriptor = new ApplicationDescriptor();
            dab.setApplicationProperties(descriptor, new File("nonexistent.nonexistent"));
            appProps = descriptor.getAppProperties();
            assertNull(appProps.get("texas"));
            assertEquals("nation", appProps.get("peru"));
            assertNull(appProps.get("texas.capital"));
            assertNull(appProps.get("peru.capital.numberOfletters"));
            assertEquals("wayCool", appProps.get("mule"));
View Full Code Here

    }

    @Test
    public void nullDeploymentClassLoaderAfterDispose()
    {
        ApplicationDescriptor descriptor = mock(ApplicationDescriptor.class);
        when(descriptor.getAbsoluteResourcePaths()).thenReturn(new String[] {});

        ApplicationClassLoaderFactory classLoaderFactory = mock(ApplicationClassLoaderFactory.class);
        when(classLoaderFactory.create(descriptor)).thenReturn(mock(ArtifactClassLoader.class));

        DefaultMuleApplication application = new DefaultMuleApplication(descriptor, classLoaderFactory, mock(Domain.class));
View Full Code Here

        {
            throw new IllegalArgumentException("Mule application name may not contain spaces: " + appName);
        }

        AppBloodhound bh = new DefaultAppBloodhound();
        final ApplicationDescriptor descriptor = bh.fetch(appName);

        return createAppFrom(descriptor);
    }
View Full Code Here

            throw new MuleRuntimeException(
                    MessageFactory.createStaticMessage(
                            String.format("More than one mule-deploy descriptors found in application '%s'", appName)));
        }

        ApplicationDescriptor desc;

        // none found, return defaults
        if (deployFiles.isEmpty())
        {
            desc = new EmptyApplicationDescriptor(appName);
        }
        else
        {
            // lookup the implementation by extension
            final File descriptorFile = deployFiles.iterator().next();
            final String ext = FilenameUtils.getExtension(descriptorFile.getName());
            final DescriptorParser descriptorParser = parserRegistry.get(ext);

            if (descriptorParser == null)
            {
                // TODO need some kind of an InvalidAppFormatException
                throw new MuleRuntimeException(
                        MessageFactory.createStaticMessage(
                                String.format("Unsupported deployment descriptor format for app '%s': %s", appName, ext)));
            }

            desc = descriptorParser.parse(descriptorFile, appName);
            // app name is external to the deployment descriptor
            desc.setAppName(appName);
        }

        // get a ref to an optional app props file (right next to the descriptor)
        final File appPropsFile = new File(appDir, ApplicationDescriptor.DEFAULT_APP_PROPERTIES_RESOURCE);
        setApplicationProperties(desc, appPropsFile);

        final Set<PluginDescriptor> plugins = new PluginDescriptorParser(desc, appDir).parse();
        desc.setPlugins(plugins);

        return desc;

    }
View Full Code Here

TOP

Related Classes of org.mule.module.launcher.descriptor.ApplicationDescriptor

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.