001    /**
002     *   GRANITE DATA SERVICES
003     *   Copyright (C) 2006-2013 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    package org.granite.client.messaging.messages;
021    
022    import java.io.Externalizable;
023    import java.util.Map;
024    
025    /**
026     * @author Franck WOLFF
027     */
028    public interface Message extends Externalizable, Cloneable {
029    
030            public static enum Type {
031                    
032                    // Request types.
033                    PING,
034                    LOGIN,
035                    LOGOUT,
036                    INVOCATION,
037                    SUBSCRIBE,
038                    UNSUBSCRIBE,
039                    PUBLISH,
040                    
041                    // Response types.
042                    RESULT,
043                    FAULT,
044                    
045                    // Push types.
046                    TOPIC,
047                    DISCONNECT
048            }
049        
050        Type getType();
051            
052            String getId();
053        void setId(String id);
054            
055            String getClientId();
056        void setClientId(String clientId);
057    
058            long getTimestamp();
059        void setTimestamp(long timestamp);
060            
061        long getTimeToLive();
062        void setTimeToLive(long timeToLive);
063    
064        Map<String, Object> getHeaders();
065        void setHeaders(Map<String, Object> headers);
066            Object getHeader(String name);
067        void setHeader(String name, Object value);
068            boolean headerExists(String name);
069        
070        boolean isExpired();
071        boolean isExpired(long millis);
072        long getRemainingTimeToLive();
073        long getRemainingTimeToLive(long millis);
074        
075        public Message copy();
076        public Message clone() throws CloneNotSupportedException;
077    }