001    /*
002      GRANITE DATA SERVICES
003      Copyright (C) 2011 GRANITE DATA SERVICES S.A.S.
004    
005      This file is part of Granite Data Services.
006    
007      Granite Data Services is free software; you can redistribute it and/or modify
008      it under the terms of the GNU Library General Public License as published by
009      the Free Software Foundation; either version 2 of the License, or (at your
010      option) any later version.
011    
012      Granite Data Services is distributed in the hope that it will be useful, but
013      WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014      FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
015      for more details.
016    
017      You should have received a copy of the GNU Library General Public License
018      along with this library; if not, see <http://www.gnu.org/licenses/>.
019    */
020    
021    package org.granite.gravity;
022    
023    import org.granite.config.GraniteConfig;
024    import org.granite.config.ShutdownListener;
025    import org.granite.config.flex.ServicesConfig;
026    import org.granite.context.GraniteContext;
027    import org.granite.gravity.adapters.ServiceAdapter;
028    
029    import flex.messaging.messages.AsyncMessage;
030    import flex.messaging.messages.Message;
031    
032    /**
033     * @author Franck WOLFF
034     */
035    public interface Gravity extends ShutdownListener {
036    
037        ///////////////////////////////////////////////////////////////////////////
038        // Constants.
039    
040        public static final String RECONNECT_INTERVAL_MS_KEY = "reconnect-interval-ms";
041        public static final String RECONNECT_MAX_ATTEMPTS_KEY = "reconnect-max-attempts";
042        
043        public static final String BYTEARRAY_BODY_HEADER = "GDS_BYTEARRAY_BODY";    
044    
045        ///////////////////////////////////////////////////////////////////////////
046        // Granite/Services configs access.
047    
048        public GravityConfig getGravityConfig();
049        public ServicesConfig getServicesConfig();
050        public GraniteConfig getGraniteConfig();
051    
052        ///////////////////////////////////////////////////////////////////////////
053        // Properties.
054    
055            public boolean isStarted();
056    
057        ///////////////////////////////////////////////////////////////////////////
058        // Operations.
059    
060        public GraniteContext initThread();
061        public void releaseThread();
062            
063            public ServiceAdapter getServiceAdapter(String messageType, String destinationId);
064            
065        public void start() throws Exception;
066        public void reconfigure(GravityConfig gravityConfig, GraniteConfig graniteConfig);
067        public void stop() throws Exception;
068        public void stop(boolean now) throws Exception;
069    
070        public Channel getChannel(String channelId);
071        public Channel removeChannel(String channelId);
072        public boolean access(String channelId);
073        public void execute(AsyncChannelRunner runnable);
074        public boolean cancel(AsyncChannelRunner runnable);
075    
076        public Message handleMessage(Message message);
077        public Message handleMessage(Message message, boolean skipInterceptor);
078        public Message publishMessage(AsyncMessage message);
079        public Message publishMessage(Channel fromChannel, AsyncMessage message);
080    }