Examples of PageSource


Examples of railo.runtime.PageSource

   
    public PageSource getPageSourceExisting(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping, boolean onlyPhysicalExisting) {
        realPath=realPath.replace('\\','/');
        String lcRealPath = StringUtil.toLowerCase(realPath)+'/';
        Mapping mapping;
        PageSource ps;

        if(mappings!=null){
          for(int i=0;i<mappings.length;i++) {
              mapping = mappings[i];
              //print.err(lcRealPath+".startsWith"+(mapping.getStrPhysical()));
              if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
                ps= mapping.getPageSource(realPath.substring(mapping.getVirtual().length()));
                if(onlyPhysicalExisting) {
                  if(ps.physcalExists())return ps;
                }
                else if(ps.exists()) return ps;
              }
          }
        }
       
        /// special mappings
        if(useSpecialMappings && lcRealPath.startsWith("/mapping-",0)){
          String virtual="/mapping-tag";
          // tag mappings
          Mapping[] tagMappings=(this instanceof ConfigWebImpl)?new Mapping[]{((ConfigWebImpl)this).getServerTagMapping(),getTagMapping()}:new Mapping[]{getTagMapping()};
          if(lcRealPath.startsWith(virtual,0)){
            for(int i=0;i<tagMappings.length;i++) {
                mapping = tagMappings[i];
                //if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
                  ps = mapping.getPageSource(realPath.substring(virtual.length()));
                  if(onlyPhysicalExisting) {
                    if(ps.physcalExists())return ps;
                  }
                  else if(ps.exists()) return ps;
                //}
            }
          }
         
          // customtag mappings
          tagMappings=getCustomTagMappings();
          virtual="/mapping-customtag";
          if(lcRealPath.startsWith(virtual,0)){
            for(int i=0;i<tagMappings.length;i++) {
                mapping = tagMappings[i];
                //if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
                  ps = mapping.getPageSource(realPath.substring(virtual.length()));
                  if(onlyPhysicalExisting) {
                    if(ps.physcalExists())return ps;
                  }
                  else if(ps.exists()) return ps;
                //}
            }
          }
        }
       
        // component mappings (only used for gateway)
        if(pc!=null && ((PageContextImpl)pc).isGatewayContext()) {
          boolean isCFC=getCFCExtension().equalsIgnoreCase(ResourceUtil.getExtension(realPath, null));
            if(isCFC) {
            Mapping[] cmappings = getComponentMappings();
            for(int i=0;i<cmappings.length;i++) {
              ps = cmappings[i].getPageSource(realPath);
                if(onlyPhysicalExisting) {
                  if(ps.physcalExists())return ps;
                }
                else if(ps.exists()) return ps;
              }
          }
        }
       
        // config mappings
        for(int i=0;i<this.mappings.length-1;i++) {
            mapping = this.mappings[i];
            if((!onlyTopLevel || mapping.isTopLevel()) && lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
              ps= mapping.getPageSource(realPath.substring(mapping.getVirtual().length()));
              if(onlyPhysicalExisting) {
                if(ps.physcalExists())return ps;
              }
              else if(ps.exists()) return ps;
            }
        }
       
        if(useDefaultMapping){
          ps= this.mappings[this.mappings.length-1].getPageSource(realPath);
          if(onlyPhysicalExisting) {
            if(ps.physcalExists())return ps;
          }
          else if(ps.exists()) return ps;
        }
        return null;
    }
View Full Code Here

