logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Sicker <boa...@gmail.com>
Subject Re: [2/2] logging-log4j2 git commit: Deprecate factory method in favor of a builder.
Date Wed, 14 Sep 2016 17:22:52 GMT
There's an enum converter that supports all enums, so yeah, it should work.

On 14 September 2016 at 12:06, Gary Gregory <garydgregory@gmail.com> wrote:

> Nah, builders and factories should use the best type possible.
>
> I have seen the light WRT Builders. It is the best way to provide some
> kind of easy migration and adding new features. You never need to deprecate
> a factory method.
>
> I'd like to be able to use a TimeUnit as a Builder arg. Will that work out
> of the box? I recall I wrote some conversion code for other classes
> someplace at some time in the past...
>
> Gary
>
> On Wed, Sep 14, 2016 at 6:45 AM, Matt Sicker <boards@gmail.com> wrote:
>
>> We'll need a different solution for programmatic configuration. The
>> current main supported programmatic config is via the configuration builder
>> classes which rely on strings more so than objects.
>>
>> On 13 September 2016 at 23:26, Gary Gregory <garydgregory@gmail.com>
>> wrote:
>>
>>> Good to know, I'll add that. But... we still need the check in the
>>> builders for programmatic configurations.
>>>
>>> Gary
>>>
>>> On Tue, Sep 13, 2016 at 9:11 PM, Matt Sicker <boards@gmail.com> wrote:
>>>
>>>> If you use @Required on an array, it checks for non-null and non-empty.
>>>> Works on strings, collections, and maps with the same semantics.
>>>>
>>>> ---------- Forwarded message ----------
>>>> From: <ggregory@apache.org>
>>>> Date: 13 September 2016 at 22:59
>>>> Subject: [2/2] logging-log4j2 git commit: Deprecate factory method in
>>>> favor of a builder.
>>>> To: commits@logging.apache.org
>>>>
>>>>
>>>> Deprecate factory method in favor of a builder.
>>>>
>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit
>>>> /3846e2a8
>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3
>>>> 846e2a8
>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3
>>>> 846e2a8
>>>>
>>>> Branch: refs/heads/master
>>>> Commit: 3846e2a87b94639466c7ab25b333fdb4ded8defc
>>>> Parents: 981677f
>>>> Author: Gary Gregory <ggregory@apache.org>
>>>> Authored: Tue Sep 13 20:58:56 2016 -0700
>>>> Committer: Gary Gregory <ggregory@apache.org>
>>>> Committed: Tue Sep 13 20:58:56 2016 -0700
>>>>
>>>> ----------------------------------------------------------------------
>>>>  .../log4j/core/appender/routing/Routes.java     | 51
>>>> ++++++++++++++++++--
>>>>  1 file changed, 47 insertions(+), 4 deletions(-)
>>>> ----------------------------------------------------------------------
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3
>>>> 846e2a8/log4j-core/src/main/java/org/apache/logging/log4j/co
>>>> re/appender/routing/Routes.java
>>>> ----------------------------------------------------------------------
>>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java
>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/app
>>>> ender/routing/Routes.java
>>>> index aae4087..c95b64a 100644
>>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/app
>>>> ender/routing/Routes.java
>>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/app
>>>> ender/routing/Routes.java
>>>> @@ -21,8 +21,8 @@ import java.util.Objects;
>>>>  import org.apache.logging.log4j.Logger;
>>>>  import org.apache.logging.log4j.core.config.plugins.Plugin;
>>>>  import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
>>>> +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFa
>>>> ctory;
>>>>  import org.apache.logging.log4j.core.config.plugins.PluginElement;
>>>> -import org.apache.logging.log4j.core.config.plugins.PluginFactory;
>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>
>>>>  /**
>>>> @@ -31,6 +31,48 @@ import org.apache.logging.log4j.status.StatusLogger;
>>>>  @Plugin(name = "Routes", category = "Core", printObject = true)
>>>>  public final class Routes {
>>>>
>>>> +    public static class Builder implements
>>>> org.apache.logging.log4j.core.util.Builder<Routes>  {
>>>> +
>>>> +        @PluginAttribute("pattern")
>>>> +        private String pattern;
>>>> +
>>>> +        @PluginElement("Routes")
>>>> +        private Route[] routes;
>>>> +
>>>> +        @Override
>>>> +        public Routes build() {
>>>> +            if (routes == null || routes.length == 0) {
>>>> +                LOGGER.error("No routes configured");
>>>> +                return null;
>>>> +            }
>>>> +            return new Routes(pattern, routes);
>>>> +        }
>>>> +
>>>> +        public String getPattern() {
>>>> +            return pattern;
>>>> +        }
>>>> +
>>>> +        public Route[] getRoutes() {
>>>> +            return routes;
>>>> +        }
>>>> +
>>>> +        public Builder withPattern(@SuppressWarnings("hiding") String
>>>> pattern) {
>>>> +            this.pattern = pattern;
>>>> +            return this;
>>>> +        }
>>>> +
>>>> +        public Builder withRoutes(@SuppressWarnings("hiding") Route[]
>>>> routes) {
>>>> +            this.routes = routes;
>>>> +            return this;
>>>> +        }
>>>> +
>>>> +    }
>>>> +
>>>> +    @PluginBuilderFactory
>>>> +    public static Builder newBuilder() {
>>>> +        return new Builder();
>>>> +    }
>>>> +
>>>>      private static final Logger LOGGER = StatusLogger.getLogger();
>>>>
>>>>      private final String pattern;
>>>> @@ -90,11 +132,12 @@ public final class Routes {
>>>>       * @param pattern The pattern.
>>>>       * @param routes An array of Route elements.
>>>>       * @return The Routes container.
>>>> +     * @deprecated since 2.7; use {@link #newBuilder()}.
>>>>       */
>>>> -    @PluginFactory
>>>> +    @Deprecated
>>>>      public static Routes createRoutes(
>>>> -            @PluginAttribute("pattern") final String pattern,
>>>> -            @PluginElement("Routes") final Route... routes) {
>>>> +            final String pattern,
>>>> +            final Route... routes) {
>>>>          if (routes == null || routes.length == 0) {
>>>>              LOGGER.error("No routes configured");
>>>>              return null;
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> 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
>>>
>>
>>
>>
>> --
>> 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
>



-- 
Matt Sicker <boards@gmail.com>

Mime
View raw message