Hi Mitko,

I already looked at Open eHealth and this is indeed an interesting example.

I also started to look at extending RouteBuilder but quickly figured out
that it wouldn't be that easy. And since I'm currently more interested at
using the XML DSL, it wouldn't help me much.

But last night I had a small idea at how I could customize the XML DSL. I
didn't have the time to try it yet (my wife would have killed me if I would
have tried during the night ;-). But here is it:
1 - Copy/paste what has been done for OSGI to provide my own
CamelNamespaceHandler
2 - Extend manually the camel XSD to introduce my own construct (in a
distinct namespace)
3 - Provide an extended CamelContextBeanDefinitionParser to parse the
"camelContext" element. There we have access to the DOM tree of the
"camelContext" ...
4 - Traverse the DOM tree to find any element belonging to my namespace ...
and substitute them with standard Camel constructs. As we have access to the
SpringContext, we can even register any supportive Spring bean.
6 - Let the original implementation do its work on the updated DOM tree

Pros:
- No impact on camel-core / camel-spring
- Allow to create a template mechanism based on plain camel constructs

Cons:
- Only works for the XML DSL
- Need to change manually the Camel XSD

Any extra idea/remark is welcomed !

Regards,
Sebastien.

2011/2/10 mitko.kolev [via Camel] <
[email protected]>

