Skip to content

Commit

Permalink
[resolves wildfly-extras#1874] Add support for camel connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
tdiesler committed Sep 22, 2017
1 parent 95cd075 commit 3717147
Show file tree
Hide file tree
Showing 16 changed files with 269 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<module name="org.apache.camel.component.cassandra" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.castor" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.coap" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.connector" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.context" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.couchdb" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.crypto" export="true" services="export" optional="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<module xmlns="urn:jboss:module:1.1" name="org.apache.camel">

<dependencies>
<module name="org.apache.camel.catalog" export="true" />
<module name="org.apache.camel.core" export="true" services="export" />
<module name="org.apache.camel.spring" export="true" services="export">
<imports>
Expand Down
52 changes: 18 additions & 34 deletions feature/pack/etc/smartics/camel-modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
-->
<modules xmlns="http://smartics.de/ns/jboss-modules-descriptor/2">

<module name="org.apache.camel.catalog">
<include artifact="org.apache.camel:camel-catalog" />
<dependencies>
<module name="org.slf4j" />
</dependencies>
</module>

<module name="org.apache.camel.core">
<include artifact="org.apache.camel:camel-core" />
<apply-to-dependencies skip="true">
Expand Down Expand Up @@ -47,40 +54,6 @@
</dependencies>
</module>

<module name="org.apache.camel.spring">
<include artifact="org.apache.camel:camel-spring" />
<apply-to-dependencies skip="true">
</apply-to-dependencies>
<dependencies>
<module name="javax.api" />
<module name="javax.xml.bind.api" />
<module name="org.apache.camel.core" />
<module name="org.springframework.beans" export="true" />
<module name="org.springframework.context" />
<module name="org.springframework.core" />
<module name="org.springframework.jdbc" export="true" optional="true">
<imports>
<include path="META-INF" />
</imports>
<exports>
<include path="META-INF" />
<include path="org/springframework/jdbc/config" />
<exclude path="org/springframework/jdbc**" />
</exports>
</module>
<module name="org.springframework.tx" export="true">
<exports>
<exclude path="org/springframework/dao**" />
<exclude path="org/springframework/jca**" />
</exports>
</module>
<module name="org.slf4j" />
</dependencies>
<exports>
<exclude path="org/apache/camel/spring/remoting" />
</exports>
</module>

<module name="org.apache.camel.component.activemq">
<include artifact="org.apache.activemq:activemq-camel" />
<apply-to-dependencies skip="true">
Expand Down Expand Up @@ -378,6 +351,17 @@
</dependencies>
</module>

<module name="org.apache.camel.component.connector">
<include artifact="org.apache.camel:camel-connector" />
<apply-to-dependencies skip="true">
<include module="org.apache.camel.apt" />
<include module="org.springframework.boot" />
</apply-to-dependencies>
<dependencies>
<module name="org.slf4j" />
</dependencies>
</module>

<module name="org.apache.camel.component.context">
<include artifact="org.apache.camel:camel-context" />
<apply-to-dependencies skip="true">
Expand Down
34 changes: 34 additions & 0 deletions feature/pack/etc/smartics/spring-modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,40 @@
-->
<modules xmlns="http://smartics.de/ns/jboss-modules-descriptor/2">

<module name="org.apache.camel.spring">
<include artifact="org.apache.camel:camel-spring" />
<apply-to-dependencies skip="true">
</apply-to-dependencies>
<dependencies>
<module name="javax.api" />
<module name="javax.xml.bind.api" />
<module name="org.apache.camel.core" />
<module name="org.springframework.beans" export="true" />
<module name="org.springframework.context" />
<module name="org.springframework.core" />
<module name="org.springframework.jdbc" export="true" optional="true">
<imports>
<include path="META-INF" />
</imports>
<exports>
<include path="META-INF" />
<include path="org/springframework/jdbc/config" />
<exclude path="org/springframework/jdbc**" />
</exports>
</module>
<module name="org.springframework.tx" export="true">
<exports>
<exclude path="org/springframework/dao**" />
<exclude path="org/springframework/jca**" />
</exports>
</module>
<module name="org.slf4j" />
</dependencies>
<exports>
<exclude path="org/apache/camel/spring/remoting" />
</exports>
</module>

<module name="org.springframework.aop">
<properties>
<property name="jboss.api" value="private"/>
Expand Down
4 changes: 4 additions & 0 deletions feature/pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-coap</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-connector</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-context</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.apache.camel.catalog">
<resources>
<artifact name="${org.apache.camel:camel-catalog}" />
</resources>
<dependencies>
<module name="org.slf4j" />
<module name="javax.xml.bind.api" />
</dependencies>
</module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.apache.camel.component.connector">
<resources>
<artifact name="${org.apache.camel:camel-connector}" />
</resources>
<dependencies>
<module name="org.slf4j" />
<module name="javax.xml.bind.api" />
<module name="org.apache.camel.catalog" />
<module name="org.apache.camel.core" />
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<module name="org.apache.camel.component.cassandra" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.castor" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.coap" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.connector" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.context" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.couchdb" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.crypto" export="true" services="export" optional="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<module xmlns="urn:jboss:module:1.1" name="org.apache.camel">

<dependencies>
<module name="org.apache.camel.catalog" export="true" />
<module name="org.apache.camel.core" export="true" services="export" />
<module name="org.apache.camel.spring" export="true" services="export">
<imports>
Expand Down
6 changes: 6 additions & 0 deletions itests/standalone/basic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@
</dependencies>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* #%L
* Wildfly Camel :: Testsuite
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* Licensed 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.
* #L%
*/

package org.wildfly.camel.test.connector;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.camel.test.connector.foo.FooComponent;
import org.wildfly.extension.camel.CamelAware;

@CamelAware
@RunWith(Arquillian.class)
public class FooConnectorTest {

@Deployment
public static JavaArchive deployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-foo-tests");
archive.addClasses(FooComponent.class);
String fooPath = FooComponent.class.getPackage().getName().replace('.', '/');
archive.addAsManifestResource("connector/META-INF/services/foo", "services/" + fooPath);
archive.addAsResource("connector/camel-connector-schema.json", "camel-connector-schema.json");
archive.addAsResource("connector/camel-connector.json", "camel-connector.json");
return archive;
}

@Test
public void testFooConnector() throws Exception {

final CountDownLatch latch = new CountDownLatch(1);

CamelContext camelctx = new DefaultCamelContext();

FooComponent foo = new FooComponent();
camelctx.addComponent(foo.getComponentName(), foo);

camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("foo:timerName")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
latch.countDown();
}})
.to("mock:result");
}
});

