Package railo.runtime

Examples of railo.runtime.PageContextImpl


   
    Class clazz = checkPrimaryTypes(className, null);
    if(clazz!=null) return clazz;
   
    if(cl==null){
      PageContextImpl pci = (PageContextImpl) ThreadLocalPageContext.get();
      if(pci!=null){
        try {
          cl=pci.getClassLoader();
        }
        catch (IOException e) {}
      }
      if(cl==null) {
        Config config = ThreadLocalPageContext.getConfig();
View Full Code Here


  }
 
  private void pause(String name,CFMLFactoryImpl factory,List<IFDThread> threads) {
    Struct pcs = factory.getRunningPageContexts();
    Iterator<Entry<Key, Object>> it = pcs.entryIterator();
    PageContextImpl pc;
   
    while(it.hasNext()){
      pc=(PageContextImpl) it.next().getValue();
      try {
        pc.getThread().wait();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      threads.add(new FDThreadImpl(this,factory,name,pc));
    }
View Full Code Here

   * @return matching thread or null
   */
  private FDThreadImpl getByNativeIdentifier(String name,CFMLFactoryImpl factory,String id) {
    Struct pcs = factory.getRunningPageContexts();
    Iterator it = pcs.entrySet().iterator();
    PageContextImpl pc;
   
    while(it.hasNext()){
      pc=(PageContextImpl) ((Entry) it.next()).getValue();
      if(equals(pc,id)) return new FDThreadImpl(this,factory,name,pc);
    }
View Full Code Here

    return pe.getMessage();
  }
 
  public static List createExceptionStack(PageException pe) {
    StackTraceElement[] traces = pe.getStackTrace();
    PageContextImpl pc = (PageContextImpl) ThreadLocalPageContext.get();
    String template="";
    StackTraceElement trace=null;
    List list=new ArrayList();
    Resource res;
    PageSource ps;
    FDStackFrameImpl frame;
   
   
    for(int i=traces.length-1;i>=0;i--) {
      trace=traces[i];
      ps=null;
      if(trace.getLineNumber()<=0) continue;
      template=trace.getFileName();
      if(template==null || ResourceUtil.getExtension(template,"").equals("java")) continue;
     
      res = ResourceUtil.toResourceNotExisting(pc, template);
      ps = pc.toPageSource(res, null);
     
      frame = new FDStackFrameImpl(null,pc,trace,ps);
      if(ASMUtil.isOverfowMethod(trace.getMethodName())) list.set(0,frame);
      else list.add(0,frame);
     
View Full Code Here

   // private static int count=0;
   
   

    private Object _callCachedWithin(PageContext pc,Collection.Key calledName, Object[] args, Struct values,boolean doIncludePath) throws PageException {
      PageContextImpl pci=(PageContextImpl) pc;
      String id = UDFUtil.callerHash(this,args,values);
     
    Cache cache = Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_FUNCTION,DEFAULT_CACHE)
    Object o =  cache.getValue(id,null);
   
    // get from cache
    if(o instanceof UDFCacheEntry ) {
      UDFCacheEntry entry = (UDFCacheEntry)o;
      //if(entry.creationdate+properties.cachedWithin>=System.currentTimeMillis()) {
        try {
          pc.write(entry.output);
        } catch (IOException e) {
          throw Caster.toPageException(e);
        }
        return entry.returnValue;
      //}
     
      //cache.remove(id);
    }
     
    // execute the function
    BodyContent bc =  pci.pushBody();
     
      try {
        Object rtn = _call(pci,calledName, args, values, doIncludePath);
        String out = bc.getString();
        cache.put(id, new UDFCacheEntry(out, rtn),properties.cachedWithin,properties.cachedWithin);
View Full Code Here

    }
   
    private Object _call(PageContext pc,Collection.Key calledName, Object[] args, Struct values,boolean doIncludePath) throws PageException {
     
      //print.out(count++);
      PageContextImpl pci=(PageContextImpl) pc;
      Argument newArgs= pci.getScopeFactory().getArgumentInstance();
        newArgs.setFunctionArgumentNames(properties.argumentsSet);
        LocalImpl newLocal=pci.getScopeFactory().getLocalInstance();
       
    Undefined   undefined=pc.undefinedScope();
    Argument  oldArgs=pc.argumentsScope();
        Local    oldLocal=pc.localScope();
        Collection.Key oldCalledName=pci.getActiveUDFCalledName();
       
    pc.setFunctionScopes(newLocal,newArgs);
    pci.setActiveUDFCalledName(calledName);
   
    int oldCheckArgs=undefined.setMode(properties.localMode==null?pc.getApplicationContext().getLocalMode():properties.localMode.intValue());
    PageSource psInc=null;
    try {
      PageSource ps = getPageSource();
      if(doIncludePath)psInc = ps;
      //if(!ps.getDisplayPath().endsWith("Dump.cfc"))print.e(getPageSource().getDisplayPath());
      if(doIncludePath && getOwnerComponent()!=null) {
        //if(!ps.getDisplayPath().endsWith("Dump.cfc"))print.ds(ps.getDisplayPath());
        psInc=ComponentUtil.getPageSource(getOwnerComponent());
        if(psInc==pci.getCurrentTemplatePageSource()) {
          psInc=null;
        }
       
      }
      pci.addPageSource(ps,psInc);
      pci.addUDF(this);
     
//////////////////////////////////////////
      BodyContent bc=null;
      Boolean wasSilent=null;
      boolean bufferOutput=getBufferOutput(pci);
      if(!getOutput()) {
        if(bufferOutput) bc =  pci.pushBody();
        else wasSilent=pc.setSilent()?Boolean.TRUE:Boolean.FALSE;
      }
     
        UDF parent=null;
        if(ownerComponent!=null) {
          parent=pci.getActiveUDF();
          pci.setActiveUDF(this);
        }
        Object returnValue = null;
       
        try {
         
          if(args!=nulldefineArguments(pc,getFunctionArguments(),args,newArgs);
        else       defineArguments(pc,getFunctionArguments(),values,newArgs);
         
        returnValue=implementation(pci);
        if(ownerComponent!=null)pci.setActiveUDF(parent);
      }
          catch(Throwable t) {
            if(ownerComponent!=null)pci.setActiveUDF(parent);
            if(!getOutput()) {
              if(bufferOutput)BodyContentUtil.flushAndPop(pc,bc);
              else if(!wasSilent)pc.unsetSilent();
            }
            //BodyContentUtil.flushAndPop(pc,bc);
            throw Caster.toPageException(t);
          }
          if(!getOutput()) {
            if(bufferOutput)BodyContentUtil.clearAndPop(pc,bc);
            else if(!wasSilent)pc.unsetSilent();
          }
          //BodyContentUtil.clearAndPop(pc,bc);
         
         
         
         
          if(properties.returnType==CFTypes.TYPE_ANY) return returnValue;
          else if(Decision.isCastableTo(properties.strReturnType,returnValue,false,false,-1)) return returnValue;
          else throw new UDFCasterException(this,properties.strReturnType,returnValue);
      //REALCAST return Caster.castTo(pageContext,returnType,returnValue,false);
//////////////////////////////////////////
     
    }
    finally {
      pc.removeLastPageSource(psInc!=null);
      pci.removeUDF();
            pci.setFunctionScopes(oldLocal,oldArgs);
            pci.setActiveUDFCalledName(oldCalledName);
        undefined.setMode(oldCheckArgs);
            pci.getScopeFactory().recycle(newArgs);
            pci.getScopeFactory().recycle(newLocal);
    }
  }
View Full Code Here

    else throw new ExpressionException("The attribute duration must be greater or equal than 0, now ["+duration+"]");
   
  }

    private void doJoin() throws ApplicationException {
      PageContextImpl mpc=(PageContextImpl)getMainPageContext(pc);
   
      String[] names;
      if(lcName==null) {
        names=mpc.getThreadScopeNames();
      }
      else names=ListUtil.listToStringArray(lcName, ',');
     
      ChildThread ct;
      Threads ts;
      long start=System.currentTimeMillis(),_timeout=timeout>0?timeout:-1;
     
      for(int i=0;i<names.length;i++) {
        if(StringUtil.isEmpty(names[i],true))continue;
        //PageContextImpl mpc=(PageContextImpl)getMainPageContext(pc);
        ts = mpc.getThreadScope(names[i]);
        if(ts==null)
          throw new ApplicationException("there is no thread running with the name ["+names[i]+"], only the following threads existing ["+ListUtil.arrayToList(mpc.getThreadScopeNames(),", ")+"]");
        ct=ts.getChildThread();
       
        if(ct.isAlive()) {
          try {
          if(_timeout!=-1)ct.join(_timeout);
View Full Code Here

        }
      }
     
    }
  private void doTerminate() throws ApplicationException {
    PageContextImpl mpc=(PageContextImpl)getMainPageContext(pc);
   
    Threads ts = mpc.getThreadScope(lcName);
   
    if(ts==null)
      throw new ApplicationException("there is no thread running with the name ["+name+"]");
    ChildThread ct = ts.getChildThread();
   
View Full Code Here

     * @param config
     */
    public static void addTagMetaData(ConfigWebImpl cw) {
      if(true) return;
     
      PageContextImpl pc=null;
      try{
        pc = ThreadUtil.createPageContext(cw, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM,
        "localhost", "/","", new Cookie[0], new Pair[0], new Pair[0], new StructImpl());
       
      }
      catch(Throwable t){
        return;
      }
      PageContext orgPC = ThreadLocalPageContext.get();
      ThreadLocalPageContext.register(pc);
        try{
        TagLibTagAttr attrFileName,attrIsWeb;
          String filename;
        Boolean isWeb;
        TagLibTag tlt;
       
        TagLib[] tlds = cw.getTLDs();
        for(int i=0;i<tlds.length;i++){
          Map<String, TagLibTag> tags = tlds[i].getTags();
          Iterator<TagLibTag> it = tags.values().iterator();
          while(it.hasNext()){
            tlt = it.next();
            if("railo.runtime.tag.CFTagCore".equals(tlt.getTagClassName())) {
              attrFileName = tlt.getAttribute("__filename");
              attrIsWeb = tlt.getAttribute("__isweb");
              if(attrFileName!=null && attrIsWeb!=null) {
                filename = Caster.toString(attrFileName.getDefaultValue(),null);
                isWeb=Caster.toBoolean(attrIsWeb.getDefaultValue(),null);
                if(filename!=null && isWeb!=null) {
                  addTagMetaData(pc, tlds[i], tlt, filename,isWeb.booleanValue());
                }
              }
            }
          }
        }
      }
      catch(Throwable t){
        //t.printStackTrace();
      }
      finally{
        pc.release();
        ThreadLocalPageContext.register(orgPC);
      }
  }
View Full Code Here

        }
       
        // call page again and
        //MetaData.getInstance(getDirectory()).add(ci.getName(), ci.getRaw());
       
        PageContextImpl pci = (PageContextImpl)pageContext;
        pci.getRootOut().doCache(ci);
         
    }
View Full Code Here

TOP

Related Classes of railo.runtime.PageContextImpl

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.