use of org.mule.runtime.api.component.Component 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.api.component.Component in project mule by mulesoft.
the class ApplicationModel method resolveComponentTypes.
/**
* Resolves the types of each component model when possible.
*/
public void resolveComponentTypes() {
// TODO MULE-13894 enable this once changes are completed and no componentBuildingDefinition is needed
// checkState(componentBuildingDefinitionRegistry.isPresent(),
// "ApplicationModel was created without a " + ComponentBuildingDefinitionProvider.class.getName());
componentBuildingDefinitionRegistry.ifPresent(buildingDefinitionRegistry -> {
executeOnEveryComponentTree(componentModel -> {
Optional<ComponentBuildingDefinition<?>> buildingDefinition = buildingDefinitionRegistry.getBuildingDefinition(componentModel.getIdentifier());
buildingDefinition.map(definition -> {
ObjectTypeVisitor typeDefinitionVisitor = new ObjectTypeVisitor(componentModel);
definition.getTypeDefinition().visit(typeDefinitionVisitor);
componentModel.setType(typeDefinitionVisitor.getType());
return definition;
}).orElseGet(() -> {
String classParameter = componentModel.getParameters().get(CLASS_ATTRIBUTE);
if (classParameter != null) {
try {
componentModel.setType(ClassUtils.getClass(classParameter));
} catch (ClassNotFoundException e) {
throw new RuntimeConfigurationException(I18nMessageFactory.createStaticMessage(String.format("Could not resolve class '%s' for component '%s'", classParameter, componentModel.getComponentLocation())));
}
}
return null;
});
});
});
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class FlowRefFactoryBean method getReferencedFlow.
protected Processor getReferencedFlow(String name, FlowRefMessageProcessor flowRefMessageProcessor) throws MuleException {
if (name == null) {
throw new RoutePathNotFoundException(createStaticMessage("flow-ref name expression returned 'null'"), flowRefMessageProcessor);
}
Component referencedFlow = getReferencedProcessor(name);
if (referencedFlow == null) {
throw new RoutePathNotFoundException(createStaticMessage("No flow/sub-flow with name '%s' found", name), flowRefMessageProcessor);
}
// for subflows, we create a new one so it must be initialised manually
if (!(referencedFlow instanceof Flow)) {
if (referencedFlow instanceof SubflowMessageProcessorChainBuilder) {
MessageProcessorChainBuilder chainBuilder = (MessageProcessorChainBuilder) referencedFlow;
locator.find(flowRefMessageProcessor.getRootContainerLocation()).filter(c -> c instanceof Flow).map(c -> (Flow) c).ifPresent(f -> chainBuilder.setProcessingStrategy(f.getProcessingStrategy()));
referencedFlow = chainBuilder.build();
}
initialiseIfNeeded(referencedFlow, muleContext);
Map<QName, Object> annotations = new HashMap<>(referencedFlow.getAnnotations());
annotations.put(ROOT_CONTAINER_NAME_KEY, getRootContainerLocation().toString());
referencedFlow.setAnnotations(annotations);
startIfNeeded(referencedFlow);
}
return (Processor) referencedFlow;
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class LocatedMuleExceptionTestCase method annotatedComponent.
@Test
public void annotatedComponent() {
Component annotated = mock(Component.class);
when(annotated.getAnnotation(eq(docNameAttrName))).thenReturn("Mock Component");
when(annotated.toString()).thenReturn("Mock@1");
configureProcessorLocation(annotated);
LocatedMuleException lme = new LocatedMuleException(annotated);
assertThat(lme.getInfo().get(INFO_LOCATION_KEY).toString(), is("Mock@1 @ app:muleApp.xml:10 (Mock Component)"));
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class MVELExpressionLanguageTestCase method setupMVEL.
@Before
public void setupMVEL() throws InitialisationException {
mvel = new MVELExpressionLanguage(muleContext);
mvel.initialise();
flowConstruct = mock(FlowConstruct.class, withSettings().extraInterfaces(Component.class));
when(flowConstruct.getName()).thenReturn("myFlow");
final DefaultComponentLocation location = fromSingleComponent("myFlow");
when(((Component) flowConstruct).getAnnotation(LOCATION_KEY)).thenReturn(location);
when(((Component) flowConstruct).getLocation()).thenReturn(location);
}
Aggregations