use of org.mule.runtime.core.internal.registry.MuleRegistry in project mule by mulesoft.
the class TransformDiscoveryTestCase method testSimpleDiscovery.
@Test
public void testSimpleDiscovery() throws Exception {
MuleRegistry registry = ((MuleContextWithRegistries) muleContext).getRegistry();
Transformer t = registry.lookupTransformer(DataType.STRING, DataType.fromType(Apple.class));
assertNotNull(t);
assertEquals(StringToApple.class, t.getClass());
t = registry.lookupTransformer(DataType.STRING, DataType.fromType(Orange.class));
assertNotNull(t);
assertEquals(StringToOrange.class, t.getClass());
try {
registry.lookupTransformer(DataType.STRING, DataType.fromType(Banana.class));
fail("There is no transformer to go from String to Banana");
} catch (TransformerException e) {
// expected
}
registry.registerTransformer(new StringToRedApple());
t = registry.lookupTransformer(DataType.STRING, DataType.fromType(RedApple.class));
assertNotNull(t);
assertEquals(StringToRedApple.class, t.getClass());
}
use of org.mule.runtime.core.internal.registry.MuleRegistry in project mule by mulesoft.
the class DefaultPolicyManager method initialise.
@Override
public void initialise() throws InitialisationException {
operationPolicyProcessorFactory = new DefaultOperationPolicyProcessorFactory(policyStateHandler);
sourcePolicyProcessorFactory = new DefaultSourcePolicyProcessorFactory(policyStateHandler);
MuleRegistry registry = ((MuleContextWithRegistries) muleContext).getRegistry();
policyProvider = registry.lookupLocalObjects(PolicyProvider.class).stream().findFirst().orElse(new NullPolicyProvider());
sourcePolicyParametersTransformerCollection = registry.lookupObjects(SourcePolicyParametersTransformer.class);
operationPolicyParametersTransformerCollection = registry.lookupObjects(OperationPolicyParametersTransformer.class);
policyPointcutParametersManager = new PolicyPointcutParametersManager(registry.lookupObjects(SourcePolicyPointcutParametersFactory.class), registry.lookupObjects(OperationPolicyPointcutParametersFactory.class));
}
use of org.mule.runtime.core.internal.registry.MuleRegistry in project mule by mulesoft.
the class DefaultsConfigurationBuilder method doConfigure.
@Override
protected void doConfigure(MuleContext muleContext) throws Exception {
MuleRegistry registry = ((MuleContextWithRegistries) muleContext).getRegistry();
new SimpleRegistryBootstrap(APP, muleContext).initialise();
configureQueueManager(muleContext);
registry.registerObject(OBJECT_MULE_CONTEXT, muleContext);
registerObject(OBJECT_SECURITY_MANAGER, new DefaultMuleSecurityManager(), muleContext);
registerObject(BASE_IN_MEMORY_OBJECT_STORE_KEY, createDefaultInMemoryObjectStore(), muleContext);
registerObject(BASE_PERSISTENT_OBJECT_STORE_KEY, createDefaultPersistentObjectStore(), muleContext);
registerLocalObjectStoreManager(muleContext, registry);
registerObject(OBJECT_SCHEDULER_POOLS_CONFIG, SchedulerContainerPoolsConfig.getInstance(), muleContext);
registerObject(OBJECT_SCHEDULER_BASE_CONFIG, config().withPrefix(muleContext.getConfiguration().getId()).withShutdownTimeout(() -> muleContext.getConfiguration().getShutdownTimeout(), MILLISECONDS), muleContext);
registerObject(OBJECT_STORE_MANAGER, new MuleObjectStoreManager(), muleContext);
registerObject(OBJECT_DEFAULT_MESSAGE_PROCESSING_MANAGER, new MuleMessageProcessingManager(), muleContext);
registerObject(OBJECT_MULE_STREAM_CLOSER_SERVICE, new DefaultStreamCloserService(), muleContext);
registerObject(OBJECT_LOCK_PROVIDER, new SingleServerLockProvider(), muleContext);
registerObject(OBJECT_LOCK_FACTORY, new MuleLockFactory(), muleContext);
registerObject(OBJECT_PROCESSING_TIME_WATCHER, new DefaultProcessingTimeWatcher(), muleContext);
registerObject(OBJECT_DEFAULT_RETRY_POLICY_TEMPLATE, new NoRetryPolicyTemplate(), muleContext);
registerObject(OBJECT_CONVERTER_RESOLVER, new DynamicDataTypeConversionResolver(muleContext), muleContext);
registerObject(DEFAULT_OBJECT_SERIALIZER_NAME, new JavaObjectSerializer(), muleContext);
registerObject(OBJECT_EXPRESSION_LANGUAGE, new MVELExpressionLanguage(muleContext), muleContext);
StreamingManager streamingManager = new DefaultStreamingManager();
registerObject(OBJECT_STREAMING_MANAGER, streamingManager, muleContext);
registerObject(OBJECT_EXPRESSION_MANAGER, new DefaultExpressionManager(), muleContext);
registerObject(OBJECT_TIME_SUPPLIER, new LocalTimeSupplier(), muleContext);
registerObject(OBJECT_CONNECTION_MANAGER, new DefaultConnectionManager(muleContext), muleContext);
registerObject(METADATA_SERVICE_KEY, new MuleMetadataService(), muleContext);
registerObject(VALUE_PROVIDER_SERVICE_KEY, new MuleValueProviderService(), muleContext);
registerObject(PROCESSOR_INTERCEPTOR_MANAGER_REGISTRY_KEY, new DefaultProcessorInterceptorManager(), muleContext);
registerObject(OBJECT_NOTIFICATION_DISPATCHER, new DefaultNotificationDispatcher(), muleContext);
registerObject(NotificationListenerRegistry.REGISTRY_KEY, new DefaultNotificationListenerRegistry(), muleContext);
registerObject(EventContextService.REGISTRY_KEY, new DefaultEventContextService(), muleContext);
registerObject(OBJECT_TRANSACTION_FACTORY_LOCATOR, new TransactionFactoryLocator(), muleContext);
registerObject(ComponentInitialStateManager.SERVICE_ID, new ComponentInitialStateManager() {
@Override
public boolean mustStartMessageSource(Component component) {
return true;
}
}, muleContext);
}
use of org.mule.runtime.core.internal.registry.MuleRegistry in project mule by mulesoft.
the class DefaultExtensionManagerTestCase method getOperationExecutorThroughImplicitConfigurationConcurrently.
@Test
public void getOperationExecutorThroughImplicitConfigurationConcurrently() throws Exception {
final int threadCount = 2;
final CountDownLatch joinerLatch = new CountDownLatch(threadCount);
MuleRegistry registry = muleContext.getRegistry();
when(extension1ConfigurationModel.getModelProperty(ParameterGroupModelProperty.class)).thenReturn(empty());
doAnswer(invocation -> {
registerIntoMockContext(muleContext, getImplicitConfigurationProviderName(extensionModel1, extension1ConfigurationModel), extension1ConfigurationProvider);
new Thread(() -> extensionsManager.getConfiguration(extensionModel1, extension1OperationModel, event)).start();
joinerLatch.countDown();
return null;
}).when(registry).registerObject(anyString(), anyObject());
Optional<ConfigurationInstance> configurationInstance = extensionsManager.getConfiguration(extensionModel1, extension1OperationModel, event);
joinerLatch.countDown();
assertThat(configurationInstance.isPresent(), is(true));
assertThat(joinerLatch.await(5, TimeUnit.SECONDS), is(true));
assertThat(configurationInstance.get().getValue(), is(sameInstance(configInstance)));
}
use of org.mule.runtime.core.internal.registry.MuleRegistry in project mule by mulesoft.
the class MuleTestUtils method createAndRegisterFlow.
/**
* Creates a new flow and registers it in the given {@code mockComponentLocator}
*
* @param mockComponentLocator a {@link Mockito#mock(Class)} {@link ConfigurationComponentLocator}
*/
public static Flow createAndRegisterFlow(MuleContext context, String flowName, ConfigurationComponentLocator mockComponentLocator) throws MuleException {
Flow flow = createFlow(context, flowName);
MuleRegistry registry = ((MuleContextWithRegistries) context).getRegistry();
if (registry != null) {
registry.registerFlowConstruct(flow);
}
when(mockComponentLocator.find(Location.builder().globalName(flowName).build())).thenReturn(Optional.of(flow));
return flow;
}
Aggregations