Examples of railo.runtime.PageSource

    public PageSource[] getPageSources(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping) {
        realPath=realPath.replace('\\','/');
        String lcRealPath = StringUtil.toLowerCase(realPath)+'/';
        Mapping mapping;

        PageSource ps;
        List<PageSource> list=new ArrayList<PageSource>();
     
        if(mappings!=null){
          for(int i=0;i<mappings.length;i++) {
              mapping = mappings[i];
              //print.err(lcRealPath+".startsWith"+(mapping.getStrPhysical()));
              if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
                list.add(mapping.getPageSource(realPath.substring(mapping.getVirtual().length())));
              }
          }
        }
       
        /// special mappings
        if(useSpecialMappings && lcRealPath.startsWith("/mapping-",0)){
          String virtual="/mapping-tag";
          // tag mappings
          Mapping[] tagMappings=(this instanceof ConfigWebImpl)?new Mapping[]{((ConfigWebImpl)this).getServerTagMapping(),getTagMapping()}:new Mapping[]{getTagMapping()};
          if(lcRealPath.startsWith(virtual,0)){
            for(int i=0;i<tagMappings.length;i++) {
                ps=tagMappings[i].getPageSource(realPath.substring(virtual.length()));
                if(ps.exists()) list.add(ps);
            }
          }
         
          // customtag mappings
          tagMappings=getCustomTagMappings();
          virtual="/mapping-customtag";
          if(lcRealPath.startsWith(virtual,0)){
            for(int i=0;i<tagMappings.length;i++) {
                ps=tagMappings[i].getPageSource(realPath.substring(virtual.length()));
                if(ps.exists()) list.add(ps);
            }
          }
        }
       
        // component mappings (only used for gateway)
        if(pc!=null && ((PageContextImpl)pc).isGatewayContext()) {
          boolean isCFC=getCFCExtension().equalsIgnoreCase(ResourceUtil.getExtension(realPath, null));
            if(isCFC) {
            Mapping[] cmappings = getComponentMappings();
            for(int i=0;i<cmappings.length;i++) {
              ps=cmappings[i].getPageSource(realPath);
              if(ps.exists()) list.add(ps);
              }
          }
        }
       
        // config mappings
View Full Code Here

Examples of railo.runtime.PageSource

 
  public Page getCachedPage(PageContext pc,String pathWithCFC) throws PageException {
    if(componentPathCache==null) return null;
   
    PageSource ps = componentPathCache.get(pathWithCFC.toLowerCase());
    if(ps==null) return null;
    return ((PageSourceImpl)ps).loadPage(pc,(Page)null);
  }
View Full Code Here

Examples of railo.runtime.PageSource

    Resource[] children = dir.listResources(FILTER);
   
    RestSettings settings = pc.getApplicationContext().getRestSettings();
    ArrayList<Source> sources = new ArrayList<Source>();
 
    PageSource ps;
    ComponentAccess cfc;
    Struct meta;
    String path;
    for(int i=0;i<children.length;i++){
      try{
View Full Code Here

Examples of railo.runtime.PageSource

      String cp = SystemUtil.addPlaceHolder(res, null);
      if(!StringUtil.isEmpty(cp))return cp;
    }
   
    //Config config=pc.getConfig();
    PageSource ps = pc.toPageSource(res,null);
    if(ps==null) return absPath;
   
    String realPath = ps.getRealpath();
    realPath=realPath.replace('\\', '/');
    if(StringUtil.endsWith(realPath,'/'))realPath=realPath.substring(0,realPath.length()-1);
   
    String mapping=ps.getMapping().getVirtual();
    mapping=mapping.replace('\\', '/');
    if(StringUtil.endsWith(mapping,'/'))mapping=mapping.substring(0,mapping.length()-1);
   
    return mapping+realPath;
  }
View Full Code Here

