Skip to content

Instantly share code, notes, and snippets.

View andrewharmellaw's full-sized avatar

Andrew Harmel-Law andrewharmellaw

View GitHub Profile
@andrewharmellaw
andrewharmellaw / AboutMaps.scala
Created May 28, 2013 11:47
Scala convention: Parens on a method when it changes state
myMap.clear() // Convention is to use parens if possible when method called changes state
@andrewharmellaw
andrewharmellaw / camel-server.xml
Created June 13, 2013 09:00
Spring Context XMl file for Camel
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.10.4.xsd">
<!-- Declare a Camel context -->
@andrewharmellaw
andrewharmellaw / camel-server.xml
Created June 13, 2013 09:10
Imports of significant sub-system configs into camel-server.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.10.4.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
@andrewharmellaw
andrewharmellaw / pom.xml
Created June 13, 2013 09:19
Sample Maven 3 POM for a Camel project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yourcompany.yourapp</groupId>
<artifactId>yourartifact</artifactId></artifactId>
<version>0.1-SNAPSHOT</version>
<name>Your Application</name>
@andrewharmellaw
andrewharmellaw / activemq-config.xml
Created June 13, 2013 09:27
Example ActiveMQ Spring-style config for Camel
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:broker="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.8.0.xsd">
<broker:broker useJmx="true" persistent="true" brokerName="${activemq.broker.name}">
<broker:transportConnectors>
<!-- expose a VM transport for in-JVM transport between AMQ and Camel on the server side -->
@andrewharmellaw
andrewharmellaw / camel-server.xml
Created June 13, 2013 09:41
Camel Spring config file showing loading of non-camel and camel properties files (WAR-bundled and external)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.10.4.xsd">
<!-- Spring property placeholder.
@andrewharmellaw
andrewharmellaw / ExampleCamelPropertiesInUnitTest.java
Created June 13, 2013 09:49
Example of using Camel properties in Java code (in this case in a Unit Test)
/**
* @author Andrew Harmel-Law
*/
@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring/camel-CamelTDDExampleTest.xml"})
public class ExampleCamelPropertiesInUnitTest {
private String inboxDir;
private String outboxDir;
@andrewharmellaw
andrewharmellaw / TDDRoute.java
Created June 13, 2013 09:59
Example Java DSL Route for Camel
package com.mycompany.myapp.route;
import org.apache.camel.builder.RouteBuilder;
public class TDDRoute extends RouteBuilder {
public void configure() {
from("file:{{file.inbox}}").to("file:{{file.outbox}}");
}
}
@andrewharmellaw
andrewharmellaw / camel-server.xml
Created June 13, 2013 10:04
Camel Spring Config file showing scanning for Java DSL Routes
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.10.4.xsd">
<!-- Declare a Camel context -->
@andrewharmellaw
andrewharmellaw / TestMyRouteTransactionality.java
Created June 13, 2013 10:27
Example JUnit test showing class name and test name conventions
package com.mycompany.myapp.serviceactivator;
public class TestMyRouteTransactionality {
@Test
public void callWithSimpleFulfillmentRequest() throws Exception {
// Given... Do some setup and declare mocks and expectations here...
// When... Do the work here...