Installation Guide

   The project source codes & binaries are all packed as one compressed  file. Once you export all files within the compressed package, you'll find  distribution sub directory which contains binary distributions of the project. Under dist sub directory there are three important jar files as below:

+distribution
   -SRClientV1.5.0.jar (client side classes only)
   -SRServerV1.5.0.jar (server side classes only)
   -SRV1.5.0.jar (all in one package)

Integrating SR With Your Web Project

   A typical java web project places jar files under WEB-INF\lib directory. So the first thing you should do is putting either SRServerV1.5.0.jar file or SRV1.5.0.jar file under your WEB-INF\lib directory. Then you need to place project listener class and servlet class lines in your web application configuration file. The only runtime dependency of the project is commons-logging for the logging purposes. You can find this library in the lib sub directory. If you already have it in your project, just skip copying it under WEB-INF\lib directory. 

web.xml

    web.xml file can be found in your WEB-INF directory. You should add following lines in your web.xml file to get SR up and running.

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"                     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  ...
    <context-param>
        <description>SR Config Files</description>
        <param-name>srConfigFilesPattern</param-name>
        <param-value>SR.*\.xml</param-value>
    </context-param>

    <listener>
        <description>SRContextLoaderListener</description>
        <display-name>SRContextLoaderListener</display-name>
        <listener-class>
            org.sr.server.http.SRContextLoaderListener
        </listener-class>
    </listener>

    <servlet>
        <servlet-name>JSONRRServlet</servlet-name>
        <servlet-class>org.sr.server.http.json.JSONRRServlet</servlet-class>
        <init-param>
            <param-name>keepalive</param-name>
            <param-value>1</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>       
    </servlet>

    <servlet-mapping>
        <servlet-name>JSONRRServlet</servlet-name>
        <url-pattern>/JSONRR</url-pattern>
    </servlet-mapping>

    <servlet>
    <servlet-name>CPResource</servlet-name>
        <servlet-class>org.sr.resource.CPResource</servlet-class>
        <load-on-startup>1</load-on-startup>       
    </servlet>
    <servlet-mapping>
        <servlet-name>CPResource</servlet-name>
        <url-pattern>/cpr/*</url-pattern>
    </servlet-mapping>

  .....

</web-app>


srConfigFilesPattern Context Parameter

     This parameter is required to specify configuration files. The parameter value is a java regular expression string. Therefore in the example we are specifying xml files which started with SR prefix. The listener looks up configuration files always under WEB-INF directory.

  SRContextLoaderListener listener

    This listener initializes the framework. It reads all configuration files and initializes locator instances.

JSONRRServlet  Servlet

    This servlet is the Request Response type messaging end-point implementation of the framework, so don't forget to note where you map this servlet. It would be your messaging end-point for your clients. 

CPResource Servlet

This servlet is designed to access resources that are in java class path like project jar files. Because we do pack all classes and resources in jar files its necessary to access those. It must always be to mapped to “/cpr” directory.


Simple Remoting Configuration File

    SR expects that you place all xml configuration files under your WEB-INF directory. Configuration file details can be found in user's guide.

Java Client

    It's enough to have SRClient.jar in your classpath. You can immediately start  using JSONRRClient class to communicate with your remote services.

Java Script Client
  
    The project comes with Java Script client implementation. In order to use SR libraries you should import them into your html code as following.

   <script type="text/javascript" language="JavaScript" src="/cpr/JSONRequest.js"></script>

   A typical SR message must contain a unique identifier in it. You may need a unique identifier generator to satisfy this requirement.  You can find a third party Java Script library in jar distribution. You can also place that in your html file

  <script type="text/javascript" language="JavaScript" src="/cpr/UUID.js"></script>


 

 

 

Comments