001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.listener; 020 021import javax.servlet.ServletException; 022 023import lucee.runtime.CFMLFactory; 024import lucee.runtime.PageContext; 025import lucee.runtime.PageSource; 026import lucee.runtime.exp.PageException; 027 028/** 029 * interface for PageContext to interact with CFML 030 * 031 */ 032public interface ApplicationListener { 033 034 public static final int MODE_CURRENT2ROOT=0; 035 public static final int MODE_CURRENT=1; 036 public static final int MODE_ROOT=2; 037 public static final int MODE_CURRENT_OR_ROOT=4; 038 public static final String CFC_EXTENSION="cfc"; 039 040 public void setMode(int mode); 041 public int getMode(); 042 043 044 /** 045 * @return the type 046 */ 047 public String getType(); 048 049 /** 050 * @param type the type to set 051 *///FUTURE remove method 052 public void setType(String type); 053 054 /** 055 * this method will be called the application self 056 * @param pc 057 * @param requestedPage 058 * @throws PageException 059 * @throws ServletException 060 */ 061 public void onRequest(PageContext pc,PageSource requestedPage, RequestListener rl) throws PageException; 062 063 /** 064 * this method will be called when a new session starts 065 * @throws PageException 066 */ 067 public void onSessionStart(PageContext pc) throws PageException; 068 069 /** 070 * this method will be called when a session ends 071 * @param cfmlFactory 072 * @param applicationName 073 * @param cfid 074 * @throws PageException 075 */ 076 public void onSessionEnd(CFMLFactory cfmlFactory, String applicationName, String cfid) throws PageException; 077 078 /** 079 * this method will be called when a new application context starts 080 * @throws PageException 081 */ 082 public boolean onApplicationStart(PageContext pc) throws PageException; 083 084 /** 085 * this method will be called when a application scope ends 086 * @throws PageException 087 */ 088 public void onApplicationEnd(CFMLFactory cfmlFactory, String applicationName) throws PageException; 089 090 /** 091 * this method will be called when a server starts 092 * @throws PageException 093 */ 094 public void onServerStart() throws PageException; 095 096 /** 097 * this method will be called when the server shutdown correctly (no crashes) 098 * @throws PageException 099 */ 100 public void onServerEnd() throws PageException; 101 102 /** 103 * this method will be called if server has a error (exception) not throwed by a try-catch block 104 * @param pe PageExcpetion Exception that has been throwed 105 */ 106 public void onError(PageContext pc,PageException pe); 107 108 /** 109 * called after "onRequestEnd" to generate debugging output, will only be called when debugging is enabled 110 * @throws PageException 111 */ 112 public void onDebug(PageContext pc) throws PageException; 113 114 /** 115 * will be called when server is run int a timeout 116 */ 117 public void onTimeout(PageContext pc); 118 119 public boolean hasOnApplicationStart(); 120 public boolean hasOnSessionStart(PageContext pc); 121}