Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Conditional XML feature?



On 14 October 2015 at 02:49, Tom Zeller <tzeller@xxxxxxxxxxxxxx> wrote:

> On Oct 6, 2015, at 2:48 AM, Greg Wilkins <gregw@xxxxxxxxxxx> wrote:
>
>
> We have been increasingly parametrizing the XML configuration so that most commonly set values can come from properties, so the XML is full of lots of clauses like:
>
> <Set name="someName"><Property name="scope.someName" default="someValue" /></Set>
>
> This works fine except for the issue that the default value has to be hard coded into the XML and the java (for embedded usage).   For the best part of 20 years I've rejected the idea of conditional XML (just write java!), but I'm kind of thinking now that it would be good to avoid the default value by having XML like:
>
> <If name="scope.someName"><Set name="someName"><Property name="scope.someName"/></Set></If>
>
> So the set would be done only if the property was set and thus no default value is needed.  This would also allow multiple statements which could provide conditional configuration which would otherwise need a module (or XML editing) and could even have <Else?> clauses.
>
> Is this a bad idea or something we should consider for 9.4.0?

I don’t know :-)

However, in your example above, I don’t know what :

 <If name="scope.someName”>

refers to. Whose name ?


It is just the name of any property.  In this example it is the property that is used to get the value for a Set call.  So it could be something like:

   <If name="https.port"><Set name="port"><Property name="https.port"/></Set></If>

But it could also be used with a gating property name:


   <If name="https.enabled">
      <Set name="scheme">https</Set>
      <Set name="port"><Property name="https.port"/></Set>
      <Call name="addCustomizer"><Arg><New class="o.e.j.s.SecureRequestCustomizer"/></Arg></Call>
   </If>


Also, if the default value for a <Property /> could itself be a property (probably not nested), that might alleviate hardcoding defaults in Java/XML.

Turtles all the way down :)

That may still be better than what we have, although I prefer having the defaults in the code rather than the ini files.

cheers



--

Back to the top