Parameterable Headers in SailFin
By bsankararao on Nov 20, 2008
Headers which have "field-name: field-value \*(;parameter-name=parameter-value)" have a direct support for manipulating headers in JSR 289 and referred as Parameterable Headers. javax.servlet.sip.Parameterable interface defines the contract for Parameterable header, javax.servlet.sip.SipFactory.createParameterable(String) helps in creating a Parameterable and javax.servlet.sip.ServletMessage getters and setters helps in adding and retrieves headers in Parameterable form.
According to the JSR 289, a Parameterable header should be interpreted as "field-value \*(;parameter-name[=parameter-value])"
where the field-value may be in name-addr or addr-spec format as defined in RFC 3261 or may be any sequence of tokens till the first semicolon.
With the above interpretation, almost all the headers would be qualified as Parameterable headers, and there is away to create Parameterable but then there is a restriction while adding the created Parameterable to the message as the JSR 289 disallows any header, whose form is not the form in its BNF.
java.lang.IllegalArgumentException - if the specified header is not defined to hold Parameterable values or if the specified header field is a system header
With this the implementation is in a tricky situation and it has to know before hand, what are all the headers which have Parameterable header form, if not for the extension headers, this task is not overly complex. Since some of the extension headers defined by other RFCs might have Parameterable form, there should be a way of extending the list of headers, which takes Parameterable form.
SailFin's Parameterable implementation has been extended so that there is a configurable way of allowing any header to be added to SipServletMessage as a Parameterable. Two system properties which effect this behaviour are:
1) org.glassfish.sip.parameterablecheck : This property can be set to to false to allow any header name to be added to the message as a Parameterable as long as it follows Parameterable's BNF.
Example, the domain.xml:
2) org.glassfish.sip.parameterablelist : This property can be used to specify the explicit list of header names to be considered as Parameterable headers. Union of predefined Parameterable headers as specified in the 4.2.1 of the JSR 289 spec
and this list will be considered as the list of Parameterable headers.
Example, in the domain.xml:
We hope, predefined parameterable headers are good enough for most users and where it is not sufficient, above mechanism can be used.