Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C94EA10D32 for ; Sun, 1 Jun 2014 23:00:41 +0000 (UTC) Received: (qmail 58929 invoked by uid 500); 1 Jun 2014 23:00:41 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 58898 invoked by uid 500); 1 Jun 2014 23:00:41 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 58885 invoked by uid 99); 1 Jun 2014 23:00:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Jun 2014 23:00:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Jun 2014 23:00:42 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B00672388AA7; Sun, 1 Jun 2014 23:00:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1599076 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginBuilderAttributeVisitor.java Date: Sun, 01 Jun 2014 23:00:17 -0000 To: commits@logging.apache.org From: mattsicker@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140601230017.B00672388AA7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mattsicker Date: Sun Jun 1 23:00:17 2014 New Revision: 1599076 URL: http://svn.apache.org/r1599076 Log: Add visitor strategy for @PluginBuilderAttribute. Added: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginBuilderAttributeVisitor.java (with props) Added: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginBuilderAttributeVisitor.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginBuilderAttributeVisitor.java?rev=1599076&view=auto ============================================================================== --- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginBuilderAttributeVisitor.java (added) +++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginBuilderAttributeVisitor.java Sun Jun 1 23:00:17 2014 @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.logging.log4j.core.config.plugins.visitors; + +import java.util.Map; + +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.core.config.Node; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; + +/** + * PluginVisitor for PluginBuilderAttribute. If {@code null} is returned for the + * {@link #visit(org.apache.logging.log4j.core.config.Configuration, org.apache.logging.log4j.core.config.Node, org.apache.logging.log4j.core.LogEvent)} + * method, then the default value of the field should remain untouched. + * + * @see org.apache.logging.log4j.core.config.plugins.util.PluginBuilder + */ +public class PluginBuilderAttributeVisitor extends AbstractPluginVisitor { + + public PluginBuilderAttributeVisitor() { + super(PluginBuilderAttribute.class); + } + + @Override + public Object visit(final Configuration configuration, final Node node, final LogEvent event) { + final String overridden = this.annotation.value(); + final String name = overridden.isEmpty() ? this.member.getName() : overridden; + final Map attributes = node.getAttributes(); + final String rawValue = removeAttributeValue(attributes, name, this.aliases); + final String replacedValue = this.substitutor.replace(event, rawValue); + final Object value = convert(replacedValue, null); + LOGGER.debug("Attribute({}=\"{}\")", name, value); + return value; + } +} Propchange: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginBuilderAttributeVisitor.java ------------------------------------------------------------------------------ svn:eol-style = native