restgroupsServer
Class MailboxBlockingResource

java.lang.Object
  extended by org.restlet.resource.UniformResource
      extended by org.restlet.resource.ServerResource
          extended by restgroupsServer.BaseResource
              extended by restgroupsServer.MailboxBlockingResource

public class MailboxBlockingResource
extends BaseResource

This class handles operations executed on the "/groups/{privateGroupName}/mailbox/blocking" resource. The GET retrieveMessages() method performs blocking reception of messages. It means that if there are no new messages waiting for the client, the GET request is suspended until new message arrive. The processing of the GET request is resumed after sending the DELETE request (stopListening() ) , regardless whether new messages just arrived or not.

Author:
tkob

Field Summary
 
Fields inherited from class restgroupsServer.BaseResource
mySession
 
Constructor Summary
MailboxBlockingResource()
           
 
Method Summary
 org.restlet.representation.Representation retrieveMessages()
          The client calling this GET method receives new messages as soon as possible: if the new messages arrive before the client sends the GET request, the messages are returned immediately.
 void stopListening()
          When the client sends the GET request (retrieveMessages()) and there are no new messages waiting for him, the processing of the GET request is suspended until new message arrive.
 
Methods inherited from class restgroupsServer.BaseResource
doInit, getFactory, getProfileEntities, getProfileEntitiesThreadIDs, getProfilesPilotEntities, getRequestSessionId, printProfileEntities, printProfilesPilotEntities, setResponseSessionId
 
Methods inherited from class org.restlet.resource.ServerResource
delete, delete, describeVariants, doConditionalHandle, doHandle, doHandle, doNegotiatedHandle, get, get, getConverterService, getInfo, getInfo, getMetadataService, getPreferredVariant, getVariants, handle, head, head, isAnnotated, isConditional, isExisting, isInRole, isNegotiated, options, options, post, post, put, put, redirectPermanent, redirectPermanent, redirectSeeOther, redirectSeeOther, redirectTemporary, redirectTemporary, setAllowedMethods, setAnnotated, setChallengeRequests, setConditional, setCookieSettings, setDimensions, setExisting, setLocationRef, setLocationRef, setNegotiated, setServerInfo, setStatus, setStatus, setStatus, setStatus, updateAllowedMethods, updateDimensions
 
Methods inherited from class org.restlet.resource.UniformResource
doCatch, doRelease, getAllowedMethods, getApplication, getChallengeRequests, getChallengeResponse, getClientInfo, getConditions, getContext, getCookies, getCookieSettings, getDimensions, getHostRef, getLocationRef, getLogger, getMatrix, getMethod, getOriginalRef, getProtocol, getQuery, getRanges, getReference, getReferrerRef, getRequest, getRequestAttributes, getRequestEntity, getResponse, getResponseAttributes, getResponseEntity, getRootRef, getServerInfo, getStatus, init, isConfidential, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailboxBlockingResource

public MailboxBlockingResource()
Method Detail

retrieveMessages

@Get(value="xml")
public org.restlet.representation.Representation retrieveMessages()
The client calling this GET method receives new messages as soon as possible: if the new messages arrive before the client sends the GET request, the messages are returned immediately. If there are no new messages, processing of the GET request is suspended until new message arrives or the DELETE stopListening() method is called.

If another thread called this method for the same client, the "blockingMessageReception" error is returned.

Returns:
XML representation containing list of new messages or empty list if continuation of blocked processing is caused by calling the DELETE stopListening() method.

stopListening

@Delete
public void stopListening()
When the client sends the GET request (retrieveMessages()) and there are no new messages waiting for him, the processing of the GET request is suspended until new message arrive. The processing of the suspended GET request can be resumed (and finalized) after calling this DELETE method. Then the GET retrieveMessages() returns a list of messages which just arrived or empty list of messages.

If the client has not called the GET retrieveMessages() method, the "blockingMessageReception" error is returned.