You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Maria Arias de Reyna Dominguez <ma...@redhat.com> on 2021/07/26 07:14:41 UTC

Guides on how to add a new language?

Hi!

Do we have any documentation on how to create new languages in Camel?
Not use them, create them.

I'm thinking of adding a new geospatial language with capabilities for
conditionals like "if geometryA is contained inside geometryB" or
similar. This will help processing data by areas, for example. Or
filtering only the data that match certain spatial constraints.

I have seen how xpath language is defined in
https://github.com/apache/camel/tree/main/components/camel-xpath and I
think I can use that as an example of how to define a new language.

But then I see that I would have to touch core stuff like
https://github.com/apache/camel/blob/main/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClause.java
to be able to build the routes programmatically.

Does this mean that all languages must be on core in the end? There's
no way to make them optional/dependencies?

I'm trying to make it optional because I am going to use the geotools
library to handle geometries and that means another dependency I want
to avoid. Even if it is not big, it's another one.

Kind regards,
María.
She / Her / Hers


Re: Guides on how to add a new language?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yes its a good idea to look at camel-xpath, or some other language how
its implemented and integrated (datasonnet was last added new
language).

In the core you must add a "model" of the new language, which just is
like an interface and the DSL for the new language.
You can only use standard Java types (String, boolean, int, etc as
data types) in the core, if the language has some special
configuration options (however most languages dont really have any /
much configuration).
A language can also have a annotation that allows to use the language
with POJOs as part of parameter, like the @XPath annotation.

However the implementation of the language is a new component in the
components folder.

Just hack away and reach out if you need help.
Mind that there build system (when you compile) will auto generated
some extra source code in the src/main/generates folder when adding
new languages so that is not a problem.
And you can always just rm -rf src/main/generated if there is some
problem, and let it regenerate the source code again.




On Mon, Jul 26, 2021 at 9:16 AM Maria Arias de Reyna Dominguez
<ma...@redhat.com> wrote:
>
> Hi!
>
> Do we have any documentation on how to create new languages in Camel?
> Not use them, create them.
>
> I'm thinking of adding a new geospatial language with capabilities for
> conditionals like "if geometryA is contained inside geometryB" or
> similar. This will help processing data by areas, for example. Or
> filtering only the data that match certain spatial constraints.
>
> I have seen how xpath language is defined in
> https://github.com/apache/camel/tree/main/components/camel-xpath and I
> think I can use that as an example of how to define a new language.
>
> But then I see that I would have to touch core stuff like
> https://github.com/apache/camel/blob/main/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClause.java
> to be able to build the routes programmatically.
>
> Does this mean that all languages must be on core in the end? There's
> no way to make them optional/dependencies?
>
> I'm trying to make it optional because I am going to use the geotools
> library to handle geometries and that means another dependency I want
> to avoid. Even if it is not big, it's another one.
>
> Kind regards,
> María.
> She / Her / Hers
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2