[ 
https://issues.apache.org/jira/browse/CAMEL-5986?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Karim de Fombelle updated CAMEL-5986:
-------------------------------------

    Description: 
Camel-CDI offers a mechanism to resolve property placeholders like  
{{{{property1}}}} in an endpoint uri as described in camel 
[documentation|http://camel.apache.org/using-propertyplaceholder.html]
These placeholders could come from ConfigSource loaded via the deltaspike 
configuration CDI extension and its ConfigResolver class according comments on 
class
Anyway this choice is surprising because the documentation of the 
org.apache.deltaspike.core.api.config.PropertyFileConfig specifies the 
following:
{code}
 *  <p>Please note that the configuration will only be available
 *  after the boot is finished. This means that you cannot use
 *  this configuration inside a CDI Extension before the boot
 *  is finished!</p>
{code}
camel-cdi module contains a test class 
_org.apache.camel.cdi.component.properties.PropertiesComponentTest_ which IMHO 
does not illustrate the real use we would need in a CDI container.
It support placeholders replacing after the boot of the CDI container, which is 
inline with the javdoc illustrated below.
But from my standpoint the real benefit would be to use such a feature as 
follows:
{code}
@RunWith(Arquillian.class)
@ApplicationScoped
public class CamelCdiCamel5986Test {

    //~ 
----------------------------------------------------------------------------------------------------------------
    //~ Instance fields 
    //~ 
----------------------------------------------------------------------------------------------------------------

    @Inject
    private SampleConfigBean bean;

    @Inject
    @Mock("mock:{{property1}}")
    private MockEndpoint mockEndpoint;

    //~ 
----------------------------------------------------------------------------------------------------------------
    //~ Methods 
    //~ 
----------------------------------------------------------------------------------------------------------------

    @Deployment
    public static Archive<?> createDeployment() {
        //J-
        JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
                        .addClasses(TestRouteBuilder.class, 
SampleConfigBean.class)
                        .addAsResource("META-INF/camel.properties")//according 
CdiConfigFile
                        .addPackages(true, 
ConfigurationExtension.class.getPackage())
                        .addPackages(true, CdiCamelContext.class.getPackage())
                        .addAsManifestResource(EmptyAsset.INSTANCE, 
"beans.xml");
        return jar;
        //J+
    }

    @Test
    public void testConfiguration() {
        assertNotNull("bean config is null", bean);
        assertNotNull("mockEndpoint is null", mockEndpoint);
        assertEquals("end", bean.getProperty1());
    }

    //~ 
----------------------------------------------------------------------------------------------------------------
    //~ Inner Classes 
    //~ 
----------------------------------------------------------------------------------------------------------------

    @ContextName
    public static class TestRouteBuilder extends RouteBuilder {

        @Override
        public void configure() throws Exception {
            from("direct:begin").to("mock:{{property1}}");
        }

    }

    public static class SampleConfigBean {

        @Inject
        @ConfigProperty(name = "property1")
        private String property1;

        public String getProperty1() {
            return property1;
        }

    }

    /**
     * Copy of class from camel-cdi test class 
org.apache.camel.cdi.support.CdiConfigFile
     */
    public static class CdiConfigFile implements PropertyFileConfig {

        private static final long serialVersionUID = 1L;

        @Override
        public String getPropertyFileName() {
            return "META-INF/camel.properties";
        }

    }

}
{code}


  was:
Camel-CDI offers a mechanism to resolve property placeholders like  
{{{{property1}}}} in an endpoint uri as described in camel 
[documentation|http://camel.apache.org/using-propertyplaceholder.html]
These placeholders could come from ConfigSource loaded via the deltaspike 
configuration CDI extension and its ConfigResolver class.
However this implementation could be limited and/or not suitable in some cases 
(cf. [DELTASPIKE-311|https://issues.apache.org/jira/browse/DELTASPIKE-311])
Would it be possible to provide a customised CdiPropertiesParser?

    
> Resolve property placeholders via another mechanism than deltaspike
> -------------------------------------------------------------------
>
>                 Key: CAMEL-5986
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5986
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-cdi
>    Affects Versions: 2.11.1
>            Reporter: Karim de Fombelle
>
> Camel-CDI offers a mechanism to resolve property placeholders like  
> {{{{property1}}}} in an endpoint uri as described in camel 
> [documentation|http://camel.apache.org/using-propertyplaceholder.html]
> These placeholders could come from ConfigSource loaded via the deltaspike 
> configuration CDI extension and its ConfigResolver class according comments 
> on class
> Anyway this choice is surprising because the documentation of the 
> org.apache.deltaspike.core.api.config.PropertyFileConfig specifies the 
> following:
> {code}
>  *  <p>Please note that the configuration will only be available
>  *  after the boot is finished. This means that you cannot use
>  *  this configuration inside a CDI Extension before the boot
>  *  is finished!</p>
> {code}
> camel-cdi module contains a test class 
> _org.apache.camel.cdi.component.properties.PropertiesComponentTest_ which 
> IMHO does not illustrate the real use we would need in a CDI container.
> It support placeholders replacing after the boot of the CDI container, which 
> is inline with the javdoc illustrated below.
> But from my standpoint the real benefit would be to use such a feature as 
> follows:
> {code}
> @RunWith(Arquillian.class)
> @ApplicationScoped
> public class CamelCdiCamel5986Test {
>     //~ 
> ----------------------------------------------------------------------------------------------------------------
>     //~ Instance fields 
>     //~ 
> ----------------------------------------------------------------------------------------------------------------
>     @Inject
>     private SampleConfigBean bean;
>     @Inject
>     @Mock("mock:{{property1}}")
>     private MockEndpoint mockEndpoint;
>     //~ 
> ----------------------------------------------------------------------------------------------------------------
>     //~ Methods 
>     //~ 
> ----------------------------------------------------------------------------------------------------------------
>     @Deployment
>     public static Archive<?> createDeployment() {
>         //J-
>         JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
>                         .addClasses(TestRouteBuilder.class, 
> SampleConfigBean.class)
>                         
> .addAsResource("META-INF/camel.properties")//according CdiConfigFile
>                         .addPackages(true, 
> ConfigurationExtension.class.getPackage())
>                         .addPackages(true, CdiCamelContext.class.getPackage())
>                         .addAsManifestResource(EmptyAsset.INSTANCE, 
> "beans.xml");
>         return jar;
>         //J+
>     }
>     @Test
>     public void testConfiguration() {
>         assertNotNull("bean config is null", bean);
>         assertNotNull("mockEndpoint is null", mockEndpoint);
>         assertEquals("end", bean.getProperty1());
>     }
>     //~ 
> ----------------------------------------------------------------------------------------------------------------
>     //~ Inner Classes 
>     //~ 
> ----------------------------------------------------------------------------------------------------------------
>     @ContextName
>     public static class TestRouteBuilder extends RouteBuilder {
>         @Override
>         public void configure() throws Exception {
>             from("direct:begin").to("mock:{{property1}}");
>         }
>     }
>     public static class SampleConfigBean {
>         @Inject
>         @ConfigProperty(name = "property1")
>         private String property1;
>         public String getProperty1() {
>             return property1;
>         }
>     }
>     /**
>      * Copy of class from camel-cdi test class 
> org.apache.camel.cdi.support.CdiConfigFile
>      */
>     public static class CdiConfigFile implements PropertyFileConfig {
>         private static final long serialVersionUID = 1L;
>         @Override
>         public String getPropertyFileName() {
>             return "META-INF/camel.properties";
>         }
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to