Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Commit

Permalink
Initial version of JMS connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
dhirajsb committed Nov 13, 2017
1 parent 96e3102 commit ad08dc5
Show file tree
Hide file tree
Showing 126 changed files with 11,270 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2016 Red Hat, Inc.
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.
-->
<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">

<parent>
<groupId>io.syndesis</groupId>
<artifactId>activemq-connectors</artifactId>
<version>0.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>activemq-publish-bytes-connector</artifactId>
<name>Syndesis Connectors :: ActiveMQ Publish Bytes Connector</name>
<description>JMS Publish Bytes Connector</description>
<packaging>jar</packaging>

<dependencyManagement>
<dependencies>
<!-- Camel BOM -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-parent</artifactId>
<version>${camel.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
<groupId>io.syndesis</groupId>
<artifactId>jms-model</artifactId>
<version>0.5-SNAPSHOT</version>
</dependency>

<!-- base component to use for this connector -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sjms2</artifactId>
</dependency>
<!-- add spring-boot support -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sjms2-starter</artifactId>
</dependency>

<!-- ActiveMQ dependencies -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
</dependency>

<!-- camel-connector -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-connector</artifactId>
</dependency>

<!-- camel and spring boot compiler plugins -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>apt</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring-boot.version}</version>
</dependency>

</dependencies>

<build>
<defaultGoal>install</defaultGoal>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

<!-- generate components meta-data and validate component includes documentation etc -->
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-package-maven-plugin</artifactId>
<version>${camel.version}</version>
<executions>
<execution>
<id>prepare</id>
<goals>
<goal>prepare-components</goal>
</goals>
<phase>generate-resources</phase>
</execution>
<!--
<execution>
<id>validate</id>
<goals>
<goal>validate-components</goal>
</goals>
<phase>prepare-package</phase>
</execution>
-->
</executions>
</plugin>

<!-- turn off jar plugin as we use connector plugin to jar instead -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<executions>
<execution>
<id>default-jar</id>
<phase />
</execution>
</executions>
</plugin>

<!-- generate connector -->
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-connector-maven-plugin</artifactId>
<version>${camel.version}</version>
<executions>
<execution>
<id>boot</id>
<goals>
<goal>prepare-spring-boot-auto-configuration</goal>
</goals>
<configuration>
<!-- we don't want license headers -->
<includeLicenseHeader>false</includeLicenseHeader>
<!-- we don't want camel.connector as prefix -->
<configurationPrefix>false</configurationPrefix>
</configuration>
</execution>
<execution>
<id>connector</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (C) 2017 Red Hat, Inc.
*
* 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.
*/
package io.syndesis.connector.jms;

import org.apache.camel.Exchange;
import org.apache.camel.Message;

