org.mule.util.NotificationUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mule-core Show documentation
Show all versions of mule-core Show documentation
Mule server and core classes
/*
* 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;
}
}