org.restlet.ext.sip
Class SipClientResource

java.lang.Object
  extended by org.restlet.resource.Resource
      extended by org.restlet.resource.UniformResource
          extended by org.restlet.resource.ClientResource
              extended by org.restlet.ext.sip.SipClientResource

public class SipClientResource
extends ClientResource

Client-side resource for the sip protocol. Acts like a proxy of a target resource.

This class changes the semantics of the Resource.getRequest() and Resource.getResponse() methods. Since a clientResource may receive severals responses for a single request (in case of interim response), the getResponse() method returns the last received response object. The Request object returned by the getRequest() is actually a prototype which is cloned (except the representation) just before the ClientResource.handle() method is called.

Users must be aware that by most representations can only be read or written once. Some others, such as StringRepresentation stored the entity in memory which can be read several times but has the drawback to consume memory.

Concurrency note: instances of the class are not designed to be shared among several threads. If thread-safety is necessary, consider using the lower-level Client class instead.

Author:
Thierry Boileau, Jerome Louvel

Constructor Summary
SipClientResource(Context context, Method method, Reference reference)
          Constructor.
SipClientResource(Context context, Method method, String uri)
          Constructor.
SipClientResource(Context context, Method method, URI uri)
          Constructor.
SipClientResource(Context context, Reference reference)
          Constructor.
SipClientResource(Context context, SipRequest request, SipResponse response)
          Constructor.
SipClientResource(Context context, String uri)
          Constructor.
SipClientResource(Context context, URI uri)
          Constructor.
SipClientResource(Method method, Reference reference)
          Constructor.
SipClientResource(Method method, String uri)
          Constructor.
SipClientResource(Method method, URI uri)
          Constructor.
SipClientResource(Reference reference)
          Constructor.
SipClientResource(SipClientResource resource)
          Constructor.
SipClientResource(SipRequest request, SipResponse response)
          Constructor.
SipClientResource(String uri)
          Constructor.
SipClientResource(URI uri)
          Constructor.
 
Method Summary
 void ack()
          Confirms that the client has received a final response to an INVITE request.
 void ack(Representation representation)
          Confirms that the client has received a final response to an INVITE request.
 Representation bye()
          Indicates to the server that the user agent wishes to release the call.
 void cancel()
          Cancels a pending request with the same Call-ID, To, From and CSeq (sequence number only) header field values.
static
<T> T
create(Context context, Reference reference, Class<? extends T> resourceInterface)
          Creates a client resource that proxy calls to the given Java interface into Restlet method calls.
static
<T> T
create(Reference reference, Class<? extends T> resourceInterface)
          Creates a client resource that proxy calls to the given Java interface into Restlet method calls.
static
<T> T
create(String uri, Class<? extends T> resourceInterface)
          Creates a client resource that proxy calls to the given Java interface into Restlet method calls.
 Request createRequest(Request prototype)
           
