This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new fb0f98e1db7 CAMEL-20361: The generated marker file in META-INF
services did not allow sub-folders due to a recent santize fix.
fb0f98e1db7 is described below
commit fb0f98e1db7a87fb116256fd5b883ae38acbe632
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Feb 18 09:07:19 2024 +0100
CAMEL-20361: The generated marker file in META-INF services did not allow
sub-folders due to a recent santize fix.
---
.../http/plugin/camel-platform-http-jolokia | 2 --
.../jolokia} | 0
.../plugin/DefaultJolokiaPlatformHttpPlugin.java | 12 ++++++------
.../DefaultJolokiaPlatformHttpPluginTest.java | 2 +-
.../platform/http/platform-http-plugin-registry | 2 --
.../plugin-registry} | 0
.../platform/http/PlatformHttpPluginRegistry.java | 21 ++++++++-------------
.../http/plugin/JolokiaPlatformHttpPlugin.java | 4 ++--
.../http/spi/PlatformHttpPluginRegistry.java | 16 +++++++++++++---
.../packaging/GenerateDataTypeTransformerMojo.java | 2 +-
.../camel/maven/packaging/SpiGeneratorMojo.java | 2 +-
11 files changed, 32 insertions(+), 31 deletions(-)
diff --git
a/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/plugin/camel-platform-http-jolokia
b/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/plugin/camel-platform-http-jolokia
deleted file mode 100644
index 0a5eddbdad4..00000000000
---
a/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/plugin/camel-platform-http-jolokia
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-class=org.apache.camel.component.platform.http.plugin.DefaultJolokiaPlatformHttpPlugin
\ No newline at end of file
diff --git
a/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/camel-platform-http-jolokia
b/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/platform-http/jolokia
similarity index 100%
rename from
components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/camel-platform-http-jolokia
rename to
components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/platform-http/jolokia
diff --git
a/components/camel-platform-http-jolokia/src/main/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPlugin.java
b/components/camel-platform-http-jolokia/src/main/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPlugin.java
index 55cd5abe6f1..7701a57b6fd 100644
---
a/components/camel-platform-http-jolokia/src/main/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPlugin.java
+++
b/components/camel-platform-http-jolokia/src/main/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPlugin.java
@@ -37,7 +37,7 @@ import org.jolokia.service.serializer.JolokiaSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@JdkService(DefaultJolokiaPlatformHttpPlugin.NAME)
+@JdkService("platform-http/" + JolokiaPlatformHttpPlugin.NAME)
public class DefaultJolokiaPlatformHttpPlugin extends ServiceSupport
implements JolokiaPlatformHttpPlugin {
private static final Logger LOG =
LoggerFactory.getLogger(DefaultJolokiaPlatformHttpPlugin.class);
@@ -62,7 +62,7 @@ public class DefaultJolokiaPlatformHttpPlugin extends
ServiceSupport implements
serviceManager.addService(new JolokiaSerializer());
serviceManager.addService(new LocalRequestHandler(1));
- LOG.info("Creating DefaultJolokiaPlatformHttpPlugin with restrictor
{}", restrictor);
+ LOG.info("Creating DefaultJolokiaPlatformHttpPlugin with Restrictor:
{}", restrictor);
}
@Override
@@ -87,15 +87,15 @@ public class DefaultJolokiaPlatformHttpPlugin extends
ServiceSupport implements
try {
var restrictor =
RestrictorFactory.lookupPolicyRestrictor(pLocation);
if (restrictor != null) {
- jolokiaLogHandler.info("Using access restrictor " + pLocation);
+ jolokiaLogHandler.info("Using access restrictor: " +
pLocation);
return restrictor;
} else {
- jolokiaLogHandler.info("No access restrictor found at " +
pLocation + ", access to all MBeans is allowed");
+ jolokiaLogHandler.info("No access restrictor found at: " +
pLocation + ", access to all MBeans is allowed");
return new AllowAllRestrictor();
}
} catch (IOException e) {
- jolokiaLogHandler.error("Error while accessing access restrictor
at " + pLocation +
- ". Denying all access to MBeans for security
reasons. Exception: " + e,
+ jolokiaLogHandler.error("Error while accessing access restrictor:
at " + pLocation +
+ ". Denying all access to MBeans for
security reasons. Exception: " + e,
e);
return new DenyAllRestrictor();
}
diff --git
a/components/camel-platform-http-jolokia/src/test/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPluginTest.java
b/components/camel-platform-http-jolokia/src/test/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPluginTest.java
index 0eeaec4639a..f98ef6e22bf 100644
---
a/components/camel-platform-http-jolokia/src/test/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPluginTest.java
+++
b/components/camel-platform-http-jolokia/src/test/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPluginTest.java
@@ -38,7 +38,7 @@ public class DefaultJolokiaPlatformHttpPluginTest extends
ContextTestSupport {
PlatformHttpPluginRegistry registry =
resolvePlatformHttpPluginRegistry();
Assertions.assertNotNull(registry);
DefaultJolokiaPlatformHttpPlugin plugin =
(DefaultJolokiaPlatformHttpPlugin) registry
-
.resolvePluginById(DefaultJolokiaPlatformHttpPlugin.NAME).orElseThrow();
+ .resolvePluginById("jolokia").orElseThrow();
Assertions.assertNotNull(plugin);
HttpRequestHandler handler = plugin.getRequestHandler();
diff --git
a/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/platform-http-plugin-registry
b/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/platform-http-plugin-registry
deleted file mode 100644
index a845295309d..00000000000
---
a/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/platform-http-plugin-registry
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-class=org.apache.camel.component.platform.http.PlatformHttpPluginRegistry
diff --git
a/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/component-platform-http-platform-http-plugin-registry
b/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/platform-http/plugin-registry
similarity index 100%
rename from
components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/component-platform-http-platform-http-plugin-registry
rename to
components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/platform-http/plugin-registry
diff --git
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpPluginRegistry.java
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpPluginRegistry.java
index 115e2722f4f..b4acd4675e9 100644
---
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpPluginRegistry.java
+++
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpPluginRegistry.java
@@ -35,45 +35,39 @@ import org.slf4j.LoggerFactory;
/**
* Default {@link
org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry}.
*/
-@JdkService(org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry.FACTORY)
+@JdkService(PlatformHttpPluginRegistry.FACTORY)
public class PlatformHttpPluginRegistry extends ServiceSupport
implements
org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry {
+ private static final Logger LOG =
LoggerFactory.getLogger(PlatformHttpPluginRegistry.class);
+
private static final String PLATFORM_HTTP_PLUGIN_FACTORY_PATH
- = "META-INF/services/org/apache/camel/" +
PLATFORM_HTTP_FACTORY_PATH + "plugin/";
- private CamelContext camelContext;
+ = "META-INF/services/org/apache/camel/platform-http/";
+ private CamelContext camelContext;
private final Set<PlatformHttpPlugin> plugins = new
TreeSet<>(Comparator.comparing(PlatformHttpPlugin::getId));
- private static final Logger LOG =
LoggerFactory.getLogger(PlatformHttpPluginRegistry.class);
-
@Override
public Optional<PlatformHttpPlugin> resolvePluginById(String id) {
PlatformHttpPlugin answer = plugins.stream().filter(plugin ->
plugin.getId().equals(id)).findFirst()
.orElse(getCamelContext().getRegistry().findByTypeWithName(PlatformHttpPlugin.class).get(id));
-
if (answer == null) {
answer = resolvePluginWithFactoryFinderById(id);
}
-
if (answer != null) {
register(answer);
}
-
return Optional.ofNullable(answer);
}
@Override
public boolean register(PlatformHttpPlugin plugin) {
- boolean result;
-
if (getPlugin(plugin.getId()).isPresent()) {
return false;
}
- result = plugins.add(plugin);
-
+ boolean result = plugins.add(plugin);
if (result) {
CamelContextAware.trySetCamelContext(plugin, camelContext);
ServiceHelper.startService(plugin);
@@ -100,10 +94,10 @@ public class PlatformHttpPluginRegistry extends
ServiceSupport
private PlatformHttpPlugin resolvePluginWithFactoryFinderById(String id) {
PlatformHttpPlugin answer = null;
+
FactoryFinder factoryFinder
=
getCamelContext().getCamelContextExtension().getFactoryFinder(PLATFORM_HTTP_PLUGIN_FACTORY_PATH);
Class<?> type = factoryFinder.findOptionalClass(id).orElse(null);
-
if (type != null) {
if (PlatformHttpPlugin.class.isAssignableFrom(type)) {
answer = (PlatformHttpPlugin)
camelContext.getInjector().newInstance(type, false);
@@ -118,4 +112,5 @@ public class PlatformHttpPluginRegistry extends
ServiceSupport
return answer;
}
+
}
diff --git
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/plugin/JolokiaPlatformHttpPlugin.java
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/plugin/JolokiaPlatformHttpPlugin.java
index 12e622fbfa4..04393c1491d 100644
---
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/plugin/JolokiaPlatformHttpPlugin.java
+++
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/plugin/JolokiaPlatformHttpPlugin.java
@@ -20,11 +20,11 @@ import
org.apache.camel.component.platform.http.spi.PlatformHttpPlugin;
import org.jolokia.server.core.http.HttpRequestHandler;
/**
- * camel-platform-http plugin.
+ * Plugin for Jolokia
*/
public interface JolokiaPlatformHttpPlugin extends PlatformHttpPlugin {
- String NAME = "camel-platform-http-jolokia";
+ String NAME = "jolokia";
HttpRequestHandler getRequestHandler();
}
diff --git
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPluginRegistry.java
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPluginRegistry.java
index e5742a87f1f..481ac41b6b8 100644
---
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPluginRegistry.java
+++
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPluginRegistry.java
@@ -26,11 +26,21 @@ import org.apache.camel.StaticService;
*/
public interface PlatformHttpPluginRegistry extends CamelContextAware,
StaticService {
- String PLATFORM_HTTP_FACTORY_PATH = "component/platform/http/";
-
- String FACTORY = PLATFORM_HTTP_FACTORY_PATH +
"platform-http-plugin-registry";
+ String FACTORY = "platform-http/plugin-registry";
+ /**
+ * Resolve a plugin by id
+ *
+ * @param id the plugin id
+ * @return the plugin if found
+ */
Optional<PlatformHttpPlugin> resolvePluginById(String id);
+ /**
+ * Register the plugin into the registry.
+ *
+ * @param plugin the plugin
+ * @return true if the plugin was added, or false if already exists
+ */
boolean register(PlatformHttpPlugin plugin);
}
diff --git
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDataTypeTransformerMojo.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDataTypeTransformerMojo.java
index d490476a7d0..5c511a84cbd 100644
---
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDataTypeTransformerMojo.java
+++
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDataTypeTransformerMojo.java
@@ -219,7 +219,7 @@ public class GenerateDataTypeTransformerMojo extends
AbstractGeneratorMojo {
}
private String sanitizeFileName(String fileName) {
- return fileName.replaceAll("[^A-Za-z0-9-]", "-");
+ return fileName.replaceAll("[^A-Za-z0-9-/]", "-");
}
private String asTitle(String name) {
diff --git
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
index 75be1f2a493..c4b66b9e63b 100644
---
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
+++
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
@@ -163,7 +163,7 @@ public class SpiGeneratorMojo extends AbstractGeneratorMojo
{
}
private String sanitizeFileName(String fileName) {
- return fileName.replaceAll("[^A-Za-z0-9-]", "-");
+ return fileName.replaceAll("[^A-Za-z0-9-/]", "-");
}
private boolean isLocal(String className) {