org.granite.client.messaging.channel
Class AbstractHTTPChannel

java.lang.Object
  extended by org.granite.client.messaging.channel.AbstractChannel<Transport>
      extended by org.granite.client.messaging.channel.AbstractHTTPChannel
All Implemented Interfaces:
Runnable, Channel, TransportStopListener
Direct Known Subclasses:
AbstractAMFChannel

public abstract class AbstractHTTPChannel
extends AbstractChannel<Transport>
implements TransportStopListener, Runnable

Author:
Franck WOLFF

Field Summary
protected  boolean authenticated
           
protected  long defaultTimeToLive
           
protected  int maxConcurrentRequests
           
protected  boolean pinged
           
 
Fields inherited from class org.granite.client.messaging.channel.AbstractChannel
clientId, credentials, id, transport, transportData, uri
 
Fields inherited from interface org.granite.client.messaging.channel.Channel
BYTEARRAY_BODY_HEADER, DEFAULT_TIME_TO_LIVE, RECONNECT_INTERVAL_MS_KEY, RECONNECT_MAX_ATTEMPTS_KEY
 
Constructor Summary
AbstractHTTPChannel(Transport transport, String id, URI uri, int maxConcurrentRequests)
           
 
Method Summary
protected abstract  TransportMessage createTransportMessage(AsyncToken token)
           
protected abstract  ResponseMessage decodeResponse(InputStream is)
           
 long getDefaultTimeToLive()
           
 int getMaxConcurrentRequests()
           
protected  RequestMessage getRequest(String id)
           
 boolean isAuthenticated()
           
 boolean isStarted()
           
 ResponseMessageFuture logout(ResponseListener... listeners)
           
 void onCancelled(TransportMessage message)
           
 void onError(TransportMessage message, Exception e)
           
 void onMessage(InputStream is)
           
 void onStop(Transport transport)
           
 void run()
           
protected  boolean schedule(TimerTask timerTask, long delay)
           
 ResponseMessageFuture send(RequestMessage request, ResponseListener... listeners)
           
 void setDefaultTimeToLive(long defaultTimeToLive)
           
 boolean start()
           
 boolean stop()
           
 
Methods inherited from class org.granite.client.messaging.channel.AbstractChannel
getClientId, getCredentials, getId, getTransport, getTransportData, getUri, setCredentials, setTransportData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pinged

protected volatile boolean pinged

authenticated

protected volatile boolean authenticated

maxConcurrentRequests

protected volatile int maxConcurrentRequests

defaultTimeToLive

protected volatile long defaultTimeToLive
Constructor Detail

AbstractHTTPChannel

public AbstractHTTPChannel(Transport transport,
                           String id,
                           URI uri,
                           int maxConcurrentRequests)
Method Detail

createTransportMessage

protected abstract TransportMessage createTransportMessage(AsyncToken token)
                                                    throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

decodeResponse

protected abstract ResponseMessage decodeResponse(InputStream is)
                                           throws IOException
Throws:
IOException

schedule

protected boolean schedule(TimerTask timerTask,
                           long delay)

getDefaultTimeToLive

public long getDefaultTimeToLive()
Specified by:
getDefaultTimeToLive in interface Channel

setDefaultTimeToLive

public void setDefaultTimeToLive(long defaultTimeToLive)
Specified by:
setDefaultTimeToLive in interface Channel

isAuthenticated

public boolean isAuthenticated()
Specified by:
isAuthenticated in interface Channel

getMaxConcurrentRequests

public int getMaxConcurrentRequests()

onStop

public void onStop(Transport transport)
Specified by:
onStop in interface TransportStopListener

start

public boolean start()
Specified by:
start in interface Channel

isStarted

public boolean isStarted()
Specified by:
isStarted in interface Channel

stop

public boolean stop()
Specified by:
stop in interface Channel

run

public void run()
Specified by:
run in interface Runnable

getRequest

protected RequestMessage getRequest(String id)

send

public ResponseMessageFuture send(RequestMessage request,
                                  ResponseListener... listeners)
Specified by:
send in interface Channel

logout

public ResponseMessageFuture logout(ResponseListener... listeners)
Specified by:
logout in interface Channel

onMessage

public void onMessage(InputStream is)
Specified by:
onMessage in interface Channel

onError

public void onError(TransportMessage message,
                    Exception e)
Specified by:
onError in interface Channel

onCancelled

public void onCancelled(TransportMessage message)
Specified by:
onCancelled in interface Channel