protected  Response createResponse(Request request)
           
 String getCommandSequence()
          Returns the request's command sequence.
 Address getFrom()
          Returns the request initiator's address.
 SipRequest getRequest()
           
 String getRequestCallId()
          Returns the request's call ID.
 SipResponse getResponse()
           
 String getResponseCallId()
          Returns the response's call ID.
 List<SipRecipientInfo> getSipRequestRecipientsInfo()
          Returns the request's list of Via entries.
 List<SipRecipientInfo> getSipResponseRecipientsInfo()
          Returns the response's list of Via entries.
 Address getTo()
          Returns the request recipient's address.
 Representation info()
          Communicating mid-session signaling information along the signaling path for the call.
 Representation info(Representation representation)
          Communicating mid-session signaling information along the signaling path for the call.
 Representation invite()
          Indicates that the user or service is being invited to participate in a session.
 Representation invite(Representation representation)
          Indicates that the user or service is being invited to participate in a session.
 Representation notify(Representation representation)
          Informs subscribers of changes in state to which the subscriber has a subscription.
 Representation options()
          Queries a SIP server as to its capabilities.
 void publish()
          Creates, modifies, and removes event state associated with an address-of-record.
 void publish(Representation representation)
          Creates, modifies, and removes event state associated with an address-of-record.
 void refer()
          Indicates that the target recipient should contact a third party using the contact information provided in the request.
 void register()
          Registers the address listed in the To header field with a SIP server.
 void register(Address to)
          Registers the address listed in the To header field with a SIP server.
 void setCallId(String callId)
          Sets the identifier of the call.
 void setCommandSequence(String commandSequence)
          Sets the identifier of the command.
 void setFrom(Address from)
          Sets the description of the request's initiator.
 void setRequest(Request request)
           
 void setRequestCallId(String callId)
          Sets the request's call ID.
 void setResponse(Response response)
           
 void setTo(Address to)
          Sets the logical recipient of the request.
 void subscribe()
          Requests current state and state updates from a remote node.
 void subscribe(Representation representation)
          Requests current state and state updates from a remote node.
 
Methods inherited from class org.restlet.resource.ClientResource
accept, accept, addQueryParameter, addQueryParameter, addQueryParameters, addSegment, createNext, createRequest, delete, delete, delete, doError, doRelease, finalize, get, get, get, getAttribute, getChild, getChild, getChild, getChild, getMaxRedirects, getNext, getOnResponse, getOnSent, getParent, getParent, getRetryAttempts, getRetryDelay, handle, handle, handle, handle, handle, handle, handle, handle, handle, handle, handleInbound, handleOutbound, hasNext, head, head, isFollowingRedirects, isRequestEntityBuffering, isResponseEntityBuffering, isRetryOnError, options, options, post, post, post, post, put, put, put, put, redirect, retry, setAttribute, setChallengeResponse, setChallengeResponse, setClientInfo, setConditions, setCookies, setEntityBuffering, setFollowingRedirects, setHostRef, setHostRef, setLoggable, setMaxRedirects, setMethod, setNext, setOnResponse, setOnSent, setOriginalRef, setProtocol, setProxyChallengeResponse, setProxyChallengeResponse, setRanges, setReference, setReference, setReferrerRef, setReferrerRef, setRequestEntityBuffering, setResponseEntityBuffering, setRetryAttempts, setRetryDelay, setRetryOnError, wrap
 
Methods inherited from class org.restlet.resource.Resource
doCatch, doError, doInit, getAllowedMethods, getApplication, getChallengeRequests, getChallengeResponse, getClientInfo, getConditions, getConnegService, getContext, getConverterService, getCookies, getCookieSettings, getDimensions, getHostRef, getLocationRef, getLogger, getMatrix, getMatrixValue, getMaxForwards, getMetadataService, getMethod, getOriginalRef, getProtocol, getProxyChallengeRequests, getProxyChallengeResponse, getQuery, getQueryValue, getRanges, getReference, getReferrerRef, getRequestAttributes, getRequestCacheDirectives, getRequestEntity, getResponseAttributes, getResponseCacheDirectives, getResponseEntity, getRootRef, getServerInfo, getStatus, getStatusService, init, isConfidential, isLoggable, release, setApplication, setQueryValue, toObject, toRepresentation, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SipClientResource

public SipClientResource(Context context,
                         URI uri)
Constructor.

Parameters:
context - The context.
uri - The target URI.

SipClientResource

public SipClientResource(Context context,
                         Method method,
                         URI uri)
Constructor.

Parameters:
context - The context.
method - The method to call.
uri - The target URI.

SipClientResource

public SipClientResource(Context context,
                         Method method,
                         Reference reference)
Constructor.

Parameters:
context - The context.
method - The method to call.
reference - The target reference.

SipClientResource

public SipClientResource(Context context,
                         Method method,
                         String uri)
Constructor.

Parameters:
context - The context.
method - The method to call.
uri - The target URI.

