CVS update: JGroups/src/org/jgroups/stack ProtocolStack.java

"Bela Ban" <[email protected]> Wed, 20 Oct 2010 14:09:32 +0000
Newsgroups gmane.comp.java.javagroups.cvs
Message-ID <[email protected]>
  User: belaban 
  Date: 10/10/20 14:09:32

  Modified:    src/org/jgroups/stack ProtocolStack.java
  Log:
  modified addProtocol(s) (https://jira.jboss.org/browse/JGRP-1245)
  
  Revision  Changes    Path
  1.110     +33 -9     JGroups/src/org/jgroups/stack/ProtocolStack.java
  
  Index: ProtocolStack.java
  ===================================================================
  RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/stack/ProtocolStack.java,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- ProtocolStack.java	6 Oct 2010 09:47:56 -0000	1.109
  +++ ProtocolStack.java	20 Oct 2010 14:09:32 -0000	1.110
  @@ -30,7 +30,7 @@
    * stacks, and to destroy them again when not needed anymore
    *
    * @author Bela Ban
  - * @version $Id: ProtocolStack.java,v 1.109 2010/10/06 09:47:56 belaban Exp $
  + * @version $Id: ProtocolStack.java,v 1.110 2010/10/20 14:09:32 belaban Exp $
    */
   public class ProtocolStack extends Protocol implements Transport {
       public static final int ABOVE = 1; // used by insertProtocol()
  @@ -483,25 +483,49 @@
        * Adds a protocol at the tail of the protocol list
        * @param prot
        * @return
  +     * @since 2.11
        */
       public ProtocolStack addProtocol(Protocol prot) {
           if(prot == null)
               return this;
  +        prot.setUpProtocol(this);
           if(bottom_prot == null) {
               top_prot=bottom_prot=prot;
               return this;
           }
   
  -        Protocol curr=bottom_prot;
  -        for(;;) {
  -            Protocol tmp=curr.getUpProtocol();
  -            if(tmp != null)
  -                curr=tmp;
  -            else
  -                break;
  +        prot.setDownProtocol(top_prot);
  +        prot.getDownProtocol().setUpProtocol(prot);
  +        top_prot=prot;
  +
  +        return this;
  +    }
  +
  +    /**
  +     * Adds a list of protocols
  +     * @param prots
  +     * @return
  +     * @since 2.11
  +     */
  +    public ProtocolStack addProtocols(Protocol ... prots) {
  +        if(prots != null) {
  +            for(Protocol prot: prots)
  +                addProtocol(prot);
           }
  +        return this;
  +    }
   
  -        insertProtocolInStack(prot, curr, ABOVE);
  +    /**
  +     * Adds a list of protocols
  +     * @param prots
  +     * @return
  +     * @since 2.1
  +     */
  +    public ProtocolStack addProtocols(List<Protocol> prots) {
  +        if(prots != null) {
  +            for(Protocol prot: prots)
  +                addProtocol(prot);
  +        }
           return this;
       }
   
  
  
  

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev