01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.wicket.util.io;
18:
19: import java.io.NotSerializableException;
20: import java.util.ArrayList;
21: import java.util.List;
22:
23: import org.apache.wicket.util.string.AppendingStringBuffer;
24:
25: /**
26: * @author jcompagner
27: */
28: public class WicketSerializeableException extends
29: NotSerializableException {
30: private static final long serialVersionUID = 1L;
31:
32: private final List list;
33:
34: /**
35: * Construct.
36: *
37: * @param message
38: * @param cause
39: */
40: public WicketSerializeableException(String message) {
41: super (message);
42: list = new ArrayList();
43: }
44:
45: /**
46: * Construct.
47: *
48: * @param message
49: * @param cause
50: */
51: public WicketSerializeableException(String message, Throwable cause) {
52: this (message);
53: initCause(cause);
54: }
55:
56: /**
57: * @see java.lang.Throwable#getMessage()
58: */
59: public String getMessage() {
60: AppendingStringBuffer asb = new AppendingStringBuffer(super
61: .getMessage());
62: if (list.size() > 0) {
63: asb.append("\n");
64: for (int i = list.size(); --i >= 0;) {
65: String element = (String) list.get(i);
66: asb.append(element);
67: asb.append("->");
68: }
69: asb.setLength(asb.length() - 2);
70: }
71: asb
72: .append(
73: "\nNOTE: if you feel Wicket is at fault with this exception")
74: .append(
75: ", please report to the mailing list. You can switch to ")
76: .append("JDK based serialization by calling: ")
77: .append(
78: "org.apache.wicket.util.lang.Objects.setObjectStreamFactory(")
79: .append(
80: "new IObjectStreamFactory.DefaultObjectStreamFactory()) ")
81: .append("e.g. in the init method of your application");
82: return asb.toString();
83: }
84:
85: /**
86: * @param traceString
87: */
88: public void addTrace(String traceString) {
89: list.add(traceString);
90: }
91: }
|