/  7
 
Rapid Converged Web-Telecom Application Development with Grails, SIP Servlets and SailFin
Gautam Arora[gautamsarora@gatech.edu]
(Research Assistant, GT-RNOC , Georgia Tech, Atlanta, U.S.A)
This tutorial demonstrates the development of Converged Applications using Grails Web Applicationframework with SIP Servlets and deployment on Sailfin SIP Application Server.
Introduction
Grails: is a MVC action-based agile web application framework that follows the principles of Convention Over Configuration and DRY (Don't Repeat Yourself). It builds on existing mature Javatechnologies like Spring, Hibernate, Sitemesh and uses Groovy to bind them together. It providesseamless integration with Java technologies (thats as simple as dropping the jar in the lib folder). SIP Servlets:The SIP Servlet API (JSR 289) is an extension of the HTTP Servlet API and enables the developmentof server components that can talk SIP. These can be deployed alongside Java EE components on SIPApplications Servers (SIP AS) like Sailfin[1] and allow the development of Converged Applicationslike ClickToDial etc.
The motivation here is to demonstrate the integration of SIP Servlets with a Grails Web Application for rapid development of converged [HTTP+SIP] applications. The integration procedure for HTTP,SIP Servlets would be relevant for adding support for server-side components of other protocols aswell e.g. XMPP 
We build a sample
converged ClickToDial [C2D] application (grails-c2app)
, which will provide awebpage displaying a list of users registered with SIP AS and allow the user to click on a link on thewebpage to setup a call between 2 users.The ClickToDial feature is similar to a Skype Me! Button that can be embedded on a webpage, butwith our custom ClickToDial application, the call will be setup by the converged application developed by us allowing us to integrate it with our business logic and other 3
rd
party services. 
 
Following a detailed explanation of the guts of the integration effort, we introduce the
Grails ClickToDial plugin (grails-c2d)
which eliminates the manual effort in building the c2dgrailsapp and demonstrates building the same capability by simply installing the plugin.
Setup
The application will be developed using the latest versions for Groovy (1.6), Grails (1.1) and deployedon Sailfin (1.0)The various strategies to integrate SIP Servlets with Web applications include:1.Java EE Web App with Java SIP Servlets [existing Sailfin ClickToDial app]2.Grails Web App with Java SIP Servlets [covered below]3.Grails Plugin to configure Java SIP Servlets [covered below]4.Grails Web App with SIP Groovlets (SIP Servlets in Groovy) [future work]
 Additional features for this web app like authentication, using other web services is similar to the procedure followed with existing web applications and we will focus on the Servlet integration. In his tutorial, "E4SS/Grails/Sailfin tutorial"[3], Gregory Bond demonstrates the integration of E4SS with Grails.The goal of this tutorial is to demonstrate the integration of regular SIP Servlets with Grails. For this project, code from the Sailfin ClickToDial project was modified to replace the JPA support with GrailsORM (GORM) layer.
The integration of SIP Servlets in the Grails web application is similar in parts to the integration with(HTTP) Servlets. Therefore, we will first list out the steps to get regular Servlets to work with a Grailsweb application and then move onto the SIP Servlet specific bits.In the following sections, we show the Grails/HttpServlet integration, then Grails/SipServlet integrationand the Grails/ClickToDial plugin.
Building the skeleton Grails app
The following steps show the development of a simple Grails application containing a single model'Person' class and applying static scaffolding (use dynamic scaffolding is also possible and works fine)to generate a CRUD web interface for it.1.$ grails create-app grails-c2dapp2.$ cd grails-c2dapp3.$ grails install-plugin hibernate4.$ grails create-domain-class PersonEdit Person class to add name(String) and telephone(String)5.$ grails generate-all Person6.$ grails run-appTest the application at "http://localhost:8080/grails-c2dapp/"In order to enable quick testing of the application, default accounts for 'alice' and 'bob' can be created in[grails-app/conf/BootStrap.groovy]
 Note: Due to a bug in grails 1.1, we need to install the hibernate plugin to allow us to generate the scaffolded views.
 
Integrating Grails and HTTP Servlets
1. Grails web app packaged with Servlets1.$ grails install-templatesProduces a web.xml at src/templates/war 2.Develop the servlets at src/java [refer: HelloWorldServlet.java code snippet#1]3.Add <servlet> and <servlet-mapping> for the servlets in web.xml [refer: src/templates/war/]4.$ grails run-appTest the servlet integration at "http://localhost:8080/grails-c2dapp/hello"5.$ grails war [optional]Build a war file that can be deployed on a web container like Jetty, Tomcat, Glassfish etc.2. HTTP Servlets access the GORM domain classes using ServiceAs shown in the E4SS/Grails/Sailfin tutorial, we build a grails service inorder to gain access to theGrails Domain classes from the Servlets. This approach requires Service class, ServiceInterface and aSpringUtility class.
 Note: In context with the SIP Servlets, this would be used by the SIP Servlet to set the User telephone field on REGISTER sip request and get the value for building an INVITE message. Of course, we could have the Servlet directly access the tables to get/set the values, but that won't be true integration!
1.$ grails create-service DomainAccessBuilds the DomainAccessService class at [services/DomainAccessService.groovy] that exposesmethods which will be called by the Servlet2.Build an interface[src/java/DomainAccessServiceInterface] and make the service classimplement this interface [refer code]3.Build a Spring Utility class [src/java/SpringUtils.java] that will inject the grails service in theservlet at runtime [refer code]4.Develop the servlets at src/java [refer to code snippet#2 in HelloWorldServlet in sourcecodethat shows how to use the DomainAccess grails service]5.$ grails run-appTest the servlet and service integration at "http://localhost:8080/grails-c2dapp/hello?from=bob&to=alice" Note: Before testing, create person by names alice and bob along with telephone information toview result of the previous request
 For a more detailed explanation of these steps, refer to the E4SS/Grails/Sailfin tutorial [3].
3. Grails web link calls a HTTP ServletThere could be multiple ways to implement this (the simplest being calling the servlet directly from theview or a CallController and use a CallService to call the servlet) We'll choose the first simpler approach.1.Edit the list.gsp[views/person/list.gsp] and create a "ClickToDial" link that will call the servletand pass the 2 users as parameters e.g. /hello?from=alice&to=bob[refer: list.gsp for the code additions]
 Note: If we implement a login-based system, we would need to pass only the caller as param
2.$ grails run-app

Share & Embed

More from this user

Add a Comment

Characters: ...