/**
* Camel activemq-publish-bytes connector
*/
public class ActiveMQPublishBytesComponent extends AbstractActiveMQConnector {

public ActiveMQPublishBytesComponent() {
super("activemq-publish-bytes", ActiveMQPublishBytesComponent.class.getName());

setBeforeProducer( (Exchange exchange) -> {

// extract headers and body
Message out = exchange.getIn();
JmsBytesMessage jmsBytesMessage = out.getBody(JmsBytesMessage.class);
out.setBody(jmsBytesMessage.getBody());
if (jmsBytesMessage.getHeaders() != null) {
out.setHeaders(jmsBytesMessage.getHeaders());
}
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package io.syndesis.connector.jms.springboot;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import javax.annotation.PostConstruct;
import io.syndesis.connector.jms.ActiveMQPublishBytesComponent;
import org.apache.camel.CamelContext;
import org.apache.camel.component.connector.ConnectorCustomizer;
import org.apache.camel.spi.HasId;
import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
import org.apache.camel.util.IntrospectionSupport;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
* Generated by camel-connector-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.connector.SpringBootAutoConfigurationMojo")
@Configuration
@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@EnableConfigurationProperties(ActiveMQPublishBytesConnectorConfiguration.class)
public class ActiveMQPublishBytesConnectorAutoConfiguration {

private static final Logger LOGGER = LoggerFactory
.getLogger(ActiveMQPublishBytesConnectorAutoConfiguration.class);
@Autowired
private ApplicationContext applicationContext;
@Autowired
private CamelContext camelContext;
@Autowired
private ActiveMQPublishBytesConnectorConfiguration configuration;
@Autowired(required = false)
private List<ConnectorCustomizer<ActiveMQPublishBytesComponent>> customizers;

@Lazy
@Bean(name = "activemq-publish-bytes-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean
public ActiveMQPublishBytesComponent configureActiveMQPublishBytesComponent()
throws Exception {
ActiveMQPublishBytesComponent connector = new ActiveMQPublishBytesComponent();
connector.setCamelContext(camelContext);
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null,
false);
CamelPropertiesHelper.setCamelProperties(camelContext, connector,
parameters, false);
connector.setOptions(parameters);
if (ObjectHelper.isNotEmpty(customizers)) {
for (ConnectorCustomizer<ActiveMQPublishBytesComponent> customizer : customizers) {
boolean useCustomizer = (customizer instanceof HasId)
? HierarchicalPropertiesEvaluator
.evaluate(
applicationContext.getEnvironment(),
"camel.connector.customizer",
"camel.connector.activemq-publish-bytes.customizer",
((HasId) customizer).getId())
: HierarchicalPropertiesEvaluator
.evaluate(applicationContext.getEnvironment(),
"camel.connector.customizer",
"camel.connector.activemq-publish-bytes.customizer");
if (useCustomizer) {
LOGGER.debug("Configure connector {}, with customizer {}",
connector, customizer);
customizer.customize(connector);
}
}
}
return connector;
}

@PostConstruct
public void postConstructActiveMQPublishBytesComponent() {
Map<String, Object> parameters = new HashMap<>();
for (Map.Entry<String, ActiveMQPublishBytesConnectorConfigurationCommon> entry : configuration
.getConfigurations().entrySet()) {
parameters.clear();
ActiveMQPublishBytesComponent connector = new ActiveMQPublishBytesComponent();
connector.setCamelContext(camelContext);
try {
IntrospectionSupport.getProperties(entry.getValue(),
parameters, null, false);
CamelPropertiesHelper.setCamelProperties(camelContext,
connector, parameters, false);
connector.setOptions(parameters);
if (ObjectHelper.isNotEmpty(customizers)) {
for (ConnectorCustomizer<ActiveMQPublishBytesComponent> customizer : customizers) {
boolean useCustomizer = (customizer instanceof HasId)
? HierarchicalPropertiesEvaluator.evaluate(
applicationContext.getEnvironment(),
"camel.connector.customizer",
"camel.connector.activemq-publish-bytes."
+ entry.getKey()
+ ".customizer",
((HasId) customizer).getId())
: HierarchicalPropertiesEvaluator.evaluate(
applicationContext.getEnvironment(),
"camel.connector.customizer",
"camel.connector.activemq-publish-bytes."
+ entry.getKey()
+ ".customizer");
if (useCustomizer) {
LOGGER.debug(
"Configure connector {}, with customizer {}",
connector, customizer);
customizer.customize(connector);
}
}
}
camelContext.addComponent(entry.getKey(), connector);
} catch (Exception e) {
throw new BeanCreationException(entry.getKey(), e.getMessage(),
e);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.syndesis.connector.jms.springboot;

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Generated;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Generated("org.apache.camel.maven.connector.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "activemq-publish-bytes")
public class ActiveMQPublishBytesConnectorConfiguration
extends
ActiveMQPublishBytesConnectorConfigurationCommon {

/**
* Define additional configuration definitions
*/
private Map<String, ActiveMQPublishBytesConnectorConfigurationCommon> configurations = new HashMap<>();

public Map<String, ActiveMQPublishBytesConnectorConfigurationCommon> getConfigurations() {
return configurations;
}
}
Loading

0 comments on commit ad08dc5

Please sign in to comment.