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
@Processor | |
public String getDistance(@Optional @Default("San+Francisco") String origin, | |
String destination) throws Exception | |
{ | |
String effectiveUrl = String.format(PROTOTYPE_URL, origin, destination, distanceUnit); | |
InputStream responseStream = new URL(effectiveUrl).openConnection().getInputStream(); | |
try | |
{ | |
return getXPath(responseStream, DISTANCE_XPATH); | |
} |
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
@Module(name="googlemaps", schemaVersion="1.0") | |
public class GoogleMapsModule | |
{ | |
private static final String PROTOTYPE_URL = | |
"http://maps.googleapis.com/maps/api/distancematrix/xml?origins=%s&destinations=%s&units=%s&sensor=false"; | |
private static final String DISTANCE_XPATH = "//DistanceMatrixResponse/row/element/distance/text/text()"; | |
@Configurable | |
private DistanceUnit distanceUnit; | |
@Processor |
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
@Test | |
public void testFlow() throws Exception | |
{ | |
runFlowAndExpect("testFlow", "23.8 km"); | |
} |
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
<mule xmlns="http://www.mulesoft.org/schema/mule/core" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:googlemaps="http://www.mulesoft.org/schema/mule/googlemaps" | |
xsi:schemaLocation=" | |
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd | |
http://www.mulesoft.org/schema/mule/googlemaps http://www.mulesoft.org/schema/mule/googlemaps/1.0/mule-googlemaps.xsd"> | |
<googlemaps:config distanceUnit ="KM"/> | |
<flow name="testFlow"> |
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
<mule xmlns="http://www.mulesoft.org/schema/mule/core" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:spring="http://www.springframework.org/schema/beans" | |
xmlns:googlemaps="http://www.mulesoft.org/schema/mule/googlemaps" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd | |
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd | |
http://www.mulesoft.org/schema/mule/googlemaps http://www.mulesoft.org/schema/mule/googlemaps/1.0-SNAPSHOT/mule-googlemaps.xsd"> | |
<googlemaps:config myProperty="Some string" |
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
@Module(name="googlemaps", schemaVersion="1.0") | |
public class GoogleMapsModule | |
{ | |
private static final String PROTOTYPE_URL = | |
"http://maps.googleapis.com/maps/api/distancematrix/xml?origins=%s&destinations=%s&units=%s&sensor=false"; | |
private static final String DISTANCE_XPATH = "//DistanceMatrixResponse/row/element/distance/text/text()"; | |
@Configurable | |
@Optional | |
@Default("MI") | |
private DistanceUnit defaultDistanceUnit; |
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 org.mule.api.annotations.Module; | |
import org.mule.api.ConnectionException; | |
import org.mule.api.annotations.Configurable; | |
import org.mule.api.annotations.Processor; | |
@Module(name="googlemaps", schemaVersion="1.0") | |
public class GoogleMapsModule | |
{ |
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
mvn archetype:generate -DarchetypeGroupId=org.mule.tools.devkit -DarchetypeArtifactId=mule-devkit-archetype-generic -DarchetypeVersion=3.0.1 -DarchetypeRepository=http://repository.mulesoft.org/releases/ -DgroupId=org.mule -DartifactId=google-maps-connector -Dversion=1.0 -DmuleVersion=3.2.0 -DmuleModuleName=GoogleMaps |
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
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:jira="http://www.mulesoft.org/schema/mule/jira" | |
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd | |
http://www.mulesoft.org/schema/mule/jira http://www.mulesoft.org/schema/mule/jira/1.0/mule-jira.xsd"> |
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
<jira:add-comment issueKey="XYZ-123" commentAuthor="Federico" commentBody="This is the comment for the issue"/> |