Skip to content

Instantly share code, notes, and snippets.

@stephenfenech-nosto
stephenfenech-nosto / blognotifier.xml
Created February 13, 2012 17:47
Mule powered Blog Notifier configuration
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:twitter="http://www.mulesoft.org/schema/mule/twitter"
xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="CE-3.2.1"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
@stephenfenech-nosto
stephenfenech-nosto / gist:1616595
Created January 15, 2012 17:59
PHP proxy to get the xsd from github.
<?php
$requestUrl = $_GET['url'];
switch($requestUrl){
case "schema/mule/tools/3.2/mule-tools.xsd":{
$targetUrl = "https://raw.github.com/stephenfenech/integrationcocktail-blog/master/mule/mule-tools/src/main/resources/META-INF/mule-tools.xsd";
break;
}
default : $targetUrl = "https://raw.github.com/stephenfenech/integrationcocktail-blog/master/mule/mule-tools/src/main/resources/META-INF/mule-tools.xsd";
}
@stephenfenech-nosto
stephenfenech-nosto / gist:1616568
Created January 15, 2012 17:50
Apache rewrite rule to forward XSD requests to myproxy.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{THE_REQUEST} .*\.xsd
RewriteRule ^(.*)$ myproxy.php?url=$1
@stephenfenech-nosto
stephenfenech-nosto / gist:1612525
Created January 14, 2012 18:59
Mule Flow Controller : Generalizing
Lifecycle lifecycle=muleContext.getRegistry().lookupObject(flowName);
if(lifecycle == null)
{
throw new DefaultMuleException("No flow found with name "+flowName);
}
String actionTaken=null;
logger.debug("Excecuting " + action + " on " + flowName);
if(lifecycle instanceof Service)
{
@stephenfenech-nosto
stephenfenech-nosto / FlowController.java
Created January 14, 2012 18:51
Mule Flow Controller
package org.ic.mule.tools.processor.control;
import ...
public class FlowController implements MessageProcessor{
...
@Override
public MuleEvent process(MuleEvent event) throws MuleException {
@stephenfenech-nosto
stephenfenech-nosto / RethrowException.java
Created January 13, 2012 21:57
Rethrowing caught excaptions in Camel
package org.ic.camel.tools.bean.exception;
import org.apache.camel.Exchange;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RethrowException {
Logger logger=LoggerFactory.getLogger(RethrowException.class);
@stephenfenech-nosto
stephenfenech-nosto / gist:1600848
Created January 12, 2012 14:34
RouteController-PerformAction-ExecutorService
public void performAction(Exchange exchange) throws Exception {
//Skipping some lines here...
if (routeId.equals(exchange.getFromRouteId())) {
// Run the controlling in a separate thread in order for the current
// flow to finish
final String finalRouteId = routeId;
context.getExecutorServiceManager().newSingleThreadExecutor(this, "RouteControllerSelf").execute(new Runnable() {
@Override
public void run() {
try {
@stephenfenech-nosto
stephenfenech-nosto / gist:1595479
Created January 11, 2012 16:29
RouteController-PerformAction-SpawnThread
public void performAction(Exchange exchange) throws Exception {
//Skipping some lines here...
if (routeId.equals(exchange.getFromRouteId())) {
// Run the controlling in a separate thread in order for the current
// flow to finish
final String finalRouteId = routeId;
new Thread(new Runnable() {
@Override
public void run() {
try {
@stephenfenech-nosto
stephenfenech-nosto / RouteController.java
Created January 9, 2012 17:55
Route Controller first implementation
package org.ic.camel.tools.bean.control;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.ic.camel.tools.IntegrationCocktailConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RouteController {
public static final String START = "START";
@stephenfenech-nosto
stephenfenech-nosto / CocktailServiceTest.java
Created December 26, 2011 10:38
Integration Cocktail : Testing that Service methods are Secured - CocktailServiceTest
package org.ic.service;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/META-INF/spring/applicationContext*.xml")
public class CocktailServiceTest extends AbstractSecurityTest {