Author: mattsicker
Date: Mon May 26 04:43:16 2014
New Revision: 1597513
URL: http://svn.apache.org/r1597513
Log:
Add PluginVisitors for a few more annotations.
Added:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginConfigurationVisitor.java
(with props)
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginNodeVisitor.java
(with props)
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java
(with props)
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/SensitivePluginAttributeVisitor.java
(with props)
Added:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginConfigurationVisitor.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginConfigurationVisitor.java?rev=1597513&view=auto
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginConfigurationVisitor.java
(added)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginConfigurationVisitor.java
Mon May 26 04:43:16 2014
@@ -0,0 +1,43 @@
+/*
+ * 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 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.PluginConfiguration;
+
+/**
+ * PluginVisitor implementation for {@link PluginConfiguration}.
+ */
+public class PluginConfigurationVisitor extends
AbstractPluginVisitor<PluginConfiguration> {
+ public PluginConfigurationVisitor() {
+ super(PluginConfiguration.class);
+ }
+
+ @Override
+ public Object visit(final Configuration configuration, final Node node,
final LogEvent event) {
+ if (this.conversionType.isInstance(configuration)) {
+ LOGGER.debug("Configuration({})", configuration.getName());
+ return configuration;
+ }
+ LOGGER.warn("Variable annotated with @PluginConfiguration is not
compatible with type {}.",
+ configuration.getClass());
+ return null;
+ }
+}
Propchange:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginConfigurationVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginNodeVisitor.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginNodeVisitor.java?rev=1597513&view=auto
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginNodeVisitor.java
(added)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginNodeVisitor.java
Mon May 26 04:43:16 2014
@@ -0,0 +1,42 @@
+/*
+ * 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 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.PluginNode;
+
+/**
+ * PluginVisitor implementation for {@link PluginNode}
+ */
+public class PluginNodeVisitor extends AbstractPluginVisitor<PluginNode> {
+ public PluginNodeVisitor() {
+ super(PluginNode.class);
+ }
+
+ @Override
+ public Object visit(final Configuration configuration, final Node node,
final LogEvent event) {
+ if (this.conversionType.isInstance(node)) {
+ LOGGER.debug("Node={}", node.getName());
+ return node;
+ }
+ LOGGER.warn("Variable annotated with @PluginNode is not compatible
with the type {}.", node.getClass());
+ return null;
+ }
+}
Propchange:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginNodeVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java?rev=1597513&view=auto
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java
(added)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java
Mon May 26 04:43:16 2014
@@ -0,0 +1,42 @@
+/*
+ * 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 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.PluginValue;
+
+/**
+ * PluginVisitor implementation for {@link PluginValue}.
+ */
+public class PluginValueVisitor extends AbstractPluginVisitor<PluginValue> {
+ public PluginValueVisitor() {
+ super(PluginValue.class);
+ }
+
+ @Override
+ public Object visit(final Configuration configuration, final Node node,
final LogEvent event) {
+ final String name = this.annotation.value();
+ final String rawValue = node.getValue() != null ? node.getValue() :
+ removeAttributeValue(node.getAttributes(), "value");
+ final String value = this.substitutor.replace(event, rawValue);
+ LOGGER.debug("{}={}", name, value);
+ return value;
+ }
+}
Propchange:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/SensitivePluginAttributeVisitor.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/SensitivePluginAttributeVisitor.java?rev=1597513&view=auto
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/SensitivePluginAttributeVisitor.java
(added)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/SensitivePluginAttributeVisitor.java
Mon May 26 04:43:16 2014
@@ -0,0 +1,48 @@
+/*
+ * 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.SensitivePluginAttribute;
+import org.apache.logging.log4j.core.util.NameUtil;
+
+/**
+ * PluginVisitor implementation for {@link SensitivePluginAttribute}.
+ */
+public class SensitivePluginAttributeVisitor extends
AbstractPluginVisitor<SensitivePluginAttribute> {
+ public SensitivePluginAttributeVisitor() {
+ super(SensitivePluginAttribute.class);
+ }
+
+ @Override
+ public Object visit(final Configuration configuration, final Node node,
final LogEvent event) {
+ final String name = this.annotation.value();
+ final Map<String, String> attributes = node.getAttributes();
+ final String rawValue = removeAttributeValue(attributes, name,
this.aliases);
+ final String replacedValue = this.substitutor.replace(event, rawValue);
+ final String rawDefaultValue = this.annotation.defaultValue();
+ final String replacedDefaultValue = this.substitutor.replace(event,
rawDefaultValue);
+ final Object value = convert(replacedValue, replacedDefaultValue);
+ LOGGER.debug("Attribute({}=\"{}\"", name, NameUtil.md5(value +
this.getClass().getName()));
+ return value;
+ }
+}
Propchange:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/SensitivePluginAttributeVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native