Search in sources :

Example 6 with DefaultMuleConfiguration

use of org.mule.runtime.core.api.config.DefaultMuleConfiguration in project mule by mulesoft.

the class MuleConfigurationConfigurator method doGetObject.

@Override
public Object doGetObject() throws Exception {
    MuleConfiguration configuration = muleContext.getConfiguration();
    if (configuration instanceof DefaultMuleConfiguration) {
        DefaultMuleConfiguration defaultConfig = (DefaultMuleConfiguration) configuration;
        defaultConfig.setDefaultResponseTimeout(config.getDefaultResponseTimeout());
        defaultConfig.setDefaultTransactionTimeout(config.getDefaultTransactionTimeout());
        defaultConfig.setShutdownTimeout(config.getShutdownTimeout());
        defaultConfig.setDefaultErrorHandlerName(config.getDefaultErrorHandlerName());
        defaultConfig.addExtensions(config.getExtensions());
        defaultConfig.setMaxQueueTransactionFilesSize(config.getMaxQueueTransactionFilesSizeInMegabytes());
        defaultConfig.setDynamicConfigExpiration(config.getDynamicConfigExpiration());
        validateDefaultErrorHandler();
        applyDefaultIfNoObjectSerializerSet(defaultConfig);
        return configuration;
    } else {
        throw new ConfigurationException(createStaticMessage("Unable to set properties on read-only MuleConfiguration: " + configuration.getClass()));
    }
}
Also used : DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration) MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException)

Example 7 with DefaultMuleConfiguration

use of org.mule.runtime.core.api.config.DefaultMuleConfiguration 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 8 with DefaultMuleConfiguration

use of org.mule.runtime.core.api.config.DefaultMuleConfiguration in project mule by mulesoft.

the class MessagingExceptionTestCase method before.

@Before
public void before() throws MuleException {
    originalVerboseExceptions = MuleException.verboseExceptions;
    locationProvider.setMuleContext(mockContext);
    DefaultMuleConfiguration mockConfiguration = mock(DefaultMuleConfiguration.class);
    when(mockConfiguration.getId()).thenReturn("MessagingExceptionTestCase");
    when(mockContext.getConfiguration()).thenReturn(mockConfiguration);
    when(mockContext.getTransformationService()).thenReturn(transformationService);
    testEvent = eventBuilder(muleContext).message(of(TEST_PAYLOAD)).build();
}
Also used : DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration) Before(org.junit.Before)

Example 9 with DefaultMuleConfiguration

use of org.mule.runtime.core.api.config.DefaultMuleConfiguration in project mule by mulesoft.

the class LocalTxQueueTransactionRecovererTestCase method doSetUp.

@Override
protected void doSetUp() throws Exception {
    ((DefaultMuleConfiguration) muleContext.getConfiguration()).setWorkingDirectory(temporaryFolder.getRoot().getAbsolutePath());
    txLog = new LocalTxQueueTransactionJournal(temporaryFolder.getRoot().getAbsolutePath(), muleContext);
    inQueue = new DefaultQueueStore(QUEUE_NAME, muleContext, new DefaultQueueConfiguration(0, true));
    persistentTransactionContext = new PersistentQueueTransactionContext(txLog, createQueueProvider(inQueue));
    queueTransactionRecoverer = new LocalTxQueueTransactionRecoverer(txLog, createQueueProvider(inQueue));
}
Also used : DefaultQueueConfiguration(org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration) DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration) LocalTxQueueTransactionRecoverer(org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer) LocalTxQueueTransactionJournal(org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal)

Example 10 with DefaultMuleConfiguration

use of org.mule.runtime.core.api.config.DefaultMuleConfiguration in project mule by mulesoft.

the class PolicyMuleContextBuilder method createMuleConfiguration.

@Override
protected DefaultMuleConfiguration createMuleConfiguration() {
    final DefaultMuleConfiguration configuration = new DefaultMuleConfiguration(true);
    initializeFromProperties(configuration);
    configuration.setId(policyName);
    final String encoding = defaultEncoding;
    if (!isBlank(encoding)) {
        configuration.setDefaultEncoding(encoding);
    }
    return configuration;
}
Also used : DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration)

Aggregations

DefaultMuleConfiguration (org.mule.runtime.core.api.config.DefaultMuleConfiguration)11 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 MuleContext (org.mule.runtime.core.api.MuleContext)2 ConfigurationBuilder (org.mule.runtime.core.api.config.ConfigurationBuilder)2 ConfigurationException (org.mule.runtime.core.api.config.ConfigurationException)2 MuleConfiguration (org.mule.runtime.core.api.config.MuleConfiguration)2 SimpleConfigurationBuilder (org.mule.runtime.core.api.config.builders.SimpleConfigurationBuilder)2 DefaultMuleContextFactory (org.mule.runtime.core.api.context.DefaultMuleContextFactory)2 MuleContextBuilder (org.mule.runtime.core.api.context.MuleContextBuilder)2 File (java.io.File)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 Collections.emptyList (java.util.Collections.emptyList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Optional.empty (java.util.Optional.empty)1