Package railo.runtime

Examples of railo.runtime.PageContextImpl


            return res;
        }
     
        //if(allowRealpath){
          if(StringUtil.startsWith(path,'/')) {
            PageContextImpl pci=(PageContextImpl) pc;
            ConfigWebImpl cwi=(ConfigWebImpl) pc.getConfig();
            PageSource[] sources = cwi.getPageSources(pci, pc.getApplicationContext().getMappings(), path, false, pci.useSpecialMappings(), true);
            //Resource[] reses = cwi.getPhysicalResourcesX(pc,pc.getApplicationContext().getMappings(),path,false,pci.useSpecialMappings(),true);
            if(!ArrayUtil.isEmpty(sources)) {
             
              for(int i=0;i<sources.length;i++){
                if(sources[i].exists()) return sources[i].getResource();
View Full Code Here


        if(res.isAbsolute() && (res.exists() || parentExists(res))) {
          return res;
        }
       
        if(StringUtil.startsWith(destination,'/')) {
          PageContextImpl pci=(PageContextImpl) pc;
          ConfigWebImpl cwi=(ConfigWebImpl) pc.getConfig();
          PageSource[] sources = cwi.getPageSources(pci, pc.getApplicationContext().getMappings(), destination,
              false, pci.useSpecialMappings(),true);
          //Resource[] reses = cwi.getPhysicalResourcesX(pc,pc.getApplicationContext().getMappings(),destination,false,pci.useSpecialMappings(),true);
          if(!ArrayUtil.isEmpty(sources)) {
            for(int i=0;i<sources.length;i++){
              if(sources[i].exists() || parentExists(sources[i])) {
                res=sources[i].getResource();
View Full Code Here

        return res;
      }
     
      boolean isUNC;
        if(!(isUNC=isUNCPath(destination)) && StringUtil.startsWith(destination,'/')) {
          PageContextImpl pci=(PageContextImpl) pc;
          ConfigWebImpl cwi=(ConfigWebImpl) pc.getConfig();
          PageSource[] sources = cwi.getPageSources(pci, pc.getApplicationContext().getMappings(), destination, false,
              pci.useSpecialMappings(), SystemUtil.isWindows());
          //Resource[] arr = cwi.getPhysicalResources(pc,pc.getApplicationContext().getMappings(),destination,false,pci.useSpecialMappings(),SystemUtil.isWindows());
          if(!ArrayUtil.isEmpty(sources)) {
            for(int i=0;i<sources.length;i++){
              res=sources[i].getResource();
              if(res!=null) return res;
View Full Code Here

  /*public static Object createProxy(Config config,Component cfc, String className) throws PageException, IOException {
    return createProxy(cfc, null, ClassUtil.loadClass(config.getClassLoader(), className));
  }*/

  public static Object createProxy(PageContext pc, Component cfc, Class extendz,Class... interfaces) throws PageException, IOException {
    PageContextImpl pci=(PageContextImpl) pc;
    if(extendz==null) extendz=Object.class;
    if(interfaces==null) interfaces=new Class[0];
    else {
      for(int i=0;i<interfaces.length;i++){
        if(!interfaces[i].isInterface())
          throw new IOException("definition ["+interfaces[i].getName()+"] is a class and not a interface");
      }
    }
   
   
   
    Type typeExtends = Type.getType(extendz);
    Type[] typeInterfaces = ASMUtil.toTypes(interfaces);
    String[] strInterfaces=new String[typeInterfaces.length];
    for(int i=0;i<strInterfaces.length;i++){
      strInterfaces[i]=typeInterfaces[i].getInternalName();
    }
   
   
    String className=createClassName(extendz,interfaces);
      //Mapping mapping = cfc.getPageSource().getMapping();
   
      // get ClassLoader
      PhysicalClassLoader cl=null;
    try {
      cl = (PhysicalClassLoader) pci.getRPCClassLoader(false);// mapping.getConfig().getRPCClassLoader(false)
    } catch (IOException e) {
      throw Caster.toPageException(e);
    }
    Resource classFile = cl.getDirectory().getRealResource(className.concat(".class"));
   
    // check if already exists, if yes return
    if(classFile.exists()) {
      //Object obj=newInstance(cl,className,cfc);
      // if(obj!=null) return obj;
    }
   
    /*
    String classNameOriginal=component.getPageSource().getFullClassName();
      String realOriginal=classNameOriginal.replace('.','/');
    Resource classFileOriginal = mapping.getClassRootDirectory().getRealResource(realOriginal.concat(".class"));
    */ 
    ClassWriter cw = ASMUtil.getClassWriter();
     
    cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, className, null, typeExtends.getInternalName(), strInterfaces);
    //BytecodeContext statConstr = null;//new BytecodeContext(null,null,null,cw,real,ga,Page.STATIC_CONSTRUCTOR);
    //BytecodeContext constr = null;//new BytecodeContext(null,null,null,cw,real,ga,Page.CONSTRUCTOR);
   
   
    // field Component
    FieldVisitor _fv = cw.visitField(Opcodes.ACC_PRIVATE, "cfc", COMPONENT_NAME, null, null);
    _fv.visitEnd();
    _fv = cw.visitField(Opcodes.ACC_PRIVATE, "config", CONFIG_WEB_NAME, null, null);
    _fv.visitEnd();
   
     // Constructor
        GeneratorAdapter adapter = new GeneratorAdapter(Opcodes.ACC_PUBLIC,CONSTRUCTOR,null,null,cw);
        Label begin = new Label();
        adapter.visitLabel(begin);
    adapter.loadThis();
        adapter.invokeConstructor(Types.OBJECT, SUPER_CONSTRUCTOR);
       
        //adapter.putField(JAVA_PROXY, arg1, arg2)

        adapter.visitVarInsn(Opcodes.ALOAD, 0);
        adapter.visitVarInsn(Opcodes.ALOAD, 1);
        adapter.visitFieldInsn(Opcodes.PUTFIELD, className, "config", CONFIG_WEB_NAME);

        adapter.visitVarInsn(Opcodes.ALOAD, 0);
        adapter.visitVarInsn(Opcodes.ALOAD, 2);
        adapter.visitFieldInsn(Opcodes.PUTFIELD, className, "cfc", COMPONENT_NAME);
   
        adapter.visitInsn(Opcodes.RETURN);
    Label end = new Label();
    adapter.visitLabel(end);
    adapter.visitLocalVariable("config",CONFIG_WEB_NAME, null, begin, end, 1);
    adapter.visitLocalVariable("cfc",COMPONENT_NAME, null, begin, end, 2);
   
        //adapter.returnValue();
        adapter.endMethod();
       
   
    // create methods
    Set<Class> cDone=new HashSet<Class>();
    Map<String,Class> mDone=new HashMap<String,Class>();
    for(int i=0;i<interfaces.length;i++){
      _createProxy(cw,cDone,mDone, cfc, interfaces[i],className);
    }
        cw.visitEnd();
       
       
        // create class file
        byte[] barr = cw.toByteArray();
     
        try {
          ResourceUtil.touch(classFile);
          IOUtil.copy(new ByteArrayInputStream(barr), classFile,true);
         
          cl = (PhysicalClassLoader) pci.getRPCClassLoader(true);
          Class<?> clazz = cl.loadClass(className, barr);
          return newInstance(clazz, pc.getConfig(),cfc);
        }
        catch(Throwable t) {
          throw Caster.toPageException(t);
View Full Code Here

        //filename = appendix+'.'+pageContext.getConfig().getCFMLExtension();
    }

    @Override
    public int doStartTag() throws PageException    {
      PageContextImpl pci=(PageContextImpl) pageContext;
    boolean old=pci.useSpecialMappings(true);
    try{
      initFile();
        callerScope.initialize(pageContext);
          if(source.isCFC())return cfcStartTag();
          return cfmlStartTag()
    }
    finally{
      pci.useSpecialMappings(old);
    }
    }
View Full Code Here

    }
    }

    @Override
    public int doEndTag()   {
      PageContextImpl pci=(PageContextImpl) pageContext;
    boolean old=pci.useSpecialMappings(true);
    try{
      if(source.isCFC())_doCFCFinally();
          return EVAL_PAGE;
    }
    finally{
      pci.useSpecialMappings(old);
    }
    }
View Full Code Here

    CFMLFactoryImpl factory = (CFMLFactoryImpl) ((ConfigImpl)pc.getConfig()).getFactory();
        HttpServletRequest  req=new HTTPServletRequestWrap(cloneHttpServletRequest(pc));
        HttpServletResponse  rsp=createHttpServletResponse(os);
       
        // copy state
        PageContextImpl pci = (PageContextImpl) pc;
    PageContextImpl dest = factory.getPageContextImpl(factory.getServlet(), req, rsp, null, false, -1, false,registerPC, isChild);
    pci.copyStateTo(dest);
    return dest;
  }
View Full Code Here

  }

  private boolean isValid(Config config, String serverPassword) {
    if(StringUtil.isEmpty(serverPassword,true)) {
      try {
        PageContextImpl pc = (PageContextImpl) ThreadLocalPageContext.get();
        serverPassword=pc.getServerPassword();
      }
      catch (Throwable t) {}
    }
    config=ThreadLocalPageContext.getConfig(config);
   
View Full Code Here

  public Object getComponent(String cfcPath,String id) throws PageException  {
    String requestURI=toRequestURI(cfcPath);
   
    PageContext oldPC = ThreadLocalPageContext.get();
    PageContextImpl pc = createPageContext(requestURI,id, "init", null, false);
    try {
      ThreadLocalPageContext.register(pc);
      return getCFC(pc,requestURI);
    }
    finally{
View Full Code Here

  public Object call(String cfcPath,String id,String functionName,Struct arguments, boolean cfcPeristent, Object defaultValue) throws PageException  {
    String requestURI=toRequestURI(cfcPath);
   
    PageContext oldPC = ThreadLocalPageContext.get();
    PageContextImpl pc=createPageContext(requestURI,id,functionName,arguments,cfcPeristent);
   
    try {
      ThreadLocalPageContext.register(pc);
      Component cfc=getCFC(pc,requestURI);
      if(cfc.containsKey(functionName)){
        pc.execute(requestURI, true,false);
        // Result
        return pc.variablesScope().get(AMF_FORWARD,null);
      }
    }
    finally{
      CFMLFactory f = config.getFactory();
      f.releasePageContext(pc);
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.