Package railo.runtime.listener

Examples of railo.runtime.listener.ApplicationListener


  private static final long serialVersionUID = -3868545140988347285L;

  @Override
  public void doEnd(StorageScopeEngine engine,StorageScopeCleaner cleaner,String appName, String cfid) {
    CFMLFactoryImpl factory = engine.getFactory();
    ApplicationListener listener = factory.getConfig().getApplicationListener();
    try {
      cleaner.info("call onSessionEnd for "+appName+"/"+cfid);
      listener.onSessionEnd(factory, appName, cfid);
    }
    catch (Throwable t) {
      ExceptionHandler.log(factory.getConfig(),Caster.toPageException(t));
    }
  }
View Full Code Here


   
    _doEnd((CFMLFactoryImpl) config.getFactory(), appName, cfid);
  }
 
  private void _doEnd(CFMLFactoryImpl factory,String appName, String cfid) {
    ApplicationListener listener = factory.getConfig().getApplicationListener();
    try {
      factory.getScopeContext().info("call onSessionEnd for "+appName+"/"+cfid);
      listener.onSessionEnd(factory, appName, cfid);
    }
    catch (Throwable t) {
      ExceptionHandler.log(factory.getConfig(),Caster.toPageException(t));
    }
  }
View Full Code Here

    return debugger;
  }
   
    @Override
    public void executeRest(String realPath, boolean throwExcpetion) throws PageException  {
      ApplicationListener listener=null;//config.get ApplicationListener();
      try{
      String pathInfo = req.getPathInfo();
     
      // charset
      try{
        String charset=HTTPUtil.splitMimeTypeAndCharset(req.getContentType(),new String[]{"",""})[1];
      if(StringUtil.isEmpty(charset))charset=ThreadLocalPageContext.getConfig().getWebCharset();
        java.net.URL reqURL = new java.net.URL(req.getRequestURL().toString());
        String path=ReqRspUtil.decode(reqURL.getPath(),charset,true);
        String srvPath=req.getServletPath();
        if(path.startsWith(srvPath)) {
          pathInfo=path.substring(srvPath.length());
        }
      }
      catch (Exception e){}
     
     
      // Service mapping
      if(StringUtil.isEmpty(pathInfo) || pathInfo.equals("/")) {// ToDo
        // list available services (if enabled in admin)
        if(config.getRestList()) {
          try {
          HttpServletRequest _req = getHttpServletRequest();
            write("Available sevice mappings are:<ul>");
            railo.runtime.rest.Mapping[] mappings = config.getRestMappings();
            railo.runtime.rest.Mapping _mapping;
          String path;
          for(int i=0;i<mappings.length;i++){
            _mapping=mappings[i];
            Resource p = _mapping.getPhysical();
            path=_req.getContextPath()+ReqRspUtil.getScriptName(_req)+_mapping.getVirtual();
            write("<li "+(p==null || !p.isDirectory()?" style=\"color:red\"":"")+">"+path+"</li>");
           
           
          }
          write("</ul>");
         
        } catch (IOException e) {
          throw Caster.toPageException(e);
        }
        }
        else
          RestUtil.setStatus(this, 404, null);
      return;
     
     
      // check for matrix
      int index;
      String entry;
      Struct matrix=new StructImpl();
      while((index=pathInfo.lastIndexOf(';'))!=-1){
        entry=pathInfo.substring(index+1);
        pathInfo=pathInfo.substring(0,index);
        if(StringUtil.isEmpty(entry,true)) continue;
       
        index=entry.indexOf('=');
        if(index!=-1)matrix.setEL(entry.substring(0,index).trim(), entry.substring(index+1).trim());
        else matrix.setEL(entry.trim(), "");
      }
     
      // get accept
      List<MimeType> accept = ReqRspUtil.getAccept(this);
      MimeType contentType = ReqRspUtil.getContentType(this);
     
      // check for format extension
      //int format = getApplicationContext().getRestSettings().getReturnFormat();
      int format;
      boolean hasFormatExtension=false;
      if(StringUtil.endsWithIgnoreCase(pathInfo, ".json")) {
        pathInfo=pathInfo.substring(0,pathInfo.length()-5);
        format = UDF.RETURN_FORMAT_JSON;
        accept.clear();
        accept.add(MimeType.APPLICATION_JSON);
        hasFormatExtension=true;
      }
      else if(StringUtil.endsWithIgnoreCase(pathInfo, ".wddx")) {
        pathInfo=pathInfo.substring(0,pathInfo.length()-5);
        format = UDF.RETURN_FORMAT_WDDX;
        accept.clear();
        accept.add(MimeType.APPLICATION_WDDX);
        hasFormatExtension=true;
      }
      else if(StringUtil.endsWithIgnoreCase(pathInfo, ".cfml")) {
        pathInfo=pathInfo.substring(0,pathInfo.length()-5);
        format = UDF.RETURN_FORMAT_SERIALIZE;
        accept.clear();
        accept.add(MimeType.APPLICATION_CFML);
        hasFormatExtension=true;
      }
      else if(StringUtil.endsWithIgnoreCase(pathInfo, ".serialize")) {
        pathInfo=pathInfo.substring(0,pathInfo.length()-10);
        format = UDF.RETURN_FORMAT_SERIALIZE;
        accept.clear();
        accept.add(MimeType.APPLICATION_CFML);
        hasFormatExtension=true;
      }
      else if(StringUtil.endsWithIgnoreCase(pathInfo, ".xml")) {
        pathInfo=pathInfo.substring(0,pathInfo.length()-4);
        format = UDF.RETURN_FORMAT_XML;
        accept.clear();
        accept.add(MimeType.APPLICATION_XML);
        hasFormatExtension=true;
      }
      else if(StringUtil.endsWithIgnoreCase(pathInfo, ".java")) {
        pathInfo=pathInfo.substring(0,pathInfo.length()-5);
        format = UDFPlus.RETURN_FORMAT_JAVA;
        accept.clear();
        accept.add(MimeType.APPLICATION_JAVA);
        hasFormatExtension=true;
      }
      else {
        format = getApplicationContext().getRestSettings().getReturnFormat();
        //MimeType mt=MimeType.toMimetype(format);
        //if(mt!=null)accept.add(mt);
      }
     
      if(accept.size()==0) accept.add(MimeType.ALL);
     
      // loop all mappings
      //railo.runtime.rest.Result result = null;//config.getRestSource(pathInfo, null);
      RestRequestListener rl=null;
      railo.runtime.rest.Mapping[] restMappings = config.getRestMappings();
      railo.runtime.rest.Mapping m,mapping=null,defaultMapping=null;
      //String callerPath=null;
      if(restMappings!=null)for(int i=0;i<restMappings.length;i++) {
            m = restMappings[i];
            if(m.isDefault())defaultMapping=m;
            if(pathInfo.startsWith(m.getVirtualWithSlash(),0) && m.getPhysical()!=null) {
              mapping=m;
              //result = m.getResult(this,callerPath=pathInfo.substring(m.getVirtual().length()),format,matrix,null);
              rl=new RestRequestListener(m,pathInfo.substring(m.getVirtual().length()),matrix,format,hasFormatExtension,accept,contentType,null);
              break;
            }
        }
     
      // default mapping
      if(mapping==null && defaultMapping!=null && defaultMapping.getPhysical()!=null) {
        mapping=defaultMapping;
            //result = mapping.getResult(this,callerPath=pathInfo,format,matrix,null);
          rl=new RestRequestListener(mapping,pathInfo,matrix,format,hasFormatExtension,accept,contentType,null);
      }
     
     
      //base = PageSourceImpl.best(config.getPageSources(this,null,realPath,true,false,true));
     
     
      if(mapping==null || mapping.getPhysical()==null){
        RestUtil.setStatus(this,404,"no rest service for ["+pathInfo+"] found");
      }
      else {
        base=config.toPageSource(null, mapping.getPhysical(), null);
        listener=((MappingImpl)base.getMapping()).getApplicationListener();
          listener.onRequest(this, base,rl);
      }
     
     
     
      }
      catch(Throwable t) {
        PageException pe = Caster.toPageException(t);
        if(!Abort.isSilentAbort(pe)){
          log(true);
          if(fdEnabled){
              FDSignal.signal(pe, false);
            }
          if(listener==null) {
            if(base==null)listener=config.getApplicationListener();
            else listener=((MappingImpl)base.getMapping()).getApplicationListener();
          }
          listener.onError(this,pe)
        }
        else log(false);

        if(throwExcpetion) throw pe;
      }
View Full Code Here

          }*/
        }
        if(base==null) base=PageSourceImpl.best(config.getPageSources(this,null,realPath,onlyTopLevel,false,true));
      }
      else base=PageSourceImpl.best(config.getPageSources(this,null,realPath,onlyTopLevel,false,true));
      ApplicationListener listener=gatewayContext?config.getApplicationListener():((MappingImpl)base.getMapping()).getApplicationListener();
     
     
      try {
        listener.onRequest(this,base,null);
        log(false);
      }
      catch(Throwable t) {
        PageException pe = Caster.toPageException(t);
        if(!Abort.isSilentAbort(pe)){
          this.pe=pe;
          log(true);
          if(fdEnabled){
              FDSignal.signal(pe, false);
            }
          listener.onError(this,pe)
        }
        else log(false);

        if(throwExcpetion) throw pe;
      }
      finally {
       
       
            if(enablecfoutputonly>0){
              setCFOutputOnly((short)0);
            }
            if(!gatewayContext && getConfig().debug()) {
              try {
          listener.onDebug(this);
        }
              catch (PageException pe) {
                if(!Abort.isSilentAbort(pe))listener.onError(this,pe);
        }
            }
            base=null;
      }
  }
