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
@Override | |
public void onNotification(MuleContextNotification notification) { | |
if (notification.getAction() == MuleContextNotification.CONTEXT_STARTED) { | |
logger.info("Context Started"); | |
final Runnable startFlow=createParalelStart(notification); | |
new Thread(startFlow).start(); | |
} | |
} |
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
private Runnable createParalelStart(final MuleContextNotification notification) { | |
final Runnable callFlow = new Runnable() { | |
public void run() { | |
try | |
{ | |
Thread.sleep(4000); | |
logger.info("Starting up process in 4 second"); | |
executeFlow(notification); | |
} |
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
private void executeFlow(final MuleContextNotification notification) throws MuleException { | |
DefaultMuleMessage message=new DefaultMuleMessage(notification,context); | |
MuleClient client=context.getClient(); | |
client.send("vm://startup", message); | |
} |
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
public class FlowInvokerContextListener implements MuleContextNotificationListener<MuleContextNotification> { | |
@Inject | |
private MuleContext context; | |
private static final Logger logger = Logger.getLogger(FlowInvokerContextListener.class); |
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
<configuration doc:name="Configuration"> | |
<expression-language> | |
<global-functions> | |
def dayOfTheMonth(date){ | |
import java.util.Calendar; | |
import java.text.SimpleDateFormat; | |
cal = Calendar.getInstance(); | |
sdf = new SimpleDateFormat('yyyyMMdd'); |
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
<flow name="usingTransformerAnnotation"> | |
<http:listener config-ref="HTTP_Listener_Configuration" path="/transformerAnnotation" doc:name="HTTP" allowedMethods="GET"/> | |
<set-payload value="#['Annotated Max!']" doc:name="Set Payload"/> | |
<component class="javacall.AnimalTransformerAnnotation" doc:name="Java"/> | |
<object-to-string-transformer doc:name="Object to String"/> | |
</flow> |
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
@ContainsTransformerMethods | |
public class AnimalTransformerAnnotation { | |
@Transformer | |
public Animal returnAnimal(@Payload String name){ | |
return new Animal(name); | |
} | |
} |
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
<flow name="usingTransformer"> | |
<http:listener config-ref="HTTP_Listener_Configuration" path="/transformer" allowedMethods="GET" doc:name="HTTP"/> | |
<set-variable variableName="flowVarName" value="#['Max the Mule']" doc:name="Variable"/> | |
<custom-transformer returnClass="model.Animal" class="javacall.AnimalTransformer" doc:name="Java"/> | |
<object-to-string-transformer doc:name="Object to String"/> | |
</flow> |
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
public class AnimalTransformer extends AbstractMessageTransformer{ | |
public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { | |
String flowVarName = message.getProperty("flowVarName", PropertyScope.INVOCATION); | |
Animal animal=new Animal(flowVarName); | |
return animal; | |
} | |
} |
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
<flow name="usingCustomMessageProcessor"> | |
<http:listener config-ref="HTTP_Listener_Configuration" path="/customMessage" doc:name="HTTP" allowedMethods="GET"/> | |
<custom-processor class="javacall.MessageProcessorCall" doc:name="Custom Processor"/> | |
<object-to-string-transformer doc:name="Object to String"/> | |
</flow> |