Skip to main content

Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.

  • From: Jean Deruelle < >
  • To: jsr359-experts < >
  • Subject: Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.
  • Date: Mon, 7 Oct 2013 14:23:19 +0200

I'm OK with that proposal as well.

Jean


On Mon, Oct 7, 2013 at 2:21 PM, Nitzan Nissim 
< >
 wrote:

> RFC 3261 talks about  "header fields"
> Maybe it will be appropriate to use this term here as well?
>
> (for getters, setters and interface name, e.g. Iterator<HeaderField>
> getHeaderFields(String name); )
>
> Thanks,
> Nitzan
>
> _______________________________________________
> Nitzan Nissim
> SIP Container Architect, WebSphere SIP Infrastructure
> IBM Software Group, AIM
> Israel Software Lab
> +972 (54) 6976107
> +972 (8) 9482326
> 
>
>
>
>
>
>
> From:   Jean Deruelle 
> < >
> To:     jsr359-experts 
> < >,
> Date:   07/10/2013 02:54 PM
> Subject:        Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header
>             support by introducing a Header interface.
>
>
>
> How about getSIPHeader ?
>
> Jean
>
>
> On Mon, Oct 7, 2013 at 1:40 PM, binod pg 
> < >
>  wrote:
>   Since we haven't heard any new ideas, look like we need to choose between
>   getHeaders2 and getHeaderEntry.
>   And I prefer getHeaderEntry to getHeaders2 instead of dropping the whole
>   proposal.
>
>   Let me know what you think.
>
>   - Binod.
>
>
>   On 9/26/2013 9:43 AM, Jonas Borjesson wrote:
>    Yeah, naming is hard. I agree that we def should not use getHeaders2
>    but HeaderEntry as you say refer to a Map.Entry and at least to me
>    these two things are not the same at all. With that being said, I
>    currently do not have any better suggestion myself so perhaps someone
>    else has a good idea regarding naming this.
>
>    /Jonas
>
>    On Wed, Sep 25, 2013 at 9:08 PM, Binod 
> < >
>  wrote:
>      Hi Jonas,
>
>      Obviously Header is my first choice as well. I drifted to HeaderEntry
>      (much like java.util.Map.Entry) to avoid the "getHeaders2" method.
>
>      So, do you have any other proposal for managing this method name
>      issue?
>
>      thanks,
>      Binod.
>
>
>      On Wednesday 25 September 2013 10:47 PM, jonbo372 (JIRA) wrote:
>             [
>
> https://java.net/jira/browse/SIPSERVLET_SPEC-24?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=369019#action_369019
>
>       ]
>
>       jonbo372 commented on SIPSERVLET_SPEC-24:
>       -----------------------------------------
>
>       Agreed. As the javadoc says for the getHeader2, a better name is
>       certainly
>       needed. I don't really like getHeaderEntry (if I understood you
>       correctly)
>       because I don't like to change the name of the Header since it is a
>       Header
>       and not a HeaderEntry.
>
>       Parameterable and Address would simply inherit from the Header
>       interface.
>       Compare to JSR32. Hence, just cast it if you know it is of a certain
>       type.
>
>
>         Improve header support by introducing a Header interface.
>         ---------------------------------------------------------
>
>                           Key: SIPSERVLET_SPEC-24
>                           URL:
>         https://java.net/jira/browse/SIPSERVLET_SPEC-24
>                       Project: sipservlet-spec
>                    Issue Type: Improvement
>                      Reporter: jonbo372
>                      Assignee: jonbo372
>
>         In 289, if you want to extract out all the headers out of a sip
>         message
>         you will end up writing a double for-loop to get all the headers
>         and their
>         values out. Also, you have to come up with your own structure for
>         storing
>         that information in a meaningful way. Consider the following
>         example that
>         extracts out all X-headers out of a message and returns them in a
>         list:
>         {code:title=Example of extracting out X-headers in 289|
>         borderStyle=solid}
>             private List<Header> extractXHeaders(final SipServletMessage
>         msg) {
>                   final Iterator<String> it = msg.getHeaderNames();
>                   if (it == null) {
>                       return Collections.emptyList();
>                   }
>                   final List<Header> xHeaders = new ArrayList<Header>();
>                   while (it.hasNext()) {
>                       final String header = it.next();
>                       if (header.toLowerCase().startsWith("x-")) {
>                           final ListIterator<String> valueIt =
>         msg.getHeaders(header);
>                           while (valueIt.hasNext()) {
>                               final String value = valueIt.next();
>                               xHeaders.add(new Header(header, value));
>                           }
>                       }
>                   }
>                   return xHeaders;
>               }
>         {code}
>         Not shown in the above snippet is the Header class that holds the
>         name
>         and the value of the header.
>         h2. Suggested solution:
>         Introduce a Header interface that all headers will inherit from (in
>         the
>         current specification that would be Parameterable only) and expose
>         new
>         convenience methods in SipServletMessage for extracting out all
>         headers.
>         Note: full interface declaration at the end
>         {code:title=Summary of new interfaces|borderStyle=solid}
>         Interface Header {
>              String getName();
>              String getValue();
>         }
>         SipServletMessage {
>              ...
>              Iterator<Header> getHeaders();
>              ...
>         }
>         {code}
>         With the new interface additions the same code for extracting out
>         the
>         x-headers:
>         {code:title=Example of extracting out X-headers in 359 (with
>         proposed
>         changes)|borderStyle=solid}
>               private List<Header> extractHeaders2(final SipServletMessage
>         msg) {
>                   final Iterator<Header> headers = msg.getHeaders();
>                   final List<Header> xHeaders = new ArrayList<Header>();
>                   while (headers.hasNext()) {
>                       final Header header = headers.next();
>                       if (header.getName().toLowerCase().equals("x-")) {
>                           xHeaders.add(header);
>                       }
>                   }
>                   return xHeaders;
>               }
>         {code}
>         This will also allow people to create their own Header library
>         which
>         would have a cleaner integration with the container because of the
>         re-usable
>         Header-interface.
>         h2. Suggested Interface
>         {code:title=Suggested additions to the
>         SipServletMessage|borderStyle=solid}
>              public static interface SipServletMessage {
>                   /**
>                    * Obtain a list of all the headers in the {@link
>         SipServletMessage}.
>                    * The order of the headers in the list follows that of
>         the
>                    * {@link SipServletMessage}.
>                    *
>                    * Note, modifying the iterator will not change the
>         headers in
>         the
>                    * {@link SipServletMessage}.
>                    *
>                    * @return an iterator of all the headers in the message
>         or an
>         empty
>                    *         iterator if there are none.
>                    */
>                   Iterator<Header> getHeaders();
>                   /**
>                    * Returns the header with specified name. If the message
>         did
>         not
>                    * include a header of the specified name, this method
>         returns
>         null. If
>                    * multiple headers exist, the first one is returned. The
>         header
>         name is
>                    * case insensitive.
>                    *
>                    * TODO: better name
>                    */
>                   Header getHeader2(String name);
>                   /**
>                    * Get all the headers with the specified name. If there
>         are no
>         headers
>                    * with that name an empty iterator will be returned. The
>         name
>         is case
>                    * insensitive.
>                    *
>                    * @param name
>                    *            the name of the header to extract out of
>         this
>                    *            {@link SipServletMessage}
>                    * @return an iterator of headers or an empty iterator if
>         no
>         headers
>                    *         with that name exists.
>                    */
>                   Iterator<Header> getHeaders2(String name);
>                   /**
>                    * Add a header to this message.
>                    *
>                    * @param header
>                    *            the header to add to this message.
>                    *
>                    * @throws IllegalArgumentException
>                    *             if the specified header field is a system
>         header
>         or if it
>                    *             cannot legally appear in this message
>                    */
>                   void addHeader(Header header) throws
>         IllegalArgumentException;
>                   /**
>                    * Sets a header. If the header already has been set, the
>         new
>         header
>                    * will overwrite the previous one. If there are multiple
>         headers with
>                    * the * same name, they all are replaced by this header
>         name
>                    *
>                    * @param header
>                    * @throws IllegalArgumentException
>                    * @throws NullPointerException
>                    */
>                   void setHeader(Header header) throws
>         IllegalArgumentException,
>         NullPointerException;
>               }
>         {code}
>
>
>
>
>


Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.

binod pg 10/07/2013

Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.

Jean Deruelle 10/07/2013

Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.

Nitzan Nissim 10/07/2013

Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.

Jean Deruelle 10/07/2013

Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.

binod pg 10/07/2013

Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.

Jonas Borjesson 10/07/2013

Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.

binod pg 10/21/2013

Re: [JIRA] Commented: (SIPSERVLET_SPEC-24) Improve header support by introducing a Header interface.

Jonas Borjesson 10/23/2013
 
 
Close
loading
Please Confirm
Close