Class RestListener

All Implemented Interfaces:
HasSpecialDefaultValues, HasPhysicalDestination, IConfigurable, IConfigurationAware, IListener<Message>, INamedObject, IPushingListener<Message>, IScopeProvider, ServiceClient, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

public class RestListener extends PushingListenerAdapter implements HasPhysicalDestination, HasSpecialDefaultValues
Listener that allows a Receiver to receive messages as a REST webservice. Prepends the configured URI pattern with rest/. When you are writing a new Frank config, you are recommended to use an ApiListener instead. You can find all serviced URI patterns in the Frank!Console: main menu item Webservice, heading Available REST Services.

Note: Servlets' multipart configuration expects a Content-Type of multipart/form-data (see So do not use other multipart content types like multipart/related

Niels Meijer, Gerrit van Brakel
  • Constructor Details

    • RestListener

      public RestListener()
  • Method Details

    • open

      public void open() throws ListenerException
      Description copied from interface: IListener
      Prepares the listener for receiving messages. open() is called once each time the listener is started.
      Specified by:
      open in interface IListener<Message>
      open in class PushingListenerAdapter
    • close

      public void close()
      Description copied from interface: IListener
      Close all resources used for listening. Called once each time the listener is stopped.
      Specified by:
      close in interface IListener<Message>
      close in class PushingListenerAdapter
    • processRequest

      public Message processRequest(Message message, PipeLineSession session) throws ListenerException
      Description copied from interface: ServiceClient
      Method to implement for processing a request. This will usually delegate to a IListener implementation.
      TODO: We may want to add the correlationId parameter back to this method, for cleaner calling and cleaner implementation.
      Specified by:
      processRequest in interface ServiceClient
      processRequest in class PushingListenerAdapter
      message - Message to process
      session - PipeLineSession of the request. If the request has a correlation ID, it should be put into this session.
      Resulting Message.
      ListenerException - Thrown if an exception occurs.
    • transformToJson

      public Message transformToJson(Message message) throws PipeRunException, ConfigurationException
    • transformToXml

      public Message transformToXml(Message message) throws PipeRunException
    • getSpecialDefaultValue

      public Object getSpecialDefaultValue(String attributeName, Object defaultValue, Map<String,String> attributes)
      Specified by:
      getSpecialDefaultValue in interface HasSpecialDefaultValues
    • getPhysicalDestinationName

      public String getPhysicalDestinationName()
      Specified by:
      getPhysicalDestinationName in interface HasPhysicalDestination
    • getRestUriPattern

      public String getRestUriPattern()
    • setUriPattern

      public void setUriPattern(String uriPattern)
      Uri pattern to match, the {uri} part in{uri}, where and ibis4something refer to 'your ibis'.
    • setMethod

      public void setMethod(String method)
      Method (e.g. GET or POST) to match
    • setEtagSessionKey

      public void setEtagSessionKey(String etagSessionKey)
      Key of session variable to store etag
    • setContentTypeSessionKey

      public void setContentTypeSessionKey(String contentTypeSessionKey)
      Key of Session variable that determines requested content type, overrides produces
    • setRestPath

      public void setRestPath(String restPath)
      Can be either /rest or /rest-public and must correspond with the available RestListenerServlet path(s).
    • setAuthRoles

      public void setAuthRoles(String string)
      Comma separated list of authorization roles which are granted for this rest service
      Default value
    • setWriteToSecLog

      public void setWriteToSecLog(boolean b)
    • setWriteSecLogMessage

      public void setWriteSecLogMessage(boolean b)
    • setRetrieveMultipart

      public void setRetrieveMultipart(boolean b)
      Indicates whether the parts of a multipart entity should be retrieved and put in session keys. This can only be done once!
      Default value
    • setConsumes

      public void setConsumes(RestListener.MediaTypes consumes)
      Mediatype (e.g. XML, JSON, TEXT) the RestServiceDispatcher receives as input
      Default value
    • setProduces

      public void setProduces(RestListener.MediaTypes produces)
      Mediatype (e.g. XML, JSON, TEXT) the RestServiceDispatcher sends as output, if set to json the ibis will automatically try to convert the xml message
      Default value
    • setValidateEtag

      public void setValidateEtag(boolean b)
      If set to true the ibis will automatically validate and process etags
      Default value
    • setGenerateEtag

      public void setGenerateEtag(boolean b)
      If set to true the ibis will automatically create an etag
      Default value
    • setAutomaticallyTransformToAndFromJson

      public void setAutomaticallyTransformToAndFromJson(boolean b)
      Uses an JsonPipe to convert the json-input to xml, and xml-output to json. Use with caution, a properly configured Input/Output-wrapper can do much more and is more robust!
      Default value
    • getDomain

      public String getDomain()
      Specified by:
      getDomain in interface HasPhysicalDestination
    • getUriPattern

      public String getUriPattern()
    • getMethod

      public String getMethod()
    • getEtagSessionKey

      public String getEtagSessionKey()
    • getContentTypeSessionKey

      public String getContentTypeSessionKey()
    • getRestPath

      public String getRestPath()
    • getView

      public Boolean getView()
    • getAuthRoles

      public String getAuthRoles()
    • isWriteToSecLog

      public boolean isWriteToSecLog()
    • isWriteSecLogMessage

      public boolean isWriteSecLogMessage()
    • isRetrieveMultipart

      public boolean isRetrieveMultipart()
    • isAutomaticallyTransformToAndFromJson

      public boolean isAutomaticallyTransformToAndFromJson()
    • getConsumes

      public RestListener.MediaTypes getConsumes()
    • getProduces

      public RestListener.MediaTypes getProduces()
    • isValidateEtag

      public boolean isValidateEtag()
    • isGenerateEtag

      public boolean isGenerateEtag()