Examples of railo.runtime.PageSource

        Object parameters=null;
        try {
            cfc="/"+serviceName.replace('.','/')+".cfc";
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            pc=createPageContext(factory,cfc,"method="+serviceMethodName,baos,req);
            PageSource source = ((PageContextImpl)pc).getPageSourceExisting(cfc);

            if(caster==null)caster=((ConfigImpl)pc.getConfig()).getAMFCaster(configMap);
            parameters=caster.toCFMLObject(rawParams);
          if(source!=null) {
            print(pc,cfc+"?method="+serviceMethodName);
              // Map
              //print.err(parameters);
            if(parameters instanceof Map){
              //print.err("map");
                pc.getHttpServletRequest().setAttribute("argumentCollection", parameters);
              }
            // List
              else if(parameters instanceof List){
                //print.err("list");
                pc.getHttpServletRequest().setAttribute("argumentCollection", parameters);
              }
              else {
                ArrayList list = new ArrayList();
                list.add(parameters);
                pc.getHttpServletRequest().setAttribute("argumentCollection", list);
               
              }
             
                // Execute
                pc.execute(cfc,true);

                // write back response
                writeBackResponse(pc,rsp);
               
                // After
              return caster.toAMFObject(pc.variablesScope().get(AMF_FORWARD,null));
             
            }
        }
        finally {
            if(pc!=null)factory.releaseRailoPageContext(pc);
        }   
       
     // CFML Files
        String cfml;
        try {
            cfml="/"+(serviceName.replace('.','/')+'/'+serviceMethodName.replace('.','/'))+".cfm";
            pc=createPageContext(factory,cfml,"",null,req);
            PageSource source = ((PageContextImpl)pc).getPageSourceExisting(cfml);
           
            if(source!=null) {
              print(pc,cfml);
              // Before
                Struct params=new StructImpl();
View Full Code Here

Examples of railo.runtime.PageSource

        return size;
    }
    private void removeOldest(PageSourcePool[] pools) {
        PageSourcePool pool=null;
        Object key=null;
        PageSource ps=null;
       
        long date=-1;
        for(int i=0;i<pools.length;i++) {
          try {
              Object[] keys=pools[i].keys();
              for(int y=0;y<keys.length;y++) {
                  ps = pools[i].getPageSource(keys[y],false);
                  if(date==-1 || date>ps.getLastAccessTime()) {
                      pool=pools[i];
                      key=keys[y];
                      date=ps.getLastAccessTime();
                  }
              }
          }
          catch(Throwable t) {
            pools[i].clear();
View Full Code Here

Examples of railo.runtime.PageSource

      attributesScope.removeEL(KeyConstants._template);
        String template=objTemplate.toString();

            if(StringUtil.startsWith(template,'/'))  {
              PageSource[] sources = ((PageContextImpl)pageContext).getPageSources(template);
              PageSource ps = MappingImpl.isOK(sources);
             
              if(ps==null)
          throw new MissingIncludeException(sources[0],"could not find template ["+template+"], file ["+sources[0].getDisplayPath()+"] doesn't exist");
              source=new InitFile(ps,template,template.endsWith('.'+pageContext.getConfig().getCFCExtension()));
            }
View Full Code Here

Examples of railo.runtime.PageSource

    int line=0;
    String template="",tlast;
    Struct item;
    StackTraceElement trace=null;
    int index=-1;
    PageSource ps;
    for(int i=0;i<traces.length;i++) {
      trace=traces[i];
      tlast=template;
      template=trace.getFileName();
      if(trace.getLineNumber()<=0 || template==null || ResourceUtil.getExtension(template,"").equals("java")) continue;
      // content
      if(!StringUtil.emptyIfNull(tlast).equals(template))index++;
     
      String[] content=null;
      try {
       
        Resource res = config.getResource(template);
       
        // never happens i think
        if(!res.exists()) {
          res = ResourceUtil.toResourceNotExisting(ThreadLocalPageContext.get(), template);
        }
        
        if(res.exists()) 
          content=IOUtil.toStringArray(IOUtil.getReader(res,CharsetUtil.toCharset(config.getTemplateCharset())));
        else {
          if(sources.size()>index)ps = sources.get(index);
          else ps=null;
          if(ps!=null && trace.getClassName().equals(ps.getFullClassName())) {
            if(ps.physcalExists())
              content=IOUtil.toStringArray(IOUtil.getReader(ps.getPhyscalFile(), CharsetUtil.toCharset(config.getTemplateCharset())));
            template=ps.getDisplayPath();
          }
        } 
      }
      catch (Throwable th) {
        //th.printStackTrace();
View Full Code Here

Examples of railo.runtime.PageSource

  public void serviceFile(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException {
    req=new HTTPServletRequestWrap(req);
    CFMLFactory factory=getCFMLFactory(servlet.getServletContext(), servlet.getServletConfig(), req);
        ConfigWeb config = factory.getConfig();
        PageSource ps = config.getPageSourceExisting(null, null, req.getServletPath(), false, true, true, false);
        //Resource res = ((ConfigWebImpl)config).getPhysicalResourceExistingX(null, null, req.getServletPath(), false, true, true);
       
    if(ps==null) {
        rsp.sendError(404);
      }
      else {
        Resource res = ps.getResource();
        if(res==null) {
          rsp.sendError(404);
        }
        else {
          ReqRspUtil.setContentLength(rsp,res.length());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.