Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Commit

Permalink
Merge pull request #5 from jimmidyson/remove-json-marshal-steps
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-bot[bot] committed Jul 18, 2017
2 parents 85ace24 + da754f6 commit 34f43bc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,65 +119,55 @@ protected void configureRule(Flow flow, int syndesisIndex) throws MalformedURLEx
name = "flow" + (syndesisIndex + 1);
flow.setName(name);
}

RouteDefinition route = null;
List<Step> steps = flow.getSteps();
int validSteps = 0;
if (steps != null) {
for (Step item : steps) {
if (item instanceof Function) {
Function function = (Function) item;
String functionName = function.getName();
if (!Strings.isEmpty(functionName)) {
if (route != null) {
route.to("json:marshal");
}
String method = null;
int idx = functionName.indexOf("::");
if (idx > 0) {
method = functionName.substring(idx + 2);
functionName = functionName.substring(0, idx);
}
String uri = "class:" + functionName;
if (method != null) {
uri += "?method=" + method;
}
route = fromOrTo(route, name, uri, message);

message.append(functionName);
if (method != null) {
message.append("." + method + "()");
} else {
message.append(".main()");
}
validSteps++;
if (steps == null || steps.isEmpty()) {
throw new IllegalStateException("No valid steps! Invalid flow " + flow);
}

for (Step item : steps) {
if (item instanceof Function) {
Function function = (Function) item;
String functionName = function.getName();
if (!Strings.isEmpty(functionName)) {
String method = null;
int idx = functionName.indexOf("::");
if (idx > 0) {
method = functionName.substring(idx + 2);
functionName = functionName.substring(0, idx);
}
} else if (item instanceof Endpoint) {
Endpoint invokeEndpoint = (Endpoint) item;
String uri = invokeEndpoint.getUri();
if (!Strings.isEmpty(uri)) {
if (route != null) {
route.to("json:marshal");
}
route = fromOrTo(route, name, uri, message);
message.append(uri);
validSteps++;
String uri = "class:" + functionName;
if (method != null) {
uri += "?method=" + method;
}
} else {
addStep(route, item);
validSteps++;
route = fromOrTo(route, name, uri, message);

message.append(functionName);
if (method != null) {
message.append("." + method + "()");
} else {
message.append(".main()");
}
}
} else if (item instanceof Endpoint) {
Endpoint invokeEndpoint = (Endpoint) item;
String uri = invokeEndpoint.getUri();
if (!Strings.isEmpty(uri)) {
route = fromOrTo(route, name, uri, message);
message.append(uri);
}
} else {
addStep(route, item);
}
}
if (route == null || validSteps == 0) {
throw new IllegalStateException("No valid steps! Invalid flow " + flow);

}
if (flow.isLogResultEnabled()) {
String chain = "log:" + name + "?showStreams=true";
route.to(chain);
message.append(" => ");
message.append(chain);
validSteps++;
}
LOG.info(message.toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ProcessorDefinition handle(Endpoint step, ProcessorDefinition route, Synd
String uri = step.getUri();
if (!Strings.isEmpty(uri)) {
uri = routeBuilder.convertEndpointURI(uri);
route = route.to("json:marshal").to(uri);
route = route.to(uri);
}
return route;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ProcessorDefinition handle(Function step, ProcessorDefinition route, Synd
uri += "?method=" + method;
}
uri = routeBuilder.convertEndpointURI(uri);
route = route.to("json:marshal").to(uri);
route = route.to(uri);
}
return route;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.camel.Expression;
import org.apache.camel.model.ProcessorDefinition;
import org.apache.camel.model.SplitDefinition;
import org.apache.camel.model.dataformat.JsonLibrary;

@AutoService(StepHandler.class)
public class SplitHandler implements StepHandler<Split> {
Expand All @@ -32,7 +33,7 @@ public boolean canHandle(Step step) {
@Override
public ProcessorDefinition handle(Split step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) {
Expression expression = routeBuilder.getMandatoryExpression(step, step.getExpression());
SplitDefinition split = route.split(expression);
ProcessorDefinition split = route.split(expression).marshal().json(JsonLibrary.Jackson);
return routeBuilder.addSteps(split, step.getSteps());
}
}

0 comments on commit 34f43bc

Please sign in to comment.