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 <[email protected]> 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 <[email protected]> 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: <[email protected]> >> Date: 13 September 2016 at 22:59 >> Subject: [2/2] logging-log4j2 git commit: Deprecate factory method in >> favor of a builder. >> To: [email protected] >> >> >> 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/3846e2a8 >> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3846e2a8 >> >> Branch: refs/heads/master >> Commit: 3846e2a87b94639466c7ab25b333fdb4ded8defc >> Parents: 981677f >> Author: Gary Gregory <[email protected]> >> Authored: Tue Sep 13 20:58:56 2016 -0700 >> Committer: Gary Gregory <[email protected]> >> 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 <[email protected]> >> > > > > -- > E-Mail: [email protected] | [email protected] > 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 <[email protected]>
