Skip to content

Instantly share code, notes, and snippets.

@marianogonzalez
marianogonzalez / MultipartHttpToMapTransformer.java
Created January 4, 2012 14:53
MultipartHttpToMapTransformer
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.fileupload.MultipartStream;
import org.apache.log4j.Logger;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import org.mule.transformer.AbstractMessageTransformer;
@marianogonzalez
marianogonzalez / MultipartHttpToMapTransformeraux.java
Created January 4, 2012 15:02
MultipartHttpToMapTransformer aux
protected Map<String, String> parseHeaders(String headerPart)
{
Map<String, String> headers = new HashMap<String, String>();
char buffer[] = new char[1024];
boolean done = false;
int j = 0;
int i;
String header, headerName, headerValue;
try
{
@marianogonzalez
marianogonzalez / gist:1677400
Created January 25, 2012 17:18
ErrorNotificationFlow
<flow name="NotificationOfError">
<vm:inbound-endpoint path="notifyError" />
<object-to-string-transformer />
<smtp:outbound-endpoint host="smtp.gmail.com"
port="587" user="${email.user}" password="${email.pass}" from="${email.user}"
to="${email.support}" subject="Houston: We have a problem!"
connector-ref="emailConnector" />
</flow>
@marianogonzalez
marianogonzalez / gist:1677502
Created January 25, 2012 17:36
Consuming the error flow
muleContext.getClient().send("vm://notifyError", exception)
@marianogonzalez
marianogonzalez / gist:1690712
Created January 27, 2012 20:19
create child context
// reference the files with the customized flows and resources
ConfigResource[2] resources = new ConfigResource[2];
resources[0] = new ConfigResource(new URL(pathToCustomFile1));
resources[1] = new ConfigResource(new URL(pathToCustomFile2));
// create a spring configuration builder
SpringXmlConfigurationBuilder springXmlConfigurationBuilder = new SpringXmlConfigurationBuilder(resources);
//reference the parent
springXmlConfigurationBuilder.setParentContext(parentMuleContext);
@marianogonzalez
marianogonzalez / gist:1690775
Created January 27, 2012 20:32
access child context
MuleContext child = contextsMap.get(contextName);
child.getClient().send("vm://notifyError", exception)
xjc example.xsd
<!-- give jaxb a package to scan for annotations -->
<mulexml:jaxb-context name="myJaxB" packageNames="com.mulesoft.example" />
<sub-flow name="xmlMarshalling">
<!-- custom transformer that would populate your bean -->
<custom-transformer class="com.mulesoft.example.PayloadToBeanTransformer" />
<!-- Generate the XML -->
<mulexml:jaxb-object-to-xml-transformer name="myMarshaller" jaxbContext-ref="myJaxB"/>
</sub-flow>
@marianogonzalez
marianogonzalez / gist:1718825
Created February 1, 2012 19:37
gpg gen key
gpg --gen-key
@marianogonzalez
marianogonzalez / gist:1719003
Created February 1, 2012 20:01
key manager
<spring:bean id="pgpKeyManager" class="org.mule.module.pgp.PGPKeyRingImpl" init-method="initialise">
<spring:property name="publicKeyRingFileName" value="./public.gpg" />
<spring:property name="secretKeyRingFileName" value="./secring.gpg" />
<spring:property name="secretAliasId" value="1218002276979500705" />
<spring:property name="secretPassphrase" value="myPassPhrase" />
</spring:bean>