[camel] branch master updated: Fixed CS for Camel-Grape

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: Fixed CS for Camel-Grape

acosentino
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new e0809db  Fixed CS for Camel-Grape
e0809db is described below

commit e0809dbcb77ae86115dd8f2a021a1086c9b69c5d
Author: Andrea Cosentino <[hidden email]>
AuthorDate: Mon Feb 11 14:35:24 2019 +0100

    Fixed CS for Camel-Grape
---
 .../apache/camel/component/grape/GrapeCommand.java |  6 +-
 .../camel/component/grape/GrapeComponent.java      |  1 +
 .../camel/component/grape/GrapeConstants.java      |  7 ++-
 .../camel/component/grape/GrapeEndpoint.java       |  4 +-
 .../camel/component/grape/GrapeProducer.java       | 65 +++++++++++-----------
 .../camel/component/grape/MavenCoordinates.java    | 21 +++----
 .../camel/component/grape/PatchesRepository.java   |  2 +-
 7 files changed, 54 insertions(+), 52 deletions(-)

diff --git a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeCommand.java b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeCommand.java
index a8d5940..11c1a98 100644
--- a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeCommand.java
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeCommand.java
@@ -18,8 +18,6 @@ package org.apache.camel.component.grape;
 
 public enum GrapeCommand {
 
-    grab,
-    listPatches,
-    clearPatches
+    grab, listPatches, clearPatches
 
-}
\ No newline at end of file
+}
diff --git a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeComponent.java b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeComponent.java
index d5d99dc..9d76a9d 100644
--- a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeComponent.java
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeComponent.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.grape;
 import java.util.Map;
 
 import groovy.lang.GroovyClassLoader;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
diff --git a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeConstants.java b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeConstants.java
index 72e2e47..cbab1d8 100644
--- a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeConstants.java
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeConstants.java
@@ -16,8 +16,11 @@
  */
 package org.apache.camel.component.grape;
 
