Search in sources :

Example 1 with MuleContextFactory

use of org.mule.runtime.core.api.context.MuleContextFactory in project mule by mulesoft.

the class AbstractBenchmark method createMuleContextWithServices.

protected MuleContext createMuleContextWithServices() throws MuleException {
    MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
    List<ConfigurationBuilder> builderList = new ArrayList<>();
    builderList.add(new BasicRuntimeServicesConfigurationBuilder());
    builderList.add(new DefaultsConfigurationBuilder());
    return muleContextFactory.createMuleContext(builderList.toArray(new ConfigurationBuilder[] {}));
}
Also used : DefaultMuleContextFactory(org.mule.runtime.core.api.context.DefaultMuleContextFactory) DefaultsConfigurationBuilder(org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder) ConfigurationBuilder(org.mule.runtime.core.api.config.ConfigurationBuilder) MuleContextFactory(org.mule.runtime.core.api.context.MuleContextFactory) DefaultMuleContextFactory(org.mule.runtime.core.api.context.DefaultMuleContextFactory) ArrayList(java.util.ArrayList) DefaultsConfigurationBuilder(org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder)

Example 2 with MuleContextFactory

use of org.mule.runtime.core.api.context.MuleContextFactory in project mule by mulesoft.

the class AbstractMuleContextTestCase method createMuleContext.

protected MuleContext createMuleContext() throws Exception {
    // Should we set up the manager for every method?
    MuleContext context;
    if (isDisposeContextPerClass() && muleContext != null) {
        context = muleContext;
    } else {
        final ClassLoader executionClassLoader = getExecutionClassLoader();
        final ClassLoader originalContextClassLoader = currentThread().getContextClassLoader();
        try {
            currentThread().setContextClassLoader(executionClassLoader);
            MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
            List<ConfigurationBuilder> builders = new ArrayList<>();
            builders.add(new SimpleConfigurationBuilder(getStartUpRegistryObjects()));
            addBuilders(builders);
            builders.add(getBuilder());
            MuleContextBuilder contextBuilder = MuleContextBuilder.builder(APP);
            DefaultMuleConfiguration muleConfiguration = new DefaultMuleConfiguration();
            String workingDirectory = this.workingDirectory.getRoot().getAbsolutePath();
            LOGGER.info("Using working directory for test: " + workingDirectory);
            muleConfiguration.setWorkingDirectory(workingDirectory);
            muleConfiguration.setId(this.getClass().getSimpleName() + "#" + name.getMethodName());
            contextBuilder.setMuleConfiguration(muleConfiguration);
            contextBuilder.setExecutionClassLoader(executionClassLoader);
            contextBuilder.setObjectSerializer(getObjectSerializer());
            contextBuilder.setDeploymentProperties(getDeploymentProperties());
            configureMuleContext(contextBuilder);
            context = muleContextFactory.createMuleContext(builders, contextBuilder);
            recordSchedulersOnInit(context);
            if (!isGracefulShutdown()) {
                // Even though graceful shutdown is disabled allow small amount of time to avoid rejection errors when stream emits
                // complete signal
                ((DefaultMuleConfiguration) context.getConfiguration()).setShutdownTimeout(NON_GRACEFUL_SHUTDOWN_TIMEOUT);
            }
        } finally {
            currentThread().setContextClassLoader(originalContextClassLoader);
        }
    }
    return context;
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) DefaultMuleContextFactory(org.mule.runtime.core.api.context.DefaultMuleContextFactory) SimpleConfigurationBuilder(org.mule.runtime.core.api.config.builders.SimpleConfigurationBuilder) DefaultsConfigurationBuilder(org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder) ConfigurationBuilder(org.mule.runtime.core.api.config.ConfigurationBuilder) TestServicesConfigurationBuilder(org.mule.tck.config.TestServicesConfigurationBuilder) MuleContextFactory(org.mule.runtime.core.api.context.MuleContextFactory) DefaultMuleContextFactory(org.mule.runtime.core.api.context.DefaultMuleContextFactory) DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration) ArrayList(java.util.ArrayList) SimpleConfigurationBuilder(org.mule.runtime.core.api.config.builders.SimpleConfigurationBuilder) MuleContextBuilder(org.mule.runtime.core.api.context.MuleContextBuilder)

Example 3 with MuleContextFactory

use of org.mule.runtime.core.api.context.MuleContextFactory in project mule by mulesoft.

the class ApplicationContextBuilder method doBuildContext.

protected MuleContext doBuildContext() throws Exception {
    MuleContext context;
    MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
    List<ConfigurationBuilder> builders = new ArrayList<>();
    builders.add(getAppBuilder(this.applicationResources));
    addBuilders(builders);
    configureMuleContext(muleContextBuilder);
    context = muleContextFactory.createMuleContext(builders, muleContextBuilder);
    return context;
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) DefaultMuleContextFactory(org.mule.runtime.core.api.context.DefaultMuleContextFactory) SpringXmlConfigurationBuilderFactory.createConfigurationBuilder(org.mule.runtime.config.api.SpringXmlConfigurationBuilderFactory.createConfigurationBuilder) ConfigurationBuilder(org.mule.runtime.core.api.config.ConfigurationBuilder) MuleContextFactory(org.mule.runtime.core.api.context.MuleContextFactory) DefaultMuleContextFactory(org.mule.runtime.core.api.context.DefaultMuleContextFactory) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)3 ConfigurationBuilder (org.mule.runtime.core.api.config.ConfigurationBuilder)3 DefaultMuleContextFactory (org.mule.runtime.core.api.context.DefaultMuleContextFactory)3 MuleContextFactory (org.mule.runtime.core.api.context.MuleContextFactory)3 MuleContext (org.mule.runtime.core.api.MuleContext)2 DefaultsConfigurationBuilder (org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder)2 SpringXmlConfigurationBuilderFactory.createConfigurationBuilder (org.mule.runtime.config.api.SpringXmlConfigurationBuilderFactory.createConfigurationBuilder)1 DefaultMuleConfiguration (org.mule.runtime.core.api.config.DefaultMuleConfiguration)1 SimpleConfigurationBuilder (org.mule.runtime.core.api.config.builders.SimpleConfigurationBuilder)1 MuleContextBuilder (org.mule.runtime.core.api.context.MuleContextBuilder)1 TestServicesConfigurationBuilder (org.mule.tck.config.TestServicesConfigurationBuilder)1