Language Injection and base DomElements with DOM Api

Hi,

Is currently any support for 'base elements' within the Dom Api?

IE, the XML looks like the following (Apache Camel XML DSL)

<setBody>
    <expression>...</expression>
</setBody>


Where the 'expression' element may be one of the following elements

<groovy>...</groovy>
<javaScript>...</javaScript>
<php>..</php>


I have envision the code to maybe look like the following, of course it doesn't work though as the TagName won't be valid! :(

public interface SetBody extends DomElement {
    Expression getExpression();
}
public interface Expression extends DomElement {
  String getValue();
}

public interface groovy extends Expression {
}


public interface javaScript extends Expression { }

public interface php extends Expression { }


Is there a way to do this?

I also wonder if there is any annotations to inject a language in with the DOM Api? I could not find any documentation or previous discussions on this matter sadly

IE Is there an annotation describing @LanguageInjection("languageId") or such

public interface javaScript extends Expression {
    @LangaugeInjection("javaScript")
    String getValue();
}



Any help would be much appreciated! :)

Thanks

1 comment

AFAIK you'll have to provide typed getters for each DomElement variant which could be nested. Ofcourse, common functionality can be extracted into super-class.

There's so such "automatic" language injection annotation, you can use MultiHostInjector and match against DomPattern or provide configuration file for IntelliLang plugin (user-configurable, but IntelliLang plugin needs to be activated). The latter also does not offer some advanced functionality as e.g. providing special context objects programatically for resolving.

PS: Could you share your status/plans for Apache Camel support?

0

Please sign in to leave a comment.