You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2014/05/28 06:12:11 UTC

org.apache.logging.log4j.core.config.plugins.PluginAttribute.value()

PluginAttribute.value() looks misnamed, why not call it "name"?

This is better:

    @PluginFactory
    public static ConsoleAppender createAppender(
            @PluginElement("Layout") Layout<? extends Serializable> layout,
            @PluginElement("Filters") final Filter filter,
            @PluginAttribute(name= "target", defaultStringValue =
"SYSTEM_OUT") final String targetStr,
            @PluginAttribute("name") final String name,
            @PluginAttribute(name= "follow", defaultBooleanValue = false)
final String follow,
            @PluginAttribute(name= "ignoreExceptions", defaultBooleanValue
= true) final String ignore) {

than:

    @PluginFactory
    public static ConsoleAppender createAppender(
            @PluginElement("Layout") Layout<? extends Serializable> layout,
            @PluginElement("Filters") final Filter filter,
            @PluginAttribute(value = "target", defaultStringValue =
"SYSTEM_OUT") final String targetStr,
            @PluginAttribute("name") final String name,
            @PluginAttribute(value = "follow", defaultBooleanValue = false)
final String follow,
            @PluginAttribute(value = "ignoreExceptions",
defaultBooleanValue = true) final String ignore) {

IMO that is...

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

Re: org.apache.logging.log4j.core.config.plugins.PluginAttribute.value()

Posted by Matt Sicker <bo...@gmail.com>.
That actually reminds me. Would it be a good idea to make a separate
annotation for plugin attributes for a builder class? The default value can
be inferred by not setting anything after the constructor (real default
values), and the name can be inferred by the field name. Plus, it could go
with the whole String value() default "" bit to override the name.


On 27 May 2014 23:28, Matt Sicker <bo...@gmail.com> wrote:

> Would make sense for that annotation due to the default value things.
>
>
> On 27 May 2014 23:12, Gary Gregory <ga...@gmail.com> wrote:
>
>> PluginAttribute.value() looks misnamed, why not call it "name"?
>>
>> This is better:
>>
>>     @PluginFactory
>>     public static ConsoleAppender createAppender(
>>             @PluginElement("Layout") Layout<? extends Serializable>
>> layout,
>>             @PluginElement("Filters") final Filter filter,
>>             @PluginAttribute(name= "target", defaultStringValue =
>> "SYSTEM_OUT") final String targetStr,
>>             @PluginAttribute("name") final String name,
>>             @PluginAttribute(name= "follow", defaultBooleanValue = false)
>> final String follow,
>>             @PluginAttribute(name= "ignoreExceptions",
>> defaultBooleanValue = true) final String ignore) {
>>
>> than:
>>
>>     @PluginFactory
>>     public static ConsoleAppender createAppender(
>>             @PluginElement("Layout") Layout<? extends Serializable>
>> layout,
>>             @PluginElement("Filters") final Filter filter,
>>             @PluginAttribute(value = "target", defaultStringValue =
>> "SYSTEM_OUT") final String targetStr,
>>             @PluginAttribute("name") final String name,
>>             @PluginAttribute(value = "follow", defaultBooleanValue =
>> false) final String follow,
>>             @PluginAttribute(value = "ignoreExceptions",
>> defaultBooleanValue = true) final String ignore) {
>>
>> IMO that is...
>>
>> 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
>>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>



-- 
Matt Sicker <bo...@gmail.com>

Re: org.apache.logging.log4j.core.config.plugins.PluginAttribute.value()

Posted by Matt Sicker <bo...@gmail.com>.
Would make sense for that annotation due to the default value things.


On 27 May 2014 23:12, Gary Gregory <ga...@gmail.com> wrote:

> PluginAttribute.value() looks misnamed, why not call it "name"?
>
> This is better:
>
>     @PluginFactory
>     public static ConsoleAppender createAppender(
>             @PluginElement("Layout") Layout<? extends Serializable> layout,
>             @PluginElement("Filters") final Filter filter,
>             @PluginAttribute(name= "target", defaultStringValue =
> "SYSTEM_OUT") final String targetStr,
>             @PluginAttribute("name") final String name,
>             @PluginAttribute(name= "follow", defaultBooleanValue = false)
> final String follow,
>             @PluginAttribute(name= "ignoreExceptions", defaultBooleanValue
> = true) final String ignore) {
>
> than:
>
>     @PluginFactory
>     public static ConsoleAppender createAppender(
>             @PluginElement("Layout") Layout<? extends Serializable> layout,
>             @PluginElement("Filters") final Filter filter,
>             @PluginAttribute(value = "target", defaultStringValue =
> "SYSTEM_OUT") final String targetStr,
>             @PluginAttribute("name") final String name,
>             @PluginAttribute(value = "follow", defaultBooleanValue =
> false) final String follow,
>             @PluginAttribute(value = "ignoreExceptions",
> defaultBooleanValue = true) final String ignore) {
>
> IMO that is...
>
> 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
>



-- 
Matt Sicker <bo...@gmail.com>

Re: org.apache.logging.log4j.core.config.plugins.PluginAttribute.value()

Posted by Matt Sicker <bo...@gmail.com>.
Well, if we can agree to use the builder class pattern instead of the
factory method pattern, then default values are specified as default field
values which are already typed perfectly fine as a language feature since
day 1.

I'll work on updating my proposal with the alternate annotations to show
how easy this should be.


On 30 May 2014 15:30, Paul Benedict <pb...@apache.org> wrote:

> I don't see the added value in having
> defaultStringValue/defaultBooleanValue/defaultXYZValue. The complexity
> isn't justified, I think. Using a literal string is still much easier to
> comprehend; the type safety seems overkill.
>
>
> Cheers,
> Paul
>
>
> On Fri, May 30, 2014 at 3:25 PM, Matt Sicker <bo...@gmail.com> wrote:
>
>> I think as long as we add a javadoc (if it's not already there) to the
>> value() method, then we're good to go!
>>
>>
>> On 30 May 2014 13:32, Gary Gregory <ga...@gmail.com> wrote:
>>
>>> Hm... annotations do not work like that, if we renamed 'value' to
>>> 'name', you cannot use the short hand @PluginElement("Layout"), you'd have
>>> to use @PluginElement(name = "Layout")
>>>
>>> So I think we can drop this discussion... check?
>>>
>>> Gary
>>>
>>>
>>> On Wed, May 28, 2014 at 12:12 AM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>>> PluginAttribute.value() looks misnamed, why not call it "name"?
>>>>
>>>> This is better:
>>>>
>>>>     @PluginFactory
>>>>     public static ConsoleAppender createAppender(
>>>>             @PluginElement("Layout") Layout<? extends Serializable>
>>>> layout,
>>>>             @PluginElement("Filters") final Filter filter,
>>>>             @PluginAttribute(name= "target", defaultStringValue =
>>>> "SYSTEM_OUT") final String targetStr,
>>>>             @PluginAttribute("name") final String name,
>>>>             @PluginAttribute(name= "follow", defaultBooleanValue =
>>>> false) final String follow,
>>>>             @PluginAttribute(name= "ignoreExceptions",
>>>> defaultBooleanValue = true) final String ignore) {
>>>>
>>>> than:
>>>>
>>>>     @PluginFactory
>>>>     public static ConsoleAppender createAppender(
>>>>             @PluginElement("Layout") Layout<? extends Serializable>
>>>> layout,
>>>>             @PluginElement("Filters") final Filter filter,
>>>>             @PluginAttribute(value = "target", defaultStringValue =
>>>> "SYSTEM_OUT") final String targetStr,
>>>>             @PluginAttribute("name") final String name,
>>>>             @PluginAttribute(value = "follow", defaultBooleanValue =
>>>> false) final String follow,
>>>>             @PluginAttribute(value = "ignoreExceptions",
>>>> defaultBooleanValue = true) final String ignore) {
>>>>
>>>> IMO that is...
>>>>
>>>> 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 <bo...@gmail.com>
>>
>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: org.apache.logging.log4j.core.config.plugins.PluginAttribute.value()

Posted by Paul Benedict <pb...@apache.org>.
I don't see the added value in having
defaultStringValue/defaultBooleanValue/defaultXYZValue. The complexity
isn't justified, I think. Using a literal string is still much easier to
comprehend; the type safety seems overkill.


Cheers,
Paul


On Fri, May 30, 2014 at 3:25 PM, Matt Sicker <bo...@gmail.com> wrote:

> I think as long as we add a javadoc (if it's not already there) to the
> value() method, then we're good to go!
>
>
> On 30 May 2014 13:32, Gary Gregory <ga...@gmail.com> wrote:
>
>> Hm... annotations do not work like that, if we renamed 'value' to 'name',
>> you cannot use the short hand @PluginElement("Layout"), you'd have to use
>> @PluginElement(name = "Layout")
>>
>> So I think we can drop this discussion... check?
>>
>> Gary
>>
>>
>> On Wed, May 28, 2014 at 12:12 AM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>>> PluginAttribute.value() looks misnamed, why not call it "name"?
>>>
>>> This is better:
>>>
>>>     @PluginFactory
>>>     public static ConsoleAppender createAppender(
>>>             @PluginElement("Layout") Layout<? extends Serializable>
>>> layout,
>>>             @PluginElement("Filters") final Filter filter,
>>>             @PluginAttribute(name= "target", defaultStringValue =
>>> "SYSTEM_OUT") final String targetStr,
>>>             @PluginAttribute("name") final String name,
>>>             @PluginAttribute(name= "follow", defaultBooleanValue =
>>> false) final String follow,
>>>             @PluginAttribute(name= "ignoreExceptions",
>>> defaultBooleanValue = true) final String ignore) {
>>>
>>> than:
>>>
>>>     @PluginFactory
>>>     public static ConsoleAppender createAppender(
>>>             @PluginElement("Layout") Layout<? extends Serializable>
>>> layout,
>>>             @PluginElement("Filters") final Filter filter,
>>>             @PluginAttribute(value = "target", defaultStringValue =
>>> "SYSTEM_OUT") final String targetStr,
>>>             @PluginAttribute("name") final String name,
>>>             @PluginAttribute(value = "follow", defaultBooleanValue =
>>> false) final String follow,
>>>             @PluginAttribute(value = "ignoreExceptions",
>>> defaultBooleanValue = true) final String ignore) {
>>>
>>> IMO that is...
>>>
>>> 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 <bo...@gmail.com>
>

Re: org.apache.logging.log4j.core.config.plugins.PluginAttribute.value()

Posted by Matt Sicker <bo...@gmail.com>.
I think as long as we add a javadoc (if it's not already there) to the
value() method, then we're good to go!


On 30 May 2014 13:32, Gary Gregory <ga...@gmail.com> wrote:

> Hm... annotations do not work like that, if we renamed 'value' to 'name',
> you cannot use the short hand @PluginElement("Layout"), you'd have to use
> @PluginElement(name = "Layout")
>
> So I think we can drop this discussion... check?
>
> Gary
>
>
> On Wed, May 28, 2014 at 12:12 AM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> PluginAttribute.value() looks misnamed, why not call it "name"?
>>
>> This is better:
>>
>>     @PluginFactory
>>     public static ConsoleAppender createAppender(
>>             @PluginElement("Layout") Layout<? extends Serializable>
>> layout,
>>             @PluginElement("Filters") final Filter filter,
>>             @PluginAttribute(name= "target", defaultStringValue =
>> "SYSTEM_OUT") final String targetStr,
>>             @PluginAttribute("name") final String name,
>>             @PluginAttribute(name= "follow", defaultBooleanValue = false)
>> final String follow,
>>             @PluginAttribute(name= "ignoreExceptions",
>> defaultBooleanValue = true) final String ignore) {
>>
>> than:
>>
>>     @PluginFactory
>>     public static ConsoleAppender createAppender(
>>             @PluginElement("Layout") Layout<? extends Serializable>
>> layout,
>>             @PluginElement("Filters") final Filter filter,
>>             @PluginAttribute(value = "target", defaultStringValue =
>> "SYSTEM_OUT") final String targetStr,
>>             @PluginAttribute("name") final String name,
>>             @PluginAttribute(value = "follow", defaultBooleanValue =
>> false) final String follow,
>>             @PluginAttribute(value = "ignoreExceptions",
>> defaultBooleanValue = true) final String ignore) {
>>
>> IMO that is...
>>
>> 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 <bo...@gmail.com>

Re: org.apache.logging.log4j.core.config.plugins.PluginAttribute.value()

Posted by Gary Gregory <ga...@gmail.com>.
Hm... annotations do not work like that, if we renamed 'value' to 'name',
you cannot use the short hand @PluginElement("Layout"), you'd have to use
@PluginElement(name = "Layout")

So I think we can drop this discussion... check?

Gary


On Wed, May 28, 2014 at 12:12 AM, Gary Gregory <ga...@gmail.com>
wrote:

> PluginAttribute.value() looks misnamed, why not call it "name"?
>
> This is better:
>
>     @PluginFactory
>     public static ConsoleAppender createAppender(
>             @PluginElement("Layout") Layout<? extends Serializable> layout,
>             @PluginElement("Filters") final Filter filter,
>             @PluginAttribute(name= "target", defaultStringValue =
> "SYSTEM_OUT") final String targetStr,
>             @PluginAttribute("name") final String name,
>             @PluginAttribute(name= "follow", defaultBooleanValue = false)
> final String follow,
>             @PluginAttribute(name= "ignoreExceptions", defaultBooleanValue
> = true) final String ignore) {
>
> than:
>
>     @PluginFactory
>     public static ConsoleAppender createAppender(
>             @PluginElement("Layout") Layout<? extends Serializable> layout,
>             @PluginElement("Filters") final Filter filter,
>             @PluginAttribute(value = "target", defaultStringValue =
> "SYSTEM_OUT") final String targetStr,
>             @PluginAttribute("name") final String name,
>             @PluginAttribute(value = "follow", defaultBooleanValue =
> false) final String follow,
>             @PluginAttribute(value = "ignoreExceptions",
> defaultBooleanValue = true) final String ignore) {
>
> IMO that is...
>
> 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