Groovy is an agile dynamic language for the Java Platform.
Cipango team has developped an extension to be able to write SIP Servlets application using Groovy scripts.
This extension use two Groovy scripts:
javax.servlet.sip.SipServletRequest
. If the init parameter <code>request.script</code> is set, then the script is relative to /WEB-INF/groovy/
. Else the default location /WEB-INF/groovy/requests.groovy
is used.javax.servlet.sip.SipServletResponse
. If the init parameter response.script
is set, then the script is relative to /WEB-INF/groovy/
. Else the default location /WEB-INF/groovy/responses.groovy
is used.<sipapp> ... <servlet> <servlet-name>groovy</servlet-name> <servlet-class>org.cipango.groovy.GroovyServlet</servlet-class> <init-param> <param-name>defaultScript</param-name> <param-value>addHeader.groovy</param-value> </init-param> <load-on-startup/> </servlet> </sipapp> |
responses.groovy
in WEB-INF/groovy
.groovy-all-xyz.jar
and cipango-groovy-xyz.jar
into WEB-INF/lib
.The following variables are ready for use in SIP Groovlets:
name |
bound to |
Scope (in which script) |
---|---|---|
request |
the |
request |
params |
Map of all request parameters |
request |
response |
the |
response |
context |
the |
all |
session |
the |
all |
factory |
the |
all |
name |
shorthand to |
Scope (in which script) |
---|---|---|
proxy() |
request.getProxy().proxyTo(request.getRequestURI()); |
request |
proxy(String uri) |
proxy(sipFactory.createURI()); |
request |
proxy(URI) |
request.getProxy().proxyTo(uri); |
request |
sendResponse(int status) |
request.createResponse(status).send(); |
request |
sendResponse(int status, String reason) |
request.createResponse(status, reason).send(); |
request |
pushRoute(String route) |
request.pushRoute(sipFactory.createAddress(route)); |
request |
request.addHeader("P-Asserted-Identity", "sip:bob@cipango.voip") proxy() |
response.addHeader("Handled-By", "Cipango-Groovy") println response |