Show TOC

Customizing Input Formatting of REST RequestsLocate this document in the navigation structure

Customize the formatting of the input content of REST requests by replacing the existing stream resource jar file with your own implementation. You may wish to do this for several reasons. For example, you may wish to use different formatting for HTTP requests if you have incoming events in your system that have a different or more complex structure, such as nested or structured events. Or you may have an initialization process that you need to execute when the Web Services Provider server first starts up. Or finally, you may want to control the connection and publishing of events to Event Stream Processor.

Context

The ESP REST Provider supports two types of resources:
  • stream resource allows you to send requests and publish your events to Event Stream Processor
  • project resource allows you to control the lifecycle of a project in Event Stream Processor
These resources (jar files) can be found in the STREAMING_HOME/wsp directory.

To create a custom resource, create a custom Java project and implement the IResource interface (which requires you to also implement the IFormatter, IPublisher, and IInitializer interfaces). See %STREAMING_HOME%\doc\wsp on Windows or $STREAMING_HOME/doc/wsp on Linux/Solaris.

Procedure

  1. Create your own jar file for the stream resource. For example, <MyCustomStreamResource>.jar.
  2. Copy the jar to the STREAMING_HOME/wsp directory.
  3. Update the resources.xml file in the same directory to support your custom resource. The content should be:
    <Resources>          
                      <Resource>
                        <Name>stream</Name>
                        <JarName>myCustomStreamResource</JarName>
                                    <ClassName>com.sybase.esp.wsp.rest.sample.stream.StreamResource</ClassName>
                      </Resource>
                      <Resource>
                        <Name>project</Name>
                        <JarName>ProjectResource</JarName>
                                    <ClassName>com.sybase.esp.wsp.rest.project.ProjectResource</ClassName>
                      </Resource>
    </Resources>
    
  4. Use the %STREAMING_HOME%\wsp\wsp.bat or $STREAMING_HOME/wsp/wsp.sh script to start the ESP REST Provider (Jetty) server.