net.sourceforge.jwap.wsp
Class CWSPSession

java.lang.Object
  |
  +--net.sourceforge.jwap.wsp.CWSPSession
All Implemented Interfaces:
IWTPUpperLayer

public class CWSPSession
extends java.lang.Object
implements IWTPUpperLayer

This class implements the WSP state machine named "management entity" in the Wireless Session Protocol Specification by the WAP-forum.
Using this class the programmer can use all methods of the WSP layer. To use the WAP-Stack with a class corresponding to HttpURLConnection please use WapURLConnection by calling

URL example = new URL("wap://wap.nokia.com");
URLConnection con = example.getConnection();

Author:
Niko Bender

Field Summary
static short ABORT_CONGESTION
           
static short ABORT_CONNECTERR
           
static short ABORT_DISCONNECT
           
static short ABORT_MOREXCEEDED
           
static short ABORT_MRUEXCEEDED
           
static short ABORT_NETERR
           
static short ABORT_PEERREQ
           
static short ABORT_PROTOERR
           
static short ABORT_RESUME
           
static short ABORT_SUSPEND
           
static short ABORT_USERDCR
           
static short ABORT_USERDCU
           
static short ABORT_USERPND
           
static short ABORT_USERREQ
           
static short ABORT_USERRFS
           
static short STATE_CONNECTED
           
static short STATE_CONNECTING
           
static short STATE_NULL
           
static short STATE_RESUMING
           
static short STATE_SUSPENDED
           
 java.lang.String[] states
           
 
Constructor Summary
CWSPSession(CWSPSocketAddress address, CWSPSocketAddress localAddress, IWSPUpperLayer upperLayer, boolean verbose)
          Construct a new WSP session.
CWSPSession(CWSPSocketAddress address, IWSPUpperLayer upperLayer, boolean verbose)
          Construct a new WSP session.
CWSPSession(java.net.InetAddress toAddress, int toPort, java.net.InetAddress localAddress, int localPort, IWSPUpperLayer upperLayer, boolean verbose)
          Construct a new WSP Session.
CWSPSession(java.net.InetAddress toAddress, int toPort, IWSPUpperLayer upperLayer)
          Construct a new WSP session.
CWSPSession(java.net.InetAddress toAddress, int toPort, IWSPUpperLayer upperLayer, boolean verbose)
          Construct a new WSP Session.
 
Method Summary
 void disconnect()
           
 short getDisconnectCode()
           
 int getMRU()
           
 long getSessionID()
           
 short getState()
           
 short getSuspendedCode()
           
 CWTPSocket getWTPSocket()
           
 boolean isDisonnected()
           
 boolean isSuspended()
           
 void removeMethod(CWSPMethodManager m)
           
 void s_connect()
          Establish a WSP connection.
 void s_connect(CWSPHeaders headers)
          Establish a WSP connection using WSP headers
 void s_disconnect()
          S-Disconnect.req
 CWSPMethodManager s_get(CWSPHeaders headers, java.lang.String uri)
          Use this method to construct a GET-MethodInvoke.req.
 CWSPMethodManager s_get(java.lang.String uri)
          Use this method to construct a GET-MethodInvoke.req.
 CWSPMethodManager s_methodInvoke(CWSPPDU pdu)
          S-MethodInvoke.req To construct a POST- or GET-Request please use get(String uri) or post(byte[] data, String contentType) instead of this method.
 CWSPMethodManager s_post(byte[] data, java.lang.String contentType, java.lang.String uri)
          Use this method to construct a POST-MethodInvoke.req.
 CWSPMethodManager s_post(CWSPHeaders headers, byte[] data, java.lang.String contentType, java.lang.String uri)
          Use this method to construct a POST-MethodInvoke.req.
 void s_resume()
          S-Resume.req
 boolean s_suspend()
          S-Suspend.req
 void suspend()
           
 void tr_abort(short abortReason)
          TR-Abort.ind
 void tr_process(CWTPEvent p)
          process all TR-*.ind and TR-*.cnf service primitives except TR-Abort (call tr-abort(short abortReason) to indicate a Abort by TR).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_NULL

public static final short STATE_NULL

STATE_CONNECTING

public static final short STATE_CONNECTING

STATE_CONNECTED

public static final short STATE_CONNECTED

STATE_SUSPENDED

public static final short STATE_SUSPENDED

STATE_RESUMING

public static final short STATE_RESUMING

ABORT_PROTOERR

public static final short ABORT_PROTOERR

ABORT_DISCONNECT

public static final short ABORT_DISCONNECT

ABORT_SUSPEND

public static final short ABORT_SUSPEND

ABORT_RESUME

public static final short ABORT_RESUME

ABORT_CONGESTION

public static final short ABORT_CONGESTION

ABORT_CONNECTERR

public static final short ABORT_CONNECTERR

ABORT_MRUEXCEEDED

public static final short ABORT_MRUEXCEEDED

ABORT_MOREXCEEDED

public static final short ABORT_MOREXCEEDED

ABORT_PEERREQ

public static final short ABORT_PEERREQ

ABORT_NETERR

public static final short ABORT_NETERR

ABORT_USERREQ

public static final short ABORT_USERREQ

ABORT_USERRFS

public static final short ABORT_USERRFS

ABORT_USERPND

public static final short ABORT_USERPND

ABORT_USERDCR

public static final short ABORT_USERDCR

ABORT_USERDCU

public static final short ABORT_USERDCU

states

public java.lang.String[] states
Constructor Detail

CWSPSession

