private Page loadPhysical ( PageContext pc , Page page ) throws TemplateException { if ( ! mapping . hasPhysical ( ) ) return null ; ConfigWeb config = pc . getConfig ( ) ; PageContextImpl pci = ( PageContextImpl ) pc ; if ( ( mapping . getInspectTemplate ( ) == Config . INSPECT_NEVER || pci . isTrusted ( page ) ) && isLoad ( LOAD_PHYSICAL ) ) return page ; Resource srcFile = getPhyscalFile ( ) ; long srcLastModified = srcFile . lastModified ( ) ; if ( srcLastModified == 0L ) return null ; // Page exists if ( page != null ) { // if(page!=null && !recompileAlways) { if ( srcLastModified != page . getSourceLastModified ( ) ) { // same size, maybe the content has not changed? boolean same = false ; if ( page instanceof PagePro && ( ( PagePro ) page ) . getSourceLength ( ) == srcFile . length ( ) ) { PagePro pp = ( PagePro ) page ; try { same = pp . getHash ( ) == PageSourceCode . toString ( this , config . getTemplateCharset ( ) ) . hashCode ( ) ; } catch ( IOException e ) { /* * in case this exception happen, the following compile process will fail as well and report the * error */ } } if ( ! same ) { this . page = page = compile ( config , mapping . getClassRootDirectory ( ) , page , false , pc . ignoreScopes ( ) ) ; page . setPageSource ( this ) ; page . setLoadType ( LOAD_PHYSICAL ) ; } } } // page doesn't exist else { Resource classRootDir = mapping . getClassRootDirectory ( ) ; Resource classFile = classRootDir . getRealResource ( getJavaName ( ) + ".class" ) ; boolean isNew = false ; // new class if ( flush || ! classFile . exists ( ) ) { this . page = page = compile ( config , classRootDir , null , false , pc . ignoreScopes ( ) ) ; flush = false ; isNew = true ; } // load page else { try { this . page = page = newInstance ( mapping . getPhysicalClass ( this . getClassName ( ) ) ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; this . page = page = null ; } if ( page == null ) this . page = page = compile ( config , classRootDir , null , false , pc . ignoreScopes ( ) ) ; } // check if version changed or lasMod if ( ! isNew && ( srcLastModified != page . getSourceLastModified ( ) || page . getVersion ( ) != pc . getConfig ( ) . getFactory ( ) . getEngine ( ) . getInfo ( ) . getFullVersionInfo ( ) ) ) { isNew = true ; this . page = page = compile ( config , classRootDir , page , false , pc . ignoreScopes ( ) ) ; } page . setPageSource ( this ) ; page . setLoadType ( LOAD_PHYSICAL ) ; } pci . setPageUsed ( page ) ; return page ; }
throws only an exception when compilation fails