You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/01/31 08:04:35 UTC
camel git commit: Add camel-atmos to kit. Polish the component so it
has out of the box documentation. Add name option so the endpoint can have a
logical name so the endpoints can be more natural.
Repository: camel
Updated Branches:
refs/heads/master 55de48785 -> 484789537
Add camel-atmos to kit. Polish the component so it has out of the box documentation. Add name option so the endpoint can have a logical name so the endpoints can be more natural.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/48478953
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/48478953
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/48478953
Branch: refs/heads/master
Commit: 484789537bb9b692d69a877a72c49a2cc0c00fbb
Parents: 55de487
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Jan 31 08:04:30 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Jan 31 08:04:30 2015 +0100
----------------------------------------------------------------------
apache-camel/pom.xml | 4 +-
.../src/main/descriptors/common-bin.xml | 2 +-
components/camel-atmos/pom.xml | 162 +++++++++----------
.../camel/component/atmos/AtmosComponent.java | 40 +++--
.../component/atmos/AtmosConfiguration.java | 32 +++-
.../camel/component/atmos/AtmosEndpoint.java | 19 ++-
.../atmos/util/AtmosPropertyManager.java | 3 +
.../component/atmos/AtmosConsumerTest.java | 5 +-
parent/pom.xml | 6 +
9 files changed, 151 insertions(+), 122 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/48478953/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index de74f8b..0007eef 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -69,11 +69,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-atmosphere-websocket</artifactId>
+ <artifactId>camel-atmos</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-atoms</artifactId>
+ <artifactId>camel-atmosphere-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
http://git-wip-us.apache.org/repos/asf/camel/blob/48478953/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index b9f0596..c2dda52 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -28,8 +28,8 @@
<include>org.apache.camel:camel-ahc-ws</include>
<include>org.apache.camel:camel-amqp</include>
<include>org.apache.camel:camel-apns</include>
+ <include>org.apache.camel:camel-atmos</include>
<include>org.apache.camel:camel-atmosphere-websocket</include>
- <include>org.apache.camel:camel-atoms</include>
<include>org.apache.camel:camel-atom</include>
<include>org.apache.camel:camel-aws</include>
<include>org.apache.camel:camel-avro</include>
http://git-wip-us.apache.org/repos/asf/camel/blob/48478953/components/camel-atmos/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-atmos/pom.xml b/components/camel-atmos/pom.xml
index c18de89..af1fcd0 100644
--- a/components/camel-atmos/pom.xml
+++ b/components/camel-atmos/pom.xml
@@ -15,102 +15,92 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>components</artifactId>
- <version>2.15-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.15-SNAPSHOT</version>
+ </parent>
- <artifactId>camel-atmos</artifactId>
- <packaging>bundle</packaging>
- <name>Camel :: Atmos</name>
- <description>Camel Atmos support</description>
+ <artifactId>camel-atmos</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Atmos</name>
+ <description>Camel Atmos support</description>
- <properties>
- <camel.osgi.export.pkg>org.apache.camel.component.atmos.*</camel.osgi.export.pkg>
- <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=atmos</camel.osgi.export.service>
- </properties>
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.atmos.*</camel.osgi.export.pkg>
+ <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=atmos</camel.osgi.export.service>
+ </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
- <!-- atmos -->
- <dependency>
- <groupId>com.emc.vipr</groupId>
- <artifactId>atmos-client</artifactId>
- <version>2.2.2</version>
- </dependency>
+ <!-- atmos -->
+ <dependency>
+ <groupId>com.emc.vipr</groupId>
+ <artifactId>atmos-client</artifactId>
+ <version>${atmos-client-version}</version>
+ </dependency>
- <!-- apache commons-io -->
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>${commons-io-version}</version>
- </dependency>
+ <!-- apache commons-io -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>${commons-io-version}</version>
+ </dependency>
- <!-- testing -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <build>
+ <profiles>
+ <profile>
+ <id>no-integration-test</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
<plugins>
- <!-- Allows the routes to be run via 'mvn camel:run' -->
- <plugin>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-maven-plugin</artifactId>
- <version>${project.version}</version>
- </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>
+ **/integration/**
+ </exclude>
+ </excludes>
+ </configuration>
+ </plugin>
</plugins>
- </build>
-
- <profiles>
- <profile>
- <id>no-integration-test</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>
- **/integration/**
- </exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ </build>
+ </profile>
+ </profiles>
</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/48478953/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
index 0008ce6..19e8233 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
@@ -22,43 +22,43 @@ import org.apache.camel.Endpoint;
import org.apache.camel.component.atmos.util.AtmosOperation;
import org.apache.camel.component.atmos.util.AtmosPropertyManager;
import org.apache.camel.component.atmos.validator.AtmosConfigurationValidator;
-import org.apache.camel.impl.DefaultComponent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.camel.impl.UriEndpointComponent;
-public class AtmosComponent extends DefaultComponent {
+public class AtmosComponent extends UriEndpointComponent {
- private static final transient Logger LOG = LoggerFactory.getLogger(AtmosComponent.class);
+ public AtmosComponent() {
+ super(AtmosEndpoint.class);
+ }
- /**
- * Create a camel endpoint after passing validation on the incoming url.
- *
- * @param uri the full URI of the endpoint
- * @param remaining the remaining part of the URI without the query
- * parameters or component prefix
- * @param parameters the optional parameters passed in
- * @return the camel endpoint
- * @throws Exception
- */
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
AtmosConfiguration configuration = new AtmosConfiguration();
+ String name = null;
+ String operation = remaining;
+
+ String[] parts = remaining.split("/");
+ if (parts.length > 1) {
+ name = parts[0];
+ operation = parts[1];
+ }
+ configuration.setName(name);
+ configuration.setOperation(AtmosOperation.valueOf(operation));
+
// set options from component
- configuration.setUri((String) parameters.get("uri") == null
+ configuration.setUri(parameters.get("uri") == null
? AtmosPropertyManager.getInstance().getProperty("uri")
: (String) parameters.get("uri"));
- configuration.setSecretKey((String) parameters.get("secretKey") == null
+ configuration.setSecretKey(parameters.get("secretKey") == null
? AtmosPropertyManager.getInstance().getProperty("secretKey")
: (String) parameters.get("secretKey"));
configuration.setLocalPath((String) parameters.get("localPath"));
configuration.setRemotePath((String) parameters.get("remotePath"));
configuration.setNewRemotePath((String) parameters.get("newRemotePath"));
configuration.setQuery((String) parameters.get("query"));
- configuration.setOperation(AtmosOperation.valueOf(remaining));
configuration.setFullTokenId(parameters.get("fullTokenId") == null
? AtmosPropertyManager.getInstance().getProperty("fullTokenId")
: (String) parameters.get("fullTokenId"));
- configuration.setEnableSslValidation(Boolean.parseBoolean((String) AtmosPropertyManager.getInstance().getProperty("sslValidation")));
+ configuration.setEnableSslValidation(Boolean.parseBoolean(AtmosPropertyManager.getInstance().getProperty("sslValidation")));
//pass validation test
AtmosConfigurationValidator.validate(configuration);
@@ -66,8 +66,6 @@ public class AtmosComponent extends DefaultComponent {
// and then override from parameters
setProperties(configuration, parameters);
- LOG.info("atmos configuration set!");
-
Endpoint endpoint = new AtmosEndpoint(uri, this, configuration);
return endpoint;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/48478953/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
index 71b41ac..bbcc477 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
@@ -22,34 +22,44 @@ import java.net.URISyntaxException;
import com.emc.atmos.api.AtmosApi;
import com.emc.atmos.api.AtmosConfig;
import com.emc.atmos.api.jersey.AtmosApiClient;
-
import org.apache.camel.component.atmos.util.AtmosException;
import org.apache.camel.component.atmos.util.AtmosOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.spi.UriPath;
+@UriParams
public class AtmosConfiguration {
-
- private static final transient Logger LOG = LoggerFactory.getLogger(AtmosConfiguration.class);
+ @UriPath
+ private String name;
+ @UriPath
+ private AtmosOperation operation;
//atmos shared secret
+ @UriParam
private String secretKey;
//local path to put files
+ @UriParam
private String localPath;
//where to put files on atmos
+ @UriParam
private String remotePath;
//new path on atmos when moving files
+ @UriParam
private String newRemotePath;
//search query on atmos
+ @UriParam
private String query;
//atmos client fullTokenId
+ @UriParam
private String fullTokenId;
//atmos server uri
+ @UriParam
private String uri;
//atmos ssl validation
+ @UriParam
private boolean enableSslValidation;
//specific atmos operation for the component
- private AtmosOperation operation;
//reference to atmo client
private AtmosApi client;
@@ -81,7 +91,15 @@ public class AtmosConfiguration {
this.client = atmosclient;
}
-
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
public String getSecretKey() {
return secretKey;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/48478953/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
index 29841db..2f00199 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
@@ -28,15 +28,19 @@ import org.apache.camel.component.atmos.integration.producer.AtmosPutProducer;
import org.apache.camel.component.atmos.util.AtmosException;
import org.apache.camel.component.atmos.util.AtmosOperation;
import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.camel.component.atmos.util.AtmosConstants.POLL_CONSUMER_DELAY;
+@UriEndpoint(scheme = "atmos", consumerClass = AtmosScheduledPollConsumer.class, label = "file,cloud")
public class AtmosEndpoint extends DefaultEndpoint {
private static final transient Logger LOG = LoggerFactory.getLogger(AtmosEndpoint.class);
+ @UriParam
private AtmosConfiguration configuration;
public AtmosEndpoint() {
@@ -51,6 +55,14 @@ public class AtmosEndpoint extends DefaultEndpoint {
super(endpointUri);
}
+ public AtmosConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(AtmosConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
/**
* Create one of the camel producer available based on the configuration
*
@@ -58,8 +70,8 @@ public class AtmosEndpoint extends DefaultEndpoint {
* @throws Exception
*/
public Producer createProducer() throws Exception {
- LOG.info("resolve producer atmos endpoint {" + configuration.getOperation().toString() + "}");
- LOG.info("resolve producer atmos attached client: " + configuration.getClient());
+ LOG.debug("resolve producer atmos endpoint {" + configuration.getOperation().toString() + "}");
+ LOG.debug("resolve producer atmos attached client: " + configuration.getClient());
if (configuration.getOperation() == AtmosOperation.put) {
return new AtmosPutProducer(this, configuration);
} else if (this.configuration.getOperation() == AtmosOperation.del) {
@@ -83,7 +95,8 @@ public class AtmosEndpoint extends DefaultEndpoint {
public Consumer createConsumer(Processor processor) throws Exception {
LOG.debug("resolve consumer atmos endpoint {" + configuration.getOperation().toString() + "}");
LOG.debug("resolve consumer atmos attached client:" + configuration.getClient());
- AtmosScheduledPollConsumer consumer = null;
+
+ AtmosScheduledPollConsumer consumer;
if (this.configuration.getOperation() == AtmosOperation.get) {
consumer = new AtmosScheduledPollGetConsumer(this, processor, configuration);
consumer.setDelay(POLL_CONSUMER_DELAY);
http://git-wip-us.apache.org/repos/asf/camel/blob/48478953/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
index 0b76edb..b510064 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
@@ -23,6 +23,9 @@ import java.util.Properties;
public final class AtmosPropertyManager {
+ // TODO: this is wrong, this should be configured on the component instead
+ // and no static code please!
+
private static Properties properties;
private static AtmosPropertyManager instance;
http://git-wip-us.apache.org/repos/asf/camel/blob/48478953/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/AtmosConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/AtmosConsumerTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/AtmosConsumerTest.java
index 85dbb0f..b4c339d 100644
--- a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/AtmosConsumerTest.java
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/AtmosConsumerTest.java
@@ -33,7 +33,7 @@ public class AtmosConsumerTest extends CamelTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("atmos://" + get + "?remotePath=/path").to("mock:test");
+ from("atmos:foo/" + get + "?remotePath=/path").to("mock:test");
}
};
}
@@ -41,13 +41,14 @@ public class AtmosConsumerTest extends CamelTestSupport {
@Test
public void shouldCreateGetConsumer() throws Exception {
// Given
- Endpoint atmosEndpoint = context.getEndpoint("atmos://" + get + "?remotePath=/path");
+ AtmosEndpoint atmosEndpoint = context.getEndpoint("atmos:foo/" + get + "?remotePath=/path", AtmosEndpoint.class);
// When
Consumer consumer = atmosEndpoint.createConsumer(null);
// Then
Assert.assertTrue(consumer instanceof AtmosScheduledPollGetConsumer);
+ assertEquals("foo", atmosEndpoint.getConfiguration().getName());
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/48478953/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 64246bb..379186c 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -54,6 +54,7 @@
<asm-bundle-version>3.3.1_1</asm-bundle-version>
<asm-version>3.3.1</asm-version>
<aspectj-version>1.6.2</aspectj-version>
+ <atmos-client-version>2.2.2</atmos-client-version>
<atmosphere-version>2.2.4</atmosphere-version>
<atmosphere-version-range>[2.0,3.0)</atmosphere-version-range>
<atomikos-transactions-version>3.9.3</atomikos-transactions-version>
@@ -580,6 +581,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-atmos</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-apns</artifactId>
<version>${project.version}</version>
</dependency>