Created
June 15, 2010 23:57
-
-
Save ddossot/439918 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mule; | |
import java.util.HashMap; | |
import java.util.Map; | |
import org.mule.api.MuleEventContext; | |
import org.mule.api.MuleMessage; | |
import org.mule.api.MuleSession; | |
import org.mule.api.endpoint.EndpointURI; | |
import org.mule.api.service.Service; | |
import code.lucamarrocco.hoptoad.HoptoadNoticeBuilder; | |
public class MuleHoptoadNoticeBuilder extends HoptoadNoticeBuilder { | |
public MuleHoptoadNoticeBuilder(final String apiKey, final Throwable throwable, final String env, | |
final MuleEventContext eventContext) { | |
super(apiKey, throwable, env); | |
filteredSystemProperties(); | |
if (eventContext != null) { | |
addFromEventContext(eventContext); | |
} | |
} | |
private void addFromEventContext(final MuleEventContext eventContext) { | |
projectRoot(eventContext.getMuleContext().getConfiguration().getWorkingDirectory()); | |
final EndpointURI endpointURI = eventContext.getEndpointURI(); | |
final Service service = eventContext.getService(); | |
if (endpointURI != null && service != null) { | |
setRequest(endpointURI.toString(), service.getName()); | |
} | |
final MuleMessage message = eventContext.getMessage(); | |
if (message != null) { | |
request(getAllMessageProperties(message)); | |
} | |
final MuleSession session = eventContext.getSession(); | |
if (session != null) { | |
session(getAllSessionProperties(session)); | |
} | |
} | |
private Map<String, Object> getAllMessageProperties(final MuleMessage message) { | |
final Map<String, Object> messageProperties = new HashMap<String, Object>(); | |
for (final String propertyName : message.getPropertyNames()) { | |
messageProperties.put(propertyName, message.getProperty(propertyName)); | |
} | |
return messageProperties; | |
} | |
private Map<String, Object> getAllSessionProperties(final MuleSession session) { | |
final Map<String, Object> sessionProperties = new HashMap<String, Object>(); | |
for (final Object propertyName : session.getPropertyNamesAsSet()) { | |
sessionProperties.put(propertyName.toString(), session.getProperty(propertyName)); | |
} | |
return sessionProperties; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment