001    // Copyright 2006, 2008 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry5.ioc.internal.services;
016    
017    import org.apache.tapestry5.ioc.internal.util.InternalUtils;
018    import org.apache.tapestry5.ioc.services.ExceptionInfo;
019    
020    import static java.util.Collections.unmodifiableList;
021    import java.util.List;
022    import java.util.Map;
023    
024    public class ExceptionInfoImpl implements ExceptionInfo
025    {
026        private final String className;
027    
028        private final String message;
029    
030        private final Map<String, Object> properties;
031    
032        private final List<StackTraceElement> stackTrace;
033    
034        public ExceptionInfoImpl(Throwable t, Map<String, Object> properties, List<StackTraceElement> stackTrace)
035        {
036            className = t.getClass().getName();
037            message = t.getMessage() != null ? t.getMessage() : "";
038    
039            this.properties = properties;
040            this.stackTrace = unmodifiableList(stackTrace);
041        }
042    
043        public String getClassName()
044        {
045            return className;
046        }
047    
048        public String getMessage()
049        {
050            return message;
051        }
052    
053        public Object getProperty(String name)
054        {
055            return properties.get(name);
056        }
057    
058        public List<String> getPropertyNames()
059        {
060            return InternalUtils.sortedKeys(properties);
061        }
062    
063        public List<StackTraceElement> getStackTrace()
064        {
065            return stackTrace;
066        }
067    
068    }