camelctx.start();
try {
Assert.assertTrue("Countdown reached zero", latch.await(5, TimeUnit.MINUTES));
} finally {
camelctx.stop();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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.wildfly.camel.test.connector.foo;

import org.apache.camel.component.connector.DefaultConnectorComponent;

public class FooComponent extends DefaultConnectorComponent {

public FooComponent() {
super("foo", FooComponent.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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.
#

class=org.wildfly.camel.test.connector.foo.FooComponent
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"component": {
"kind": "component",
"baseScheme": "timer",
"scheme": "foo",
"syntax": "foo:timerName",
"title": "Foo",
"description": "Something cool",
"label": "foo,timer",
"deprecated": false,
"async": false,
"consumerOnly": true,
"lenientProperties": false,
"javaType": "org.wildfly.camel.test.connector.foo.FooComponent",
"groupId": "org.foo",
"artifactId": "foo-connector",
"version": "${project.version}"
},
"componentProperties": {
},
"properties": {
"timerName": { "kind": "path", "displayName": "Timer Name", "group": "consumer", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The name of the timer" },
"period": { "kind": "parameter", "displayName": "Period", "group": "consumer", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "secret": false, "defaultValue": 5000, "description": "If greater than 0 generate periodic events every period milliseconds. The default value is 1000. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour)." },
"repeatCount": { "kind": "parameter", "displayName": "Repeat Count", "group": "consumer", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "secret": false, "defaultValue": 0, "description": "Specifies a maximum limit of number of fires. So if you set it to 1 the timer will only fire once. If you set it to 5 it will only fire five times. A value of zero or negative means fire forever." }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"baseScheme": "timer",
"baseGroupId": "org.apache.camel",
"baseArtifactId": "camel-core",
"baseVersion": "${version.apache.camel}",
"baseJavaType": "org.apache.camel.component.timer.TimerComponent",
"name": "Foo",
"scheme": "foo",
"javaType": "org.wildfly.camel.test.connector.foo.FooComponent",
"groupId": "org.foo",
"artifactId": "foo-connector",
"version": "${project.version}",
"description": "Something cool",
"labels": [ "foo", "timer" ],
"pattern": "From",
"inputDataType": "none",
"outputDataType": "none",
"endpointOptions": [ "timerName", "period", "repeatCount" ],
"endpointValues": {
"fixedRate": true,
"period": 5000
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<version-maven-jar-plugin>2.6</version-maven-jar-plugin>
<version-maven-javadoc-plugin>2.9.1</version-maven-javadoc-plugin>
<version-maven-release-plugin>2.5</version-maven-release-plugin>
<version-maven-resources-plugin>2.7</version-maven-resources-plugin>
<version-maven-resources-plugin>3.0.2</version-maven-resources-plugin>
<version-maven-source-plugin>2.3</version-maven-source-plugin>
<version-maven-surefire-plugin>2.18.1</version-maven-surefire-plugin>
<version-maven-war-plugin>3.0.0</version-maven-war-plugin>
Expand Down

0 comments on commit 3717147

Please sign in to comment.