You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2019/01/11 22:09:15 UTC

[camel] 10/13: Switch camel-grape to java to leverage build tools

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

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

commit bef5ea7486de669a373f99f31c6987b89ea24634
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Jan 11 18:31:09 2019 +0100

    Switch camel-grape to java to leverage build tools
---
 components/camel-grape/pom.xml                     | 60 --------------
 .../camel-grape/src/main/docs/grape-component.adoc |  2 +-
 .../component/grape/FilePatchesRepository.groovy   | 60 --------------
 .../camel/component/grape/GrapeEndpoint.groovy     | 79 ------------------
 .../camel/component/grape/GrapeProducer.groovy     | 68 ----------------
 .../camel/component/grape/MavenCoordinates.groovy  | 59 --------------
 .../component/grape/FilePatchesRepository.java     | 82 +++++++++++++++++++
 .../camel/component/grape/GrapeCommand.java}       |  4 +-
 .../camel/component/grape/GrapeComponent.java}     | 39 +++++----
 .../camel/component/grape/GrapeConstants.java}     |  6 +-
 .../camel/component/grape/GrapeEndpoint.java       | 95 ++++++++++++++++++++++
 .../camel/component/grape/GrapeProducer.java       | 77 ++++++++++++++++++
 .../camel/component/grape/MavenCoordinates.java    | 70 ++++++++++++++++
 .../camel/component/grape/PatchesRepository.java}  |  6 +-
 .../org/apache/camel/component/grape/grape.json    | 29 -------
 15 files changed, 355 insertions(+), 381 deletions(-)

diff --git a/components/camel-grape/pom.xml b/components/camel-grape/pom.xml
index 7abc37a..8b6b2db 100644
--- a/components/camel-grape/pom.xml
+++ b/components/camel-grape/pom.xml
@@ -32,9 +32,6 @@
   <description>The grape component allows you to fetch, load and manage additional jars when CamelContext is running</description>
 
   <properties>
-    <groovy-eclipse-batch.version>2.4.3-01</groovy-eclipse-batch.version>
-    <groovy-eclipse-compiler.version>2.9.2-01</groovy-eclipse-compiler.version>
-    <plexus-compiler-api.version>2.8.3</plexus-compiler-api.version>
     <camel.osgi.export.pkg />
   </properties>
 
@@ -91,63 +88,6 @@
     </dependency>
   </dependencies>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <dependencies>
-          <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-eclipse-batch</artifactId>
-            <version>${groovy-eclipse-batch.version}</version>
-          </dependency>
-          <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-eclipse-compiler</artifactId>
-            <version>${groovy-eclipse-compiler.version}</version>
-          </dependency>
-          <dependency>
-            <groupId>org.codehaus.plexus</groupId>
-            <artifactId>plexus-compiler-api</artifactId>
-            <version>${plexus-compiler-api.version}</version>
-          </dependency>
-        </dependencies>
-        <configuration>
-          <compilerId>groovy-eclipse-compiler</compilerId>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.codehaus.groovy</groupId>
-        <artifactId>groovy-eclipse-compiler</artifactId>
-        <version>${groovy-eclipse-compiler.version}</version>
-        <extensions>true</extensions>
-      </plugin>
-      <plugin>
-        <groupId>com.google.code.maven-replacer-plugin</groupId>
-        <artifactId>replacer</artifactId>
-        <version>1.5.3</version>
-        <executions>
-          <execution>
-            <phase>prepare-package</phase>
-            <goals>
-              <goal>replace</goal>
-            </goals>
-          </execution>
-        </executions>
-        <configuration>
-          <file>${basedir}/target/classes/org/apache/camel/component/grape/grape.json</file>
-          <replacements>
-            <replacement>
-              <token>ARTIFACT_VERSION</token>
-              <value>${project.version}</value>
-            </replacement>
-          </replacements>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
   <profiles>
     <profile>
       <id>jdk9+-build</id>
diff --git a/components/camel-grape/src/main/docs/grape-component.adoc b/components/camel-grape/src/main/docs/grape-component.adoc
index b241aba..54610d7 100644
--- a/components/camel-grape/src/main/docs/grape-component.adoc
+++ b/components/camel-grape/src/main/docs/grape-component.adoc
@@ -51,7 +51,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *synchronous* (producer) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean
+| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
 |===
 // endpoint options: END
 
