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.gateway;
020
021import java.io.IOException;
022import java.util.Map;
023
024public interface Gateway {
025    
026        public static final int STARTING = 1;
027    public static final int RUNNING = 2;
028    public static final int STOPPING = 3;
029    public static final int STOPPED = 4;
030    public static final int FAILED = 5;
031    
032    /**
033     * method to initialize the gateway
034     * @param engine the gateway engine
035     * @param id the id of the gateway 
036     * @param cfcPath the path to the listener component
037     * @param config the configuration as map
038     */
039    public void init(GatewayEngine engine,String id, String cfcPath,Map config) throws IOException;
040
041    /**
042     * returns the id of the gateway
043     * @return the id of the gateway
044     */
045    public String getId();
046    
047    /**
048     * sends a message based on given data
049     * @param data
050     * @return answer from gateway
051     */
052    public String sendMessage(Map data) throws IOException;
053    
054    /**
055     * return helper object
056     * @return helper object
057     */
058    public Object getHelper();
059    
060    /**
061     * starts the gateway
062     * @throws GatewayException
063     */
064    public void doStart() throws IOException;
065    
066    /**
067     * stop the gateway
068     * @throws GatewayException
069     */
070    public void doStop() throws IOException;
071    
072    /**
073     * restart the gateway
074     * @throws GatewayException
075     */
076    public void doRestart() throws IOException;
077    
078    /**
079     * returns a string that is used by the event gateway administrator to display status
080     * @return status (STARTING, RSTOPPING, STOPPED, FAILED)
081     */
082    public int getState();
083}