Package railo.runtime

Examples of railo.runtime.Page


         
         
          //Page p = ps.loadPage(pc.getConfig());
          String name=res.getName();
          name=name.substring(0,name.length()-4);
          Page p = ComponentLoader.loadPage(pc, ps,true);
          if(!(p instanceof InterfacePage)){
            ComponentAccess cfc = ComponentLoader.loadComponent(pc, p, ps, name, true,true);
            if(cfc.isPersistent()){
              components.add(cfc);
            }
View Full Code Here


  }

  public static Page getPage(PageContext pc, PageSource ps) throws PageException {
    PageSourceImpl psi = (PageSourceImpl)ps;
   
    Page p = psi.getPage();
    if(p!=null){
      //print.o("getPage(existing):"+ps.getDisplayPath()+":"+psi.hashCode()+":"+p.hashCode());
      return p;
    }
    pc=ThreadLocalPageContext.get(pc);
View Full Code Here

      rawPath=rawPath.trim().replace('\\','/');
      String path=(rawPath.indexOf("./")==-1)?rawPath.replace('.','/'):rawPath;
      String pathWithCFC=path.concat(".cfc");
      boolean isRealPath=!StringUtil.startsWith(pathWithCFC,'/');
      PageSource currPS = pc.getCurrentPageSource();
      Page currP=((PageSourceImpl)currPS).loadPage(pc,(Page)null);
     
      PageSource ps=null;
      Page page=null;
     
      if(searchLocal==null)
        searchLocal=Caster.toBoolean(config.getComponentLocalSearch());
      if(searchRoot==null)
        searchRoot=Caster.toBoolean(config.getComponentRootSearch());
     
      //boolean searchLocal=config.getComponentLocalSearch();
    // CACHE
      // check local in cache
      String localCacheName=null;
      if(searchLocal && isRealPath){
        localCacheName=currPS.getDisplayPath().replace('\\', '/');
        localCacheName=localCacheName.substring(0,localCacheName.lastIndexOf('/')+1).concat(pathWithCFC);
        if(doCache){
          page=config.getCachedPage(pc, localCacheName);
          if(page!=null) return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
        }
      }
     
      // check import cache
      if(doCache && isRealPath){
        ImportDefintion impDef = config.getComponentDefaultImport();
        ImportDefintion[] impDefs=currP==null?new ImportDefintion[0]:currP.getImportDefintions();
        int i=-1;
        do{
         
          if(impDef.isWildcard() || impDef.getName().equalsIgnoreCase(path)){
            page=config.getCachedPage(pc, "import:"+impDef.getPackageAsPath()+pathWithCFC);
            if(page!=null) return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
           
            //app-page=config.getCachedPage(pc, "import:"+appName+":"+impDef.getPackageAsPath()+pathWithCFC);
            //app-if(page!=null) return load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
          }
          impDef=++i<impDefs.length?impDefs[i]:null;
        }
        while(impDef!=null);
      }
     
      if(doCache) {
        // check global in cache
        page=config.getCachedPage(pc, pathWithCFC);
        if(page!=null) return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
       
        // get pages from application mappings
        //app-page=config.getCachedPage(pc, ":"+appName+":"+pathWithCFC);
        //app-if(page!=null) return load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
      }
     
    // SEARCH
      // search from local
      if(searchLocal && isRealPath)  {
        // check realpath
        PageSource[] arr = ((PageContextImpl)pc).getRelativePageSources(pathWithCFC);
        page=PageSourceImpl.loadPage(pc, arr,null);
      if(page!=null){
        if(doCache)config.putCachedPageSource(localCacheName, page.getPageSource());
        return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
      }
      }
     
      // search with imports
      Mapping[] cMappings = config.getComponentMappings();
     
      if(isRealPath){

        ImportDefintion impDef = config.getComponentDefaultImport();
        ImportDefintion[] impDefs=currP==null?new ImportDefintion[0]:currP.getImportDefintions();
        PageSource[] arr;

       
        int i=-1;
        do{
          if(impDef.isWildcard() || impDef.getName().equalsIgnoreCase(path)){
           
            // search from local first
            if(searchLocal){
              arr = ((PageContextImpl)pc).getRelativePageSources(impDef.getPackageAsPath()+pathWithCFC);
              page=PageSourceImpl.loadPage(pc, arr,null);
              if(page!=null)  {
                if(doCache)config.putCachedPageSource("import:"+impDef.getPackageAsPath()+pathWithCFC, page.getPageSource());
                return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
                }
            }
           
            // search local component mappings
            /*app-if(lcMappings!=null) {
              Mapping m;
                for(int y=0;y<lcMappings.length;y++){
                  m=lcMappings[y];
                  String key=appName+":"+impDef.getPackageAsPath()+pathWithCFC;
                  ps=m.getPageSource(impDef.getPackageAsPath()+pathWithCFC);
                  page=((PageSourceImpl)ps).loadPage(pc,pc.getConfig(),null);
                if(page!=null)  {   
                  if(doCache)config.putCachedPageSource("import:"+key, page.getPageSource());
                  return load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
                  }
                }
              }*/
           
            // search mappings and webroot
            page=PageSourceImpl.loadPage(pc, ((PageContextImpl)pc).getPageSources("/"+impDef.getPackageAsPath()+pathWithCFC), null);
            if(page!=null){
                String key=impDef.getPackageAsPath()+pathWithCFC;
                if(doCache && !((MappingImpl)page.getPageSource().getMapping()).isAppMapping())
                  config.putCachedPageSource("import:"+key, page.getPageSource());
              return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
              }
           
            // search component mappings
            Mapping m;
              for(int y=0;y<cMappings.length;y++){
                m=cMappings[y];
                ps=m.getPageSource(impDef.getPackageAsPath()+pathWithCFC);
                page=((PageSourceImpl)ps).loadPage(pc,(Page)null);
              if(page!=null)  {   
                if(doCache)config.putCachedPageSource("import:"+impDef.getPackageAsPath()+pathWithCFC, page.getPageSource());
                return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
                }
              }
          }
          impDef=++i<impDefs.length?impDefs[i]:null;
        }
        while(impDef!=null);
       
      }
           
    String p;
      if(isRealPathp='/'+pathWithCFC;
      else p=pathWithCFC;
     

   
      // search local component mappings
      /* app-if(lcMappings!=null) {
        Mapping m;
        for(int i=0;i<lcMappings.length;i++){
          m=lcMappings[i];
          ps=m.getPageSource(p);
          page=((PageSourceImpl)ps).loadPage(pc,pc.getConfig(),null);
          String key=":"+appName+":"+pathWithCFC;
          if(page!=null){
            if(doCache)config.putCachedPageSource(key, page.getPageSource());
            return load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
            }
        }
      }*/
     
      // search mappings and webroot
      page=PageSourceImpl.loadPage(pc,((PageContextImpl)pc).getPageSources(p),null);
      if(page!=null){
        String key=pathWithCFC;
        if(doCache && !((MappingImpl)page.getPageSource().getMapping()).isAppMapping())
          config.putCachedPageSource(key, page.getPageSource());
      return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
      }
   
      // search component mappings
      Mapping m;
      for(int i=0;i<cMappings.length;i++){
        m=cMappings[i];
        ps=m.getPageSource(p);
        page=((PageSourceImpl)ps).loadPage(pc,(Page)null);
       
        // recursive search
        if(page==null && config.doComponentDeepSearch() && m.hasPhysical() && path.indexOf('/')==-1) {
          String _path=getPagePath(pc, m.getPhysical(), null,pathWithCFC,DirectoryResourceFilter.FILTER);
          if(_path!=null) {
            ps=m.getPageSource(_path);
              page=((PageSourceImpl)ps).loadPage(pc,(Page)null);
              doCache=false;// do not cache this, it could be ambigous
          }
        }
       
        if(page!=null){
          if(doCache)config.putCachedPageSource(pathWithCFC, page.getPageSource());
          return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
          }
      }
     

      // search relative to active cfc (this get not cached because the cache get ambigous if we do)
      if(searchLocal && isRealPath)  {
        if(child==null) {
          Component cfc = pc.getActiveComponent();
          if(cfc!=null) child = cfc.getPageSource();
        }
       
       
        if(child!=null) {
          ps=child.getRealPage(pathWithCFC);
          if(ps!=null) {
          page=((PageSourceImpl)ps).loadPage(pc,(Page)null);
 
          if(page!=null){
            return returnPage?page:load(pc,page,page.getPageSource(),trim(path.replace('/', '.')),isRealPath,interfaceUDFs);
          }
        }
        }
      }
     
View Full Code Here

import railo.runtime.type.util.ArrayUtil;

public class MetadataUtil {

    public static Page getPageWhenMetaDataStillValid(PageContext pc,ComponentImpl comp, boolean ignoreCache) throws PageException {
      Page page = getPage(pc,comp._getPageSource());
      if(ignoreCache) return page;

      if(page.metaData!=null && page.metaData.get()!=null) {
        if(hasChanged(pc,((MetaDataSoftReference)page.metaData).creationTime,comp)) {
          page.metaData=null;
View Full Code Here

        }
      }
      return page;
  }
    public static Page getPageWhenMetaDataStillValid(PageContext pc,InterfaceImpl interf, boolean ignoreCache) throws PageException {
      Page page = getPage(pc,interf.getPageSource());
      if(ignoreCache) return page;
     
      if(page.metaData!=null && page.metaData.get()!=null) {
        if(hasChanged(pc,((MetaDataSoftReference)page.metaData).creationTime,interf))
          page.metaData=null;
View Full Code Here

   
  private static boolean hasChanged(PageContext pc,long lastMetaCreation, ComponentImpl cfc) throws PageException {
    if(cfc==null) return false;
   
    // check the component
    Page p = getPage(pc, cfc._getPageSource());
    if(hasChanged(p.getCompileTime(),lastMetaCreation)) return true;
   
    // check interfaces
    InterfaceCollection ic = cfc._interfaceCollection();
        if(ic!=null){
          if(hasChanged(pc,lastMetaCreation,ic.getInterfaces())) return true;
View Full Code Here

        }
    return false;
  }

  private static boolean hasChanged(PageContext pc,long lastMetaCreation, InterfaceImpl inter) throws PageException {
    Page p = getPage(pc, inter.getPageSource());
    if(hasChanged(p.getCompileTime(),lastMetaCreation)) return true;
      return hasChanged(pc,lastMetaCreation,inter.getExtends());
  }
View Full Code Here

  private static boolean hasChanged(long compileTime, long lastMetaCreation) {
    return compileTime>lastMetaCreation;
  }
 
  private static Page getPage(PageContext pc,PageSource ps) throws PageException {
    Page page = ((PageSourceImpl)ps).getPage();
      if(page==null) {
        page = ps.loadPage(pc.getConfig());
      }
    return page;
  }
View Full Code Here

      ConfigWebImpl config=(ConfigWebImpl) pc.getConfig();
      PageSource ps = isWeb?
          config.getTagMapping().getPageSource(filename):
          config.getServerTagMapping().getPageSource(filename);
     
      Page p = ps.loadPage(pc);
      ComponentImpl c = ComponentLoader.loadComponent(pc, p, ps, filename, true,true);
      ComponentWrap cw = ComponentWrap.toComponentWrap(Component.ACCESS_PRIVATE,c);
      Struct meta = Caster.toStruct( cw.get(KeyConstants._metadata,null),null);

      // TODO handle all metadata here and make checking at runtime useless
View Full Code Here

    execute(null);
  }
  public PageException execute(Config config)   {
    PageContext oldPc = ThreadLocalPageContext.get();
   
    Page p=page;
   
    if(parent!=null){
      pc=parent;
      ThreadLocalPageContext.register(pc);
    }
    else {
      ConfigWebImpl cwi;
      try {
        cwi = (ConfigWebImpl)config;
        DevNullOutputStream os = DevNullOutputStream.DEV_NULL_OUTPUT_STREAM;
        pc=ThreadUtil.createPageContext(cwi, os, serverName, requestURI, queryString, SerializableCookie.toCookies(cookies), headers, parameters, attributes);
        pc.setRequestTimeout(requestTimeout);
        p=PageSourceImpl.loadPage(pc, cwi.getPageSources(oldPc==null?pc:oldPc,null, template, false,false,true));
        //p=cwi.getPageSources(oldPc,null, template, false,false,true).loadPage(cwi);
      } catch (PageException e) {
        return e;
      }
        pc.addPageSource(p.getPageSource(), true);
    }
    pc.setThreadScope("thread", new ThreadsImpl(this));
    pc.setThread(Thread.currentThread());
   
    //String encodings = pc.getHttpServletRequest().getHeader("Accept-Encoding");
   
    Undefined undefined=pc.us();
   
    Argument newArgs=new ArgumentThreadImpl((Struct) Duplicator.duplicate(attrs,false));
        LocalImpl newLocal=pc.getScopeFactory().getLocalInstance();
        //Key[] keys = attrs.keys();
        Iterator<Entry<Key, Object>> it = attrs.entryIterator();
        Entry<Key, Object> e;
    while(it.hasNext()){
      e = it.next();
      newArgs.setEL(e.getKey(),e.getValue());
    }
   
    newLocal.setEL(KEY_ATTRIBUTES, newArgs);

    Argument oldArgs=pc.argumentsScope();
        Local oldLocal=pc.localScope();
       
        int oldMode=undefined.setMode(Undefined.MODE_LOCAL_OR_ARGUMENTS_ALWAYS);
    pc.setFunctionScopes(newLocal,newArgs);
   
    try {
      p.threadCall(pc, threadIndex);
    }
    catch (Throwable t) {
      if(!Abort.isSilentAbort(t)) {
        ConfigWeb c = pc.getConfig();
        if(c instanceof ConfigImpl) {
View Full Code Here

TOP

Related Classes of railo.runtime.Page

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.