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.loader.engine;
020
021import java.io.IOException;
022import java.net.URL;
023import java.util.Map;
024
025import javax.servlet.ServletConfig;
026import javax.servlet.ServletContext;
027import javax.servlet.ServletException;
028import javax.servlet.http.HttpServlet;
029import javax.servlet.http.HttpServletRequest;
030import javax.servlet.http.HttpServletResponse;
031import javax.servlet.jsp.JspException;
032
033import lucee.runtime.CFMLFactory;
034import lucee.runtime.PageContext;
035import lucee.runtime.util.Cast;
036import lucee.runtime.util.Creation;
037import lucee.runtime.util.Decision;
038import lucee.runtime.util.Excepton;
039import lucee.runtime.util.HTTPUtil;
040import lucee.runtime.util.Operation;
041import lucee.runtime.util.ResourceUtil;
042import lucee.runtime.util.ZipUtil;
043import lucee.runtime.video.VideoUtil;
044
045/**
046 * The CFML Engine
047 */
048public interface CFMLEngine { 
049
050    /**
051     * Field <code>CAN_UPDATE</code>
052     */
053    public static int CAN_UPDATE=0;
054    
055    /**
056     * Field <code>CAN_RESTART</code>
057     */
058    public static int CAN_RESTART=1; 
059    public static int CAN_RESTART_ALL=CAN_RESTART; 
060    public static int CAN_RESTART_CONTEXT=2; 
061
062    public abstract  CFMLFactory getCFMLFactory(ServletContext srvContext, ServletConfig srvConfig,HttpServletRequest req) throws ServletException;
063    
064    /**
065     * adds a servlet config 
066     * @param config
067     * @throws ServletException
068     */
069    public abstract void addServletConfig(ServletConfig config) throws ServletException;
070    
071    /**
072     * method to invoke the engine for CFML
073     * @param servlet
074     * @param req
075     * @param rsp
076     * @throws ServletException
077     * @throws IOException
078     * @throws ServletException 
079     */
080    public void serviceCFML(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp) throws IOException, ServletException;
081
082    /**
083     * method to invoke the engine for AMF
084     * @param servlet
085     * @param req
086     * @param rsp
087     * @throws ServletException
088     * @throws IOException
089     */
090    public void serviceAMF(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp) 
091        throws ServletException, IOException;
092
093    
094    /* *
095     * method to invoke the engine for AMF
096     * @param serviceAdapter 
097     * @param message
098     * @return
099     * /
100    //public Object executeFlex(ServiceAdapter serviceAdapter, Message message);*/
101    
102    
103
104    /**
105     * method to invoke the engine for a simple file
106     * @param servlet
107     * @param req
108     * @param rsp
109     * @throws ServletException
110     * @throws IOException
111     */
112    public void serviceFile(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException; 
113    
114    /**
115     * method to invoke the engine for a Rest Requests
116     * @param servlet
117     * @param req
118     * @param rsp
119     * @throws ServletException
120     * @throws IOException
121     */
122    public abstract void serviceRest(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException; 
123    
124    
125    /**
126     * @return returns the version of the engine in the format [x.x.x.xxx]
127     */
128    public String getVersion();
129    
130    /**
131     * @return returns the stae of the version (alpha,beta,rc,final)
132     */
133    public String getState();
134    
135    /**
136     * @return returns how this engine will be updated (auto, manuell)
137     */
138    public String getUpdateType();
139
140    /**
141     * @return return location URL to get updates for the engines
142     */
143    public URL getUpdateLocation();
144
145    /**
146     * checks if process has the right to do was given with type, the engine with given password
147     * @param type restart type (CFMLEngine.CAN_UPDATE, CFMLEngine.CAN_RESTART)
148     * @param password 
149     * @return has right
150     */
151    public boolean can(int type, String password); 
152    
153    /**
154     * @return returns the engine that has produced this engine
155     */
156    public CFMLEngineFactory getCFMLEngineFactory();
157
158    /**
159     * reset the engine
160     */
161    public void reset();
162    
163    /**
164     * reset the engine
165     */
166    public void reset(String configId);
167    
168    /** 
169     * return the cast util 
170     * @return operaton util 
171     */ 
172    public Cast getCastUtil(); 
173    
174    /** 
175     * return the operation util 
176     * @return operaton util 
177     */ 
178    public Operation getOperatonUtil(); 
179
180    /** 
181     * returns the decision util 
182     * @return decision util 
183     */ 
184    public Decision getDecisionUtil(); 
185    
186    /** 
187     * returns the decision util 
188     * @return decision util 
189     */ 
190    public Excepton getExceptionUtil();
191    
192    
193    
194    /** 
195     * returns the decision util 
196     * @return decision util 
197     */ 
198    public Creation getCreationUtil();
199
200        /**
201         * returns the FusionDebug Engine
202         * @return IFDController
203         */
204        public Object getFDController();
205
206        /**
207         * returns the Blaze DS Util 
208         * @return Blaze DS Util 
209         */
210        public Object getBlazeDSUtil(); 
211
212        /**
213         * returns the Resource Util 
214         * @return Blaze DS Util 
215         */
216        public ResourceUtil getResourceUtil(); 
217        
218        /**
219         * returns the HTTP Util
220         * @return the HTTP Util
221         */
222        public HTTPUtil getHTTPUtil(); 
223        
224        /**
225         * @return return PageContext for the current PageContext
226         */
227        public PageContext getThreadPageContext();
228
229        public VideoUtil getVideoUtil();
230
231        public ZipUtil getZipUtil();
232
233        public abstract void cli(Map<String, String> config, ServletConfig servletConfig) throws IOException, JspException, ServletException;
234
235        public abstract void registerThreadPageContext(PageContext pc);
236
237        
238        // FUTURE add public ConfigServer getConfigServer(String password);
239
240    // FUTURE add public ConfigServer getConfigServer(String key, long timeNonce);
241
242        
243}