> Hello Everyone,
>
> @Sebastian: maybe you could take a look at the Open eHealth integration
> Platform (named IPF). It has a Groovy DSL that extends the Camel Java DSL.
> Here is a link to get started
>
> http://repo.openehealth.org/confluence/display/ipf2/Core+features#Corefeatures-Scriptinglayer
>
> . If you use the IPF Groovy DSL in IDEA  you can even have auto
> completion, and type safety. If you have questions regarding IPF DSL, you
> may use the IPF user mailing lists.
>
> I am  also  tying to find a solution to change  the Camel Java DSL
> implementation so that it allows extension.In general my approach is
> simple: Extend RouteBuilder, make it return My RouteDefinition with my
> extensions.
>
> public abstract class MyRouteBuilder extends RouteBuilder {
> ...
>    @Override
>    public MyRouteBuilder from(String uri) {
>       return (MyRouteDefinition) super.from(uri);
>    }
> ...
> }
>
> public class MyRouteDefinition extends RouteDefinition {
> ...
>       public MyRouteDefinition noStreamCaching() {
>           return (MyRouteDefinition) super.noStreamCaching();
>       }
> ...
> }
>
> public class RouteDefinition extends ProcessorDefinition<RouteDefinition>
> {
> ...
>    public RouteDefinition noStreamCaching() {
>      setStreamCache("false");
>      StreamCaching.noStreamCaching(getInterceptStrategies());
>      return this;
>     }
> ...
> }
>
> There is one problem with this: currently rhe RouteDefinition class "does
> not allow" DSL extension ( because RouteBuilder.noStreamCaching() returns
> type RouteDefinition). This is so, because if you extends RouteDefinition,
> and you use streamCaching() you loose the type of your extension, so you
> won't be able to see your extensions in the IDE after streamCaching().
>
> This is not the case when you look at ProcessorDefinition, which
> RouteDefinition  extends. ProcessorDefinition is declared as:
>
> public abstract class ProcessorDefinition<Type extends
> ProcessorDefinition<Type>> ... {
> ...
>  public Type to(String uri) {
>  }
> ...
> }
> Note that, the class ProcessorDefinition "allows" DSL extensions, because
> it returns the generic Type, while RouteDefinition does not allow such
> extensions.
>
>
>  If I come up with a simple solution, that does not invove a lot of
> refactoring and duplication,  I will  write. If I do not find such
> solution I will post my results anyway.
>
>
> Regards,
> Mitko
>
>
>
>
>
>
>
> From:
> James Strachan <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=3379222&i=0>>
>
> To:
> [hidden email] <http://user/SendEmail.jtp?type=node&node=3379222&i=1>
> Date:
> 10.02.2011 13:13
> Subject:
> Re: How to extend the Spring DSL ?
> Sent by:
> [hidden email] <http://user/SendEmail.jtp?type=node&node=3379222&i=2>
>
>
>
> On 10 February 2011 11:25, sebastien.petrucci
> <[hidden email] <http://user/SendEmail.jtp?type=node&node=3379222&i=3>>
> wrote:
>
> >
> > Thank you for your answer.
> >
> > I just would like to better explain what I'm doing.
> >
> > I work on a product which is an integration platform for the financial
> > world. This product is used in some banks and coporates. Our product is
> > built on top of another commercial ESB, for which we provide a number of
> > specific extensions (custom connectors, message validation, statefull
> > routing ...)
> > As we want to rethink our product and move away from our current ESB,
> I'm
> > currently evaluating the various solutions available on the market. So
> far,
> > I've seen some of the bigger products (like Oracle SOA) as well as lower
> > level integration frameworks like Apache Camel or Spring Integration.
> >
> > To me, Camel has some trully some valuable assets ... the most important
> > being its simple and intuitive (java or XML) DSL. It really brings an
> added
> > value on multiple levels (dev, clarity, supportability, learning curve,
> > ....) that the other solutions don't have.
> > I truly thing that, it would be a KILLER FEATURE to make the DSL somehow
> > extendable.
> > That would allow users to wrap their custom components and expose them
> as
> > verbs, directly in the DSL ! This way, you can specialize Camel to suit
> your
> > needs, preferred practices and components, ... in an elegant way. To my
> > knowledge, nobody on the market proposes that !
> >
> > Please consider this as a possible enhencement for the future of Camel.
> >
> > In the meantime, I will continue my attempts to extend the Spring XML
> DSL
> > without impacting camel-spring.
>
> Note that there's nothing to stop you having custom DSLs outside of
> Camel's core. Making an extensible Java + XML + Scala DSL is gonna be
> hard (e.g. XSD pain) and quickly loses the value proposition of the
> DSL since for tooling a DSL must be static; but its easy right now to
> extend those (making new XSDs importing Camel's XSD, or deriving from
> the Java builders etc). This is how we do Camel BAM today...
> http://camel.apache.org/bam.html
>
> Though its worth questioning, do you really want new verbs or nouns?
> Often folks want to drop in their own components into Camel; wrap up
> some service or functionality as a black box then route into it or
> from it with standard Camel; for this the Camel Component / Endpoint
> abstraction seems a perfect fit.
>
> Its very trivial to make something which acts as a regular Camel
> Component; you've then logical names or 'verbs' for the individual
> endpoints/ports/features the component supports. You can then use
> regular Camel DSL to send events/messages into or out of any part of
> the component; so you can easily extend vanilla Camel to add any kind
> of service or feature; so long as you can represent it as a bean or
> endpoint.
>
> e.g. in your example you could do...
>
> <route>
>   <from uri="..." />
>   <to uri="mycompany:semantic-validation/somePackage"/>
>   <to uri="...">
> </route>
>
> --
> James
> -------
> FuseSource
> Email: [hidden email]<http://user/SendEmail.jtp?type=node&node=3379222&i=4>
> Web: http://fusesource.com
> Twitter: jstrachan
> Blog: http://macstrac.blogspot.com/
>
> Open Source Integration
>
>
>
>
>
>
>
> InterComponentWare AG:
> Vorstand: Peter Kirschbauer (Vors.), Jörg Stadler
> Aufsichtsratsvors.: Prof. Dr. Christof Hettich
> Firmensitz: 69190 Walldorf, Altrottstraße 31
> AG Mannheim HRB 351761 / USt.-IdNr.: DE 198388516
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/How-to-extend-the-Spring-DSL-tp3376044p3379222.html
>   To unsubscribe from How to extend the Spring DSL ?, click 
> here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3376044&code=c2ViYXN0aWVuLnBldHJ1Y2NpQGdtYWlsLmNvbXwzMzc2MDQ0fDMzMTgxNzA0Ng==>.
>
>

-- 
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-extend-the-Spring-DSL-tp3376044p3379281.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to