logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: PluginAttribute choice
Date Mon, 02 Jun 2014 14:22:22 GMT
If we support typed attributes as we do now, you can still use Strings
everywhere, it's up to the plugin author.

I really did not like seeing the same String to foo type conversion code in
each plugin. The less boiler plate code the better.

There is less room for error when you declare your param as an int or other
(primitive or not) type. It's a nice separation of concerns.

Gary


On Mon, Jun 2, 2014 at 9:56 AM, Paul Benedict <pbenedict@apache.org> wrote:

> I go back and forth with the need to have plugin attributes be strongly
> typed. First, I am not a fan of it because annotations don't support
> multiple types well (as Ralph said) and string expressions can be pretty
> powerful if you want to allow script expressions (as Ralph said). That is
> my real opinion of the matter. But I don't mind being a team player to help
> other designs... :-) If you all do decide to go with strongly typed
> annotations, definitely go with multiple annotation types (as I proposed a
> few days back).
>
> Yet I don't think you guys should worry too much about strongly typed data
> here because annotation processing is all about validating the metadata --
> no matter what you choose. There isn't any tangible gain on making this
> feature strongly typed. I would simply treat the default value as an
> expression and call it a day. That will remove the added complexity of
> needing other annotations.
>
>
>
> Cheers,
> Paul
>
>
> On Mon, Jun 2, 2014 at 8:48 AM, Matt Sicker <boards@gmail.com> wrote:
>
>> Jackson is how we handle YAML and JSON configs anyways. It might be worth
>> looking into for 2.1.
>>
>>
>> On 2 June 2014 08:19, Gary Gregory <garydgregory@gmail.com> wrote:
>>
>>> I'm not trying to handle all cases under the sun. But... we've chosen
>>> NOT to use an XML Schema based XML IO framework (like JAXB or Jackson),
>>> instead we've invented our own. I know we do JSON as well, but so does
>>> Jackson and it likely also has a plugin for YAML. So now, every time I'm
>>> looking for some minor improvement, it means tweaking our custom framework
>>> or adding boilerplate code to plugins. It's a pain, but that's where we are
>>> today. At least now, with the new type converters, I get the type
>>> conversion from to int for free :-)
>>>
>>> In this case, I meant, you can only use attribute A or B.
>>>
>>> It is probably worth stepping back and looking at the big picture and
>>> whether we want to invest in improving the current config IO framework or
>>> at least consider if Jackson would be a better fit. Likely not for 2.0 ;-)
>>>
>>> Gary
>>>
>>>
>>> On Mon, Jun 2, 2014 at 4:03 AM, Ralph Goers <rgoers@apache.org> wrote:
>>>
>>>> Are you looking for annotations to handle every kind of thing you might
>>>> like to do instead of just putting a couple lines of code in the factory
>>>> method? I would have handled this by saying foo and bar both need to be
>>>> Integer and then adding a line do code that insures exactly one, or at most
>>>> one, is present ( depending on what you want ).
>>>>
>>>> I really have no idea what it means for an attribute or element to be
>>>> in a "choice". Does it mean at most one is specified or exactly one? What
>>>> if I want exactly one in some cases and at most one in others?
>>>>
>>>> Ralph
>>>>
>>>> On Jun 1, 2014, at 11:53 PM, Gary Gregory <garydgregory@gmail.com>
>>>> wrote:
>>>>
>>>> How do I tell my plugin that it can have attribute1 or 2, but not both?
>>>> IOW I want the config framework to do the validation for me.
>>>>
>>>> How about:
>>>>
>>>>
>>>> @PluginAttribute(choice="group1") int foo,
>>>>
>>>>
>>>>
>>>>
>>>> @PluginAttribute(choice="group1") int bar
>>>>
>>>> Same thing for elements.
>>>>
>>>> Thoughts?
>>>>
>>>> Gary
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> Java Persistence with Hibernate, Second Edition
>>>> <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>>
>>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> Java Persistence with Hibernate, Second Edition
>>> <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>
>>
>>
>> --
>> Matt Sicker <boards@gmail.com>
>>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
View raw message