[ 
https://issues.apache.org/jira/browse/CAMEL-18189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17716746#comment-17716746
 ] 

Grzegorz Grzybek commented on CAMEL-18189:
------------------------------------------

For a tiny moment I was thinking it's a matter of adding {{<beans>}} 
({{org.apache.camel.model.BeansDefinition)}} in addition to existing {{<bean>}} 
({{org.apache.camel.model.BeanDefinition}}) model.

The point is that {{org.apache.camel.reifier.BeanReifier#createProcessor()}} 
which uses {{org.apache.camel.model.BeanDefinition}} to create a _bean_ is 
using it to create a processor delegating to a method of a bean - there's no 
way to configure properties of the bean created and whatever form is used:
{code:xml}
  <bean xmlns="http://camel.apache.org/schema/spring"; beanType="fqcn" />
{code}
{code:xml}
  <bean xmlns="http://camel.apache.org/schema/spring"; ref="ref-to-a-bean" />
{code}

the bean is created by the registry - using the first form (with classname), 
the {{@Autowired}} Spring annotation is used and the bean may have the 
properties injected, however there's no way to declare in XML the 
properties/constructor arguments.

Existing {{<bean>}} means "bean processor which calls a bean (from the 
registry) method" and it wouldn't be wise to add 2nd meaning: "bean definition 
for a bean instance to put into the underlying registry"...

{{org.apache.camel.dsl.yaml.deserializers.BeansDeserializer#construct()}} is 
actually doing what should be done, but narrowed to yaml DSL - it parses the 
input (yaml) and adds the created beans (with proper {{properties}} handling - 
though without constructor args for example) to a registry obtained from 
{{org.apache.camel.CamelContext#getRegistry()}}... This doesn't help much in 
general (for XML DSL).

In other words, IMO {{org.apache.camel.model.BeanDefinition}} can't be reused 
to play two roles:
* bean processor
* bean definition (to populate the registry)

The naming curse is also visible here - for the new {{<bean>}} element:
* the XML element name should differ ({{<bean-definition>}}?)
* the new class in {{org.apache.camel.model}} should rather be called 
{{BeanDefinitionDefinition}} (:panic:) and should NOT extend 
{{org.apache.camel.model.ProcessorDefinition}}

Well, the journey continues.

> camel-core - XML DSL <beans> for custom beans and to embed Camel routes in 
> same file
> ------------------------------------------------------------------------------------
>
>                 Key: CAMEL-18189
>                 URL: https://issues.apache.org/jira/browse/CAMEL-18189
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-core-xml
>            Reporter: Claus Ibsen
>            Assignee: Grzegorz Grzybek
>            Priority: Major
>             Fix For: Future
>
>
> We may consider a root tag such as <beans> that are Camel specific and 
> therefore works on all runtimes, where we can have basic support for 
> dependency injection with <bean> and also embed Camel <routes> and <rests> 
> and <routeConfigurations> and <routeTemplates> etc all in the same file.
> This can be handy for low-code projects with Camel K / Camel JBang.



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

Reply via email to