camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/4] camel git commit: CAMEL-10828: camel-catalog-nexus - Initial work
Date Tue, 14 Feb 2017 18:20:20 GMT
CAMEL-10828: camel-catalog-nexus - Initial work


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

Branch: refs/heads/master
Commit: 39926008f25b3ada3fd375410dbc38ceeb21d323
Parents: fbbe4b4
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Feb 14 19:11:51 2017 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Feb 14 19:19:46 2017 +0100

----------------------------------------------------------------------
 .../catalog/nexus/BaseNexusRepository.java      | 10 +++++++++
 .../catalog/nexus/ComponentNexusRepository.java | 22 ++++++++++++++++----
 .../catalog/nexus/LocalFileNexusRepository.java |  5 +++++
 .../catalog/nexus/LocalNexusRepositoryTest.java |  5 ++++-
 4 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/39926008/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/BaseNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/BaseNexusRepository.java
b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/BaseNexusRepository.java
index 25b7b07..02cd8c7 100644
--- a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/BaseNexusRepository.java
+++ b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/BaseNexusRepository.java
@@ -176,6 +176,16 @@ public abstract class BaseNexusRepository {
     }
 
     /**
+     * Creates the url to download the artifact.
+     *
+     * @param dto  the artifact
+     * @return the url to download
+     */
+    protected String createArtifactURL(NexusArtifactDto dto) {
+        return dto.getArtifactLink();
+    }
+
+    /**
      * Runs the task to index nexus for new artifacts
      */
     protected void indexNexus() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/39926008/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
index 5887d12..d1663ca 100644
--- a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
+++ b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
@@ -23,6 +23,8 @@ import java.net.URLClassLoader;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.camel.catalog.CamelCatalog;
+
 import static org.apache.camel.catalog.CatalogHelper.loadText;
 
 /**
@@ -39,8 +41,8 @@ public class ComponentNexusRepository extends BaseNexusRepository {
         // now download the new artifact JARs and look inside to find more details
         for (NexusArtifactDto dto : newArtifacts) {
             try {
-                // download using url classloader reader
-                URL jarUrl = new URL(dto.getArtifactLink());
+                String url = createArtifactURL(dto);
+                URL jarUrl = new URL(url);
                 addCustomCamelComponentsFromArtifact(dto, jarUrl);
             } catch (Exception e) {
                 log.warn("Error downloading component JAR " + dto.getArtifactLink() + ".
This exception is ignored. " + e.getMessage());
@@ -48,6 +50,19 @@ public class ComponentNexusRepository extends BaseNexusRepository {
         }
     }
 
+    /**
+     * Adds the component to the {@link CamelCatalog}
+     *
+     * @param dto           the artifact
+     * @param camelCatalog  the Camel Catalog
+     * @param scheme        component name
+     * @param javaType      component java class
+     * @param json          component json schema
+     */
+    protected void addComponent(NexusArtifactDto dto, CamelCatalog camelCatalog, String scheme,
String javaType, String json) {
+        log.info("Added component: {}:{}:{} to Camel Catalog", dto.getGroupId(), dto.getArtifactId(),
dto.getVersion());
+        camelCatalog.addComponent(scheme, javaType, json);
+    }
 
     /**
      * Adds any discovered third party Camel components from the artifact.
@@ -67,8 +82,7 @@ public class ComponentNexusRepository extends BaseNexusRepository {
                             if (javaType != null) {
                                 String json = loadComponentJSonSchema(classLoader, scheme);
                                 if (json != null) {
-                                    log.info("Added component: {}:{}:{} to Camel Catalog",
dto.getGroupId(), dto.getArtifactId(), dto.getVersion());
-                                    getCamelCatalog().addComponent(scheme, javaType, json);
+                                    addComponent(dto, getCamelCatalog(), scheme, javaType,
json);
                                 }
                             }
                         }

http://git-wip-us.apache.org/repos/asf/camel/blob/39926008/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
index dd10306..1d341d3 100644
--- a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
+++ b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
@@ -28,4 +28,9 @@ public class LocalFileNexusRepository extends ComponentNexusRepository {
         return new URL("file:" + file.getAbsolutePath());
     }
 
+    @Override
+    protected String createArtifactURL(NexusArtifactDto dto) {
+        // load from file instead
+        return "file:target/" + dto.getArtifactId() + "-" + dto.getVersion() + ".jar";
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/39926008/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
index 7f7d7c5..9f9d7ec 100644
--- a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
+++ b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.catalog.nexus;
 import junit.framework.TestCase;
 import org.apache.camel.catalog.CamelCatalog;
 import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class LocalNexusRepositoryTest extends TestCase {
@@ -36,12 +37,14 @@ public class LocalNexusRepositoryTest extends TestCase {
     }
 
     @Test
+    @Ignore("Work in progress")
     public void testLocalNexus() throws Exception {
         int before = catalog.findComponentNames().size();
 
         repo.start();
 
-        // TODO: wait 5 sec
+        // TODO: create custom component we can use for testing here
+        // and only wait as long until a new component is added
         Thread.sleep(5000);
 
         repo.stop();


Mime
View raw message