001 // Copyright 2004, 2005 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.tapestry.pages; 016 017 import org.apache.tapestry.INamespace; 018 import org.apache.tapestry.TapestryUtils; 019 import org.apache.tapestry.engine.ISpecificationSource; 020 import org.apache.tapestry.event.PageDetachListener; 021 import org.apache.tapestry.html.BasePage; 022 import org.apache.tapestry.util.exception.ExceptionAnalyzer; 023 import org.apache.tapestry.util.exception.ExceptionDescription; 024 025 /** 026 * Default exception reporting page. 027 * 028 * @author Howard Lewis Ship 029 */ 030 031 public abstract class Exception extends BasePage implements PageDetachListener 032 { 033 /** @since 4.1.4 */ 034 public abstract String getPagePackages(); 035 /** @since 4.1.4 */ 036 public abstract String getComponentPackages(); 037 /** @since 4.1.4 */ 038 public abstract ISpecificationSource getSpecificationSource(); 039 040 /** Transient property. */ 041 public abstract void setExceptions(ExceptionDescription[] exceptions); 042 043 public void setException(Throwable value) 044 { 045 ExceptionAnalyzer analyzer = new ExceptionAnalyzer(); 046 047 ExceptionDescription[] exceptions = analyzer.analyze(value); 048 049 setExceptions(exceptions); 050 } 051 052 public boolean isDynamic() 053 { 054 return getRequestCycle().getResponseBuilder().isDynamic(); 055 } 056 057 public String[] getPackages() 058 { 059 INamespace namespace = getSpecificationSource().getApplicationNamespace(); 060 String pages = namespace.getPropertyValue(getPagePackages()); 061 String comps = namespace.getPropertyValue(getComponentPackages()); 062 063 StringBuffer sb = new StringBuffer(); 064 if (pages != null) 065 { 066 sb.append(pages); 067 068 if (comps!=null) 069 sb.append(","); 070 } 071 072 if (comps != null) 073 sb.append(comps); 074 075 return TapestryUtils.split(sb.toString(), ','); 076 } 077 }