SipClientResource

public SipClientResource(Context context,
                         Reference reference)
Constructor.

Parameters:
context - The context.
reference - The target reference.

SipClientResource

public SipClientResource(Context context,
                         SipRequest request,
                         SipResponse response)
Constructor.

Parameters:
context - The current context.
request - The handled request.
response - The handled response.

SipClientResource

public SipClientResource(Context context,
                         String uri)
Constructor.

Parameters:
context - The context.
uri - The target URI.

SipClientResource

public SipClientResource(URI uri)
Constructor.

Parameters:
uri - The target URI.

SipClientResource

public SipClientResource(Method method,
                         URI uri)
Constructor.

Parameters:
method - The method to call.
uri - The target URI.

SipClientResource

public SipClientResource(Method method,
                         Reference reference)
Constructor.

Parameters:
method - The method to call.
reference - The target reference.

SipClientResource

public SipClientResource(Method method,
                         String uri)
Constructor.

Parameters:
method - The method to call.
uri - The target URI.

SipClientResource

public SipClientResource(Reference reference)
Constructor.

Parameters:
reference - The target reference.

SipClientResource

public SipClientResource(SipClientResource resource)
Constructor.

Parameters:
resource - The client resource to copy.

SipClientResource

public SipClientResource(SipRequest request,
                         SipResponse response)
Constructor.

Parameters:
request - The handled request.
response - The handled response.

SipClientResource

public SipClientResource(String uri)
Constructor.

Parameters:
uri - The target URI.
Method Detail

create

public static <T> T create(Context context,
                           Reference reference,
                           Class<? extends T> resourceInterface)
Creates a client resource that proxy calls to the given Java interface into Restlet method calls.

Type Parameters:
T -
Parameters:
context - The context.
reference - The target reference.
resourceInterface - The annotated resource interface class to proxy.
Returns:
The proxy instance.

create

public static <T> T create(Reference reference,
                           Class<? extends T> resourceInterface)
Creates a client resource that proxy calls to the given Java interface into Restlet method calls.

Type Parameters:
T -
Parameters:
resourceInterface - The annotated resource interface class to proxy.
Returns:
The proxy instance.

create

public static <T> T create(String uri,
                           Class<? extends T> resourceInterface)
Creates a client resource that proxy calls to the given Java interface into Restlet method calls.

Type Parameters:
T -
Parameters:
uri - The target URI.
resourceInterface - The annotated resource interface class to proxy.
Returns:
The proxy instance.

ack

public void ack()
         throws ResourceException
Confirms that the client has received a final response to an INVITE request.

Throws:
ResourceException
See Also:
ACK method

ack

public void ack(Representation representation)
         throws ResourceException
Confirms that the client has received a final response to an INVITE request.

Parameters:
representation - The entity to send.
Throws:
ResourceException
See Also:
ACK method

bye

public Representation bye()
                   throws ResourceException
Indicates to the server that the user agent wishes to release the call.

Throws:
ResourceException
See Also:
BYE method

cancel

public void cancel()
            throws ResourceException
Cancels a pending request with the same Call-ID, To, From and CSeq (sequence number only) header field values.

Throws:
ResourceException
See Also:
CANCEL method

createRequest

public Request createRequest(Request prototype)
Overrides:
createRequest in class ClientResource

createResponse

protected Response createResponse(Request request)
Overrides:
createResponse in class ClientResource

getCommandSequence

public String getCommandSequence()
Returns the request's command sequence.

Returns:
The request's command sequence.

getFrom

public Address getFrom()
Returns the request initiator's address.

Returns:
The request initiator's address.

getRequest

public SipRequest getRequest()
Overrides:
getRequest in class Resource

getRequestCallId

public String getRequestCallId()
Returns the request's call ID.

Returns:
The request's call ID.

getResponse

public SipResponse getResponse()
Overrides:
getResponse in class Resource

getResponseCallId

