You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Federico Mariani (Jira)" <ji...@apache.org> on 2025/09/17 07:47:00 UTC

[jira] [Created] (CAMEL-22423) Make Camel extensible from 3d party dependencies via ServiceLoader

Federico Mariani created CAMEL-22423:
----------------------------------------

             Summary: Make Camel extensible from 3d party dependencies via ServiceLoader
                 Key: CAMEL-22423
                 URL: https://issues.apache.org/jira/browse/CAMEL-22423
             Project: Camel
          Issue Type: New Feature
            Reporter: Federico Mariani


Right now, it is not possible to customize the CamelContext from a 3d party dependency that has no access to Camel Main. During the Camel startup, an hook should be provided that can be used to customize the CamelContext without access to Camel Main. To achieve this an SPI that loads implementation via ServiceLoader may be provided during the CamelContext startup.

This way third-party components can provide custom _ContextServicePlugin_ implementations in _META-INF/services/org.apache.camel.spi.ContextServicePlugin_ and customize the CamelContext. For example, provide beans, add EventNotifier, and so on.

example of ContextServicePlugin implementation

{code:java}
public class MyContextServicePlugin implements ContextServicePlugin {
    @Override
    public void load(CamelContext camelContext) {
        camelContext.getRegistry().bind("myBean", new TestBean());
        camelContext.getRegistry().bind("mySecondBean", new AnotherTestBean());
        ...
    }
}
{code}

This code should be executed during the CamelContext startup, early in the lifcycle, before the Camel Components are loaded for example.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)