Modified: incubator/beehive/trunk/netui/src/compiler-xdoclet/org/apache/beehive/netui/xdoclet/NetuiSubTask.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-xdoclet/org/apache/beehive/netui/xdoclet/NetuiSubTask.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-xdoclet/org/apache/beehive/netui/xdoclet/NetuiSubTask.java (original) +++ incubator/beehive/trunk/netui/src/compiler-xdoclet/org/apache/beehive/netui/xdoclet/NetuiSubTask.java Fri Apr 22 00:41:54 2005 @@ -16,8 +16,7 @@ /** - * XJavaDoc subtask to run through a set of pageflows in a webapp and generate struts-config files for them. - * This uses a lot of the generic compiler model objects and xml generation code fom com.bea.netui.pageflow.model. + * XJavaDoc subtask to run through a set of page flows in a webapp and generate Struts XML config files for them. * * @ant.element display-name="Netui" name="netui" parent="org.apache.beehive.netui.xdoclet.NetuiDocletTask" */ @@ -69,1267 +68,9 @@ { _currentSourceClass = null; } - /* - - for ( Iterator i = c.getMethods().iterator(); i.hasNext(); ) - { - XMethod method = ( XMethod ) i.next(); - XDoc doc = method.getDoc(); - System.err.println( " method " + method.getName() + ": " + method.getReturnType().getType().getName() + " : " + method.getModifiers() ); - List tags = doc.getTags(); - for ( Iterator j = tags.iterator(); j.hasNext(); ) - { - XTag tag = ( XTag ) j.next(); - System.err.println( " " + tag.getName() + ": " + tag.getValue() ); - - Collection attrs = tag.getAttributeNames(); - for ( Iterator k = attrs.iterator(); k.hasNext(); ) - { - String attrName = ( String ) k.next(); - System.err.println( " " + attrName + ": " + tag.getAttributeValue( attrName ) ); - } - } - } - */ - - /* - if ( c.isA( PAGEFLOW_CLASS_NAME, true ) ) - processJpf( c, false ); - else if ( c.isA( GLOBALAPP_BASE_CLASS_NAME, true ) ) - processJpf( c, true ); - else - { - // workaround for needing to import explicit types - if the pageflow package - // was imported, and we extend the right class name, go for it. - List pkgs = c.getImportedPackages(); - Iterator pkgIter = pkgs.iterator(); - boolean found = false; - while ( pkgIter.hasNext() ) - { - XPackage pkg = (XPackage) pkgIter.next(); - if ( pkg.getName().equals( PAGEFLOW_PACKAGE ) ) - { - found = true; - break; - } - } - - boolean isJpf = false; - if ( found ) - { - XClass superClass = c.getSuperclass(); - if ( superClass.getName().equals( PAGEFLOW_SHORT_CLASS_NAME ) ) - { - isJpf = true; - processJpf( c, false ); - } - else if ( superClass.getName().equals( GLOBALAPP_SHORT_CLASS_NAME ) ) - { - isJpf = true; - processJpf( c, true ); - } - } - - if ( !isJpf && !c.isInner() ) - { - // this is not a pageflow class, make sure it did not come from a .jpf file - try - { - File sourceFile = new File( ((SourceClass)c).getFile().getPath() ); - File f = XDocletStrutsApp.getOriginalJpfSourceFile( sourceFile.getName(), c, false ); - if ( f.exists() ) - { - CompilerUtil.error( f.toString(), CompilerUtil.genMessage( "pageflow.error.does-not-extend-base", new String[] {PAGEFLOW_CLASS_NAME} ) ); - } - f = XDocletStrutsApp.getOriginalJpfSourceFile( sourceFile.getName(), c, true ); - if ( f.exists() ) - { - CompilerUtil.error( f.toString(), CompilerUtil.genMessage( "pageflow.error.does-not-extend-base", new String[] {GLOBALAPP_BASE_CLASS_NAME} ) ); - } - } - catch ( NoWebInfDirectoryException e ) - { - // ignore - } - } - } - */ - } - } - - /* - protected void processJpf( XClass jpfClass, boolean global ) - throws XDocletException - { - _pageflowCount++; - try - { - File webappRoot = XDocletStrutsApp.getWebappRootFromJpf(); - File strutsConfigDir = new File( webappRoot + STRUTS_OUTPUT_DIR ); - if ( !strutsConfigDir.exists() ) - { - strutsConfigDir.mkdirs(); - } - - _isGlobal = global; - StringBuffer configFileName = new StringBuffer(); - if ( _isGlobal ) - { - configFileName.append( STRUTS_CONFIG_PREFIX ) - .append( GLOBALAPP_MODULE_NAME ) - .append( STRUTS_CONFIG_EXTENSION ); - } - else - { - XPackage pkg = jpfClass.getContainingPackage(); - if ( !pkg.isDefaultPackage() ) - { - configFileName.append( STRUTS_CONFIG_PREFIX ); - configFileName.append( pkg.getName().replace( '.', '-' ) ); - configFileName.append( STRUTS_CONFIG_EXTENSION ); - } - else - { - configFileName.append( ROOT_STRUTS_CONFIG ); - } - } - File strutsConfigFile = new File( strutsConfigDir, configFileName.toString() ); - - // note: webapp root is not used in this situation - _strutsApp = new XDocletStrutsApp( jpfClass.getContainingPackage().getName(), strutsConfigFile, - webappRoot.getPath(), jpfClass, global ); - _strutsApp.setJpfSourceFile( new File( ((SourceClass)jpfClass).getFile().getPath() ) ); - - if ( DocletContext.getInstance().isVerbose() ) - { - System.out.println( CompilerUtil.genMessage( "compiler.info.gen.file", - new String[] { configFileName.toString(), jpfClass.getQualifiedName() } ) ); - System.out.println( CompilerUtil.genMessage( "compiler.info.original.jpf", - new String[] {_strutsApp.getOriginalJpfSourceFile().getPath()} ) ); - } - - File originalJpf = _strutsApp.getOriginalJpfSourceFile(); - File jpfParentDir = originalJpf.getParentFile(); - String jpfName = originalJpf.getName(); - - if ( global ) - { - // if global, make sure the file name is correct and it's in the right place - if ( !jpfName.equals( GLOBALAPP_FILENAME ) ) - CompilerUtil.error( "pageflow.error.global-app-wrong-name", (String[])null ); - - XPackage pkg = jpfClass.getContainingPackage(); - String pkgName = pkg.getName(); - if ( !pkgName.equals( GLOBALAPP_PACKAGE ) ) - CompilerUtil.error( "pageflow.error.wrong-package", new String[] {GLOBALAPP_PACKAGE} ); - - String fullGlobalPath = _strutsApp.getWebappRootPath() + File.separatorChar + GLOBALAPP_SOURCE_DIR; - String myPath = jpfParentDir.getPath(); - if ( !myPath.equals( fullGlobalPath ) || !originalJpf.exists() ) - CompilerUtil.error( "pageflow.error.global-app-wrong-dir", - new String[] { GLOBALAPP_FILENAME, GLOBALAPP_SOURCE_DIR } ); - } - else - { - //otherwise make sure it's a jpf file - if ( !jpfName.endsWith( PAGEFLOW_EXTENSION ) || !originalJpf.exists() ) - CompilerUtil.error( "compiler.error.wrong.extension", (String[])null ); - - // then check for other pageflows in the package - String[] otherFiles = jpfParentDir.list(); - List otherJpfs = new ArrayList(); - for ( int i=0; i<otherFiles.length; i++ ) - { - if ( otherFiles[i].endsWith( PAGEFLOW_EXTENSION ) && !otherFiles[i].equals( jpfName ) ) - otherJpfs.add( otherFiles[i] ); - } - if ( otherJpfs.size() == 1 ) - CompilerUtil.error( "pageflow.error.overlapping-pageflows1", - new String[] { (String)otherJpfs.get(0) } ); - else if ( otherJpfs.size() == 2 ) - CompilerUtil.error( "pageflow.error.overlapping-pageflows2", - new String[] { (String)otherJpfs.get(0), (String)otherJpfs.get(1) } ); - else if ( otherJpfs.size() == 3 ) - CompilerUtil.error( "pageflow.error.overlapping-pageflows3", - new String[] { (String)otherJpfs.get(0), (String)otherJpfs.get(1), (String)otherJpfs.get(2) } ); - else if ( otherJpfs.size() > 3 ) - CompilerUtil.error( "pageflow.error.overlapping-pageflows", - new String[] { (String)otherJpfs.get(0), (String)otherJpfs.get(1), (String)otherJpfs.get(2) } ); - } - - // we are catching and ignoring NetuiDocletException so that the compiler will - // continue to process and accumulate errors. - try - { checkTagPlacement( jpfClass ); } - catch ( NetuiDocletException e ) { } - - try - { processController( jpfClass ); } - catch ( NetuiDocletException e ) { } - - try - { processFormBeans( jpfClass ); } - catch ( NetuiDocletException e ) { } - - try - { processActions( jpfClass ); } - catch ( NetuiDocletException e ) { } - - // check for an explicit alternate location for the generated file - // for root or global controller only - if ( global || jpfClass.getContainingPackage().isDefaultPackage() ) - { - String alternateLocation = getAlternateLocation( _strutsApp.getWebappRootPath(), - _strutsApp.getStrutsConfigFile() ); - if ( alternateLocation != null ) - { - if ( DocletContext.getInstance().isVerbose() ) - { - System.out.println( "Using alternate config file location: " + alternateLocation ); - } - _strutsApp.setStrutsConfigFile( new File( _strutsApp.getWebappRootPath() + alternateLocation ) ); - } - } - - // write out the config file if we haven't gotten any errors - if ( !NetuiDocletTask.hasErrors( _strutsApp.getOriginalJpfSourceFile().toString() ) ) - _strutsApp.writeToSource(); - } - catch ( NetuiDocletException e ) - { - // ignore, an error was added to the task - } - catch ( NoWebInfDirectoryException e ) - { - CompilerUtil.error( e.getMessage() ); - } - catch ( Exception e ) - { - throw new XDocletException(e, e.getMessage() ); - } - finally - { - _strutsApp = null; - _exceptionHandlers = null; - _isGlobal = false; - } - } - - public void checkTagPlacement(XClass jpfClass) - throws XDocletException - { - checkTagPlacement( jpfClass.getDoc(), TAG_NAMESPACE, PageflowTags.VALID_CLASS_TAGS ); - - List fields = jpfClass.getFields(); - Iterator fieldIter = fields.iterator(); - while ( fieldIter.hasNext() ) - { - XField field = (XField) fieldIter.next(); - checkTagPlacement( field.getDoc(), TAG_NAMESPACE, PageflowTags.VALID_FIELD_TAGS ); - } - - List methods = jpfClass.getMethods(); - Iterator methodIter = methods.iterator(); - while ( methodIter.hasNext() ) - { - XMethod method = (XMethod) methodIter.next(); - XDoc doc = method.getDoc(); - checkTagPlacement( doc, TAG_NAMESPACE, PageflowTags.VALID_METHOD_TAGS ); - - // make sure any methods with a forward tag are really actions or exception handlers - XTag fwdTag = doc.getTag( FORWARD_TAG_FULL_NAME ); - if ( fwdTag != null ) - { - XTag actionTag = doc.getTag( ACTION_TAG_FULL_NAME ); - if ( actionTag == null ) - { - XTag exTag = doc.getTag( EXCEPTION_HANDLER_TAG_FULL_NAME ); - if ( exTag == null ) - { - CompilerUtil.error( fwdTag, "pageflow.error.inappropriate-forward-tag", - new String[] { FORWARD_TAG_FULL_NAME, ACTION_TAG_FULL_NAME, - EXCEPTION_HANDLER_TAG_FULL_NAME } ); - } - } - } - } - } - - private void checkTagPlacement( XDoc doc, String namespace, String[] valid ) - throws XDocletException - { - // XTags are namespaced with a '.', not a ':' - String nsDot = namespace + "."; - int nsDotLength = nsDot.length(); - List validList = Arrays.asList( valid ); - - List allTags = doc.getTags(); - Iterator iter = allTags.iterator(); - while( iter.hasNext() ) - { - XTag tag = (XTag) iter.next(); - if ( tag.getName().startsWith( nsDot ) ) - { - String tagName = tag.getName().substring( nsDotLength ); - if ( !validList.contains( tagName ) ) - { - try - { CompilerUtil.error( tag, "compiler.error.invalid.tag.location", new String[] {tag.getName()} ); } - catch ( NetuiDocletException e ) - { } // we want to continue here - } - } - } - } - - public void processController( XClass jpfClass ) - throws XDocletException - { - XTag jpfTag = jpfClass.getDoc().getTag( CONTROLLER_TAG_FULL_NAME ); - if ( jpfTag != null ) - { - // this tag isn't required, but validate it if it's there - PageflowTags.CONTROLLER_TAG_GRAMMAR.validateTag( jpfTag, jpfClass ); - _strutsApp.setStrutsMerge( jpfTag.getAttributeValue( STRUTSMERGE_ATTR ) ); - - // if nested, check for a fwd with return-action - if ( "true".equals( jpfTag.getAttributeValue( NESTED_ATTR ) ) ) - { - _strutsApp.setNestedPageFlow( true ); - - List fwdTags = jpfClass.getMethodTags( FORWARD_TAG_FULL_NAME, false ); - boolean foundReturnAction = atLeastOneTagHasAttribute( fwdTags, RETURN_ACTION_ATTR ); - if ( !foundReturnAction ) - { - // check the global forwards if we still didn't find one - fwdTags = jpfClass.getDoc().getTags( FORWARD_TAG_FULL_NAME ); - foundReturnAction = atLeastOneTagHasAttribute( fwdTags, RETURN_ACTION_ATTR ); - } - if ( !foundReturnAction ) - { - // last chance, check for a validation-error-forward - fwdTags = jpfClass.getMethodTags( VALIDATION_ERROR_FORWARD_TAG_FULL_NAME, false ); - foundReturnAction = atLeastOneTagHasAttribute( fwdTags, RETURN_ACTION_ATTR ); - } - if ( !foundReturnAction ) - CompilerUtil.error( jpfTag, "pageflow.error.no-return-action", null ); - } - } - - // check for a begin action - if ( !_isGlobal ) - { - boolean foundBegin = false; - List methods = jpfClass.getMethods(); - Iterator iter = methods.iterator(); - while ( !foundBegin && iter.hasNext() ) - { - XMethod method = (XMethod) iter.next(); - if ( method.getName().equals( BEGIN_ACTION_NAME ) ) - { - XTag tag = method.getDoc().getTag(ACTION_TAG_FULL_NAME); - if ( tag != null ) - foundBegin = true; - } - } - if ( !foundBegin ) - CompilerUtil.error( jpfTag, "pageflow.error.no-begin-action", null ); - } - - // check for invalid tags - List fields = jpfClass.getFields(); - Iterator fieldIter = fields.iterator(); - while ( fieldIter.hasNext() ) - { - XField field = (XField) fieldIter.next(); - XDoc doc = field.getDoc(); - for ( int i=0; i<INVALID_FIELD_TAGS.length; i++ ) - { - if ( doc.hasTag( INVALID_FIELD_TAGS[i] ) ) - { - XTag badTag = doc.getTag( INVALID_FIELD_TAGS[i] ); - CompilerUtil.error( badTag, "compiler.error.portable.notsupported", - new String[] {INVALID_FIELD_TAGS[i]} ); - } - } - - // also check for non-transient/static/serializable fields - if ( !field.isTransient() && !field.isStatic() && - !field.getType().isImplementingInterface( SERIALIZABLE_INTERFACE_NAME, true ) ) - { - CompilerUtil.warning( field, "pageflow.warning.nonserializable-member-data", null ); - } - } - - - // process the message resource tags - List tags = jpfClass.getDoc().getTags( MESSAGE_RESOURCES_TAG_FULL_NAME ); - Iterator tagIter = tags.iterator(); - while ( tagIter.hasNext() ) - { - XTag tag = (XTag) tagIter.next(); - PageflowTags.MSG_RES_TAG_GRAMMAR.validateTag( tag, jpfClass ); - String resources = tag.getAttributeValue( RESOURCES_ATTR ); - String key = tag.getAttributeValue( KEY_ATTR ); - MessageResourcesModel mr = new MessageResourcesModel( resources, _strutsApp ); - mr.setKey( key ); - mr.setReturnNull( false ); - _strutsApp.addMessageResources( mr ); - } - - // add global forwards and catches - checkForwardConflicts( jpfClass, jpfClass ); - addForwards( jpfClass, _strutsApp, jpfClass ); - addCatches( jpfClass, _strutsApp, jpfClass ); - } - - public void processActions( XClass jpfClass ) - throws XDocletException - { - List methods = jpfClass.getMethods(); - Iterator methodIter = methods.iterator(); - while ( methodIter.hasNext() ) - { - XMethod method = (XMethod) methodIter.next(); - XTag actionTag = method.getDoc().getTag( ACTION_TAG_FULL_NAME ); - if ( actionTag != null ) - { - PageflowTags.ACTION_TAG_GRAMMAR.validateTag( actionTag, jpfClass ); - List params = method.getParameters(); - FormBeanModel formBean = null; - XClass paramType = null; - if ( params.size() > 0 ) - { - XParameter param = (XParameter) params.get(0); - paramType = param.getType(); - boolean ok = true; - if ( params.size() > 1 ) - ok = false; - if ( ok ) - { - if ( !paramType.isA( FORM_CLASS_NAME, true ) ) - ok = false; - } - if ( !ok ) - CompilerUtil.error( actionTag, "pageflow.error.action-method-wrong-arg", - new String[] {FORM_CLASS_NAME} ); - - // if this action takes a form we haven't seen yet, add it to the map - String formType = CompilerUtil.getQualifiedName( param.getType() ); - formBean = _strutsApp.getFormBeanByType( formType ); - if ( formBean == null ) - { - formBean = addFormBean( param.getType() ); - } - - } - - // check the return type - XClass returnClass = method.getReturnType().getType(); - if ( !returnClass.isA( FORWARD_CLASS_NAME, true ) ) - CompilerUtil.error( actionTag, "pageflow.error.method-wrong-return-type", - new String[] {FORWARD_CLASS_NAME} ); - - ActionModel action = new ActionModel( "/" + method.getName(), _strutsApp ); - action.setType( jpfClass.getQualifiedName() ); - if ( formBean != null ) - action.setFormBeanName( formBean.getName() ); - action.setRoles( getActionRoles( actionTag, jpfClass ) ); - action.setScope( actionTag.getAttributeValue( "scope" ) ); // TODO: constant? - - Boolean readonly = null; - String readonlyVal = actionTag.getAttributeValue( READONLY_ATTR ); - if ( readonlyVal != null ) - { - readonly = new Boolean( readonlyVal ); - } - else - { - readonlyVal = getControllerAttribute( jpfClass, READONLY_ATTR ); - if ( readonlyVal != null && readonlyVal.equalsIgnoreCase( "true" ) ) - { - readonly = new Boolean( true ); - } - } - action.setReadonly( readonly != null ? readonly.booleanValue() : false ); - - String formMember = actionTag.getAttributeValue( FORM_ATTR ); - if ( formMember != null ) - { - // make sure the action is not readonly - if ( readonly != null && readonly.booleanValue() ) - { - CompilerUtil.error( actionTag, "pageflow.error.readonly-writable-field-member", - new String[] { FORM_ATTR } ); - } - - // need to get the fully qualified type of the field - XField formField = jpfClass.getField( formMember ); - if ( formField == null ) - CompilerUtil.error( actionTag, "pageflow.error.unresolved-field", - new String[] { formMember } ); - XClass formClass = formField.getType(); - if ( !formClass.isA( FORM_CLASS_NAME, true ) ) - CompilerUtil.error( actionTag, "pageflow.error.wrong-field-type", - new String[] { formMember, FORM_CLASS_NAME } ); - - // if we have a valid form attribute, make sure we take a parameter of the same type - if ( formBean == null || paramType == null || - !paramType.isA( formClass.getQualifiedName(), true ) ) - { - CompilerUtil.error( actionTag, "pageflow.error.action-mismatched-form", - new String[] { formMember, formClass.getName() } ); - } - - action.setFormMember( formMember); - } - - Boolean loginRequired = null; - String loginRequiredVal = actionTag.getAttributeValue( LOGIN_REQUIRED_ATTR ); - if ( loginRequiredVal != null ) - { - loginRequired = new Boolean( loginRequiredVal ); - } - else - { - loginRequiredVal = getControllerAttribute( jpfClass, LOGIN_REQUIRED_ATTR ); - if ( loginRequiredVal != null && loginRequiredVal.equalsIgnoreCase( "true" ) ) - { - loginRequired = new Boolean( true ); - } - } - action.setLoginRequired( loginRequired != null ? loginRequired.booleanValue() : false ); - - checkForwardConflicts( method, jpfClass ); - addForwards( method, action, jpfClass ); - addCatches( method, action, jpfClass ); - - // if we have a validation-error-page see if we need to make a new forward for it - String validationErrorPage = actionTag.getAttributeValue( VALIDATION_ERROR_PAGE_ATTR ); - if ( validationErrorPage != null ) - { - String inputFwd = null; - List fwdTags = method.getDoc().getTags( FORWARD_TAG_FULL_NAME ); - Iterator fwdTagIter = fwdTags.iterator(); - boolean found = false; - while ( !found && fwdTagIter.hasNext() ) - { - XTag tag = (XTag) fwdTagIter.next(); - String fwdPath = tag.getAttributeValue( PATH_ATTR ); - if ( fwdPath != null && fwdPath.equals( validationErrorPage ) ) - { - inputFwd = tag.getAttributeValue( NAME_ATTR ); - found = true; - } - } - - if ( !found ) - { - inputFwd = VALIDATION_ERROR_PAGE_FWD_NAME; - ForwardModel forward = new ForwardModel( inputFwd, - getValidPath(validationErrorPage), _strutsApp ); - warnIfPathNotFound(actionTag, validationErrorPage); - action.addForward( forward ); - } - - action.setInput( inputFwd ); - } - - // add a validation-error-forward if there is one, and make sure there is only one - XTag errorFwd = method.getDoc().getTag( VALIDATION_ERROR_FORWARD_TAG_FULL_NAME ); - if ( errorFwd != null ) - { - PageflowTags.VALIDATION_ERROR_FORWARD_TAG_GRAMMAR.validateTag( errorFwd, jpfClass ); - - // also check for other regular forwards with the same name - String name = errorFwd.getAttributeValue( NAME_ATTR ); - List otherFwds = method.getDoc().getTags( FORWARD_TAG_FULL_NAME ); - Iterator iter = otherFwds.iterator(); - while ( iter.hasNext() ) - { - XTag otherFwd = (XTag) iter.next(); - String otherName = otherFwd.getAttributeValue( NAME_ATTR ); - if ( otherName != null && otherName.equals( name ) ) - CompilerUtil.error( errorFwd, "compiler.error.duplicate.errorFwd.fwd", - new String[] {name} ); - } - - List fwdList = new ArrayList(); - fwdList.add( errorFwd ); - addForwards( method, action, jpfClass, fwdList, null, null ); - action.setInput( name ); - } - - _strutsApp.addActionMapping( action ); - } - } - } - - protected List addForwards( XProgramElement xpe, ForwardContainer container, XClass jpfClass ) - throws XDocletException - { - XDoc doc = xpe.getDoc(); - - // get explicit forward tags for this element - List forwardTags = doc.getTags( FORWARD_TAG_FULL_NAME ); - List otherForwards = addForwards( xpe, container, jpfClass, forwardTags, null, null ); - - // get forwards from exception-handler methods referenced in jpf:catch tags - forwardTags = new ArrayList(); - List exTags = doc.getTags( CATCH_TAG_FULL_NAME ); - Map handlers = getExceptionHandlers( jpfClass ); - Iterator exIter = exTags.iterator(); - while ( exIter.hasNext() ) - { - XTag exTag = (XTag) exIter.next(); - String methodName = exTag.getAttributeValue( METHOD_ATTR ); - if ( methodName != null ) - { - XMethod handler = (XMethod) handlers.get( methodName ); - if ( handler == null ) - CompilerUtil.error( exTag, "pageflow.error.unresolved-exception-handler", - new String[] { methodName } ); - - List handlerFwdTags = handler.getDoc().getTags( FORWARD_TAG_FULL_NAME ); - addForwards( xpe, container, jpfClass, handlerFwdTags, handler.getName(), otherForwards ); - } - } - - return otherForwards; - } - - protected List addForwards( XProgramElement xpe, ForwardContainer container, - XClass jpfClass, List forwardTags, String handler, List currentForwards ) - throws XDocletException - { - if ( currentForwards == null ) - currentForwards = new ArrayList(); - - // see if we're in a nested pageflow - XTag jpfTag = jpfClass.getDoc().getTag( CONTROLLER_TAG_FULL_NAME ); - boolean nested = false; - if ( jpfTag != null ) - { - String nestedValue = jpfTag.getAttributeValue( NESTED_ATTR ); - nested = new Boolean( nestedValue ).booleanValue(); - } - - // iterate over all the forwards and process them - Iterator fwdIter = forwardTags.iterator(); - while ( fwdIter.hasNext() ) - { - XTag fwdTag = (XTag)fwdIter.next(); - PageflowTags.FORWARD_TAG_GRAMMAR.validateTag( fwdTag, jpfClass ); - String name = fwdTag.getAttributeValue( NAME_ATTR ); - - String path = fwdTag.getAttributeValue( PATH_ATTR ); - warnIfPathNotFound( fwdTag, path ); - - ForwardModel forward = new ForwardModel( name, getValidPath(path), _strutsApp ); - - if ( handler != null ) - { - forward.setComment( "forward \"" + forward.getName() + "\"" + " from exception-handler " + handler ); // @TODOsp1 I18N the comment - } - - String redirect = fwdTag.getAttributeValue( REDIRECT_ATTR ); - if ( redirect == null ) - forward.setRedirect( false, false ); - else - forward.setRedirect( new Boolean( redirect ).booleanValue(), true ); - - forward.setContextRelative( path != null && path.startsWith( "/" ) ); - String returnTo = fwdTag.getAttributeValue( RETURN_TO_ATTR ); - if ( returnTo != null ) - { - if ( returnTo.equals( RETURN_TO_PAGE_LEGACY_STR ) || - returnTo.equals( RETURN_TO_CURRENT_PAGE_STR ) || - returnTo.equals( RETURN_TO_PREVIOUS_PAGE_STR ) ) - forward.setReturnToPage( true ); - else if ( returnTo.equals( RETURN_TO_ACTION_LEGACY_STR ) || - returnTo.equals( RETURN_TO_PREVIOUS_ACTION_STR ) ) - forward.setReturnToAction( true ); - forward.setPath( returnTo ); - } - String returnAction = fwdTag.getAttributeValue( RETURN_ACTION_ATTR ); - if ( returnAction != null ) - { - // make sure we're in a nested pageflow - if ( !nested ) - { - CompilerUtil.error( fwdTag, "pageflow.error.only-valid-in-nested", - new String[] { RETURN_ACTION_ATTR } ); - } - - // make sure this is a valid java identifier - if ( !isJavaIdentifier( returnAction ) ) - CompilerUtil.error( fwdTag, "pageflow.error.attr-java-identifier", - new String[] { RETURN_ACTION_ATTR } ); - - forward.setIsNestedReturn( true ); - forward.setPath( returnAction ); - - // only check return form member/type for a return action - String returnFormType = fwdTag.getAttributeValue( RETURN_FORM_TYPE_ATTR ); - if ( returnFormType != null ) - { - XClass q = jpfClass.qualify( returnFormType ); - if ( q == null || q.getClass().getName().endsWith( "UnknownClass" ) ) - CompilerUtil.error( fwdTag, "pageflow.error.unresolved-type", new String[] {returnFormType} ); - if ( !q.isA( FORM_CLASS_NAME, true ) ) - CompilerUtil.error( fwdTag, "compiler.error.wrong.type", new String[] {returnFormType, FORM_CLASS_NAME} ); - forward.setReturnFormType( CompilerUtil.getQualifiedName( q ) ); - } - - String returnFormMember = fwdTag.getAttributeValue( RETURN_FORM_ATTR ); - if ( returnFormMember != null ) - { - // need to get the fully qualified type of the field - XField returnFormField = jpfClass.getField( returnFormMember ); - if ( returnFormField == null ) - CompilerUtil.error( fwdTag, "pageflow.error.unresolved-field", - new String[] { returnFormMember } ); - XClass returnFormClass = returnFormField.getType(); - if ( !returnFormClass.isA( FORM_CLASS_NAME, true ) ) - CompilerUtil.error( fwdTag, "pageflow.error.wrong-field-type", - new String[] { returnFormMember, FORM_CLASS_NAME } ); - String returnFormClassName = CompilerUtil.getQualifiedName( returnFormClass ); - forward.setReturnFormType( returnFormClassName ); - forward.setReturnFormMember( returnFormMember ); - } - } - - container.addForward( forward ); - currentForwards.add( fwdTag ); - } - - return currentForwards; - } - - public void addCatches( XProgramElement xpe, ExceptionContainer container, XClass jpfClass ) - throws XDocletException - { - XDoc doc = xpe.getDoc(); - List exTags = doc.getTags( CATCH_TAG_FULL_NAME ); - Map handlers = getExceptionHandlers( jpfClass ); - Iterator exIter = exTags.iterator(); - while ( exIter.hasNext() ) - { - XTag exTag = (XTag) exIter.next(); - PageflowTags.CATCH_TAG_GRAMMAR.validateTag( exTag, jpfClass ); - String typeAttr = exTag.getAttributeValue( TYPE_ATTR ); - - // xjavadoc sometimes does not understand '$' to denote inner classes, '.' is safer - typeAttr = typeAttr.replace( '$', '.' ); - XClass q = jpfClass.qualify( typeAttr ); - - if ( q == null || q.getClass().getName().endsWith( "UnknownClass" ) ) - { - // sometimes an inner class will not resolve correctly without the package name, - // so try again, assuming the exception is in the same package as the jpf - XPackage pkg = jpfClass.getContainingPackage(); - q = jpfClass.qualify( pkg.getName() + "." + typeAttr ); - - if ( q == null || q.getClass().getName().endsWith( "UnknownClass" ) ) - CompilerUtil.error( exTag, "pageflow.error.unresolved-type", new String[] {typeAttr} ); - } - if ( !q.isA( THROWABLE_CLASS_NAME, true ) ) - CompilerUtil.error( exTag, "compiler.error.wrong.type", new String[] {typeAttr, THROWABLE_CLASS_NAME} ); - String type = CompilerUtil.getQualifiedName( q ); - - String pathAttr = exTag.getAttributeValue( PATH_ATTR ); - warnIfPathNotFound( exTag, pathAttr ); - String path = null; - if ( pathAttr != null ) - path = getValidPath( pathAttr ); - String handler = exTag.getAttributeValue( METHOD_ATTR ); - if ( handler != null ) - { - // check that the method handles the right exception type - XMethod method = (XMethod) handlers.get( handler ); - if ( method == null ) - CompilerUtil.error( exTag, "pageflow.error.unresolved-exception-handler", - new String[] { handler } ); - XParameter firstParam = (XParameter)method.getParameters().get(0); - if ( !q.isA( firstParam.getType().getQualifiedName() ) ) - CompilerUtil.error( exTag, "pageflow.error.incompatible-exception-handler", - new String[] { handler, q.getQualifiedName() } ); - } - String key = exTag.getAttributeValue( MESSAGE_KEY_ATTR ); - String message = exTag.getAttributeValue( MESSAGE_ATTR ); - - ExceptionModel ex = new ExceptionModel( type, path, handler, message, key, _strutsApp ); - container.addException( ex ); - } - } - - protected Map getExceptionHandlers( XClass jpfClass ) - throws XDocletException - { - if ( _exceptionHandlers == null ) - { - _exceptionHandlers = new HashMap(); - List methods = jpfClass.getMethods(); - Iterator iter = methods.iterator(); - while ( iter.hasNext() ) - { - XMethod method = (XMethod) iter.next(); - XTag exTag = method.getDoc().getTag( EXCEPTION_HANDLER_TAG_FULL_NAME ); - if ( exTag != null ) - { - PageflowTags.EX_HANDLER_TAG_GRAMMAR.validateTag( exTag, jpfClass ); - - // make sure there is no catch tag on the exception handler - XTag catchTag = method.getDoc().getTag( CATCH_TAG_FULL_NAME ); - if ( catchTag != null ) - { - CompilerUtil.error( exTag, "pageflow.error.exception-handler-catch", - new String[] { CATCH_TAG_FULL_NAME } ); - } - - // now check parameters on the handler method - List params = method.getParameters(); - if ( params.size() != 4 ) - { - CompilerUtil.error( exTag, "pageflow.error.exception-method-wrong-arg-count", new String[] {"4"} ); - } - else - { - if ( !((XParameter)params.get(0)).getType().isA( THROWABLE_CLASS_NAME, true ) ) - CompilerUtil.error( exTag, "pageflow.error.exception-method-wrong-exception-arg", - new String[] { THROWABLE_CLASS_NAME } ); - else if ( !((XParameter)params.get(1)).getType().isA( STRING_CLASS_NAME ) ) - CompilerUtil.error( exTag, "pageflow.error.exception-method-wrong-arg-type", - new String[] { "2", STRING_CLASS_NAME } ); - else if ( !((XParameter)params.get(2)).getType().isA( STRING_CLASS_NAME ) ) - CompilerUtil.error( exTag, "pageflow.error.exception-method-wrong-arg-type", - new String[] { "3", STRING_CLASS_NAME } ); - else if ( !((XParameter)params.get(3)).getType().isA( FORM_CLASS_NAME, true ) ) - CompilerUtil.error( exTag, "pageflow.error.exception-method-wrong-arg-type2", - new String[] { "4", FORM_CLASS_NAME, NETUI_FORM_CLASS_NAME } ); - } - - // check the return type - XClass returnClass = method.getReturnType().getType(); - if ( !returnClass.isA( FORWARD_CLASS_NAME, true ) ) - CompilerUtil.error( exTag, "pageflow.error.method-wrong-return-type", - new String[] {FORWARD_CLASS_NAME} ); - - if ( _exceptionHandlers.get( method.getName() ) != null ) - { - CompilerUtil.error( exTag, "pageflow.error.duplicate-exception-handler", null ); - } - _exceptionHandlers.put( method.getName(), method ); - } - } - } - return _exceptionHandlers; - } - - protected String getControllerAttribute( XClass jpfClass, String attrName ) - throws XDocletException - { - String value = null; - XTag jpfTag = jpfClass.getDoc().getTag( CONTROLLER_TAG_FULL_NAME ); - if ( jpfTag != null ) - { - value = jpfTag.getAttributeValue( attrName ); } - return value; } - protected String getActionRoles( XTag actionTag, XClass jpfClass ) - { - String rolesAllowed = null; - String actionRolesAllowed = actionTag.getAttributeValue( ROLES_ALLOWED_ATTR ); - - String jpfRolesAllowed = null; - XTag jpfTag = jpfClass.getDoc().getTag( CONTROLLER_TAG_FULL_NAME ); - if ( jpfTag != null ) - jpfRolesAllowed = jpfTag.getAttributeValue( ROLES_ALLOWED_ATTR ); - - if ( actionRolesAllowed != null || jpfRolesAllowed != null ) - { - if ( actionRolesAllowed == null && jpfRolesAllowed != null ) - { - rolesAllowed = jpfRolesAllowed; - } - else if ( actionRolesAllowed != null && jpfRolesAllowed == null ) - { - rolesAllowed = actionRolesAllowed; - } - else - { - // merge the lists - List roles = new ArrayList(); - StringBuffer buf = new StringBuffer(); - StringTokenizer actionSt = new StringTokenizer( actionRolesAllowed ); - while ( actionSt.hasMoreElements() ) - { - roles.add( actionSt.nextToken() ); - } - StringTokenizer jpfSt = new StringTokenizer( jpfRolesAllowed ); - while ( jpfSt.hasMoreElements() ) - { - String role = jpfSt.nextToken(); - if ( !roles.contains( role ) ) - roles.add( role ); - } - for ( int i=0; i<roles.size(); i++ ) - { - if ( i>0 ) - buf.append( "," ); - buf.append( (String)roles.get(i) ); - } - rolesAllowed = buf.toString(); - } - } - return rolesAllowed; - } - - public void processFormBeans( XClass jpfClass ) - throws XDocletException - { - List formBeans = new ArrayList(); - - // get the form bean inner classes - List innerClasses = jpfClass.getInnerClasses(); - Iterator innerIter = innerClasses.iterator(); - while ( innerIter.hasNext() ) - { - XClass innerClass = (XClass)innerIter.next(); - if ( innerClass.isA( FORM_CLASS_NAME, true ) ) - formBeans.add( innerClass ); - } - - Iterator formIter = formBeans.iterator(); - while ( formIter.hasNext() ) - { - XClass formClass = (XClass)formIter.next(); - addFormBean( formClass ); - } - } - - private FormBeanModel addFormBean( XClass formClass ) - { - String formType = CompilerUtil.getQualifiedName( formClass ); - String formBeanName = _strutsApp.getFormNameForType( formType ); - FormBeanModel formBean = new FormBeanModel( formBeanName, formType, _strutsApp ); - _strutsApp.addFormBean( formBean ); - return formBean; - } - - private void checkForwardConflicts( XProgramElement xpe, XClass jpfClass ) - throws XDocletException - { - XDoc doc = xpe.getDoc(); - - // get explicit forward tags for this element - List elementFwdTags = doc.getTags( FORWARD_TAG_FULL_NAME ); - - // get forwards from any handlers - Map handlerForwards = getForwardsFromCatches( xpe, jpfClass ); - - // if this is not the controller class itself, add all the global forwards - // to a separate map; we need them to check local forwards for name conflicts, - // but not to check forwards from handlers for forward conflicts - Map combinedForwards = new HashMap(); - combinedForwards.putAll( handlerForwards ); - if ( xpe != jpfClass ) - { - combinedForwards.putAll( getForwardsFromCatches( jpfClass, jpfClass ) ); - } - - // check name conflicts between explicit forwards and forwards from handlers - // NOTE: doing all these nested loops to keep track of what handler's forwards - // are being considered so that we can fill out the error message correctly - Iterator fwdTagIter = elementFwdTags.iterator(); - while ( fwdTagIter.hasNext() ) - { - XTag tag = (XTag) fwdTagIter.next(); - String name = tag.getAttributeValue( NAME_ATTR ); - - Iterator handlerIter = combinedForwards.keySet().iterator(); - while ( handlerIter.hasNext() ) - { - XTag handlerTag = (XTag)handlerIter.next(); - String handler = handlerTag.getAttributeValue( METHOD_ATTR ); - List handlerFwdTags = (List)combinedForwards.get( handlerTag ); - - Iterator handlerFwdIter = handlerFwdTags.iterator(); - while ( handlerFwdIter.hasNext() ) - { - XTag handlerFwdTag = (XTag) handlerFwdIter.next(); - String otherName = handlerFwdTag.getAttributeValue( NAME_ATTR ); - if ( name.equals( otherName ) ) - { -// pageflow.error.duplicate-attr2 = Duplicate {0} tag on method {3} (referenced from {4}) with {1}="{2}". - CompilerUtil.error( tag, "pageflow.error.duplicate-attr2", - new String[] { FORWARD_TAG_NAME, NAME_ATTR, name, handler, CATCH_TAG_FULL_NAME } ); - } - } - } - } - - // check conflicts between forwards on handlers: for each handler on this program element, - // check each of its forwards against the list of forwards from other handlers - Iterator handlerIter = handlerForwards.keySet().iterator(); - while ( handlerIter.hasNext() ) - { - XTag handlerTag = (XTag)handlerIter.next(); - String handler = handlerTag.getAttributeValue( METHOD_ATTR ); - List handlerFwdTags = (List)handlerForwards.get( handlerTag ); - - Iterator handlerFwdIter = handlerFwdTags.iterator(); - while ( handlerFwdIter.hasNext() ) - { - XTag tag = (XTag) handlerFwdIter.next(); - - Iterator otherHandlers = handlerForwards.keySet().iterator(); - while ( otherHandlers.hasNext() ) - { - XTag otherHandlerTag = (XTag) otherHandlers.next(); - String otherHandler = otherHandlerTag.getAttributeValue( METHOD_ATTR ); - if ( !handler.equals( otherHandler ) ) - { - List otherHandlerFwdTags = (List)handlerForwards.get( otherHandlerTag ); -// pageflow.error.duplicate-exception-handler-forwards = \ -// The specified exception-handler method {0} contains a forward named "{2}" which conflicts with a forward in \ -// exception-handler {1}. - String conflictingFwd = findConflictingForward( tag, otherHandlerFwdTags ); - if ( conflictingFwd != null ) - CompilerUtil.error( handlerTag, "pageflow.error.duplicate-exception-handler-forwards", - new String[] { handler, otherHandler, conflictingFwd } ); - } - } - } - } - - - } - - private Map getForwardsFromCatches( XProgramElement xpe, XClass jpfClass ) - throws XDocletException - { - Map handlers = getExceptionHandlers( jpfClass ); - Map forwards = new HashMap(); - - XDoc doc = xpe.getDoc(); - - // TODO: refactor to share code with addForwards? - List catchTags = doc.getTags( CATCH_TAG_FULL_NAME ); - - Iterator iter = catchTags.iterator(); - while ( iter.hasNext() ) - { - XTag tag = (XTag) iter.next(); - String handlerName = tag.getAttributeValue( METHOD_ATTR ); - if ( handlerName != null ) - { - XMethod handler = (XMethod)handlers.get( handlerName ); - - if ( handler == null ) - CompilerUtil.error( tag, "pageflow.error.unresolved-exception-handler", - new String[] { handlerName } ); - - List handlerFwdTags = handler.getDoc().getTags( FORWARD_TAG_FULL_NAME ); - forwards.put( tag, handlerFwdTags ); - } - } - - return forwards; - } - - private String findConflictingForward(XTag fwdTag, List currentForwards) - { - if ( currentForwards.size() == 0 ) - return null; - - String name = fwdTag.getAttributeValue( NAME_ATTR ); - Collection attrs = fwdTag.getAttributeNames(); - Iterator iter = currentForwards.iterator(); - while ( iter.hasNext() ) - { - XTag otherTag = (XTag) iter.next(); - String otherName = otherTag.getAttributeValue( NAME_ATTR ); - - // only check forwards of the same name - if ( otherName.equals( name ) ) - { - Collection otherAttrs = otherTag.getAttributeNames(); - - // if they have different number of attributes, they are conflicting - if ( otherAttrs.size() != attrs.size() ) - return name; - - Iterator attrIter = attrs.iterator(); - while ( attrIter.hasNext() ) - { - String attr = (String)attrIter.next(); - String value = fwdTag.getAttributeValue( attr ); - String otherValue = otherTag.getAttributeValue( attr ); - - // as soon as we find a difference, we have a conflict - if ( otherValue == null || !otherValue.equals( value ) ) - return name; - } - } - } - return null; - } - - private void warnIfPathNotFound( XTag tag, String path ) - { - if ( path == null || isAbsoluteURL(path) || - ( !path.endsWith(JSP_EXTENSION) && !path.endsWith(HTM_EXTENSION) && - !path.endsWith(HTML_EXTENSION) && !path.endsWith(PAGEFLOW_EXTENSION) ) ) - return; - - String base = null; - if ( path.startsWith( "/" ) ) - { - base = _strutsApp.getWebappRootPath(); - } - else - { - try - { - base = _strutsApp.getOriginalJpfSourceFile().getParent(); - } - catch ( Exception e ) - { - //ignore - } - } - - if ( base != null ) - { - File test = new File( base + File.separatorChar + path ); - if ( !test.exists() ) - CompilerUtil.warning( tag, "pageflow.warning.file-not-found", new String[] { path } ); - } - } - - private String getValidPath( String path ) - { - String result = null; - - if ( path == null || path.length() == 0 ) - result = ""; - else if ( path.startsWith( "/" ) || isAbsoluteURL( path ) ) - result = path; - else - result = "/" + path; - return result; - } - - public static boolean isAbsoluteURL( String path ) - { - try - { - return new URI( path ).getScheme() != null; - } - catch ( URISyntaxException e ) - { - // ignore - } - - return false; - } - - public static boolean isJavaIdentifier(String s) - { - if (s.length() == 0 || !Character.isJavaIdentifierStart(s.charAt(0))) - { - return false; - } - for (int i=1; i<s.length(); i++) - { - if (!Character.isJavaIdentifierPart(s.charAt(i))) - { - return false; - } - } - return true; - } - - public XDocletStrutsApp getStrutsApp() { return _strutsApp; } - - private String getAlternateLocation( String webappRootPath, File file ) - throws XDocletException - { - File webXmlFile = new File( webappRootPath + "/" + WEBINF_DIR_NAME + "/web.xml" ); - - try - { - WebAppDocument webXml = WebAppDocument.Factory.parse( webXmlFile ); - WebAppDocument.WebApp.Servlet[] servlets = webXml.getWebApp().getServletArray(); - - for ( int i = 0; i < servlets.length; i++ ) - { - WebAppDocument.WebApp.Servlet servlet = servlets[i]; - - if ( servlet.getServletName().equals( "action" ) ) - { - InitParamType[] initParams = servlet.getInitParamArray(); - - for ( int j = 0; j < initParams.length; j++ ) - { - String paramValue = initParams[j].getParamValue(); - - // - // If the referenced struts-config file has the same name as the file - // we're going to generate, use the referenced file (its location may be - // different than our default location). - // - if ( paramValue.indexOf( file.getName() ) != -1 ) - { - // - // This may be a comma-separated list of files. Find the right one. - // - if ( paramValue.indexOf( "," ) != -1 ) - { - String[] files = paramValue.split( "," ); - for ( int k = 0; k < files.length; ++k ) - { - if ( files[k].indexOf( file.getName() ) != -1 ) - { - return files[k].trim(); - } - } - } - else - { - return paramValue; - } - } - } - } - } - } - catch ( Exception e ) - { - CompilerUtil.error( "Could not read web.xml at " + webXmlFile + ": " + e.getMessage() ); - } - - return null; - } - - private boolean atLeastOneTagHasAttribute( List tags, String attribute ) - { - Iterator tagIter = tags.iterator(); - boolean foundTag = false; - while ( !foundTag && tagIter.hasNext() ) - { - XTag fwdTag = (XTag) tagIter.next(); - if ( fwdTag.getAttributeValue( attribute ) != null ) - foundTag = true; - } - return foundTag; - } - */ - - public static NetuiSubTask get() { SubTask subtask = DocletContext.getInstance().getActiveSubTask();
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java (original) +++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java Fri Apr 22 00:41:54 2005 @@ -26,6 +26,7 @@ import org.apache.beehive.netui.compiler.typesystem.impl.DelegatingImpl; import org.apache.beehive.netui.compiler.typesystem.impl.WrapperFactory; import org.apache.beehive.netui.compiler.typesystem.impl.declaration.AnnotationTypeDeclarationImpl; +import org.apache.beehive.netui.compiler.Diagnostics; import java.util.Collection; import java.util.Map; @@ -37,6 +38,7 @@ { private TypeDeclaration[] _specifiedTypeDeclarations; private Map _attributes; + private Diagnostics _diagnostics; protected AnnotationProcessorEnvironmentImpl( com.sun.mirror.apt.AnnotationProcessorEnvironment delegate ) { Modified: incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java (original) +++ incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java Fri Apr 22 00:41:54 2005 @@ -52,13 +52,14 @@ /** - * Get the cached wrapper servlet request. If none exists, creates one and caches it. + * Get the cached ScopedRequest wrapper. If none exists, creates one and caches it. * @deprecated Use [EMAIL PROTECTED] #getScopedRequest(HttpServletRequest, String, ServletContext, Object, boolean)}. * * @param realRequest the "real" (outer) HttpServletRequest, which will be wrapped. * @param overrideURI the request-URI for the wrapped object. This is a <i>webapp-relative</i> URI, * i.e., it does not include the context path. * @param servletContext the current ServletContext. + * @param scopeKey the scope-key associated with the new (or looked-up) scoped request. * @return the cached (or newly-created) ScopedRequest. */ public static ScopedRequest getScopedRequest( HttpServletRequest realRequest, String overrideURI, @@ -68,12 +69,16 @@ } /** - * Get the cached wrapper servlet request. If none exists, creates one and caches it. + * Get the cached ScopedRequest wrapper. If none exists, creates one and caches it. * * @param realRequest the "real" (outer) HttpServletRequest, which will be wrapped. * @param overrideURI the request-URI for the wrapped object. This is a <i>webapp-relative</i> URI, * i.e., it does not include the context path. * @param servletContext the current ServletContext. + * @param scopeKey the scope-key associated with the new (or looked-up) scoped request. + * @param seeOuterRequestAttributes if <code>true</code>, a request attribute will be "seen" in the outer request, + * if it is not found within the scoped request; if <code>false</code>, attributes are only seen when + * they are present in the scoped request. * @return the cached (or newly-created) ScopedRequest. */ public static ScopedRequest getScopedRequest( HttpServletRequest realRequest, String overrideURI, Modified: incubator/beehive/trunk/netui/test/conf/testRecorder-server.xml URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/conf/testRecorder-server.xml?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/test/conf/testRecorder-server.xml (original) +++ incubator/beehive/trunk/netui/test/conf/testRecorder-server.xml Fri Apr 22 00:41:54 2005 @@ -25,10 +25,14 @@ <contextRoot>/tomcatWeb</contextRoot> <servletURI>testRecorder</servletURI> </webapp> - <webapp> <name>urlTemplates</name> <contextRoot>/urlTemplates</contextRoot> + <servletURI>testRecorder</servletURI> + </webapp> + <webapp> + <name>projectModelWeb</name> + <contextRoot>/projectModelWeb</contextRoot> <servletURI>testRecorder</servletURI> </webapp> <!-- Added: incubator/beehive/trunk/netui/test/webapps/projectModel/build.xml URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/projectModel/build.xml?rev=164185&view=auto ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/projectModel/build.xml (added) +++ incubator/beehive/trunk/netui/test/webapps/projectModel/build.xml Fri Apr 22 00:41:54 2005 @@ -0,0 +1,193 @@ +<?xml version="1.0"?> + +<!-- +--> +<project name="Beehive/NetUI/Project Model Tests" default="usage" basedir="."> + + <property environment="os"/> + <import file="../../ant/webapp-imports.xml"/> + <import file="../../../../ant/${servlet.runtime}-imports.xml"/> + <import file="../../../../ant/beehive-tools.xml"/> + + <property name="webapp.name" value="projectModelWeb"/> + <property name="testRecorder.config.name" value="netui-server-projectModel-config"/> + <property name="server.root.url" value="http://localhost:8080"/> + <property name="webapp.waitfor.url" value="${server.root.url}/${webapp.name}"/> + <property name="project.dir" value="${app.dir}/projectModel"/> + <property name="web.content.dir" location="${project.dir}/webContent"/> + <property name="web.source.dir" location="${project.dir}/webSource"/> + <property name="web.output.dir" location="${project.dir}/build/webOutput"/> + <property name="web.classes.dir" location="${web.output.dir}/WEB-INF/classes"/> + <property name="source.dir" location="${project.dir}/src"/> + <property name="temp.gen.dir" location="${web.output.dir}/WEB-INF/.tmpbeansrc"/> + <property name="tmp.sourcegen.dir" value=".tmpbeansrc"/> + + + <!-- ================================================================ --> + <!-- --> + <!-- Targets for building a webapp --> + <!-- --> + <!-- ================================================================ --> + <target name="build" description="Build webapp"> + <echo message="--------------------------------------------------"/> + <echo message="| NetUI projectModelWeb DRT webapp build starting |"/> + <echo message="--------------------------------------------------"/> + + <!-- the default version of Struts for the DRTs. To override, pass -Dstruts.version=1.1 on the command line --> + <property name="struts.version" value="1.2"/> + + <echo>struts.version: ${struts.version}</echo> + + <mkdir dir="${web.output.dir}"/> + <ant antfile="${test.dir}/ant/buildWebapp.xml" target="deploy.netui" inheritAll="false"> + <property name="webapp.dir" location="${web.output.dir}"/> + <property name="include.testrecorder" value="true"/> + <property name="testRecorder.config.name" value="${testRecorder.config.name}"/> + <property name="test.file" location="${project.dir}/testRecorder/config/testRecorder-tests.xml"/> + <property name="config.file" location="${project.dir}/testRecorder/config/testRecorder-config.xml"/> + <property name="webapp.file" location="${project.dir}/testRecorder/config/testRecorder-webapp.xml"/> + <property name="struts.version" value="${struts.version}"/> + </ant> + + <path id="projectmodel.webapp.classpath"> + <path refid="appserver.build.classpath"/> + <pathelement location="${web.classes.dir}"/> + <fileset dir="${web.output.dir}/WEB-INF/lib"> + <include name="*.jar"/> + </fileset> + </path> + + <path id="projectmodel.webapp.sourcepath"> + <pathelement location="${web.source.dir}"/> + <pathelement location="${source.dir}"/> + </path> + + <delete dir="${temp.gen.dir}" includeEmptyDirs="true"/> + <mkdir dir="${web.classes.dir}"/> + + <!-- compile source files in src --> + <javac srcdir="${source.dir}" destdir="${web.classes.dir}" classpathref="projectmodel.webapp.classpath"/> + + <!-- compile XSDs --> + <echo>Building XML Schemas</echo> + <build-schemas srcdir="${project.dir}/schemas" destdir="${web.classes.dir}"/> + + <!-- compile controls --> + <echo>Building Controls</echo> + <build-controls srcdir="${source.dir}" + destdir="${web.classes.dir}" + tempdir="${temp.gen.dir}" + classpathref="projectmodel.webapp.classpath"/> + + <!-- compile JPFs --> + <echo>Building Page Flows</echo> + <build-pageflows srcdir="${web.source.dir}" + webcontentdir="${web.content.dir}" + weboutputdir="${web.output.dir}" + tempdir="${temp.gen.dir}" + classpathref="projectmodel.webapp.classpath" + sourcepathref="projectmodel.webapp.sourcepath" /> + + <!-- copy resources --> + <echo>Copying all .properties and .xml files to ${web.classes.dir}</echo> + <copy todir="${web.classes.dir}"> + <fileset dir="${web.source.dir}" includes="**/*.properties"/> + <fileset dir="${web.source.dir}" includes="**/*.xml"/> + <fileset dir="${source.dir}" includes="**/*.properties"/> + <fileset dir="${source.dir}" includes="**/*.xml"/> + </copy> + + <!-- copy web content --> + <echo>Copying content from ${web.content.dir} to ${web.output.dir}</echo> + <copy todir="${web.output.dir}"> + <fileset dir="${web.content.dir}" includes="**"/> + </copy> + + + <echo message="--------------------------------------------------"/> + <echo message="| NetUI projectModelWeb DRT webapp build ending |"/> + <echo message="--------------------------------------------------"/> + + </target> + + <target name="clean" description="Clean webapp"> + <delete dir="${web.output.dir}" failonerror="true"/> + </target> + + <!-- ================================================================ --> + <!-- --> + <!-- Targets for running test recorder test suites --> + <!-- --> + <!-- ================================================================ --> + <target name="playback" description="Playback a specified list of test recorder tests"> + <ant antfile="${test.dir}/ant/testRecorder.xml" target="playback" inheritAll="false"/> + </target> + + <target name="drt.running" description="Playback the 'drt' category to a running server"> + <ant antfile="${test.dir}/ant/testRecorder.xml" target="suite.callback" inheritAll="false"> + <property name="suite.name" value="drt"/> + <property name="playback.webapps" value="${webapp.name}"/> + <property name="waitfor.url" value="${webapp.waitfor.url}"/> + </ant> + </target> + + <target name="drt" description="Run the drt suite with full server start / stop support." depends="clean,build"> + <ant antfile="${test.dir}/ant/testRecorder.xml" inheritAll="false" target="server.test"> + <property name="app.build.file" location="${project.dir}/build.xml"/> + <property name="suite.name" value="drt"/> + <property name="drt.mode" value="true"/> + <property name="playback.webapps" value="${webapp.name}"/> + <!-- Wait for the server's root url to see if the server has started --> + <property name="waitfor.url" value="${server.root.url}"/> + </ant> + </target> + + <target name="ensure.deployed" description="Deploy webapp"> + <echo>ensure.deployed is NYI</echo> + </target> + + <!-- ================================================================ --> + <!-- --> + <!-- Targets for deploying the webapp on a server --> + <!-- --> + <!-- ================================================================ --> + <target name="deploy" description="Deploy webapp"> + <deploy-webapp webappDir="${web.output.dir}" contextPath="${webapp.name}"/> + </target> + + <target name="undeploy" description="Undeploy webapp"> + <undeploy-webapp contextPath="${webapp.name}"/> + </target> + + <target name="redeploy" description="Redeploy webapp"> + <redeploy-webapp contextPath="${webapp.name}"/> + </target> + + <!-- ================================================================ --> + <!-- --> + <!-- Targets for starting / stopping a server --> + <!-- --> + <!-- ================================================================ --> + <target name="start" description="Start server"> + <start-server shmem="false" javaOptions="-ea:org.apache.beehive.netui..."/> + </target> + + <target name="start.without.asserts" description="Start server without assertions enabled"> + <start-server shmem="false" javaOptions=""/> + </target> + + <target name="start.with.shmem" description="Start server with shared memory debugging enabled"> + <start-server shmem="true" javaOptions="-ea:org.apache.beehive.netui..."/> + </target> + + <target name="stop" description="Stop server"> + <stop-server/> + </target> + + <target name="usage"> + <java fork="no" classname="org.apache.tools.ant.Main"> + <arg line="-projecthelp"/> + </java> + </target> + +</project> Propchange: incubator/beehive/trunk/netui/test/webapps/projectModel/build.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/Messages.properties URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/Messages.properties?rev=164185&view=auto ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/Messages.properties (added) +++ incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/Messages.properties Fri Apr 22 00:41:54 2005 @@ -0,0 +1 @@ +error.required=This field is required! Propchange: incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/Messages.properties ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/MyForm.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/MyForm.java?rev=164185&view=auto ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/MyForm.java (added) +++ incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/MyForm.java Fri Apr 22 00:41:54 2005 @@ -0,0 +1,22 @@ +package common; + +import org.apache.beehive.netui.pageflow.annotations.Jpf; + [EMAIL PROTECTED](messageBundle="common.Messages") +public class MyForm +{ + private String _foo; + + @Jpf.ValidatableProperty( + [EMAIL PROTECTED](messageKey="error.required") + ) + public String getFoo() + { + return _foo; + } + + public void setFoo( String foo ) + { + _foo = foo; + } +} Propchange: incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/MyForm.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/strutsMerge.xml URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/strutsMerge.xml?rev=164185&view=auto ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/strutsMerge.xml (added) +++ incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/strutsMerge.xml Fri Apr 22 00:41:54 2005 @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> +<struts-config> + <action-mappings> + <action path="/commonMergeAction" type="org.apache.struts.actions.ForwardAction" parameter="/smokeTest/success.jsp"/> + </action-mappings> +</struts-config> Propchange: incubator/beehive/trunk/netui/test/webapps/projectModel/src/common/strutsMerge.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-config.xml URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-config.xml?rev=164185&view=auto ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-config.xml (added) +++ incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-config.xml Fri Apr 22 00:41:54 2005 @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + +<config xmlns="http://beehive.apache.org/netui/tools/testrecorder/2004"> + <suffixList> + <suffix>jsp</suffix> + <suffix>jspx</suffix> + <suffix>do</suffix> + <suffix>jpf</suffix> + <suffix>faces</suffix> + <suffix></suffix> + </suffixList> + <servletURI>testRecorder</servletURI> + <baseDirectory>@BASE_DIR@</baseDirectory> +</config> Propchange: incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-config.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-tests.xml URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-tests.xml?rev=164185&view=auto ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-tests.xml (added) +++ incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-tests.xml Fri Apr 22 00:41:54 2005 @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<testDefinitions xmlns="http://beehive.apache.org/netui/tools/testrecorder/2004"> + <categories> + <category> + <name>drt</name> + <description>drt</description> + </category> + </categories> + <tests> + <test> + <name>SmokeTest</name> + <description>Basic test of a page flow that depends on source/binary artifacts in other directories, namely, /src/common/strutsMerge.xml and /build/webOutput/WEB-INF/classes/common/MyForm.class.</description> + <webapp>projectModelWeb</webapp> + <categories> + <category>drt</category> + </categories> + </test> + </tests> +</testDefinitions> Propchange: incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-tests.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-webapp.xml URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-webapp.xml?rev=164185&view=auto ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-webapp.xml (added) +++ incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-webapp.xml Fri Apr 22 00:41:54 2005 @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + +<server xmlns="http://beehive.apache.org/netui/tools/testrecorder/2004"> + <name>projectModel</name> + <hostname>localhost</hostname> + <port>8080</port> + + <webapps> + <webapp> + <name>projectModelWeb</name> + <description>NetUI / Project Model web application</description> + <testMode>true</testMode> + <contextRoot>/projectModelWeb</contextRoot> + <testDefinitionsDirectory>@DOMAIN_DIR@/projectModel/testRecorder/tests</testDefinitionsDirectory> + </webapp> + </webapps> +</server> Propchange: incubator/beehive/trunk/netui/test/webapps/projectModel/testRecorder/config/testRecorder-webapp.xml ------------------------------------------------------------------------------ svn:eol-style = native
