Skip to content

Commit b334a5e

Browse files
committed
CAMEL-12489 - camel-infinspan: split remote and embedded components (fix findings)
1 parent 37f2ec4 commit b334a5e

File tree

9 files changed

+1410
-63
lines changed

9 files changed

+1410
-63
lines changed

catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-component.adoc

+495
Large diffs are not rendered by default.

catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-embedded-component.adoc

+843
Large diffs are not rendered by default.

components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanConsumer.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import org.apache.camel.support.DefaultConsumer;
2424
import org.infinispan.commons.api.BasicCache;
2525
import org.infinispan.commons.api.BasicCacheContainer;
26-
import org.slf4j.Logger;
27-
import org.slf4j.LoggerFactory;
2826

2927
public abstract class InfinispanConsumer<
3028
ContainerType extends BasicCacheContainer,
@@ -33,8 +31,6 @@ public abstract class InfinispanConsumer<
3331
extends DefaultConsumer
3432
implements InfinispanEventProcessor {
3533

36-
private static final Logger LOG = LoggerFactory.getLogger(InfinispanProducer.class);
37-
3834
protected final ConfigurationType configuration;
3935
protected final ManagerType manager;
4036
protected final String cacheName;
@@ -66,7 +62,7 @@ public void processEvent(String eventType, String cacheName, Object key, Object
6662
try {
6763
getProcessor().process(exchange);
6864
} catch (Exception e) {
69-
LOG.error("Error processing event ", e);
65+
getExceptionHandler().handleException(e);
7066
}
7167
}
7268

components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteProducerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* contributor license agreements. See the NOTICE file distributed with
44
* this work for additional information regarding copyright ownership.
55
* The ASF licenses this file to You under the Apache License, Version 2.0
6-
* (the "License", getCacheName()); you may not use this file except in compliance with
6+
* (the "License"); you may not use this file except in compliance with
77
* the License. You may obtain a copy of the License at
88
*
99
* http://www.apache.org/licenses/LICENSE-2.0

components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteTestSupport.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232

3333
@TestMethodOrder(MethodOrderer.MethodName.class)
3434
public class InfinispanRemoteTestSupport extends InfinispanTestSupport {
35-
protected RemoteCacheManager cacheContainer;
36-
3735
@RegisterExtension
38-
static InfinispanService service = InfinispanServiceFactory.createService();
36+
public static InfinispanService service = InfinispanServiceFactory.createService();
37+
38+
protected RemoteCacheManager cacheContainer;
3939

4040
@Override
4141
protected void setupResources() throws Exception {

components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/spring/SpringInfinispanRemoteIdempotentRepositoryCamelTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import org.springframework.test.annotation.DirtiesContext;
2222

2323
@DirtiesContext
24-
public class SpringInfinispanRemoteIdempotentRepositoryCamelTest extends SpringInfinispanRemoteIdempotentRepositoryTestSupport {
24+
public class SpringInfinispanRemoteIdempotentRepositoryCamelTest
25+
extends SpringInfinispanRemoteIdempotentRepositoryTestSupport {
26+
2527
@Override
2628
protected AbstractApplicationContext createApplicationContext() {
2729
return new ClassPathXmlApplicationContext(

components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/spring/SpringInfinispanRemoteIdempotentRepositorySpringTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
@DirtiesContext
2424
public class SpringInfinispanRemoteIdempotentRepositorySpringTest
2525
extends SpringInfinispanRemoteIdempotentRepositoryTestSupport {
26+
2627
@Override
2728
protected AbstractApplicationContext createApplicationContext() {
2829
return new ClassPathXmlApplicationContext(

components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/spring/SpringInfinispanRemoteIdempotentRepositoryTestSupport.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
import static org.junit.jupiter.api.Assertions.assertNotNull;
3434

3535
public abstract class SpringInfinispanRemoteIdempotentRepositoryTestSupport extends CamelSpringTestSupport {
36-
3736
@RegisterExtension
38-
static InfinispanService service = InfinispanServiceFactory.createService();
37+
public static InfinispanService service = InfinispanServiceFactory.createService();
3938

4039
@Override
4140
public void doPreSetup() throws Exception {

tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java

+62-51
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,25 @@ public class PrepareCatalogMojo extends AbstractMojo {
214214
private Collection<Path> allPropertiesFiles;
215215
private Map<Path, BaseModel<?>> allModels;
216216

217+
private static String asComponentName(Path file) {
218+
String name = file.getFileName().toString();
219+
if (name.endsWith(PackageHelper.JSON_SUFIX)) {
220+
return name.substring(0, name.length() - PackageHelper.JSON_SUFIX.length());
221+
} else if (name.endsWith(".adoc")) {
222+
return name.substring(0, name.length() - ".adoc".length());
223+
}
224+
return name;
225+
}
226+
227+
private static boolean excludeDocumentDir(String name) {
228+
for (String exclude : EXCLUDE_DOC_FILES) {
229+
if (exclude.equals(name)) {
230+
return true;
231+
}
232+
}
233+
return false;
234+
}
235+
217236
/**
218237
* Execute goal.
219238
*
@@ -230,9 +249,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {
230249
Stream.concat(list(componentsDir.toPath()),
231250
Stream.of(coreDir.toPath(), modelDir.toPath(), baseDir.toPath(), languagesDir.toPath(), jaxpDir.toPath(),
232251
springDir.toPath()))
233-
.filter(dir -> !"target".equals(dir.getFileName().toString())).map(this::getComponentPath)
252+
.filter(dir -> !"target".equals(dir.getFileName().toString()))
253+
.flatMap(p -> getComponentPath(p).stream())
234254
.filter(dir -> Files.isDirectory(dir.resolve("src")))
235-
.map(p -> p.resolve("target/classes")).flatMap(PackageHelper::walk).forEach(p -> {
255+
.map(p -> p.resolve("target/classes"))
256+
.flatMap(PackageHelper::walk).forEach(p -> {
236257
String f = p.getFileName().toString();
237258
if (f.endsWith(PackageHelper.JSON_SUFIX)) {
238259
allJsonFiles.add(p);
@@ -388,11 +409,11 @@ protected Set<String> executeComponents() throws Exception {
388409
// check all the component options and grab the label(s) they
389410
// use
390411
model.getComponentOptions().stream().map(BaseOptionModel::getLabel).filter(l -> !Strings.isNullOrEmpty(l)).flatMap(l -> Stream.of(label.split(",")))
391-
.forEach(usedOptionLabels::add);
412+
.forEach(usedOptionLabels::add);
392413

393414
// check all the endpoint options and grab the label(s) they use
394415
model.getEndpointOptions().stream().map(BaseOptionModel::getLabel).filter(l -> !Strings.isNullOrEmpty(l)).flatMap(l -> Stream.of(label.split(",")))
395-
.forEach(usedOptionLabels::add);
416+
.forEach(usedOptionLabels::add);
396417

397418
long unused = model.getEndpointOptions().stream().map(BaseOptionModel::getLabel).filter(Strings::isNullOrEmpty).count();
398419
if (unused >= UNUSED_LABELS_WARN) {
@@ -462,7 +483,7 @@ protected Set<String> executeDataFormats() throws Exception {
462483

463484
for (Path file : jsonFiles) {
464485

465-
DataFormatModel model = (DataFormatModel)allModels.get(file);
486+
DataFormatModel model = (DataFormatModel) allModels.get(file);
466487

467488
// Check labels
468489
String name = asComponentName(file);
@@ -518,7 +539,7 @@ protected Set<String> executeLanguages() throws Exception {
518539

519540
for (Path file : jsonFiles) {
520541

521-
LanguageModel model = (LanguageModel)allModels.get(file);
542+
LanguageModel model = (LanguageModel) allModels.get(file);
522543

523544
// Check labels
524545
String name = asComponentName(file);
@@ -572,6 +593,7 @@ private Set<String> executeOthers() throws Exception {
572593
case "camel-fhir":
573594
case "camel-debezium-common":
574595
case "camel-vertx-kafka":
596+
case "camel-infinispan":
575597
return false;
576598
default:
577599
return true;
@@ -594,7 +616,7 @@ private Set<String> executeOthers() throws Exception {
594616

595617
for (Path file : jsonFiles) {
596618

597-
OtherModel model = (OtherModel)allModels.get(file);
619+
OtherModel model = (OtherModel) allModels.get(file);
598620

599621
String name = asComponentName(file);
600622

@@ -661,21 +683,27 @@ protected void executeDocuments(Set<String> components, Set<String> dataformats,
661683
Set<Path> duplicateAdocFiles = new TreeSet<>();
662684

663685
// find all camel maven modules
664-
Stream.concat(list(componentsDir.toPath()).filter(dir -> !dir.getFileName().startsWith(".") && !"target".equals(dir.getFileName().toString())).map(this::getComponentPath),
665-
Stream.of(coreDir.toPath(), baseDir.toPath(), languagesDir.toPath(), jaxpDir.toPath()))
666-
.forEach(dir -> {
667-
List<Path> l = PackageHelper.walk(dir.resolve("src/main/docs")).filter(f -> f.getFileName().toString().endsWith(".adoc")).collect(Collectors.toList());
668-
if (l.isEmpty()) {
669-
String n = dir.getFileName().toString();
670-
boolean isDir = dir.toFile().isDirectory();
671-
boolean valid = isDir && !n.startsWith(".") && !n.endsWith("-base") && !n.endsWith("-common");
672-
if (valid) {
673-
missingAdocFiles.add(dir);
674-
}
675-
} else {
676-
adocFiles.addAll(l);
686+
Stream.concat(
687+
list(componentsDir.toPath())
688+
.filter(dir -> !dir.getFileName().startsWith(".") && !"target".equals(dir.getFileName().toString()))
689+
.flatMap(p -> getComponentPath(p).stream()),
690+
Stream.of(coreDir.toPath(), baseDir.toPath(), languagesDir.toPath(), jaxpDir.toPath()))
691+
.forEach(dir -> {
692+
List<Path> l = PackageHelper.walk(dir.resolve("src/main/docs"))
693+
.filter(f -> f.getFileName().toString().endsWith(".adoc"))
694+
.collect(Collectors.toList());
695+
696+
if (l.isEmpty()) {
697+
String n = dir.getFileName().toString();
698+
boolean isDir = dir.toFile().isDirectory();
699+
boolean valid = isDir && !n.startsWith(".") && !n.endsWith("-base") && !n.endsWith("-common");
700+
if (valid) {
701+
missingAdocFiles.add(dir);
677702
}
678-
});
703+
} else {
704+
adocFiles.addAll(l);
705+
}
706+
});
679707

680708
getLog().info("Found " + adocFiles.size() + " ascii document files");
681709

@@ -688,7 +716,7 @@ protected void executeDocuments(Set<String> components, Set<String> dataformats,
688716
// Copy all descriptors
689717
Map<Path, Path> newJsons = map(adocFiles, p -> p, p -> documentsOutDir.resolve(p.getFileName()));
690718
list(documentsOutDir).filter(p -> !newJsons.containsValue(p) && !newJsons.containsValue(p.resolveSibling(p.getFileName().toString().replace(".html", ".adoc"))))
691-
.forEach(this::delete);
719+
.forEach(this::delete);
692720
newJsons.forEach(this::copy);
693721

694722
Path all = documentsOutDir.resolve("../docs.properties");
@@ -1035,16 +1063,6 @@ private void printDocumentsReport(Set<Path> docs, Set<Path> duplicate, Set<Path>
10351063
getLog().info("================================================================================");
10361064
}
10371065

1038-
private static String asComponentName(Path file) {
1039-
String name = file.getFileName().toString();
1040-
if (name.endsWith(PackageHelper.JSON_SUFIX)) {
1041-
return name.substring(0, name.length() - PackageHelper.JSON_SUFIX.length());
1042-
} else if (name.endsWith(".adoc")) {
1043-
return name.substring(0, name.length() - ".adoc".length());
1044-
}
1045-
return name;
1046-
}
1047-
10481066
private void copyFile(Path file, Path toDir) throws IOException, MojoFailureException {
10491067
if (Files.isRegularFile(file)) {
10501068
// make sure to create out dir
@@ -1059,15 +1077,6 @@ private void copyFile(Path file, Path toDir) throws IOException, MojoFailureExce
10591077
}
10601078
}
10611079

1062-
private static boolean excludeDocumentDir(String name) {
1063-
for (String exclude : EXCLUDE_DOC_FILES) {
1064-
if (exclude.equals(name)) {
1065-
return true;
1066-
}
1067-
}
1068-
return false;
1069-
}
1070-
10711080
private List<Path> concat(List<Path> l1, List<Path> l2) {
10721081
return Stream.concat(l1.stream(), l2.stream()).collect(Collectors.toList());
10731082
}
@@ -1142,26 +1151,28 @@ private Set<Path> getDuplicates(Set<Path> jsonFiles) {
11421151
return byName.values().stream().flatMap(l -> l.stream().skip(1)).collect(Collectors.toCollection(TreeSet::new));
11431152
}
11441153

1145-
private Path getComponentPath(Path dir) {
1154+
private List<Path> getComponentPath(Path dir) {
11461155
switch (dir.getFileName().toString()) {
11471156
case "camel-as2":
1148-
return dir.resolve("camel-as2-component");
1157+
return Collections.singletonList(dir.resolve("camel-as2-component"));
11491158
case "camel-salesforce":
1150-
return dir.resolve("camel-salesforce-component");
1159+
return Collections.singletonList(dir.resolve("camel-salesforce-component"));
11511160
case "camel-olingo2":
1152-
return dir.resolve("camel-olingo2-component");
1161+
return Collections.singletonList(dir.resolve("camel-olingo2-component"));
11531162
case "camel-olingo4":
1154-
return dir.resolve("camel-olingo4-component");
1163+
return Collections.singletonList(dir.resolve("camel-olingo4-component"));
11551164
case "camel-box":
1156-
return dir.resolve("camel-box-component");
1165+
return Collections.singletonList(dir.resolve("camel-box-component"));
11571166
case "camel-servicenow":
1158-
return dir.resolve("camel-servicenow-component");
1167+
return Collections.singletonList(dir.resolve("camel-servicenow-component"));
11591168
case "camel-fhir":
1160-
return dir.resolve("camel-fhir-component");
1169+
return Collections.singletonList(dir.resolve("camel-fhir-component"));
11611170
case "camel-vertx-kafka":
1162-
return dir.resolve("camel-vertx-kafka-component");
1171+
return Collections.singletonList(dir.resolve("camel-vertx-kafka-component"));
1172+
case "camel-infinispan":
1173+
return Arrays.asList(dir.resolve("camel-infinispan"), dir.resolve("camel-infinispan-embedded"));
11631174
default:
1164-
return dir;
1175+
return Collections.singletonList(dir);
11651176
}
11661177
}
11671178

0 commit comments

Comments
 (0)