-public class GrapeConstants {
-
+public final class GrapeConstants {
+    
     public static final String GRAPE_COMMAND = "CamelGrapeCommand";
+    
+    private GrapeConstants() {  
+    }
 
 }
diff --git a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeEndpoint.java b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeEndpoint.java
index 1344bfd..e0d25c3 100644
--- a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeEndpoint.java
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeEndpoint.java
@@ -21,6 +21,7 @@ import java.util.List;
 
 import groovy.grape.Grape;
 import groovy.lang.Closure;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
@@ -32,7 +33,8 @@ import org.apache.camel.support.DefaultEndpoint;
 import org.codehaus.groovy.runtime.DefaultGroovyMethods;
 
 /**
- * The grape component allows you to fetch, load and manage additional jars when CamelContext is running.
+ * The grape component allows you to fetch, load and manage additional jars when
+ * CamelContext is running.
  */
 @UriEndpoint(firstVersion = "2.16.0", scheme = "grape", syntax = "grape:defaultCoordinates", title = "Grape", producerOnly = true, label = "management,deployment")
 public class GrapeEndpoint extends DefaultEndpoint {
diff --git a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeProducer.java b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeProducer.java
index 6c80e98..cad3737 100644
--- a/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeProducer.java
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeProducer.java
@@ -20,6 +20,7 @@ import java.util.LinkedHashMap;
 import java.util.List;
 
 import groovy.grape.Grape;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.support.DefaultProducer;
 
@@ -33,45 +34,45 @@ public class GrapeProducer extends DefaultProducer {
     public void process(Exchange exchange) {
         GrapeCommand command = exchange.getIn().getHeader(GrapeConstants.GRAPE_COMMAND, GrapeCommand.grab, GrapeCommand.class);
         switch (command) {
-            case grab:
-                ClassLoader classLoader = exchange.getContext().getApplicationContextClassLoader();
-                String rawCoordinates = exchange.getIn().getBody(String.class);
-                LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(5);
-                try {
-                    MavenCoordinates coordinates = MavenCoordinates.parseMavenCoordinates(rawCoordinates);
-                    map.put("classLoader", classLoader);
-                    map.put("group", coordinates.getGroupId());
-                    map.put("module", coordinates.getArtifactId());
-                    map.put("version", coordinates.getVersion());
-                    map.put("classifier", coordinates.getClassifier());
-                    Grape.grab(map);
-                    getEndpoint().getComponent().getPatchesRepository().install(rawCoordinates);
-                } catch (IllegalArgumentException ex) {
-                    MavenCoordinates coordinates = MavenCoordinates.parseMavenCoordinates(getEndpoint().getDefaultCoordinates());
-                    map.put("classLoader", classLoader);
-                    map.put("group", coordinates.getGroupId());
-                    map.put("module", coordinates.getArtifactId());
-                    map.put("version", coordinates.getVersion());
-                    map.put("classifier", coordinates.getClassifier());
-                    Grape.grab(map);
-                    getEndpoint().getComponent().getPatchesRepository().install(getEndpoint().getDefaultCoordinates());
-                }
-                break;
+        case grab:
+            ClassLoader classLoader = exchange.getContext().getApplicationContextClassLoader();
+            String rawCoordinates = exchange.getIn().getBody(String.class);
+            LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(5);
+            try {
+                MavenCoordinates coordinates = MavenCoordinates.parseMavenCoordinates(rawCoordinates);
+                map.put("classLoader", classLoader);
+                map.put("group", coordinates.getGroupId());
+                map.put("module", coordinates.getArtifactId());
+                map.put("version", coordinates.getVersion());
+                map.put("classifier", coordinates.getClassifier());
+                Grape.grab(map);
+                getEndpoint().getComponent().getPatchesRepository().install(rawCoordinates);
+            } catch (IllegalArgumentException ex) {
+                MavenCoordinates coordinates = MavenCoordinates.parseMavenCoordinates(getEndpoint().getDefaultCoordinates());
+                map.put("classLoader", classLoader);
+                map.put("group", coordinates.getGroupId());
+                map.put("module", coordinates.getArtifactId());
+                map.put("version", coordinates.getVersion());
+                map.put("classifier", coordinates.getClassifier());
+                Grape.grab(map);
+                getEndpoint().getComponent().getPatchesRepository().install(getEndpoint().getDefaultCoordinates());
+            }
+            break;
 
-            case listPatches:
-                List<String> patches = getEndpoint().getComponent().getPatchesRepository().listPatches();
-                exchange.getIn().setBody(patches);
-                break;
+        case listPatches:
+            List<String> patches = getEndpoint().getComponent().getPatchesRepository().listPatches();
+            exchange.getIn().setBody(patches);
+            break;
 
-            case clearPatches:
-                getEndpoint().getComponent().getPatchesRepository().clear();
-                break;
+        case clearPatches:
+            getEndpoint().getComponent().getPatchesRepository().clear();
+            break;
         }
     }
 
     @Override
     public GrapeEndpoint getEndpoint() {
-        return (GrapeEndpoint) super.getEndpoint();
+        return (GrapeEndpoint)super.getEndpoint();
     }
 
 }
diff --git a/components/camel-grape/src/main/java/org/apache/camel/component/grape/MavenCoordinates.java b/components/camel-grape/src/main/java/org/apache/camel/component/grape/MavenCoordinates.java
index 3f2fe9c..a4b615e 100644
--- a/components/camel-grape/src/main/java/org/apache/camel/component/grape/MavenCoordinates.java
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/MavenCoordinates.java
@@ -26,6 +26,14 @@ public class MavenCoordinates {
 
     private final String classifier;
 
+    MavenCoordinates(String groupId, String artifactId, String version, String classifier) {
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.version = version;
+        this.classifier = classifier;
+    }
+    
+
     public static MavenCoordinates parseMavenCoordinates(String coordinates) {
         String[] coordinatesParts = coordinates.split("/");
         String clazzifier = "";
@@ -37,18 +45,7 @@ public class MavenCoordinates {
             clazzifier = coordinatesParts[3];
         }
 
-        return new MavenCoordinates(
-                coordinatesParts[0],
-                coordinatesParts[1],
-                coordinatesParts[2],
-                clazzifier);
-    }
-
-    MavenCoordinates(String groupId, String artifactId, String version, String classifier) {
-        this.groupId = groupId;
-        this.artifactId = artifactId;
-        this.version = version;
-        this.classifier = classifier;
+        return new MavenCoordinates(coordinatesParts[0], coordinatesParts[1], coordinatesParts[2], clazzifier);
     }
 
     public String getGroupId() {
diff --git a/components/camel-grape/src/main/java/org/apache/camel/component/grape/PatchesRepository.java b/components/camel-grape/src/main/java/org/apache/camel/component/grape/PatchesRepository.java
index 09e4f53..70cfdfc 100644
--- a/components/camel-grape/src/main/java/org/apache/camel/component/grape/PatchesRepository.java
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/PatchesRepository.java
@@ -26,4 +26,4 @@ public interface PatchesRepository {
 
     void clear();
 
-}
\ No newline at end of file
+}