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[] {}));
}
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;
}
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;
}
Aggregations