Date: Thu, 28 Mar 2024 17:32:51 +0000 (UTC) Message-ID: <254764658.23.1711647171143@9d4e669c9615> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_22_2019206239.1711647171143" ------=_Part_22_2019206239.1711647171143 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
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 t=
he init parameter <code>request.script</code> is set, then the =
script is relative to /WEB-INF/groovy/
. Else the default locat=
ion /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.<sipa= pp> ... <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