Search in sources :

Example 1 with MULE_PROPERTIES_IDENTIFIER

use of org.mule.runtime.config.internal.model.ApplicationModel.MULE_PROPERTIES_IDENTIFIER in project mule by mulesoft.

the class PropertiesMapBeanDefinitionCreator method handleRequest.

@Override
boolean handleRequest(CreateBeanDefinitionRequest createBeanDefinitionRequest) {
    SpringComponentModel componentModel = createBeanDefinitionRequest.getComponentModel();
    if (componentModel.getIdentifier().equals(MULE_PROPERTIES_IDENTIFIER) || componentModel.getIdentifier().equals(MULE_PROPERTY_IDENTIFIER)) {
        ManagedMap<Object, Object> managedMap;
        if (componentModel.getIdentifier().equals(MULE_PROPERTIES_IDENTIFIER)) {
            managedMap = createManagedMapFromEntries(componentModel);
        } else {
            managedMap = new ManagedMap<>();
            ComponentModel parentComponentModel = componentModel.getParent();
            parentComponentModel.getInnerComponents().stream().filter(childComponentModel -> childComponentModel.getIdentifier().equals(MULE_PROPERTY_IDENTIFIER)).forEach(childComponentModel -> {
                processAndAddMapProperty(childComponentModel, managedMap);
            });
        }
        BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(HashMap.class);
        componentModel.setBeanDefinition(beanDefinitionBuilder.addConstructorArgValue(managedMap).getBeanDefinition());
        return true;
    }
    return false;
}
Also used : MULE_PROPERTIES_IDENTIFIER(org.mule.runtime.config.internal.model.ApplicationModel.MULE_PROPERTIES_IDENTIFIER) VALUE_REF_ATTRIBUTE(org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.VALUE_REF_ATTRIBUTE) ManagedMap(org.springframework.beans.factory.support.ManagedMap) BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) KEY_ELEMENT(org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.KEY_ELEMENT) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference) HashMap(java.util.HashMap) ManagedList(org.springframework.beans.factory.support.ManagedList) KEY_REF_ATTRIBUTE(org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.KEY_REF_ATTRIBUTE) MULE_PROPERTY_IDENTIFIER(org.mule.runtime.config.internal.model.ApplicationModel.MULE_PROPERTY_IDENTIFIER) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) BEAN_REF_ATTRIBUTE(org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.BEAN_REF_ATTRIBUTE) SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) VALUE_ATTRIBUTE(org.mule.runtime.config.internal.model.ApplicationModel.VALUE_ATTRIBUTE) MAP_ELEMENT(org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.MAP_ELEMENT) BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel)

Aggregations

HashMap (java.util.HashMap)1 SpringComponentModel (org.mule.runtime.config.internal.dsl.model.SpringComponentModel)1 MULE_PROPERTIES_IDENTIFIER (org.mule.runtime.config.internal.model.ApplicationModel.MULE_PROPERTIES_IDENTIFIER)1 MULE_PROPERTY_IDENTIFIER (org.mule.runtime.config.internal.model.ApplicationModel.MULE_PROPERTY_IDENTIFIER)1 VALUE_ATTRIBUTE (org.mule.runtime.config.internal.model.ApplicationModel.VALUE_ATTRIBUTE)1 ComponentModel (org.mule.runtime.config.internal.model.ComponentModel)1 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)1 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)1 ManagedList (org.springframework.beans.factory.support.ManagedList)1 ManagedMap (org.springframework.beans.factory.support.ManagedMap)1 BEAN_REF_ATTRIBUTE (org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.BEAN_REF_ATTRIBUTE)1 KEY_ELEMENT (org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.KEY_ELEMENT)1 KEY_REF_ATTRIBUTE (org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.KEY_REF_ATTRIBUTE)1 MAP_ELEMENT (org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.MAP_ELEMENT)1 VALUE_REF_ATTRIBUTE (org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.VALUE_REF_ATTRIBUTE)1