Package org.mule.api.context

Examples of org.mule.api.context.MuleContextFactory


        muleContext = null;

        try
        {
            SpringXmlConfigurationBuilder builder = new SpringXmlConfigurationBuilder("clientbridge/conf/client-mule-config.xml");
            MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
            muleContext = muleContextFactory.createMuleContext(builder);

            Client c = new Client();
            c.execute();
        }
        finally
View Full Code Here


            final String contextName = FilenameUtils.getBaseName(tempDir.toString());
            serverId = contextName;
        }

        WebappMuleXmlConfigurationBuilder builder = new WebappMuleXmlConfigurationBuilder(servletContext, configResource);
        MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();

        String muleAppConfig = servletContext.getInitParameter(INIT_PARAMETER_MULE_APP_CONFIG) != null
            ? servletContext.getInitParameter(INIT_PARAMETER_MULE_APP_CONFIG)
            : PropertiesMuleConfigurationFactory.getMuleAppConfiguration(configResource);
       
        DefaultMuleConfiguration muleConfiguration = new PropertiesMuleConfigurationFactory(muleAppConfig).createConfiguration();

        /*
            We deliberately enable container mode here to allow for multi-tenant environment (multiple WARs
            embedding Mule instance each). See property javadocs for more info.
         */
        muleConfiguration.setContainerMode(true);

        if (serverId != null)
        {
            muleConfiguration.setId(serverId);
        }
        MuleContextBuilder muleContextBuilder = new DefaultMuleContextBuilder();
        muleContextBuilder.setMuleConfiguration(muleConfiguration);

        // Support Spring-first configuration in webapps
        final ApplicationContext parentContext = (ApplicationContext) servletContext.getAttribute(
                                                        WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        if (parentContext != null)
        {
            builder.setParentContext(parentContext);
        }
        return muleContextFactory.createMuleContext(builder, muleContextBuilder);
    }
View Full Code Here

public class AutoConfigurationBuilderTestCase extends AbstractMuleTestCase
{

    protected MuleContext createMuleContext() throws Exception
    {
        MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
        return muleContextFactory.createMuleContext(new SimpleConfigurationBuilder(null));
    }
View Full Code Here

public class AbstractDataSourceConfigurationTestCase extends AbstractMuleTestCase
{
    protected void tryBuildingMuleContextFromInvalidConfig(String config) throws MuleException
    {
        MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
        ConfigurationBuilder builder = new SpringXmlConfigurationBuilder(config);
        muleContextFactory.createMuleContext(builder);
        fail();
    }
View Full Code Here

            MuleConfiguration configuration = createMuleConfiguration();

            MuleContextBuilder contextBuilder = new DefaultMuleContextBuilder();
            contextBuilder.setMuleConfiguration(configuration);

            MuleContextFactory contextFactory = new DefaultMuleContextFactory();
            muleContext = contextFactory.createMuleContext(configBuilders, contextBuilder);
        }
    }
View Full Code Here

{
    public void testStartup() throws Exception
    {
        SpringXmlConfigurationBuilder builder = new SpringXmlConfigurationBuilder(
            "org/mule/test/spring/mule-root-test.xml");
        MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
        MuleContext context = muleContextFactory.createMuleContext(builder);
        // MuleContext must be started explicitly after MULE-1988
        assertFalse(context.isStarted());
        context.start();
        assertTrue(context.isStarted());
View Full Code Here

        {
            context = muleContext;
        }
        else
        {
            MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
            List<ConfigurationBuilder> builders = new ArrayList<ConfigurationBuilder>();
            builders.add(new SimpleConfigurationBuilder(getStartUpProperties()));
            //If the annotations module is on the classpath, add the annotations config builder to the list
            //This will enable annotations config for this instance
            if (ClassUtils.isClassOnPath(CLASSNAME_ANNOTATIONS_CONFIG_BUILDER, getClass()))
            {
                builders.add((ConfigurationBuilder) ClassUtils.instanciateClass(CLASSNAME_ANNOTATIONS_CONFIG_BUILDER,
                                                                                ClassUtils.NO_ARGS, getClass()));
            }
            builders.add(getBuilder());
            addBuilders(builders);
            MuleContextBuilder contextBuilder = new DefaultMuleContextBuilder();
            configureMuleContext(contextBuilder);
            context = muleContextFactory.createMuleContext(builders, contextBuilder);
            if (!isGracefulShutdown())
            {
                ((DefaultMuleConfiguration) context.getConfiguration()).setShutdownTimeout(0);
            }
        }
View Full Code Here

        {
            context = muleContext;
        }
        else
        {
            MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
            List<ConfigurationBuilder> builders = new ArrayList<ConfigurationBuilder>();
            builders.add(new SimpleConfigurationBuilder(getStartUpProperties()));
            //If the annotations module is on the classpath, add the annotations config builder to the list
            //This will enable annotations config for this instance
            if (ClassUtils.isClassOnPath(CLASSNAME_ANNOTATIONS_CONFIG_BUILDER, getClass()))
            {
                builders.add((ConfigurationBuilder) ClassUtils.instanciateClass(CLASSNAME_ANNOTATIONS_CONFIG_BUILDER,
                        ClassUtils.NO_ARGS, getClass()));
            }
            builders.add(getBuilder());
            addBuilders(builders);
            MuleContextBuilder contextBuilder = new DefaultMuleContextBuilder();
            configureMuleContext(contextBuilder);
            context = muleContextFactory.createMuleContext(builders, contextBuilder);
            if (!isGracefulShutdown())
            {
                ((DefaultMuleConfiguration) context.getConfiguration()).setShutdownTimeout(0);
            }
        }
View Full Code Here

            final String contextName = FilenameUtils.getBaseName(tempDir.toString());
            serverId = contextName;
        }

        WebappMuleXmlConfigurationBuilder builder = new WebappMuleXmlConfigurationBuilder(servletContext, configResource);
        MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();

        String muleAppConfig = servletContext.getInitParameter(INIT_PARAMETER_MULE_APP_CONFIG) != null
            ? servletContext.getInitParameter(INIT_PARAMETER_MULE_APP_CONFIG)
            : PropertiesMuleConfigurationFactory.getMuleAppConfiguration(configResource);
       
        DefaultMuleConfiguration muleConfiguration = new PropertiesMuleConfigurationFactory(muleAppConfig).createConfiguration();

        /*
            We deliberately enable container mode here to allow for multi-tenant environment (multiple WARs
            embedding Mule instance each). See property javadocs for more info.
         */
        muleConfiguration.setContainerMode(true);

        if (serverId != null)
        {
            muleConfiguration.setId(serverId);
        }
        MuleContextBuilder muleContextBuilder = new DefaultMuleContextBuilder();
        muleContextBuilder.setMuleConfiguration(muleConfiguration);

        // Support Spring-first configuration in webapps
        final ApplicationContext parentContext = (ApplicationContext) servletContext.getAttribute(
                                                        WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        if (parentContext != null)
        {
            builder.setParentContext(parentContext);
        }
        return muleContextFactory.createMuleContext(builder, muleContextBuilder);
    }
View Full Code Here

            if (environmentProperties != null)
            {
                systemProperties.putAll(environmentProperties);
            }
            MuleContextFactory factory = new DefaultMuleContextFactory();

            builder = new SpringXmlConfigurationBuilder(new ConfigResource[] {config, defaultConfigOverride});
            muleContext = factory.createMuleContext(builder);
            muleContext.start();

            MuleArtifact artifact = null;
            if (embedInFlow)
            {
View Full Code Here

TOP

Related Classes of org.mule.api.context.MuleContextFactory

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.