Package railo.runtime

Examples of railo.runtime.Mapping


      isNew.setValue(false);
      String classNameOriginal=component.getPageSource().getFullClassName();
      String className=getClassname(component).concat("_wrap");
      String real=className.replace('.','/');
      String realOriginal=classNameOriginal.replace('.','/');
      Mapping mapping = component.getPageSource().getMapping();
    PhysicalClassLoader cl=null;
    try {
      cl = (PhysicalClassLoader) ((PageContextImpl)pc).getRPCClassLoader(false);
    } catch (IOException e) {
      throw Caster.toPageException(e);
    }
    Resource classFile = cl.getDirectory().getRealResource(real.concat(".class"));
    Resource classFileOriginal = mapping.getClassRootDirectory().getRealResource(realOriginal.concat(".class"));
   
  // LOAD CLASS
      //print.out(className);
    // check last Mod
    if(classFile.lastModified()>=classFileOriginal.lastModified()) {
View Full Code Here


   
    private static Class _getServerComponentPropertiesClass(PageContext pc,Component component) throws PageException, IOException, ClassNotFoundException {
      String className=getClassname(component);//StringUtil.replaceLast(classNameOriginal,"$cfc","");
      String real=className.replace('.','/');

      Mapping mapping = component.getPageSource().getMapping();
    PhysicalClassLoader cl = (PhysicalClassLoader)((PageContextImpl)pc).getRPCClassLoader(false);
   
    Resource classFile = cl.getDirectory().getRealResource(real.concat(".class"));
   
      String classNameOriginal=component.getPageSource().getFullClassName();
      String realOriginal=classNameOriginal.replace('.','/');
    Resource classFileOriginal = mapping.getClassRootDirectory().getRealResource(realOriginal.concat(".class"));

    // load existing class
    if(classFile.lastModified()>=classFileOriginal.lastModified()) {
      try {
        Class clazz=cl.loadClass(className);
View Full Code Here

    
    }
 
  public static InitFile createInitFile(PageContext pageContext,boolean isweb,String filename) {
      ConfigWebImpl config = (ConfigWebImpl) pageContext.getConfig();
      Mapping mapping=isweb?config.getTagMapping():config.getServerTagMapping();
     
      return new InitFile(
          mapping.getPageSource(filename),
          filename,
          filename.endsWith('.'+config.getCFCExtension()));
    
    }
View Full Code Here

                  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
          }
        }
       
View Full Code Here

  public Range registerString(BytecodeContext bc, String str) throws IOException {
    boolean append=true;
   
    if(staticTextLocation==null) {
      PageSource ps = bc.getPageSource();
      Mapping m = ps.getMapping();
      staticTextLocation=m.getClassRootDirectory();
     
      staticTextLocation.mkdirs();
      staticTextLocation=staticTextLocation.getRealResource(ps.getJavaName()+".txt");
      if(staticTextLocation.exists()) append=false;
      else staticTextLocation.createFile(true);
View Full Code Here

      callerScope.initialize(pageContext);
        try {
      cfc = ComponentLoader.loadComponent(pageContext,null,source.getPageSource(), source.getFilename().substring(0,source.getFilename().length()-(pageContext.getConfig().getCFCExtension().length()+1)), false,true);
    }
    catch (PageException e) {
      Mapping m = source.getPageSource().getMapping();
      ConfigWebImpl c=(ConfigWebImpl) pageContext.getConfig();
      if(m==c.getTagMapping()) m=c.getServerTagMapping();
      else m=null;
      // is te page source from a tag mapping, so perhaps it was moved from server to web context
      if(m!=null){
        PageSource ps = m.getPageSource(source.getFilename());
        try {
          cfc = ComponentLoader.loadComponent(pageContext,null,ps, source.getFilename().substring(0,source.getFilename().length()-(pageContext.getConfig().getCFCExtension().length()+1)), false,true);
        }
        catch (PageException e1) {
          throw e;
View Full Code Here

    if(searchLocal) {
      //Resource dir=pc.getCurrentTemplatePageSource().getResourceTranslated(pc).getParentResource();
      //dir=dir.getRealResource(path);
      PageSource ps= pci.getRelativePageSourceExisting(path);
      if(ps!=null){
        Mapping mapping = ps.getMapping();
        String _path=ps.getRealpath();
        _path=ListUtil.trim(_path,"\\/");
        String[] list = _listMapping(pc,mapping,_path);
        if(!ArrayUtil.isEmpty(list)) rtn=add(rtn,list);
      }
    }
   
    // check mappings (this includes the webroot)
    if(searchRoot) { 
      String virtual="/"+StringUtil.replace(packageName, ".", "/", false);
      Mapping[] mappings = config.getMappings();
      Mapping mapping;
      String _path;
      String[] list;
      for(int i=0;i<mappings.length;i++){
        mapping=mappings[i];
        if(StringUtil.startsWithIgnoreCase(virtual, mapping.getVirtual()))  {
          _path=ListUtil.trim(virtual.substring(mapping.getVirtual().length()),"\\/").trim();
          _path=StringUtil.replace(_path, "/", File.separator, false);
          list = _listMapping(pc,mapping,_path);
          if(!ArrayUtil.isEmpty(list)) rtn=add(rtn,list);
        }
      }
    }
   
    // check component mappings
    Mapping[] mappings = config.getComponentMappings();
    Mapping mapping;
    String[] list;
    for(int i=0;i<mappings.length;i++){
      mapping=mappings[i];
      list=_listMapping(pc,mapping,path);
      if(!ArrayUtil.isEmpty(list)) rtn=add(rtn,list);
View Full Code Here

    config.setMappingLogger(ConfigWebUtil.getLogAndSource(configServer, config, strLogger, true, logLevel));

    Element[] _mappings = getChildren(el, "mapping");

    Map<String,Mapping> mappings = MapFactory.<String,Mapping>getConcurrentMap();
    Mapping tmp;

    if (configServer != null && config instanceof ConfigWeb) {
      Mapping[] sm = configServer.getMappings();
      for (int i = 0; i < sm.length; i++) {
        if (!sm[i].isHidden()) {
          if (sm[i] instanceof MappingImpl) {
            tmp = ((MappingImpl) sm[i]).cloneReadOnly(config);
            mappings.put(tmp.getVirtualLowerCase(), tmp);

          }
          else {
            tmp = sm[i];
            mappings.put(tmp.getVirtualLowerCase(), tmp);
          }
        }
      }
    }

    boolean finished = false;

    if (hasAccess) {
      boolean hasRailoServerContext=false;
      for (int i = 0; i < _mappings.length; i++) {
        el = _mappings[i];

        // File
        // physical=getDir(sc,el.getAttribute("physical"),null,configDir);
        // File
        // archive=getFile(sc,el.getAttribute("archive"),null,configDir);

        String physical = el.getAttribute("physical");
        String archive = el.getAttribute("archive");
        String virtual = el.getAttribute("virtual");
        String listType = el.getAttribute("listener-type");
        String listMode = el.getAttribute("listener-mode");
        boolean readonly = toBoolean(el.getAttribute("readonly"), false);
        boolean hidden = toBoolean(el.getAttribute("hidden"), false);
        boolean toplevel = toBoolean(el.getAttribute("toplevel"), true);
        int clMaxEl = toInt(el.getAttribute("classloader-max-elements"), 100);

        if(config instanceof ConfigServer && virtual.equalsIgnoreCase("/railo-server-context/")) {
          hasRailoServerContext=true;
        }

        // railo-context
        if (virtual.equalsIgnoreCase("/railo-context/")) {
          if (StringUtil.isEmpty(listType, true))
            listType = "modern";
          if (StringUtil.isEmpty(listMode, true))
            listMode = "curr2root";
          toplevel = true;
        }

        ApplicationListener listener = ConfigWebUtil.loadListener(listType, null);
        int listenerMode = ConfigWebUtil.toListenerMode(listMode, -1);
        if (listener != null || listenerMode != -1) {
          // type
          if (mode == ConfigImpl.MODE_STRICT)
            listener = new ModernAppListener();
          else if (listener == null)
            listener = ConfigWebUtil.loadListener(config.getApplicationListener().getType(), null);
          if (listener == null)// this should never be true
            listener = new ModernAppListener();

          // mode
          if (listenerMode == -1) {
            listenerMode = config.getApplicationListener().getMode();
          }
          listener.setMode(listenerMode);

        }

        // physical!=null &&
        if ((physical != null || archive != null)) {
         
          short insTemp=inspectTemplate(el);
          if("/railo-context/".equalsIgnoreCase(virtual) || "/railo-context".equalsIgnoreCase(virtual) ||
            "/railo-server-context/".equalsIgnoreCase(virtual) || "/railo-server-context".equalsIgnoreCase(virtual))
            insTemp=ConfigImpl.INSPECT_ONCE;
          //boolean trusted = toBoolean(el.getAttribute("trusted"), false);
         
         
          String primary = el.getAttribute("primary");
          boolean physicalFirst = primary == null || !primary.equalsIgnoreCase("archive");

          tmp = new MappingImpl(config, virtual, physical, archive, insTemp, physicalFirst, hidden, readonly, toplevel, false, false, listener, clMaxEl);
          mappings.put(tmp.getVirtualLowerCase(), tmp);
          if (virtual.equals("/")) {
            finished = true;
            // break;
          }
        }
      }
     
      // set default railo-server-context
      if(config instanceof ConfigServer && !hasRailoServerContext) {
        ApplicationListener listener = ConfigWebUtil.loadListener("modern", null);
        listener.setMode(ApplicationListener.MODE_CURRENT2ROOT);
       
        tmp = new MappingImpl(config, "/railo-server-context", "{railo-server}/context/", null, ConfigImpl.INSPECT_ONCE, true, false, true, true, false, false, listener, 100);
        mappings.put(tmp.getVirtualLowerCase(), tmp);
      }
    }


    if ( !finished ) {
View Full Code Here

    // Server Mapping
    if (hasCS) {
      Mapping[] originals = configServer.getCustomTagMappings();
      Mapping[] clones = new Mapping[originals.length];
      LinkedHashMap map = new LinkedHashMap();
      Mapping m;
      for (int i = 0; i < clones.length; i++) {
        m = ((MappingImpl) originals[i]).cloneReadOnly(config);
        map.put(toKey(m), m);
        // clones[i]=((MappingImpl)m[i]).cloneReadOnly(config);
      }
View Full Code Here

    }
   
    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;
            }
View Full Code Here

TOP

Related Classes of railo.runtime.Mapping

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.