View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements. See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache license, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License. You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the license for the specific language governing permissions and
    15   * limitations under the license.
    16   */
    17  package org.apache.logging.log4j.core.jackson;
    18
    19  import java.io.Serializable;
    20
    21  import org.apache.logging.log4j.core.impl.ExtendedClassInfo;
    22  import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement;
    23
    24  import com.fasterxml.jackson.annotation.JsonCreator;
    25  import com.fasterxml.jackson.annotation.JsonIgnore;
    26  import com.fasterxml.jackson.annotation.JsonProperty;
    27  import com.fasterxml.jackson.annotation.JsonPropertyOrder;
    28  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
    29
    30  /**
    31   * Mix-in for {@link ExtendedStackTraceElement}.
    32   */
    33  @JsonPropertyOrder({ "class", "method", "file", "line", "exact", "location", "version" })
    34  abstract class ExtendedStackTraceElementMixIn implements Serializable {
    35
    36      private static final long serialVersionUID = 1L;
    37
    38      @JsonCreator
    39      public ExtendedStackTraceElementMixIn(
    40              // @formatter:off
    41              @JsonProperty("class") final String declaringClass,
    42              @JsonProperty("method") final String methodName,
    43              @JsonProperty("file") final String fileName,
    44              @JsonProperty("line") final int lineNumber,
    45              @JsonProperty("exact") final boolean exact,
    46              @JsonProperty("location") final String location,
    47              @JsonProperty("version") final String version
    48              // @formatter:on
    49      ) {
    50          // empty
    51      }
    52
    53      @JsonProperty("class")
    54      @JacksonXmlProperty(localName = "class", isAttribute = true)
    55      public abstract String getClassName();
    56
    57      @JsonProperty
    58      @JacksonXmlProperty(isAttribute = true)
    59      public abstract boolean getExact();
    60
    61      @JsonIgnore
    62      public abstract ExtendedClassInfo getExtraClassInfo();
    63
    64      @JsonProperty("file")
    65      @JacksonXmlProperty(localName = "file", isAttribute = true)
    66      public abstract String getFileName();
    67
    68      @JsonProperty("line")
    69      @JacksonXmlProperty(localName = "line", isAttribute = true)
    70      public abstract int getLineNumber();
    71
    72      @JsonProperty
    73      @JacksonXmlProperty(isAttribute = true)
    74      public abstract String getLocation();
    75
    76      @JsonProperty("method")
    77      @JacksonXmlProperty(localName = "method", isAttribute = true)
    78      public abstract String getMethodName();
    79
    80      @JsonIgnore
    81      abstract StackTraceElement getStackTraceElement();
    82
    83      @JsonProperty
    84      @JacksonXmlProperty(isAttribute = true)
    85      public abstract String getVersion();
    86
    87      @JsonIgnore
    88      public abstract boolean isNativeMethod();
    89
    90  }