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 com.fasterxml.jackson.annotation.JsonIgnore;
20  import com.fasterxml.jackson.annotation.JsonProperty;
21  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
22  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
23  import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement;
24  import org.apache.logging.log4j.core.impl.ThrowableProxy;
25  
26  /**
27   * Mix-in for {@link org.apache.logging.log4j.core.impl.ThrowableProxy}.
28   */
29  abstract class ThrowableProxyWithStacktraceAsStringMixIn {
30  
31      @JsonProperty(JsonConstants.ELT_CAUSE)
32      @JacksonXmlProperty(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_CAUSE)
33      private ThrowableProxyWithStacktraceAsStringMixIn causeProxy;
34  
35      @JsonProperty
36      @JacksonXmlProperty(isAttribute = true)
37      private int commonElementCount;
38  
39      @JsonIgnore
40      private ExtendedStackTraceElement[] extendedStackTrace;
41  
42      @JsonProperty
43      @JacksonXmlProperty(isAttribute = true)
44      private String localizedMessage;
45  
46      @JsonProperty
47      @JacksonXmlProperty(isAttribute = true)
48      private String message;
49  
50      @JsonProperty
51      @JacksonXmlProperty(isAttribute = true)
52      private String name;
53  
54      @JsonIgnore
55      private transient Throwable throwable;
56  
57      @JsonIgnore
58      public abstract String getCauseStackTraceAsString();
59  
60      @JsonProperty(JsonConstants.ELT_EXTENDED_STACK_TRACE)
61      @JacksonXmlProperty(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_EXTENDED_STACK_TRACE)
62      public abstract String getExtendedStackTraceAsString();
63  
64      @JsonIgnore
65      public abstract StackTraceElement[] getStackTrace();
66  
67      @JsonProperty(JsonConstants.ELT_SUPPRESSED)
68      @JacksonXmlElementWrapper(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED)
69      @JacksonXmlProperty(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED_ITEM)
70      public abstract ThrowableProxy[] getSuppressedProxies();
71  
72      @JsonIgnore
73      public abstract String getSuppressedStackTrace();
74  
75      @JsonIgnore
76      public abstract Throwable getThrowable();
77  
78  }