Skip to content

Commit 0ba3b38

Browse files
committed
completed tutorial
1 parent 119800b commit 0ba3b38

File tree

6 files changed

+275
-109
lines changed

6 files changed

+275
-109
lines changed

Diff for: logs/logs.txt

+246-81
Large diffs are not rendered by default.

Diff for: src/main/java/com/cf/helloworld/Main.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public static void main(String[] args) throws InterruptedException {
2828

2929
context.start();
3030

31+
final long sleepDurationInMs = 1000;
3132
for (int i = 0; i < 600; i++)
32-
{
33-
final long sleepDurationInMs = 1000;
33+
{
3434
Thread.sleep(sleepDurationInMs);
3535
}
3636

Diff for: src/main/java/com/cf/helloworld/processor/DefaultGetProcessor.java

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
/*
2-
* To change this license header, choose License Headers in Project Properties.
3-
* To change this template file, choose Tools | Templates
4-
* and open the template in the editor.
5-
*/
61
package com.cf.helloworld.processor;
7-
2+
import com.cf.helloworld.response.CustomerDetailResponse;
3+
import java.util.Date;
84
import java.util.Map;
95
import org.apache.camel.Exchange;
106
import org.apache.camel.Processor;
117
import org.slf4j.Logger;
128
import org.slf4j.LoggerFactory;
139

14-
/**
15-
*
16-
* @author David Pang
17-
*/
1810
public class DefaultGetProcessor implements Processor
1911
{
2012

@@ -25,9 +17,9 @@ public void process(Exchange ex) throws Exception
2517
{
2618
final long startTime = System.currentTimeMillis();
2719
logger.debug("Processing exchange - " + ex.toString());
28-
final String body = ex.getIn().getBody(String.class);
20+
final String request = ex.getIn().getBody(String.class);
2921
final Map<String, Object> headers = ex.getIn().getHeaders();
30-
22+
3123
final Object id = headers.get("id");
3224
logger.debug("ID: " + id);
3325

@@ -41,9 +33,12 @@ public void process(Exchange ex) throws Exception
4133

4234
}
4335
logger.debug("Headers: " + sb.toString());
36+
37+
// Construct output
38+
CustomerDetailResponse response = new CustomerDetailResponse(id.toString(), "Billy Bob", "[email protected]", new Date());
4439

4540
ex.getOut().setHeaders(ex.getIn().getHeaders());
46-
ex.getOut().setBody("DefaultGetProcessor processing complete");
41+
ex.getOut().setBody(response);
4742
logger.info("DefaultPostProcessor process() completed in " + (System.currentTimeMillis() - startTime) + " ms");
4843
}
4944

Diff for: src/main/java/com/cf/helloworld/processor/DefaultPostProcessor.java

-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
*/
66
package com.cf.helloworld.processor;
77

8-
import java.util.ArrayList;
9-
import java.util.List;
108
import java.util.Map;
11-
import java.util.Map.Entry;
129
import org.apache.camel.Exchange;
1310
import org.apache.camel.Processor;
1411
import org.slf4j.Logger;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.cf.helloworld.response;
2+
3+
import java.util.Date;
4+
5+
public class CustomerDetailResponse
6+
{
7+
public final String id;
8+
public final String name;
9+
public final String emailAddress;
10+
public final Date birthday;
11+
12+
public CustomerDetailResponse(String id, String name, String emailAddress, Date birthday)
13+
{
14+
this.id = id;
15+
this.name = name;
16+
this.emailAddress = emailAddress;
17+
this.birthday = birthday;
18+
}
19+
}

Diff for: src/main/java/com/cf/helloworld/route/RouteBuilderImpl.java

-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/*
2-
* To change this license header, choose License Headers in Project Properties.
3-
* To change this template file, choose Tools | Templates
4-
* and open the template in the editor.
5-
*/
61
package com.cf.helloworld.route;
72

83
import com.cf.helloworld.processor.DefaultGetProcessor;
@@ -11,13 +6,8 @@
116
import org.apache.camel.model.dataformat.JsonLibrary;
127
import org.apache.camel.model.rest.RestBindingMode;
138

14-
/**
15-
*
16-
* @author David Pang
17-
*/
189
public class RouteBuilderImpl extends RouteBuilder
1910
{
20-
2111
@Override
2212
public void configure() throws Exception
2313
{

0 commit comments

Comments
 (0)