diff --git a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/FilePatchesRepository.groovy b/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/FilePatchesRepository.groovy
deleted file mode 100644
index 66d25b0..0000000
--- a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/FilePatchesRepository.groovy
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.grape
-
-import org.apache.commons.lang3.SystemUtils
-
-import java.nio.file.Paths
-
-import static org.apache.commons.io.FileUtils.writeStringToFile
-import static org.apache.commons.io.IOUtils.readLines
-
-class FilePatchesRepository implements PatchesRepository {
-
-    private final File repository
-
-    FilePatchesRepository() {
-        this(Paths.get(SystemUtils.userHome.absolutePath, ".camel", "patches").toFile())
-    }
-
-    FilePatchesRepository(File repository) {
-        if(!repository.exists()) {
-            if(repository.getParentFile() != null) {
-                repository.getParentFile().mkdirs()
-            }
-            repository.createNewFile()
-        }
-        this.repository = repository
-    }
-
-    @Override
-    void install(String coordinates) {
-        writeStringToFile(repository, coordinates + "\n", true);
-    }
-
-    @Override
-    List<String> listPatches() {
-        readLines(new FileReader(repository))
-    }
-
-    @Override
-    void clear() {
-        repository.delete()
-        repository.createNewFile()
-    }
-
-}
diff --git a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeEndpoint.groovy b/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeEndpoint.groovy
deleted file mode 100644
index a82da51..0000000
--- a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeEndpoint.groovy
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.grape
-
-import org.apache.camel.CamelContext
-import org.apache.camel.Consumer
-import org.apache.camel.Processor
-import org.apache.camel.Producer
-import org.apache.camel.support.DefaultEndpoint
-import org.apache.camel.spi.Metadata
-import org.apache.camel.spi.UriEndpoint
-import org.apache.camel.spi.UriPath
-
-import static groovy.grape.Grape.grab
-import static org.apache.camel.component.grape.MavenCoordinates.parseMavenCoordinates
-
-/**
- * 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")
-class GrapeEndpoint extends DefaultEndpoint {
-
-    @UriPath(description = "Maven coordinates to use as default to grab if the message body is empty") @Metadata(required = true)
-    private final String defaultCoordinates
-
-    GrapeEndpoint(String endpointUri, String defaultCoordinates, GrapeComponent component) {
-        super(endpointUri, component)
-        this.defaultCoordinates = defaultCoordinates
-    }
-
-    static def loadPatches(CamelContext camelContext) {
-        def classLoader = camelContext.applicationContextClassLoader
-        def patchesRepository = camelContext.getComponent('grape', GrapeComponent.class).patchesRepository
-        patchesRepository.listPatches().each {
-            def coordinates = parseMavenCoordinates(it)
-            grab(classLoader: classLoader,
-                 group: coordinates.groupId, module: coordinates.artifactId, version: coordinates.version, classifier: coordinates.classifier)
-        }
-    }
-
-    @Override
-    Producer createProducer() {
-        new GrapeProducer(this)
-    }
-
-    @Override
-    Consumer createConsumer(Processor processor) {
-        throw new UnsupportedOperationException('Grape component supports only the producer side of the route.')
-    }
-
-    @Override
-    boolean isSingleton() {
-        true
-    }
-
-    String getDefaultCoordinates() {
-        defaultCoordinates
-    }
-
-    @Override
-    GrapeComponent getComponent() {
-        super.getComponent() as GrapeComponent
-    }
-
-}
\ No newline at end of file
diff --git a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeProducer.groovy b/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeProducer.groovy
deleted file mode 100644
index da4838c..0000000
--- a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeProducer.groovy
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.grape
-
-import groovy.grape.Grape
-import org.apache.camel.Exchange
-import org.apache.camel.support.DefaultProducer
-
-import static GrapeCommand.clearPatches
-import static GrapeCommand.grab
-import static GrapeCommand.listPatches
-import static GrapeConstants.GRAPE_COMMAND
-
-class GrapeProducer extends DefaultProducer {
-
-    GrapeProducer(GrapeEndpoint endpoint) {
-        super(endpoint)
-    }
-
-    @Override
-    void process(Exchange exchange) {
-        def command = exchange.in.getHeader(GRAPE_COMMAND, grab, GrapeCommand.class)
-        switch(command) {
-            case grab:
-                def classLoader = exchange.context.applicationContextClassLoader
-                def rawCoordinates = exchange.in.getBody(String.class)
-                try {
-                    def coordinates = MavenCoordinates.parseMavenCoordinates(rawCoordinates)
-                    Grape.grab(classLoader: classLoader, group: coordinates.groupId, module: coordinates.artifactId, version: coordinates.version, classifier: coordinates.classifier)
-                    endpoint.component.patchesRepository.install(rawCoordinates)
-                } catch (IllegalArgumentException ex) {
-                    def coordinates = MavenCoordinates.parseMavenCoordinates(getEndpoint().defaultCoordinates)
-                    Grape.grab(classLoader: classLoader, group: coordinates.groupId, module: coordinates.artifactId, version: coordinates.version, classifier: coordinates.classifier)
-                    endpoint.component.patchesRepository.install(getEndpoint().defaultCoordinates)
-                }
-                break
-
-            case listPatches:
-                def patches = endpoint.component.patchesRepository.listPatches()
-                exchange.getIn().setBody(patches)
-                break
-
-            case clearPatches:
-                endpoint.component.patchesRepository.clear()
-                break
-        }
-    }
-
-    @Override
-    GrapeEndpoint getEndpoint() {
-        super.getEndpoint() as GrapeEndpoint
-    }
-
-}
diff --git a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/MavenCoordinates.groovy b/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/MavenCoordinates.groovy
deleted file mode 100644
index cfeb2a0..0000000
--- a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/MavenCoordinates.groovy
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.grape
-
-import groovy.transform.ImmutableBase
-
-@ImmutableBase
-class MavenCoordinates {
-
-    private String groupId
-
-    private String artifactId
-
-    private String version
-
-    private String classifier
-
-    static MavenCoordinates parseMavenCoordinates(String coordinates) {
-        def coordinatesParts = coordinates.split('/')
-        def clazzifier = ''
-        if (coordinatesParts.length < 3 || coordinatesParts.length > 4) {
-            throw new IllegalArgumentException("Invalid coordinates: ${coordinates}")
-        }
-        if (coordinatesParts.length == 4) {
-            clazzifier = coordinatesParts[3]
-        }
-        new MavenCoordinates(groupId: coordinatesParts[0], artifactId: coordinatesParts[1], version: coordinatesParts[2], classifier: clazzifier)
-    }
-
-    String getGroupId() {
-        return groupId
-    }
-
-    String getArtifactId() {
-        return artifactId
-    }
-
-    String getVersion() {
-        return version
-    }
-
-    String getClassifier() {
-        return classifier
-    }
-}
diff --git a/components/camel-grape/src/main/java/org/apache/camel/component/grape/FilePatchesRepository.java b/components/camel-grape/src/main/java/org/apache/camel/component/grape/FilePatchesRepository.java
new file mode 100644
index 0000000..81ae1a2
--- /dev/null
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/FilePatchesRepository.java
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.grape;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOError;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+public class FilePatchesRepository implements PatchesRepository {
+
+    private final File repository;
+
+    public FilePatchesRepository() {
+        this(Paths.get(SystemUtils.getUserHome().getAbsolutePath(), ".camel", "patches").toFile());
+    }
+
+    public FilePatchesRepository(File repository) {
+        try {
+            if (!repository.exists()) {
+                if (repository.getParentFile() != null) {
+                    repository.getParentFile().mkdirs();
+                }
+
+                repository.createNewFile();
+            }
+        } catch (IOException e) {
+            throw new IOError(e);
+        }
+
+        this.repository = repository;
+    }
+
+    @Override
+    public void install(String coordinates) {
+        try {
+            FileUtils.writeStringToFile(repository, coordinates + "\n", true);
+        } catch (IOException e) {
+            throw new IOError(e);
+        }
+    }
+
+    @Override
+    public List<String> listPatches() {
+        try {
+            return IOUtils.readLines(new FileReader(repository));
+        } catch (IOException e) {
+            throw new IOError(e);
+        }
+    }
+
+    @Override
+    public void clear() {
+        try {
+            repository.delete();
+            repository.createNewFile();
+        } catch (IOException e) {
+            throw new IOError(e);
+        }
+    }
+
+}
diff --git a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeCommand.groovy b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeCommand.java
similarity index 92%
rename from components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeCommand.groovy
rename to components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeCommand.java
index 901b992..a8d5940 100644
--- a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeCommand.groovy
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeCommand.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.grape
+package org.apache.camel.component.grape;
 
-enum GrapeCommand {
+public enum GrapeCommand {
 
     grab,
     listPatches,
diff --git a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeComponent.groovy b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeComponent.java
similarity index 54%
rename from components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeComponent.groovy
rename to components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeComponent.java
index b49482a..7fbcf04 100644
--- a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeComponent.groovy
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeComponent.java
@@ -14,38 +14,41 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.grape
+package org.apache.camel.component.grape;
 
-import org.apache.camel.CamelContext
-import org.apache.camel.support.DefaultComponent
-import org.apache.camel.spi.Metadata
+import java.util.Map;
 
-class GrapeComponent extends DefaultComponent {
+import groovy.lang.GroovyClassLoader;
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.support.DefaultComponent;
 
-	@Metadata(label = "advanced", description = "Implementation of org.apache.camel.component.grape.PatchesRepository, by default: FilePatchesRepository")
-    private PatchesRepository patchesRepository = new FilePatchesRepository()
+public class GrapeComponent extends DefaultComponent {
 
-    GrapeComponent() {
+    @Metadata(label = "advanced", description = "Implementation of org.apache.camel.component.grape.PatchesRepository, by default: FilePatchesRepository")
+    private PatchesRepository patchesRepository = new FilePatchesRepository();
+
+    public GrapeComponent() {
     }
 
     @Override
-    protected GrapeEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) {
-        GrapeEndpoint grapeEndpoint = new GrapeEndpoint(uri, remaining, this)
+    protected GrapeEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        GrapeEndpoint grapeEndpoint = new GrapeEndpoint(uri, remaining, this);
         setProperties(grapeEndpoint, parameters);
-        grapeEndpoint
+        return grapeEndpoint;
     }
 
-    PatchesRepository getPatchesRepository() {
-        return patchesRepository
+    public PatchesRepository getPatchesRepository() {
+        return patchesRepository;
     }
 
-    void setPatchesRepository(PatchesRepository patchesRepository) {
-        this.patchesRepository = patchesRepository
+    public void setPatchesRepository(PatchesRepository patchesRepository) {
+        this.patchesRepository = patchesRepository;
     }
 
-    static CamelContext grapeCamelContext(CamelContext camelContext) {
-        camelContext.setApplicationContextClassLoader(new GroovyClassLoader(GrapeComponent.class.getClassLoader()))
-        camelContext
+    public static CamelContext grapeCamelContext(CamelContext camelContext) {
+        camelContext.setApplicationContextClassLoader(new GroovyClassLoader(GrapeComponent.class.getClassLoader()));
+        return camelContext;
     }
 
 }
diff --git a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeConstants.groovy b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeConstants.java
similarity index 85%
rename from components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeConstants.groovy
rename to components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeConstants.java
index c778674..72e2e47 100644
--- a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/GrapeConstants.groovy
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeConstants.java
@@ -14,10 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.grape
+package org.apache.camel.component.grape;
 
-class GrapeConstants {
+public class GrapeConstants {
 
-    static final String GRAPE_COMMAND = 'CamelGrapeCommand'
+    public static final String GRAPE_COMMAND = "CamelGrapeCommand";
 
 }
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
new file mode 100644
index 0000000..1344bfd
--- /dev/null
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeEndpoint.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.grape;
+
+import java.util.LinkedHashMap;
+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;
+import org.apache.camel.Producer;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriPath;
+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.
+ */
+@UriEndpoint(firstVersion = "2.16.0", scheme = "grape", syntax = "grape:defaultCoordinates", title = "Grape", producerOnly = true, label = "management,deployment")
+public class GrapeEndpoint extends DefaultEndpoint {
+
+    @UriPath(description = "Maven coordinates to use as default to grab if the message body is empty.")
+    @Metadata(required = true)
+    private final String defaultCoordinates;
+
+    public GrapeEndpoint(String endpointUri, String defaultCoordinates, GrapeComponent component) {
+        super(endpointUri, component);
+        this.defaultCoordinates = defaultCoordinates;
+    }
+
+    public static List<String> loadPatches(CamelContext camelContext) {
+        final ClassLoader classLoader = camelContext.getApplicationContextClassLoader();
+        PatchesRepository patchesRepository = camelContext.getComponent("grape", GrapeComponent.class).getPatchesRepository();
+        return DefaultGroovyMethods.each(patchesRepository.listPatches(), new Closure<Object>(null, null) {
+            public void doCall(String it) {
+                MavenCoordinates coordinates = MavenCoordinates.parseMavenCoordinates(it);
+                LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(5);
+                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);
+            }
+
+            public void doCall() {
+                doCall(null);
+            }
+
+        });
+    }
+
+    @Override
+    public Producer createProducer() {
+        return new GrapeProducer(this);
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) {
+        throw new UnsupportedOperationException("Grape component supports only the producer side of the route.");
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public String getDefaultCoordinates() {
+        return defaultCoordinates;
+    }
+
+    @Override
+    public GrapeComponent getComponent() {
+        return DefaultGroovyMethods.asType(super.getComponent(), GrapeComponent.class);
+    }
+
+}
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
new file mode 100644
index 0000000..6c80e98
--- /dev/null
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/GrapeProducer.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.grape;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import groovy.grape.Grape;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultProducer;
+
+public class GrapeProducer extends DefaultProducer {
+
+    public GrapeProducer(GrapeEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    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 listPatches:
+                List<String> patches = getEndpoint().getComponent().getPatchesRepository().listPatches();
+                exchange.getIn().setBody(patches);
+                break;
+
+            case clearPatches:
+                getEndpoint().getComponent().getPatchesRepository().clear();
+                break;
+        }
+    }
+
+    @Override
+    public GrapeEndpoint 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
new file mode 100644
index 0000000..3f2fe9c
--- /dev/null
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/MavenCoordinates.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.grape;
+
+public class MavenCoordinates {
+
+    private final String groupId;
+
+    private final String artifactId;
+
+    private final String version;
+
+    private final String classifier;
+
+    public static MavenCoordinates parseMavenCoordinates(String coordinates) {
+        String[] coordinatesParts = coordinates.split("/");
+        String clazzifier = "";
+        if (coordinatesParts.length < 3 || coordinatesParts.length > 4) {
+            throw new IllegalArgumentException("Invalid coordinates: " + coordinates);
+        }
+
+        if (coordinatesParts.length == 4) {
+            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;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public String getArtifactId() {
+        return artifactId;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public String getClassifier() {
+        return classifier;
+    }
+
+}
diff --git a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/PatchesRepository.groovy b/components/camel-grape/src/main/java/org/apache/camel/component/grape/PatchesRepository.java
similarity index 89%
rename from components/camel-grape/src/main/groovy/org/apache/camel/component/grape/PatchesRepository.groovy
rename to components/camel-grape/src/main/java/org/apache/camel/component/grape/PatchesRepository.java
index e5f9ce0..09e4f53 100644
--- a/components/camel-grape/src/main/groovy/org/apache/camel/component/grape/PatchesRepository.groovy
+++ b/components/camel-grape/src/main/java/org/apache/camel/component/grape/PatchesRepository.java
@@ -14,9 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.grape
+package org.apache.camel.component.grape;
 
-interface PatchesRepository {
+import java.util.List;
+
+public interface PatchesRepository {
 
     void install(String coordinates);
 
diff --git a/components/camel-grape/src/main/resources/org/apache/camel/component/grape/grape.json b/components/camel-grape/src/main/resources/org/apache/camel/component/grape/grape.json
deleted file mode 100644
index f8e36a2..0000000
--- a/components/camel-grape/src/main/resources/org/apache/camel/component/grape/grape.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
-  "component": {
-    "kind": "component",
-    "scheme": "grape",
-    "syntax": "grape:defaultCoordinates",
-    "title": "Grape",
-    "description": "Grape component allows you to fetch, load and manage additional jars when CamelContext is running.",
-    "firstVersion": "2.16.0",
-    "label": "management,deployment",
-    "deprecated": false,
-    "deprecationNote": "",
-    "async": false,
-    "consumerOnly": false,
-    "producerOnly": true,
-    "javaType": "org.apache.camel.component.grape.GrapeEndpoint",
-    "groupId": "org.apache.camel",
-    "artifactId": "camel-grape",
-    "version": "ARTIFACT_VERSION"
-  },
-  "componentProperties": {
-    "patchesRepository": { "kind": "property", "displayName": "Patches Repository", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.grape.PatchesRepository", "deprecated": false, "secret": false, "description": "Implementation of org.apache.camel.component.grape.PatchesRepository, by default: FilePatchesRepository" },
-    "resolvePropertyPlaceholders": { "kind": "property", "displayName": "Resolve Property Placeholders", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": true, "description": "Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders." }
-  },
-  "properties": {
-    "defaultCoordinates": { "kind": "path", "displayName": "Default Coordinates", "group": "producer", "required": "true", "type": "string", "javaType": "java.lang.String", "deprecated": "false", "description": "Maven coordinates to use as default to grab if the message body is empty." },
-    "synchronous": { "kind": "parameter", "displayName": "Synchronous", "group": "producer", "type": "boolean", "javaType": "boolean", "deprecated": "false", "defaultValue": "false", "description": "Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported)." }
-  }
-}
-