View Full Code Here

   
   
    private void doGetApplicationListener() throws PageException  {
        Struct sct=new StructImpl();
        pageContext.setVariable(getString("admin",action,"returnVariable"),sct);
        ApplicationListener appListener = config.getApplicationListener();
        sct.set("type",AppListenerUtil.toStringType(appListener));
        sct.set("mode",AppListenerUtil.toStringMode(appListener.getMode()));
    // replaced with encoding outputsct.set("defaultencoding", config.get DefaultEncoding());
    }
View Full Code Here

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

    logLevel = LogUtil.toIntType(application.getAttribute("deploy-log-level"), Log.LEVEL_INFO);
    config.setDeployLogger(ConfigWebUtil.getLogAndSource(configServer, config, strLogger, true, logLevel));

    // Listener type
    ApplicationListener listener;
    if (mode == ConfigImpl.MODE_STRICT) {
      listener = new ModernAppListener();
    }
    else {

      listener = ConfigWebUtil.loadListener(application.getAttribute("listener-type"), null);

      if (listener == null) {
        if (hasCS && configServer.getApplicationListener() != null)
          listener = ConfigWebUtil.loadListener(configServer.getApplicationListener().getType(), null);
        if (listener == null)
          listener = new MixedAppListener();
      }
    }

    // Listener Mode
    int listenerMode = ConfigWebUtil.toListenerMode(application.getAttribute("listener-mode"), -1);
    if (listenerMode == -1) {
      if (hasCS)
        listenerMode = configServer.getApplicationListener() == null ? ApplicationListener.MODE_CURRENT2ROOT : configServer.getApplicationListener().getMode();
      else
        listenerMode = ApplicationListener.MODE_CURRENT2ROOT;
    }

    listener.setMode(listenerMode);
    config.setApplicationListener(listener);

    // Req Timeout URL
    if (mode == ConfigImpl.MODE_STRICT) {
      config.setAllowURLRequestTimeout(false);
View Full Code Here

    if(contextes.size()==0)return;
   
   
   
        Object[] arrContextes= contextes.keySet().toArray();
    ApplicationListener listener = cfmlFactory.getConfig().getApplicationListener();
    Object applicationName,cfid,o;
    Map<String, Scope> fhm;
   
    for(int i=0;i<arrContextes.length;i++) {
      applicationName=arrContextes[i];
            fhm = contextes.get(applicationName);

      if(fhm.size()>0){
          Object[] cfids= fhm.keySet().toArray();
                int count=cfids.length;
                for(int y=0;y<cfids.length;y++) {
                  cfid=cfids[y];
                  o=fhm.get(cfid);
                  if(!(o instanceof MemoryScope)) continue;
                  MemoryScope scope=(MemoryScope) o;
            // close
            if(scope.isExpired()) {
              // TODO macht das sinn? ist das nicht kopierleiche?
              ApplicationImpl application=(ApplicationImpl) applicationContextes.get(applicationName);
              long appLastAccess=0;
              if(application!=null){
                appLastAccess=application.getLastAccess();
                application.touch();
              }
              scope.touch();
                       
              try {
                if(type==Scope.SCOPE_SESSION)listener.onSessionEnd(cfmlFactory,(String)applicationName,(String)cfid);
              }
              catch (Throwable t) {t.printStackTrace();
                ExceptionHandler.log(cfmlFactory.getConfig(),Caster.toPageException(t));
              }
              finally {
View Full Code Here

       
        if(applicationContextes.size()==0)return;
   
    long now=System.currentTimeMillis();
    Object[] arrContextes= applicationContextes.keySet().toArray();
    ApplicationListener listener = jspFactory.getConfig().getApplicationListener();
    for(int i=0;i<arrContextes.length;i++) {
            Application application=applicationContextes.get(arrContextes[i]);
     
      if(application.getLastAccess()+application.getTimeSpan()<now) {
                //SystemOut .printDate(jspFactory.getConfigWebImpl().getOut(),"Clear application scope:"+arrContextes[i]+"-"+this);
                application.touch();
        try {
          listener.onApplicationEnd(jspFactory,(String)arrContextes[i]);
        }
        catch (Throwable t) {
          ExceptionHandler.log(jspFactory.getConfig(),Caster.toPageException(t));
        }
        finally {
View Full Code Here

        String name = pc.getApplicationContext().getName();
        CFMLFactoryImpl jspFactory = (CFMLFactoryImpl)pc.getCFMLFactory();
   
        Application application=applicationContextes.get(name);
        if(application==null) throw new ApplicationException("there is no application context defined with name ["+name+"]");
        ApplicationListener listener = PageContextUtil.getApplicationListener(pc);
        application.touch();
    try {
      listener.onApplicationEnd(jspFactory,name);
    }
    finally {
      applicationContextes.remove(name);
      application.release();
    }
View Full Code Here

TOP

Related Classes of railo.runtime.listener.ApplicationListener

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.