1 18 package org.apache.beehive.netui.compiler.genmodel; 19 20 import org.apache.beehive.netui.compiler.model.ExceptionModel; 21 import org.apache.beehive.netui.compiler.model.ForwardContainer; 22 import org.apache.beehive.netui.compiler.model.ExceptionContainer; 23 import org.apache.beehive.netui.compiler.JpfLanguageConstants; 24 import org.apache.beehive.netui.compiler.CompilerUtils; 25 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; 26 import org.apache.beehive.netui.compiler.typesystem.declaration.MethodDeclaration; 27 import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration; 28 29 import java.util.List ; 30 import java.util.Collection ; 31 import java.util.Iterator ; 32 33 34 public class GenExceptionModel 35 extends ExceptionModel 36 implements JpfLanguageConstants 37 { 38 public GenExceptionModel( GenStrutsApp parentApp, AnnotationInstance annotation, ClassDeclaration jclass, 39 ForwardContainer forwardContainer ) 40 { 41 super( parentApp ); 42 43 setType( CompilerUtils.getLoadableName( CompilerUtils.getDeclaredType( annotation, TYPE_ATTR, true ) ) ); 44 setPath( CompilerUtils.getString( annotation, PATH_ATTR, true ) ); 45 setMessage( CompilerUtils.getString( annotation, MESSAGE_ATTR, true ) ); 46 setMessageKey( CompilerUtils.getString( annotation, MESSAGE_KEY_ATTR, true ) ); 47 String methodName = CompilerUtils.getString( annotation, METHOD_ATTR, true ); 48 setHandlerMethod( methodName ); 49 50 51 if ( methodName != null ) 56 { 57 MethodDeclaration method = CompilerUtils.getClassMethod( jclass, methodName, EXCEPTION_HANDLER_TAG_NAME ); 58 AnnotationInstance exHandlerAnnotation = CompilerUtils.getAnnotation( method, EXCEPTION_HANDLER_TAG_NAME ); 59 GenForwardModel.addForwards( exHandlerAnnotation, forwardContainer, jclass, parentApp, 60 " from exception-handler " + methodName ); 62 Boolean readOnly = CompilerUtils.getBoolean( exHandlerAnnotation, READONLY_ATTR, true ); 66 if ( readOnly == null ) 67 { 68 readOnly = Boolean.valueOf( parentApp.getFlowControllerInfo().getMergedControllerAnnotation().isReadOnly() ); 69 } 70 setReadonly( readOnly.booleanValue() ); 71 } 72 } 73 74 static void addCatches( AnnotationInstance annotation, ExceptionContainer container, ClassDeclaration jclass, 75 GenStrutsApp strutsApp, ForwardContainer forwardContainer ) 76 { 77 List catches = CompilerUtils.getAnnotationArray( annotation, CATCHES_ATTR, true ); 78 addCatches( catches, container, jclass, strutsApp, forwardContainer ); 79 } 80 static void addCatches( Collection catches, ExceptionContainer container, 81 ClassDeclaration jclass, GenStrutsApp strutsApp, ForwardContainer forwardContainer ) 82 { 83 if ( catches != null ) 84 { 85 for ( Iterator ii = catches.iterator(); ii.hasNext(); ) 86 { 87 AnnotationInstance i = ( AnnotationInstance ) ii.next(); 88 container.addException( new GenExceptionModel( strutsApp, i, jclass, forwardContainer ) ); 89 } 90 } 91 } 92 } 93 | Popular Tags |