camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/8] camel git commit: Refactored variable name, and removed a redudant block of code.
Date Sat, 28 May 2016 06:55:13 GMT
Refactored variable name, and removed a redudant block of code.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/41f282ba
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/41f282ba
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/41f282ba

Branch: refs/heads/master
Commit: 41f282ba661f61e9d93b4db9ba65f7b070bff964
Parents: c433331
Author: Joseluis Pedrosa <joseluis.pedrosa@elephanttalk.com>
Authored: Thu Apr 28 17:15:37 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat May 28 08:48:19 2016 +0200

----------------------------------------------------------------------
 .../component/spring/batch/SpringBatchComponent.java |  5 ++---
 .../component/spring/batch/SpringBatchProducer.java  | 15 ++++-----------
 .../spring/batch/SpringBatchEndpointTest.java        |  5 ++---
 3 files changed, 8 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/41f282ba/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java
b/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java
index 828d58d..ca1bb29 100644
--- a/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java
+++ b/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java
@@ -24,10 +24,9 @@ import org.springframework.batch.core.launch.JobLauncher;
 
 public class SpringBatchComponent extends UriEndpointComponent {
 
-    public  static final String DYNAMIC_JOBNAME = "CamelSpringBatchDynamicJobName";
-    
-    private static final String DEFAULT_JOB_LAUNCHER_REF_NAME = "jobLauncher";
+    public  static final String JOB_NAME = "CamelSpringBatch.jobName";
 
+    private static final String DEFAULT_JOB_LAUNCHER_REF_NAME = "jobLauncher";
 
     private JobLauncher jobLauncher;
     private JobLauncher defaultResolvedJobLauncher;

http://git-wip-us.apache.org/repos/asf/camel/blob/41f282ba/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
b/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
index 188b71a..7c985fe 100644
--- a/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
+++ b/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
@@ -48,25 +48,18 @@ public class SpringBatchProducer extends DefaultProducer {
     public void process(Exchange exchange) throws Exception {
 
         JobParameters jobParameters = prepareJobParameters(exchange.getIn().getHeaders());
-        String messageJobName = jobParameters.getString(SpringBatchComponent.DYNAMIC_JOBNAME);
+        String messageJobName = jobParameters.getString(SpringBatchComponent.JOB_NAME);
 
         Job job2run = this.job;
 
         if (messageJobName != null) {
-            Job dynamicJob = CamelContextHelper.mandatoryLookup(getEndpoint().getCamelContext(),
messageJobName, Job.class);
-
-            job2run = dynamicJob;
-
-            if (job2run == null) {
-                exchange.setException(new CamelExchangeException("Found header " + SpringBatchComponent.DYNAMIC_JOBNAME
-                        + " with value " + messageJobName + " but could not find a Job in
camel context", exchange));
-                return;
-            }
+            job2run = CamelContextHelper.mandatoryLookup(getEndpoint().getCamelContext(),
messageJobName, Job.class);
         }
 
+
         if (job2run == null) {
             exchange.setException(new CamelExchangeException("jobName was not specified in
the endpoint construction "
-                    + " and header " + SpringBatchComponent.DYNAMIC_JOBNAME + " could not
be found", exchange));
+                    + " and header " + SpringBatchComponent.JOB_NAME + " could not be found",
exchange));
             return;
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/41f282ba/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
index dcc0851..e145330 100644
--- a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
+++ b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
@@ -22,7 +22,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.CamelExchangeException;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.FailedToCreateRouteException;
 import org.apache.camel.builder.RouteBuilder;
@@ -118,7 +117,7 @@ public class SpringBatchEndpointTest extends CamelTestSupport {
         errorEndpoint.expectedMessageCount(1);
 
         //dynamic job should fail as header is present but the job does not exists
-        header(SpringBatchComponent.DYNAMIC_JOBNAME).append("thisJobDoesNotExsistAtAll" +
Date.from(Instant.now()));
+        header(SpringBatchComponent.JOB_NAME).append("thisJobDoesNotExsistAtAll" + Date.from(Instant.now()));
         sendBody("direct:dyanmic", "Start the job, please.");
 
         mockEndpoint.assertIsSatisfied();
@@ -133,7 +132,7 @@ public class SpringBatchEndpointTest extends CamelTestSupport {
         Thread.sleep(5000);
         //dynamic job work if header is present and the job exists
         final Map<String, Object> headers = new HashMap<>();
-        headers.put(SpringBatchComponent.DYNAMIC_JOBNAME, "dynamicMockjob");
+        headers.put(SpringBatchComponent.JOB_NAME, "dynamicMockjob");
 
         sendBody("direct:dynamic", "Start the job, please.", headers);
 


Mime
View raw message