public String getResponseCallId()
Returns the response's call ID.

Returns:
The response's call ID.

getSipRequestRecipientsInfo

public List<SipRecipientInfo> getSipRequestRecipientsInfo()
Returns the request's list of Via entries.

Returns:
The request's list of Via entries.

getSipResponseRecipientsInfo

public List<SipRecipientInfo> getSipResponseRecipientsInfo()
Returns the response's list of Via entries.

Returns:
The response's list of Via entries.

getTo

public Address getTo()
Returns the request recipient's address.

Returns:
The request recipient's address.

info

public Representation info()
                    throws ResourceException
Communicating mid-session signaling information along the signaling path for the call.

Throws:
ResourceException
See Also:
INFO method

info

public Representation info(Representation representation)
                    throws ResourceException
Communicating mid-session signaling information along the signaling path for the call.

Parameters:
representation - An optional representation.
Throws:
ResourceException
See Also:
INFO method

invite

public Representation invite()
                      throws ResourceException
Indicates that the user or service is being invited to participate in a session.

Returns:
The optional result entity.
Throws:
ResourceException
See Also:
INVITE method

invite

public Representation invite(Representation representation)
                      throws ResourceException
Indicates that the user or service is being invited to participate in a session.

Parameters:
representation - An optional representation.
Throws:
ResourceException
See Also:
INVITE method

notify

public Representation notify(Representation representation)
                      throws ResourceException
Informs subscribers of changes in state to which the subscriber has a subscription.

Parameters:
representation - The notification representation.
Returns:
The optional result entity.
Throws:
ResourceException
See Also:
NOTIFY method

options

public Representation options()
                       throws ResourceException
Queries a SIP server as to its capabilities.

Overrides:
options in class ClientResource
Throws:
ResourceException
See Also:
OPTIONS method

publish

public void publish()
             throws ResourceException
Creates, modifies, and removes event state associated with an address-of-record.

Throws:
ResourceException
See Also:
PUBLISH method

publish

public void publish(Representation representation)
             throws ResourceException
Creates, modifies, and removes event state associated with an address-of-record.

Parameters:
representation - The optional request entity.
Throws:
ResourceException
See Also:
PUBLISH method

refer

public void refer()
           throws ResourceException
Indicates that the target recipient should contact a third party using the contact information provided in the request.

Throws:
ResourceException
See Also:
REFER method

register

public void register()
              throws ResourceException
Registers the address listed in the To header field with a SIP server.

Throws:
ResourceException
See Also:
REGISTER method

register

public void register(Address to)
              throws ResourceException
Registers the address listed in the To header field with a SIP server.

Parameters:
to - The To header field.
Throws:
ResourceException
See Also:
REGISTER method

setCallId

public void setCallId(String callId)
Sets the identifier of the call.

Parameters:
callId - The identifier of the call.

setCommandSequence

public void setCommandSequence(String commandSequence)
Sets the identifier of the command.

Parameters:
commandSequence - The identifier of the command.

setFrom

public void setFrom(Address from)
Sets the description of the request's initiator.

Parameters:
from - The description of the request's initiator.

setRequest

public void setRequest(Request request)
Overrides:
setRequest in class Resource

setRequestCallId

public void setRequestCallId(String callId)
Sets the request's call ID.

Parameters:
callId - The call ID.

setResponse

public void setResponse(Response response)
Overrides:
setResponse in class Resource

setTo

public void setTo(Address to)
Sets the logical recipient of the request.

Parameters:
to - The logical recipient of the request.

subscribe

public void subscribe()
               throws ResourceException
Requests current state and state updates from a remote node.

Throws:
ResourceException
See Also:
SUBSCRIBE method

subscribe

public void subscribe(Representation representation)
               throws ResourceException
Requests current state and state updates from a remote node.

Parameters:
representation - The optional request entity.
Throws:
ResourceException
See Also:
SUBSCRIBE method


Copyright © 2005-2013 Restlet.