public CWSPSession(java.net.InetAddress toAddress,
                   int toPort,
                   IWSPUpperLayer upperLayer,
                   boolean verbose)
            throws java.net.SocketException
Construct a new WSP Session.
Parameters:
toAddress - address of the WAP gateway
toPort - WAP gateway port
upperLayer - WSP Upper Layer
verbose - verbose logging
Throws:
java.net.SocketException - if the underlying WTP socket cannot be created

CWSPSession

public CWSPSession(java.net.InetAddress toAddress,
                   int toPort,
                   java.net.InetAddress localAddress,
                   int localPort,
                   IWSPUpperLayer upperLayer,
                   boolean verbose)
            throws java.net.SocketException
Construct a new WSP Session.
Parameters:
toAddress - address of the WAP gateway
toPort - WAP gateway port
localAddress - local address to bind to (null to let the OS decide)
localPort - local port to bind to (use 0 to let the OS pick a free port)
upperLayer - WSP Upper Layer
verbose - verbose logging
Throws:
java.net.SocketException - if the underlying WTP socket cannot be created

CWSPSession

public CWSPSession(java.net.InetAddress toAddress,
                   int toPort,
                   IWSPUpperLayer upperLayer)
            throws java.net.SocketException
Construct a new WSP session.
Parameters:
toAddress - the address of the WAP gateway
toPort - WAP gateway port
upperLayer - WSP Upper Layer
Throws:
java.net.SocketException - if the underlying WTP socket cannot be created

CWSPSession

public CWSPSession(CWSPSocketAddress address,
                   IWSPUpperLayer upperLayer,
                   boolean verbose)
            throws java.net.SocketException
Construct a new WSP session.
Parameters:
toAddress - the address and port of the WAP gateway
upperLayer - WSP Upper Layer
verbose - verbose logging
Throws:
java.net.SocketException - if the underlying WTP socket cannot be created

CWSPSession

public CWSPSession(CWSPSocketAddress address,
                   CWSPSocketAddress localAddress,
                   IWSPUpperLayer upperLayer,
                   boolean verbose)
            throws java.net.SocketException
Construct a new WSP session.
Parameters:
address - the address and port of the WAP gateway
localAddress - the local address and port or null
upperLayer - WSP Upper Layer
verbose - verbose logging
Throws:
java.net.SocketException - if the underlying WTP socket cannot be created
Method Detail

s_connect

public void s_connect()
Establish a WSP connection.

s_connect

public void s_connect(CWSPHeaders headers)
Establish a WSP connection using WSP headers
Parameters:
headers - the WSP headers to set or null

s_disconnect

public void s_disconnect()
S-Disconnect.req
Returns:
S-Disconnect.ind

s_suspend

public boolean s_suspend()
S-Suspend.req
Returns:
S-Suspend.ind

s_resume

public void s_resume()
              throws java.net.SocketException
S-Resume.req

s_post

public CWSPMethodManager s_post(byte[] data,
                                java.lang.String contentType,
                                java.lang.String uri)
Use this method to construct a POST-MethodInvoke.req. This method uses methodInvoke(CWSPPDU pdu) to send the constructed WSP-POST-PDU.
Parameters:
data - The data to be POSTed
contentType - The MIME-ContentType of the data to be POSTed

s_post

public CWSPMethodManager s_post(CWSPHeaders headers,
                                byte[] data,
                                java.lang.String contentType,
                                java.lang.String uri)
Use this method to construct a POST-MethodInvoke.req. This method uses methodInvoke(CWSPPDU pdu) to send the constructed WSP-POST-PDU.
Parameters:
headers - The headers defined for the request
data - The data to be POSTed
contentType - The MIME-ContentType of the data to be POSTed
uri - the target URI to post to

s_get

public CWSPMethodManager s_get(java.lang.String uri)
Use this method to construct a GET-MethodInvoke.req. This method uses methodInvoke(CWSPPDU pdu) to send the constructed WSP-GET-PDU.
Parameters:
uri - The Unfied Resource Identifier of the resource to GET

s_get

public CWSPMethodManager s_get(CWSPHeaders headers,
                               java.lang.String uri)
Use this method to construct a GET-MethodInvoke.req. This method uses methodInvoke(CWSPPDU pdu) to send the constructed WSP-GET-PDU.
Parameters:
headers - The headers that are defined for the request
uri - The Unfied Resource Identifier of the resource to GET

s_methodInvoke

public CWSPMethodManager s_methodInvoke(CWSPPDU pdu)
S-MethodInvoke.req To construct a POST- or GET-Request please use get(String uri) or post(byte[] data, String contentType) instead of this method.
Parameters:
pdu - The GET- or POST-PDU to be sent.

removeMethod

public void removeMethod(CWSPMethodManager m)

tr_process

public void tr_process(CWTPEvent p)
process all TR-*.ind and TR-*.cnf service primitives except TR-Abort (call tr-abort(short abortReason) to indicate a Abort by TR).
Specified by:
tr_process in interface IWTPUpperLayer
Parameters:
p - The WTP Service primitive

tr_abort

public void tr_abort(short abortReason)
TR-Abort.ind
Specified by:
tr_abort in interface IWTPUpperLayer
Parameters:
abortReason - The abort reason

disconnect

public void disconnect()

suspend

public void suspend()

getState

public short getState()

getSessionID

public long getSessionID()

getMRU

public int getMRU()

isSuspended

public boolean isSuspended()

getSuspendedCode

public short getSuspendedCode()

isDisonnected

public boolean isDisonnected()

getDisconnectCode

public short getDisconnectCode()

getWTPSocket

public CWTPSocket getWTPSocket()