Skip to content

Commit

Permalink
Ref #4220: Add the camel-swift extension
Browse files Browse the repository at this point in the history
  • Loading branch information
essobedo committed Dec 12, 2022
1 parent 3865172 commit a7b9531
Show file tree
Hide file tree
Showing 32 changed files with 2,698 additions and 1,044 deletions.
13 changes: 13 additions & 0 deletions docs/modules/ROOT/examples/dataformats/swiftMt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Do not edit directly!
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-swift
cqArtifactIdBase: swift
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqJvmSince: 2.15.0
cqNativeSince: 2.15.0
cqCamelPartName: swiftMt
cqCamelPartTitle: SWIFT MT
cqCamelPartDescription: Encode and decode SWIFT MT messages.
cqExtensionPageTitle: SWIFT
13 changes: 13 additions & 0 deletions docs/modules/ROOT/examples/dataformats/swiftMx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Do not edit directly!
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-swift
cqArtifactIdBase: swift
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqJvmSince: 2.15.0
cqNativeSince: 2.15.0
cqCamelPartName: swiftMx
cqCamelPartTitle: SWIFT MX
cqCamelPartDescription: Encode and decode SWIFT MX messages.
cqExtensionPageTitle: SWIFT
46 changes: 46 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/swift.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-swift"]
= SWIFT
:linkattrs:
:cq-artifact-id: camel-quarkus-swift
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Encode and decode SWIFT messages.
:cq-deprecated: false
:cq-jvm-since: 2.15.0
:cq-native-since: 2.15.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##2.15.0## [.badge-key]##Native since##[.badge-supported]##2.15.0##
endif::[]

Encode and decode SWIFT messages.

[id="extensions-swift-whats-inside"]
== What's inside

* xref:{cq-camel-components}:dataformats:swiftMt-dataformat.adoc[SWIFT MT data format]
* xref:{cq-camel-components}:dataformats:swiftMx-dataformat.adoc[SWIFT MX data format]

Please refer to the above links for usage and configuration details.

[id="extensions-swift-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-swift[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-swift</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
<module>stax</module>
<module>stream</module>
<module>stringtemplate</module>
<module>swift</module>
<module>syslog</module>
<module>tarfile</module>
<module>telegram</module>
Expand Down
67 changes: 67 additions & 0 deletions extensions/swift/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-swift-parent</artifactId>
<version>2.15.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-swift-deployment</artifactId>
<name>Camel Quarkus :: SWIFT :: Deployment</name>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jaxb-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-swift</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* 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.quarkus.component.swift.deployment;

import com.prowidesoftware.swift.model.AbstractMessage;
import com.prowidesoftware.swift.model.MessageStandardType;
import com.prowidesoftware.swift.model.SwiftBlock;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.UnparsedTextList;
import com.prowidesoftware.swift.model.field.Field;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;

class SwiftProcessor {

private static final String FEATURE = "camel-swift";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
void indexDependencies(BuildProducer<IndexDependencyBuildItem> indexedDependency) {
// The dependency for MX message types
indexedDependency.produce(new IndexDependencyBuildItem("com.prowidesoftware", "pw-iso20022"));
// The dependency for MT message types
indexedDependency.produce(new IndexDependencyBuildItem("com.prowidesoftware", "pw-swift-core"));
}

@BuildStep
void registerOtherTypesForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {

reflectiveClass.produce(
new ReflectiveClassBuildItem(false, true, Tag.class, UnparsedTextList.class, MessageStandardType.class));

}

@BuildStep
void registerDictionaryForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndex) {

IndexView index = combinedIndex.getIndex();

String[] classes = index.getClassesInPackage(DotName.createSimple("com.prowidesoftware.swift.model.mx.dic"))
.stream()
.map(classInfo -> classInfo.name().toString())
.toArray(String[]::new);

// Register classes for refection
reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, classes));
}

@BuildStep
void registerMessageTypesForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndex) {
reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, AbstractMessage.class));
registerForReflection(combinedIndex, AbstractMessage.class.getName(), reflectiveClass);
}

@BuildStep
void registerFieldTypesForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndex) {

registerForReflection(combinedIndex, Field.class.getName(), reflectiveClass);
}

@BuildStep
void registerSwiftBlocksForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndex) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, SwiftBlock.class));
registerForReflection(combinedIndex, SwiftBlock.class.getName(), reflectiveClass);
}

private static void registerForReflection(CombinedIndexBuildItem combinedIndex, String className,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
IndexView index = combinedIndex.getIndex();

String[] classes = index.getAllKnownSubclasses(DotName.createSimple(className))
.stream()
.map(classInfo -> classInfo.name().toString())
.toArray(String[]::new);

// Register classes for refection
reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, classes));
}
}
39 changes: 39 additions & 0 deletions extensions/swift/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-extensions</artifactId>
<version>2.15.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-swift-parent</artifactId>
<name>Camel Quarkus :: SWIFT</name>
<packaging>pom</packaging>

<modules>
<module>deployment</module>
<module>runtime</module>
</modules>
</project>
Loading

0 comments on commit a7b9531

Please sign in to comment.