All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mule.util.NotificationUtils Maven / Gradle / Ivy

There is a newer version: 3.9.0
Show newest version
/*
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */
package org.mule.util;

import org.mule.api.processor.InternalMessageProcessor;
import org.mule.api.processor.MessageProcessor;
import org.mule.api.processor.MessageProcessorContainer;
import org.mule.api.processor.MessageProcessorPathElement;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Contains useful methods for the generation of message processor identifiers used by the notification system
 */
public class NotificationUtils
{

    private NotificationUtils()
    {
    }

    public static void addMessageProcessorPathElements(List processors, MessageProcessorPathElement parentElement)
    {
        if (processors == null)
        {
            return;
        }
        for (MessageProcessor mp : processors)
        {
            if (!(mp instanceof InternalMessageProcessor))
            {

                MessageProcessorPathElement messageProcessorPathElement = parentElement.addChild(mp);
                if (mp instanceof MessageProcessorContainer)
                {
                    ((MessageProcessorContainer) mp).addMessageProcessorPathElements(messageProcessorPathElement);
                }
            }

        }

    }


    public static Map buildPaths(MessageProcessorPathElement element)
    {
        return buildPaths(element, new LinkedHashMap());
    }

    private static Map buildPaths(MessageProcessorPathElement element, Map elements)
    {
        if (element.getMessageProcessor() != null)
        {
            elements.put(element.getMessageProcessor(), element.getPath());
        }
        List children = element.getChildren();
        for (MessageProcessorPathElement child : children)
        {
            buildPaths(child, elements);
        }
        return elements;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy